mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-30 10:14:14 +01:00
input/hid: Migrate to the new UUID implementation
This commit is contained in:
parent
3271099fea
commit
cb30fe50cd
@ -10,8 +10,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/new_uuid.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "common/uuid.h"
|
|
||||||
|
|
||||||
namespace Common::Input {
|
namespace Common::Input {
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ struct AnalogStatus {
|
|||||||
|
|
||||||
// Button data
|
// Button data
|
||||||
struct ButtonStatus {
|
struct ButtonStatus {
|
||||||
Common::UUID uuid{};
|
Common::NewUUID uuid{};
|
||||||
bool value{};
|
bool value{};
|
||||||
bool inverted{};
|
bool inverted{};
|
||||||
bool toggle{};
|
bool toggle{};
|
||||||
@ -109,7 +109,7 @@ using BatteryStatus = BatteryLevel;
|
|||||||
|
|
||||||
// Analog and digital joystick data
|
// Analog and digital joystick data
|
||||||
struct StickStatus {
|
struct StickStatus {
|
||||||
Common::UUID uuid{};
|
Common::NewUUID uuid{};
|
||||||
AnalogStatus x{};
|
AnalogStatus x{};
|
||||||
AnalogStatus y{};
|
AnalogStatus y{};
|
||||||
bool left{};
|
bool left{};
|
||||||
@ -120,7 +120,7 @@ struct StickStatus {
|
|||||||
|
|
||||||
// Analog and digital trigger data
|
// Analog and digital trigger data
|
||||||
struct TriggerStatus {
|
struct TriggerStatus {
|
||||||
Common::UUID uuid{};
|
Common::NewUUID uuid{};
|
||||||
AnalogStatus analog{};
|
AnalogStatus analog{};
|
||||||
ButtonStatus pressed{};
|
ButtonStatus pressed{};
|
||||||
};
|
};
|
||||||
|
@ -204,7 +204,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
if (!button_devices[index]) {
|
if (!button_devices[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto uuid = Common::UUID{button_params[index].Get("guid", "")};
|
const auto uuid = Common::NewUUID{button_params[index].Get("guid", "")};
|
||||||
button_devices[index]->SetCallback({
|
button_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
||||||
@ -218,7 +218,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
if (!stick_devices[index]) {
|
if (!stick_devices[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto uuid = Common::UUID{stick_params[index].Get("guid", "")};
|
const auto uuid = Common::NewUUID{stick_params[index].Get("guid", "")};
|
||||||
stick_devices[index]->SetCallback({
|
stick_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
||||||
@ -232,7 +232,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
if (!trigger_devices[index]) {
|
if (!trigger_devices[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto uuid = Common::UUID{trigger_params[index].Get("guid", "")};
|
const auto uuid = Common::NewUUID{trigger_params[index].Get("guid", "")};
|
||||||
trigger_devices[index]->SetCallback({
|
trigger_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
||||||
@ -269,7 +269,8 @@ void EmulatedController::ReloadInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use a common UUID for TAS
|
// Use a common UUID for TAS
|
||||||
const auto tas_uuid = Common::UUID{0x0, 0x7A5};
|
static constexpr Common::NewUUID TAS_UUID = Common::NewUUID{
|
||||||
|
{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xA5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
|
||||||
|
|
||||||
// Register TAS devices. No need to force update
|
// Register TAS devices. No need to force update
|
||||||
for (std::size_t index = 0; index < tas_button_devices.size(); ++index) {
|
for (std::size_t index = 0; index < tas_button_devices.size(); ++index) {
|
||||||
@ -278,8 +279,8 @@ void EmulatedController::ReloadInput() {
|
|||||||
}
|
}
|
||||||
tas_button_devices[index]->SetCallback({
|
tas_button_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, tas_uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index](const Common::Input::CallbackStatus& callback) {
|
||||||
SetButton(callback, index, tas_uuid);
|
SetButton(callback, index, TAS_UUID);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -290,8 +291,8 @@ void EmulatedController::ReloadInput() {
|
|||||||
}
|
}
|
||||||
tas_stick_devices[index]->SetCallback({
|
tas_stick_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, tas_uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index](const Common::Input::CallbackStatus& callback) {
|
||||||
SetStick(callback, index, tas_uuid);
|
SetStick(callback, index, TAS_UUID);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -489,7 +490,7 @@ void EmulatedController::SetMotionParam(std::size_t index, Common::ParamPackage
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::UUID uuid) {
|
Common::NewUUID uuid) {
|
||||||
if (index >= controller.button_values.size()) {
|
if (index >= controller.button_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -638,7 +639,7 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::UUID uuid) {
|
Common::NewUUID uuid) {
|
||||||
if (index >= controller.stick_values.size()) {
|
if (index >= controller.stick_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -688,7 +689,7 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback,
|
void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback,
|
||||||
std::size_t index, Common::UUID uuid) {
|
std::size_t index, Common::NewUUID uuid) {
|
||||||
if (index >= controller.trigger_values.size()) {
|
if (index >= controller.trigger_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ private:
|
|||||||
* @param index Button ID of the to be updated
|
* @param index Button ID of the to be updated
|
||||||
*/
|
*/
|
||||||
void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::UUID uuid);
|
Common::NewUUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the analog stick status of the controller
|
* Updates the analog stick status of the controller
|
||||||
@ -362,7 +362,7 @@ private:
|
|||||||
* @param index stick ID of the to be updated
|
* @param index stick ID of the to be updated
|
||||||
*/
|
*/
|
||||||
void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::UUID uuid);
|
Common::NewUUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the trigger status of the controller
|
* Updates the trigger status of the controller
|
||||||
@ -370,7 +370,7 @@ private:
|
|||||||
* @param index trigger ID of the to be updated
|
* @param index trigger ID of the to be updated
|
||||||
*/
|
*/
|
||||||
void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::UUID uuid);
|
Common::NewUUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the motion status of the controller
|
* Updates the motion status of the controller
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/new_uuid.h"
|
||||||
#include "common/point.h"
|
#include "common/point.h"
|
||||||
#include "common/uuid.h"
|
|
||||||
|
|
||||||
namespace Core::HID {
|
namespace Core::HID {
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ bool GCAdapter::Setup() {
|
|||||||
std::size_t port = 0;
|
std::size_t port = 0;
|
||||||
for (GCController& pad : pads) {
|
for (GCController& pad : pads) {
|
||||||
pad.identifier = {
|
pad.identifier = {
|
||||||
.guid = Common::UUID{Common::INVALID_UUID},
|
.guid = Common::NewUUID{},
|
||||||
.port = port++,
|
.port = port++,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
constexpr PadIdentifier key_identifier = {
|
constexpr PadIdentifier key_identifier = {
|
||||||
.guid = Common::UUID{Common::INVALID_UUID},
|
.guid = Common::NewUUID{},
|
||||||
.port = 0,
|
.port = 0,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
constexpr PadIdentifier keyboard_key_identifier = {
|
constexpr PadIdentifier keyboard_key_identifier = {
|
||||||
.guid = Common::UUID{Common::INVALID_UUID},
|
.guid = Common::NewUUID{},
|
||||||
.port = 1,
|
.port = 1,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
constexpr PadIdentifier keyboard_modifier_identifier = {
|
constexpr PadIdentifier keyboard_modifier_identifier = {
|
||||||
.guid = Common::UUID{Common::INVALID_UUID},
|
.guid = Common::NewUUID{},
|
||||||
.port = 1,
|
.port = 1,
|
||||||
.pad = 1,
|
.pad = 1,
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ constexpr int motion_wheel_y = 4;
|
|||||||
constexpr int touch_axis_x = 10;
|
constexpr int touch_axis_x = 10;
|
||||||
constexpr int touch_axis_y = 11;
|
constexpr int touch_axis_y = 11;
|
||||||
constexpr PadIdentifier identifier = {
|
constexpr PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{Common::INVALID_UUID},
|
.guid = Common::NewUUID{},
|
||||||
.port = 0,
|
.port = 0,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
const PadIdentifier GetPadIdentifier() const {
|
const PadIdentifier GetPadIdentifier() const {
|
||||||
return {
|
return {
|
||||||
.guid = Common::UUID{guid},
|
.guid = Common::NewUUID{guid},
|
||||||
.port = static_cast<std::size_t>(port),
|
.port = static_cast<std::size_t>(port),
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
@ -502,7 +502,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
|
|||||||
Common::Input::VibrationError SDLDriver::SetRumble(
|
Common::Input::VibrationError SDLDriver::SetRumble(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||||
const auto joystick =
|
const auto joystick =
|
||||||
GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port));
|
GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
|
||||||
const auto process_amplitude_exp = [](f32 amplitude, f32 factor) {
|
const auto process_amplitude_exp = [](f32 amplitude, f32 factor) {
|
||||||
return (amplitude + std::pow(amplitude, factor)) * 0.5f * 0xFFFF;
|
return (amplitude + std::pow(amplitude, factor)) * 0.5f * 0xFFFF;
|
||||||
};
|
};
|
||||||
@ -599,7 +599,7 @@ Common::ParamPackage SDLDriver::BuildParamPackageForAnalog(PadIdentifier identif
|
|||||||
Common::ParamPackage params;
|
Common::ParamPackage params;
|
||||||
params.Set("engine", GetEngineName());
|
params.Set("engine", GetEngineName());
|
||||||
params.Set("port", static_cast<int>(identifier.port));
|
params.Set("port", static_cast<int>(identifier.port));
|
||||||
params.Set("guid", identifier.guid.Format());
|
params.Set("guid", identifier.guid.RawString());
|
||||||
params.Set("axis_x", axis_x);
|
params.Set("axis_x", axis_x);
|
||||||
params.Set("axis_y", axis_y);
|
params.Set("axis_y", axis_y);
|
||||||
params.Set("offset_x", offset_x);
|
params.Set("offset_x", offset_x);
|
||||||
|
@ -50,7 +50,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 18> text_to_tas_but
|
|||||||
Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
|
Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
|
||||||
for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
|
for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
|
||||||
PadIdentifier identifier{
|
PadIdentifier identifier{
|
||||||
.guid = Common::UUID{},
|
.guid = Common::NewUUID{},
|
||||||
.port = player_index,
|
.port = player_index,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
@ -203,7 +203,7 @@ void Tas::UpdateThread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PadIdentifier identifier{
|
PadIdentifier identifier{
|
||||||
.guid = Common::UUID{},
|
.guid = Common::NewUUID{},
|
||||||
.port = player_index,
|
.port = player_index,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
constexpr PadIdentifier identifier = {
|
constexpr PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{Common::INVALID_UUID},
|
.guid = Common::NewUUID{},
|
||||||
.port = 0,
|
.port = 0,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -351,10 +351,10 @@ PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::UUID UDPClient::GetHostUUID(const std::string& host) const {
|
Common::NewUUID UDPClient::GetHostUUID(const std::string& host) const {
|
||||||
const auto ip = boost::asio::ip::make_address_v4(host);
|
const auto ip = boost::asio::ip::make_address_v4(host);
|
||||||
const auto hex_host = fmt::format("{:06x}", ip.to_uint());
|
const auto hex_host = fmt::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint());
|
||||||
return Common::UUID{hex_host};
|
return Common::NewUUID{hex_host};
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::Reset() {
|
void UDPClient::Reset() {
|
||||||
@ -385,7 +385,7 @@ std::vector<Common::ParamPackage> UDPClient::GetInputDevices() const {
|
|||||||
Common::ParamPackage identifier{};
|
Common::ParamPackage identifier{};
|
||||||
identifier.Set("engine", GetEngineName());
|
identifier.Set("engine", GetEngineName());
|
||||||
identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad));
|
identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad));
|
||||||
identifier.Set("guid", pad_identifier.guid.Format());
|
identifier.Set("guid", pad_identifier.guid.RawString());
|
||||||
identifier.Set("port", static_cast<int>(pad_identifier.port));
|
identifier.Set("port", static_cast<int>(pad_identifier.port));
|
||||||
identifier.Set("pad", static_cast<int>(pad_identifier.pad));
|
identifier.Set("pad", static_cast<int>(pad_identifier.pad));
|
||||||
devices.emplace_back(identifier);
|
devices.emplace_back(identifier);
|
||||||
|
@ -126,7 +126,7 @@ private:
|
|||||||
struct ClientConnection {
|
struct ClientConnection {
|
||||||
ClientConnection();
|
ClientConnection();
|
||||||
~ClientConnection();
|
~ClientConnection();
|
||||||
Common::UUID uuid{"7F000001"};
|
Common::NewUUID uuid{"00000000-0000-0000-0000-00007F000001"};
|
||||||
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};
|
||||||
@ -148,7 +148,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);
|
||||||
PadIdentifier GetPadIdentifier(std::size_t pad_index) const;
|
PadIdentifier GetPadIdentifier(std::size_t pad_index) const;
|
||||||
Common::UUID GetHostUUID(const std::string& host) const;
|
Common::NewUUID GetHostUUID(const std::string& host) const;
|
||||||
|
|
||||||
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
|
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const {
|
|||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto controller_iter = controller_list.find(identifier);
|
const auto controller_iter = controller_list.find(identifier);
|
||||||
if (controller_iter == controller_list.cend()) {
|
if (controller_iter == controller_list.cend()) {
|
||||||
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(),
|
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
|
||||||
identifier.pad, identifier.port);
|
identifier.pad, identifier.port);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ bool InputEngine::GetHatButton(const PadIdentifier& identifier, int button, u8 d
|
|||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto controller_iter = controller_list.find(identifier);
|
const auto controller_iter = controller_list.find(identifier);
|
||||||
if (controller_iter == controller_list.cend()) {
|
if (controller_iter == controller_list.cend()) {
|
||||||
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(),
|
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
|
||||||
identifier.pad, identifier.port);
|
identifier.pad, identifier.port);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const {
|
|||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto controller_iter = controller_list.find(identifier);
|
const auto controller_iter = controller_list.find(identifier);
|
||||||
if (controller_iter == controller_list.cend()) {
|
if (controller_iter == controller_list.cend()) {
|
||||||
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(),
|
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
|
||||||
identifier.pad, identifier.port);
|
identifier.pad, identifier.port);
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const {
|
|||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto controller_iter = controller_list.find(identifier);
|
const auto controller_iter = controller_list.find(identifier);
|
||||||
if (controller_iter == controller_list.cend()) {
|
if (controller_iter == controller_list.cend()) {
|
||||||
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(),
|
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
|
||||||
identifier.pad, identifier.port);
|
identifier.pad, identifier.port);
|
||||||
return BatteryLevel::Charging;
|
return BatteryLevel::Charging;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion)
|
|||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto controller_iter = controller_list.find(identifier);
|
const auto controller_iter = controller_list.find(identifier);
|
||||||
if (controller_iter == controller_list.cend()) {
|
if (controller_iter == controller_list.cend()) {
|
||||||
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(),
|
LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
|
||||||
identifier.pad, identifier.port);
|
identifier.pad, identifier.port);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/input.h"
|
#include "common/input.h"
|
||||||
|
#include "common/new_uuid.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "common/uuid.h"
|
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
|
|
||||||
// Pad Identifier of data source
|
// Pad Identifier of data source
|
||||||
struct PadIdentifier {
|
struct PadIdentifier {
|
||||||
Common::UUID guid{Common::INVALID_UUID};
|
Common::NewUUID guid{};
|
||||||
std::size_t port{};
|
std::size_t port{};
|
||||||
std::size_t pad{};
|
std::size_t pad{};
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ namespace std {
|
|||||||
template <>
|
template <>
|
||||||
struct hash<PadIdentifier> {
|
struct hash<PadIdentifier> {
|
||||||
size_t operator()(const PadIdentifier& pad_id) const noexcept {
|
size_t operator()(const PadIdentifier& pad_id) const noexcept {
|
||||||
u64 hash_value = pad_id.guid.uuid[1] ^ pad_id.guid.uuid[0];
|
u64 hash_value = pad_id.guid.Hash();
|
||||||
hash_value ^= (static_cast<u64>(pad_id.port) << 32);
|
hash_value ^= (static_cast<u64>(pad_id.port) << 32);
|
||||||
hash_value ^= static_cast<u64>(pad_id.pad);
|
hash_value ^= static_cast<u64>(pad_id.pad);
|
||||||
return static_cast<size_t>(hash_value);
|
return static_cast<size_t>(hash_value);
|
||||||
|
@ -57,7 +57,7 @@ void MappingFactory::RegisterButton(const MappingData& data) {
|
|||||||
Common::ParamPackage new_input;
|
Common::ParamPackage new_input;
|
||||||
new_input.Set("engine", data.engine);
|
new_input.Set("engine", data.engine);
|
||||||
if (data.pad.guid.IsValid()) {
|
if (data.pad.guid.IsValid()) {
|
||||||
new_input.Set("guid", data.pad.guid.Format());
|
new_input.Set("guid", data.pad.guid.RawString());
|
||||||
}
|
}
|
||||||
new_input.Set("port", static_cast<int>(data.pad.port));
|
new_input.Set("port", static_cast<int>(data.pad.port));
|
||||||
new_input.Set("pad", static_cast<int>(data.pad.pad));
|
new_input.Set("pad", static_cast<int>(data.pad.pad));
|
||||||
@ -93,7 +93,7 @@ void MappingFactory::RegisterStick(const MappingData& data) {
|
|||||||
Common::ParamPackage new_input;
|
Common::ParamPackage new_input;
|
||||||
new_input.Set("engine", data.engine);
|
new_input.Set("engine", data.engine);
|
||||||
if (data.pad.guid.IsValid()) {
|
if (data.pad.guid.IsValid()) {
|
||||||
new_input.Set("guid", data.pad.guid.Format());
|
new_input.Set("guid", data.pad.guid.RawString());
|
||||||
}
|
}
|
||||||
new_input.Set("port", static_cast<int>(data.pad.port));
|
new_input.Set("port", static_cast<int>(data.pad.port));
|
||||||
new_input.Set("pad", static_cast<int>(data.pad.pad));
|
new_input.Set("pad", static_cast<int>(data.pad.pad));
|
||||||
@ -138,7 +138,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
|
|||||||
Common::ParamPackage new_input;
|
Common::ParamPackage new_input;
|
||||||
new_input.Set("engine", data.engine);
|
new_input.Set("engine", data.engine);
|
||||||
if (data.pad.guid.IsValid()) {
|
if (data.pad.guid.IsValid()) {
|
||||||
new_input.Set("guid", data.pad.guid.Format());
|
new_input.Set("guid", data.pad.guid.RawString());
|
||||||
}
|
}
|
||||||
new_input.Set("port", static_cast<int>(data.pad.port));
|
new_input.Set("port", static_cast<int>(data.pad.port));
|
||||||
new_input.Set("pad", static_cast<int>(data.pad.pad));
|
new_input.Set("pad", static_cast<int>(data.pad.pad));
|
||||||
|
@ -691,7 +691,7 @@ private:
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -714,7 +714,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -736,7 +736,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
|
|||||||
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
||||||
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -768,7 +768,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -789,7 +789,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -820,7 +820,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
|
|||||||
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
||||||
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -857,7 +857,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -869,7 +869,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
|
||||||
Common::ParamPackage params) {
|
Common::ParamPackage params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -963,7 +963,7 @@ OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_)
|
|||||||
std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create(
|
std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::UUID{params.Get("guid", "")},
|
.guid = Common::NewUUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user