input_common: Fix UDP uuid
This commit is contained in:
parent
7348e205d9
commit
1d71d4b874
3 changed files with 16 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/param_package.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](Response::PortInfo info) { OnPortInfo(info); },
|
||||||
[this, client](Response::PadData data) { OnPadData(data, client); }};
|
[this, client](Response::PadData data) { OnPadData(data, client); }};
|
||||||
LOG_INFO(Input, "Starting communication with UDP input server on {}:{}", host, port);
|
LOG_INFO(Input, "Starting communication with UDP input server on {}:{}", host, port);
|
||||||
|
clients[client].uuid = GetHostUUID(host);
|
||||||
clients[client].host = host;
|
clients[client].host = host;
|
||||||
clients[client].port = port;
|
clients[client].port = port;
|
||||||
clients[client].active = 0;
|
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 PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const {
|
||||||
const std::size_t client = pad_index / PADS_PER_CLIENT;
|
const std::size_t client = pad_index / PADS_PER_CLIENT;
|
||||||
return {
|
return {
|
||||||
.guid = Common::UUID{clients[client].host},
|
.guid = clients[client].uuid,
|
||||||
.port = static_cast<std::size_t>(clients[client].port),
|
.port = static_cast<std::size_t>(clients[client].port),
|
||||||
.pad = pad_index,
|
.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() {
|
void UDPClient::Reset() {
|
||||||
for (auto& client : clients) {
|
for (auto& client : clients) {
|
||||||
if (client.thread.joinable()) {
|
if (client.thread.joinable()) {
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
struct ClientConnection {
|
struct ClientConnection {
|
||||||
ClientConnection();
|
ClientConnection();
|
||||||
~ClientConnection();
|
~ClientConnection();
|
||||||
|
Common::UUID uuid{"7F000001"};
|
||||||
std::string host{"127.0.0.1"};
|
std::string host{"127.0.0.1"};
|
||||||
u16 port{26760};
|
u16 port{26760};
|
||||||
s8 active{-1};
|
s8 active{-1};
|
||||||
|
@ -87,6 +88,7 @@ private:
|
||||||
void OnPadData(Response::PadData, std::size_t client);
|
void OnPadData(Response::PadData, std::size_t client);
|
||||||
void StartCommunication(std::size_t client, const std::string& host, u16 port);
|
void StartCommunication(std::size_t client, const std::string& host, u16 port);
|
||||||
const PadIdentifier GetPadIdentifier(std::size_t pad_index) const;
|
const PadIdentifier GetPadIdentifier(std::size_t pad_index) const;
|
||||||
|
const Common::UUID GetHostUUID(const std::string host) const;
|
||||||
|
|
||||||
// Allocate clients for 8 udp servers
|
// Allocate clients for 8 udp servers
|
||||||
static constexpr std::size_t MAX_UDP_CLIENTS = 8;
|
static constexpr std::size_t MAX_UDP_CLIENTS = 8;
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ void ConfigureInputPlayer::HandleClick(
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout_timer->start(2500); // Cancel after 2.5 seconds
|
timeout_timer->start(2500); // Cancel after 2.5 seconds
|
||||||
poll_timer->start(50); // Check for new inputs every 50ms
|
poll_timer->start(25); // Check for new inputs every 25ms
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
||||||
|
@ -1205,6 +1205,10 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.Has("motion")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Keyboard/Mouse
|
// Keyboard/Mouse
|
||||||
if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) {
|
if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) {
|
||||||
return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse";
|
return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse";
|
||||||
|
|
Loading…
Reference in a new issue