summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2020-10-16 21:20:01 -0700
committerGravatar GitHub2020-10-16 21:20:01 -0700
commitcb708631b6d891633ad4079d7796249c19147e3f (patch)
tree250b1712e0d426636a59ddb0000eaa7dabed5da5 /src
parentMerge pull request #4790 from lioncash/input-common (diff)
parentudp/client: Make use of designated initializers in TestCommunication() (diff)
downloadyuzu-cb708631b6d891633ad4079d7796249c19147e3f.tar.gz
yuzu-cb708631b6d891633ad4079d7796249c19147e3f.tar.xz
yuzu-cb708631b6d891633ad4079d7796249c19147e3f.zip
Merge pull request #4798 from lioncash/input-copy
udp/client: Take std::function by const reference with TestCommunication()
Diffstat (limited to 'src')
-rw-r--r--src/input_common/udp/client.cpp13
-rw-r--r--src/input_common/udp/client.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index bb109562c..7039d6fc3 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -333,15 +333,18 @@ const std::array<Common::SPSCQueue<UDPPadStatus>, 4>& Client::GetPadQueue() cons
333} 333}
334 334
335void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id, 335void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id,
336 std::function<void()> success_callback, 336 const std::function<void()>& success_callback,
337 std::function<void()> failure_callback) { 337 const std::function<void()>& failure_callback) {
338 std::thread([=] { 338 std::thread([=] {
339 Common::Event success_event; 339 Common::Event success_event;
340 SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, 340 SocketCallback callback{
341 [&](Response::PadData data) { success_event.Set(); }}; 341 .version = [](Response::Version) {},
342 .port_info = [](Response::PortInfo) {},
343 .pad_data = [&](Response::PadData) { success_event.Set(); },
344 };
342 Socket socket{host, port, pad_index, client_id, std::move(callback)}; 345 Socket socket{host, port, pad_index, client_id, std::move(callback)};
343 std::thread worker_thread{SocketLoop, &socket}; 346 std::thread worker_thread{SocketLoop, &socket};
344 bool result = success_event.WaitFor(std::chrono::seconds(8)); 347 const bool result = success_event.WaitFor(std::chrono::seconds(8));
345 socket.Stop(); 348 socket.Stop();
346 worker_thread.join(); 349 worker_thread.join();
347 if (result) { 350 if (result) {
diff --git a/src/input_common/udp/client.h b/src/input_common/udp/client.h
index 2491a03a2..747e0c0a2 100644
--- a/src/input_common/udp/client.h
+++ b/src/input_common/udp/client.h
@@ -150,7 +150,7 @@ private:
150}; 150};
151 151
152void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id, 152void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id,
153 std::function<void()> success_callback, 153 const std::function<void()>& success_callback,
154 std::function<void()> failure_callback); 154 const std::function<void()>& failure_callback);
155 155
156} // namespace InputCommon::CemuhookUDP 156} // namespace InputCommon::CemuhookUDP