summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/udp_client.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-25 19:53:14 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:26 +0100
commit1d71d4b87415b2581e6757f07d29275e02671b7a (patch)
treefdce385f094f5b38394e2c8582309f00756a3393 /src/input_common/drivers/udp_client.cpp
parentinput_common: Add multiple vibration curves (diff)
downloadyuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.tar
yuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.tar.gz
yuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.tar.bz2
yuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.tar.lz
yuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.tar.xz
yuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.tar.zst
yuzu-1d71d4b87415b2581e6757f07d29275e02671b7a.zip
Diffstat (limited to 'src/input_common/drivers/udp_client.cpp')
-rw-r--r--src/input_common/drivers/udp_client.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp
index 192ab336b..7cab707da 100644
--- a/src/input_common/drivers/udp_client.cpp
+++ b/src/input_common/drivers/udp_client.cpp
@@ -4,6 +4,7 @@
#include <random>
#include <boost/asio.hpp>
+#include <fmt/format.h>
#include "common/logging/log.h"
#include "common/param_package.h"
@@ -279,6 +280,7 @@ void UDPClient::StartCommunication(std::size_t client, const std::string& host,
[this](Response::PortInfo info) { OnPortInfo(info); },
[this, client](Response::PadData data) { OnPadData(data, client); }};
LOG_INFO(Input, "Starting communication with UDP input server on {}:{}", host, port);
+ clients[client].uuid = GetHostUUID(host);
clients[client].host = host;
clients[client].port = port;
clients[client].active = 0;
@@ -293,12 +295,18 @@ void UDPClient::StartCommunication(std::size_t client, const std::string& host,
const PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const {
const std::size_t client = pad_index / PADS_PER_CLIENT;
return {
- .guid = Common::UUID{clients[client].host},
+ .guid = clients[client].uuid,
.port = static_cast<std::size_t>(clients[client].port),
.pad = pad_index,
};
}
+const Common::UUID UDPClient::GetHostUUID(const std::string host) const {
+ const auto ip = boost::asio::ip::address_v4::from_string(host);
+ const auto hex_host = fmt::format("{:06x}", ip.to_ulong());
+ return Common::UUID{hex_host};
+}
+
void UDPClient::Reset() {
for (auto& client : clients) {
if (client.thread.joinable()) {