mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 14:55:42 +01:00
Merge pull request #4798 from lioncash/input-copy
udp/client: Take std::function by const reference with TestCommunication()
This commit is contained in:
commit
cb708631b6
@ -333,15 +333,18 @@ const std::array<Common::SPSCQueue<UDPPadStatus>, 4>& Client::GetPadQueue() cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id,
|
void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id,
|
||||||
std::function<void()> success_callback,
|
const std::function<void()>& success_callback,
|
||||||
std::function<void()> failure_callback) {
|
const std::function<void()>& failure_callback) {
|
||||||
std::thread([=] {
|
std::thread([=] {
|
||||||
Common::Event success_event;
|
Common::Event success_event;
|
||||||
SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {},
|
SocketCallback callback{
|
||||||
[&](Response::PadData data) { success_event.Set(); }};
|
.version = [](Response::Version) {},
|
||||||
|
.port_info = [](Response::PortInfo) {},
|
||||||
|
.pad_data = [&](Response::PadData) { success_event.Set(); },
|
||||||
|
};
|
||||||
Socket socket{host, port, pad_index, client_id, std::move(callback)};
|
Socket socket{host, port, pad_index, client_id, std::move(callback)};
|
||||||
std::thread worker_thread{SocketLoop, &socket};
|
std::thread worker_thread{SocketLoop, &socket};
|
||||||
bool result = success_event.WaitFor(std::chrono::seconds(8));
|
const bool result = success_event.WaitFor(std::chrono::seconds(8));
|
||||||
socket.Stop();
|
socket.Stop();
|
||||||
worker_thread.join();
|
worker_thread.join();
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -150,7 +150,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id,
|
void TestCommunication(const std::string& host, u16 port, std::size_t pad_index, u32 client_id,
|
||||||
std::function<void()> success_callback,
|
const std::function<void()>& success_callback,
|
||||||
std::function<void()> failure_callback);
|
const std::function<void()>& failure_callback);
|
||||||
|
|
||||||
} // namespace InputCommon::CemuhookUDP
|
} // namespace InputCommon::CemuhookUDP
|
||||||
|
Loading…
Reference in New Issue
Block a user