|
|
|
@ -14,7 +14,6 @@
|
|
|
|
|
#include "input_common/udp/client.h"
|
|
|
|
|
#include "input_common/udp/protocol.h"
|
|
|
|
|
|
|
|
|
|
using boost::asio::ip::address_v4;
|
|
|
|
|
using boost::asio::ip::udp;
|
|
|
|
|
|
|
|
|
|
namespace InputCommon::CemuhookUDP {
|
|
|
|
@ -31,10 +30,10 @@ public:
|
|
|
|
|
|
|
|
|
|
explicit Socket(const std::string& host, u16 port, u8 pad_index, u32 client_id,
|
|
|
|
|
SocketCallback callback)
|
|
|
|
|
: client_id(client_id), timer(io_service),
|
|
|
|
|
send_endpoint(udp::endpoint(address_v4::from_string(host), port)),
|
|
|
|
|
socket(io_service, udp::endpoint(udp::v4(), 0)), pad_index(pad_index),
|
|
|
|
|
callback(std::move(callback)) {}
|
|
|
|
|
: callback(std::move(callback)), timer(io_service),
|
|
|
|
|
socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id),
|
|
|
|
|
pad_index(pad_index),
|
|
|
|
|
send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {}
|
|
|
|
|
|
|
|
|
|
void Stop() {
|
|
|
|
|
io_service.stop();
|
|
|
|
@ -126,7 +125,7 @@ static void SocketLoop(Socket* socket) {
|
|
|
|
|
|
|
|
|
|
Client::Client(std::shared_ptr<DeviceStatus> status, const std::string& host, u16 port,
|
|
|
|
|
u8 pad_index, u32 client_id)
|
|
|
|
|
: status(status) {
|
|
|
|
|
: status(std::move(status)) {
|
|
|
|
|
StartCommunication(host, port, pad_index, client_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -207,7 +206,7 @@ void TestCommunication(const std::string& host, u16 port, u8 pad_index, u32 clie
|
|
|
|
|
Common::Event success_event;
|
|
|
|
|
SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {},
|
|
|
|
|
[&](Response::PadData data) { success_event.Set(); }};
|
|
|
|
|
Socket socket{host, port, pad_index, client_id, callback};
|
|
|
|
|
Socket socket{host, port, pad_index, client_id, std::move(callback)};
|
|
|
|
|
std::thread worker_thread{SocketLoop, &socket};
|
|
|
|
|
bool result = success_event.WaitFor(std::chrono::seconds(8));
|
|
|
|
|
socket.Stop();
|
|
|
|
@ -267,7 +266,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
|
|
|
|
|
complete_event.Set();
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
Socket socket{host, port, pad_index, client_id, callback};
|
|
|
|
|
Socket socket{host, port, pad_index, client_id, std::move(callback)};
|
|
|
|
|
std::thread worker_thread{SocketLoop, &socket};
|
|
|
|
|
complete_event.Wait();
|
|
|
|
|
socket.Stop();
|
|
|
|
|