diff options
| author | 2022-02-05 00:40:28 -0500 | |
|---|---|---|
| committer | 2022-02-05 13:18:41 -0500 | |
| commit | cb30fe50cd074fe05dd1d6e4b0d58116d3d98489 (patch) | |
| tree | 58450d743d317369266bbbea44734725d8b83ea6 /src | |
| parent | common: Implement NewUUID (diff) | |
| download | yuzu-cb30fe50cd074fe05dd1d6e4b0d58116d3d98489.tar.gz yuzu-cb30fe50cd074fe05dd1d6e4b0d58116d3d98489.tar.xz yuzu-cb30fe50cd074fe05dd1d6e4b0d58116d3d98489.zip | |
input/hid: Migrate to the new UUID implementation
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/input.h | 8 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 23 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 6 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/keyboard.cpp | 6 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 6 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/touch_screen.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 8 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.h | 4 | ||||
| -rw-r--r-- | src/input_common/input_engine.cpp | 10 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 6 | ||||
| -rw-r--r-- | src/input_common/input_mapping.cpp | 6 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 18 |
16 files changed, 57 insertions, 56 deletions
diff --git a/src/common/input.h b/src/common/input.h index 54fcb24b0..95d30497d 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -10,8 +10,8 @@ | |||
| 10 | #include <unordered_map> | 10 | #include <unordered_map> |
| 11 | #include <utility> | 11 | #include <utility> |
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/new_uuid.h" | ||
| 13 | #include "common/param_package.h" | 14 | #include "common/param_package.h" |
| 14 | #include "common/uuid.h" | ||
| 15 | 15 | ||
| 16 | namespace Common::Input { | 16 | namespace Common::Input { |
| 17 | 17 | ||
| @@ -97,7 +97,7 @@ struct AnalogStatus { | |||
| 97 | 97 | ||
| 98 | // Button data | 98 | // Button data |
| 99 | struct ButtonStatus { | 99 | struct ButtonStatus { |
| 100 | Common::UUID uuid{}; | 100 | Common::NewUUID uuid{}; |
| 101 | bool value{}; | 101 | bool value{}; |
| 102 | bool inverted{}; | 102 | bool inverted{}; |
| 103 | bool toggle{}; | 103 | bool toggle{}; |
| @@ -109,7 +109,7 @@ using BatteryStatus = BatteryLevel; | |||
| 109 | 109 | ||
| 110 | // Analog and digital joystick data | 110 | // Analog and digital joystick data |
| 111 | struct StickStatus { | 111 | struct StickStatus { |
| 112 | Common::UUID uuid{}; | 112 | Common::NewUUID uuid{}; |
| 113 | AnalogStatus x{}; | 113 | AnalogStatus x{}; |
| 114 | AnalogStatus y{}; | 114 | AnalogStatus y{}; |
| 115 | bool left{}; | 115 | bool left{}; |
| @@ -120,7 +120,7 @@ struct StickStatus { | |||
| 120 | 120 | ||
| 121 | // Analog and digital trigger data | 121 | // Analog and digital trigger data |
| 122 | struct TriggerStatus { | 122 | struct TriggerStatus { |
| 123 | Common::UUID uuid{}; | 123 | Common::NewUUID uuid{}; |
| 124 | AnalogStatus analog{}; | 124 | AnalogStatus analog{}; |
| 125 | ButtonStatus pressed{}; | 125 | ButtonStatus pressed{}; |
| 126 | }; | 126 | }; |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index a7cdf45e6..44e9f22b9 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -204,7 +204,7 @@ void EmulatedController::ReloadInput() { | |||
| 204 | if (!button_devices[index]) { | 204 | if (!button_devices[index]) { |
| 205 | continue; | 205 | continue; |
| 206 | } | 206 | } |
| 207 | const auto uuid = Common::UUID{button_params[index].Get("guid", "")}; | 207 | const auto uuid = Common::NewUUID{button_params[index].Get("guid", "")}; |
| 208 | button_devices[index]->SetCallback({ | 208 | button_devices[index]->SetCallback({ |
| 209 | .on_change = | 209 | .on_change = |
| 210 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { | 210 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { |
| @@ -218,7 +218,7 @@ void EmulatedController::ReloadInput() { | |||
| 218 | if (!stick_devices[index]) { | 218 | if (!stick_devices[index]) { |
| 219 | continue; | 219 | continue; |
| 220 | } | 220 | } |
| 221 | const auto uuid = Common::UUID{stick_params[index].Get("guid", "")}; | 221 | const auto uuid = Common::NewUUID{stick_params[index].Get("guid", "")}; |
| 222 | stick_devices[index]->SetCallback({ | 222 | stick_devices[index]->SetCallback({ |
| 223 | .on_change = | 223 | .on_change = |
| 224 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { | 224 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { |
| @@ -232,7 +232,7 @@ void EmulatedController::ReloadInput() { | |||
| 232 | if (!trigger_devices[index]) { | 232 | if (!trigger_devices[index]) { |
| 233 | continue; | 233 | continue; |
| 234 | } | 234 | } |
| 235 | const auto uuid = Common::UUID{trigger_params[index].Get("guid", "")}; | 235 | const auto uuid = Common::NewUUID{trigger_params[index].Get("guid", "")}; |
| 236 | trigger_devices[index]->SetCallback({ | 236 | trigger_devices[index]->SetCallback({ |
| 237 | .on_change = | 237 | .on_change = |
| 238 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { | 238 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { |
| @@ -269,7 +269,8 @@ void EmulatedController::ReloadInput() { | |||
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | // Use a common UUID for TAS | 271 | // Use a common UUID for TAS |
| 272 | const auto tas_uuid = Common::UUID{0x0, 0x7A5}; | 272 | static constexpr Common::NewUUID TAS_UUID = Common::NewUUID{ |
| 273 | {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xA5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}; | ||
| 273 | 274 | ||
| 274 | // Register TAS devices. No need to force update | 275 | // Register TAS devices. No need to force update |
| 275 | for (std::size_t index = 0; index < tas_button_devices.size(); ++index) { | 276 | for (std::size_t index = 0; index < tas_button_devices.size(); ++index) { |
| @@ -278,8 +279,8 @@ void EmulatedController::ReloadInput() { | |||
| 278 | } | 279 | } |
| 279 | tas_button_devices[index]->SetCallback({ | 280 | tas_button_devices[index]->SetCallback({ |
| 280 | .on_change = | 281 | .on_change = |
| 281 | [this, index, tas_uuid](const Common::Input::CallbackStatus& callback) { | 282 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 282 | SetButton(callback, index, tas_uuid); | 283 | SetButton(callback, index, TAS_UUID); |
| 283 | }, | 284 | }, |
| 284 | }); | 285 | }); |
| 285 | } | 286 | } |
| @@ -290,8 +291,8 @@ void EmulatedController::ReloadInput() { | |||
| 290 | } | 291 | } |
| 291 | tas_stick_devices[index]->SetCallback({ | 292 | tas_stick_devices[index]->SetCallback({ |
| 292 | .on_change = | 293 | .on_change = |
| 293 | [this, index, tas_uuid](const Common::Input::CallbackStatus& callback) { | 294 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 294 | SetStick(callback, index, tas_uuid); | 295 | SetStick(callback, index, TAS_UUID); |
| 295 | }, | 296 | }, |
| 296 | }); | 297 | }); |
| 297 | } | 298 | } |
| @@ -489,7 +490,7 @@ void EmulatedController::SetMotionParam(std::size_t index, Common::ParamPackage | |||
| 489 | } | 490 | } |
| 490 | 491 | ||
| 491 | void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, | 492 | void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 492 | Common::UUID uuid) { | 493 | Common::NewUUID uuid) { |
| 493 | if (index >= controller.button_values.size()) { | 494 | if (index >= controller.button_values.size()) { |
| 494 | return; | 495 | return; |
| 495 | } | 496 | } |
| @@ -638,7 +639,7 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback | |||
| 638 | } | 639 | } |
| 639 | 640 | ||
| 640 | void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, | 641 | void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 641 | Common::UUID uuid) { | 642 | Common::NewUUID uuid) { |
| 642 | if (index >= controller.stick_values.size()) { | 643 | if (index >= controller.stick_values.size()) { |
| 643 | return; | 644 | return; |
| 644 | } | 645 | } |
| @@ -688,7 +689,7 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, | |||
| 688 | } | 689 | } |
| 689 | 690 | ||
| 690 | void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback, | 691 | void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback, |
| 691 | std::size_t index, Common::UUID uuid) { | 692 | std::size_t index, Common::NewUUID uuid) { |
| 692 | if (index >= controller.trigger_values.size()) { | 693 | if (index >= controller.trigger_values.size()) { |
| 693 | return; | 694 | return; |
| 694 | } | 695 | } |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index d8642c5b3..ed61e9522 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -354,7 +354,7 @@ private: | |||
| 354 | * @param index Button ID of the to be updated | 354 | * @param index Button ID of the to be updated |
| 355 | */ | 355 | */ |
| 356 | void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, | 356 | void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 357 | Common::UUID uuid); | 357 | Common::NewUUID uuid); |
| 358 | 358 | ||
| 359 | /** | 359 | /** |
| 360 | * Updates the analog stick status of the controller | 360 | * Updates the analog stick status of the controller |
| @@ -362,7 +362,7 @@ private: | |||
| 362 | * @param index stick ID of the to be updated | 362 | * @param index stick ID of the to be updated |
| 363 | */ | 363 | */ |
| 364 | void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, | 364 | void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 365 | Common::UUID uuid); | 365 | Common::NewUUID uuid); |
| 366 | 366 | ||
| 367 | /** | 367 | /** |
| 368 | * Updates the trigger status of the controller | 368 | * Updates the trigger status of the controller |
| @@ -370,7 +370,7 @@ private: | |||
| 370 | * @param index trigger ID of the to be updated | 370 | * @param index trigger ID of the to be updated |
| 371 | */ | 371 | */ |
| 372 | void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index, | 372 | void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 373 | Common::UUID uuid); | 373 | Common::NewUUID uuid); |
| 374 | 374 | ||
| 375 | /** | 375 | /** |
| 376 | * Updates the motion status of the controller | 376 | * Updates the motion status of the controller |
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 778b328b9..a4ccdf11c 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -7,8 +7,8 @@ | |||
| 7 | #include "common/bit_field.h" | 7 | #include "common/bit_field.h" |
| 8 | #include "common/common_funcs.h" | 8 | #include "common/common_funcs.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/new_uuid.h" | ||
| 10 | #include "common/point.h" | 11 | #include "common/point.h" |
| 11 | #include "common/uuid.h" | ||
| 12 | 12 | ||
| 13 | namespace Core::HID { | 13 | namespace Core::HID { |
| 14 | 14 | ||
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 7ab4540a8..7a269b526 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -248,7 +248,7 @@ bool GCAdapter::Setup() { | |||
| 248 | std::size_t port = 0; | 248 | std::size_t port = 0; |
| 249 | for (GCController& pad : pads) { | 249 | for (GCController& pad : pads) { |
| 250 | pad.identifier = { | 250 | pad.identifier = { |
| 251 | .guid = Common::UUID{Common::INVALID_UUID}, | 251 | .guid = Common::NewUUID{}, |
| 252 | .port = port++, | 252 | .port = port++, |
| 253 | .pad = 0, | 253 | .pad = 0, |
| 254 | }; | 254 | }; |
diff --git a/src/input_common/drivers/keyboard.cpp b/src/input_common/drivers/keyboard.cpp index 4c1e5bbec..449509270 100644 --- a/src/input_common/drivers/keyboard.cpp +++ b/src/input_common/drivers/keyboard.cpp | |||
| @@ -9,17 +9,17 @@ | |||
| 9 | namespace InputCommon { | 9 | namespace InputCommon { |
| 10 | 10 | ||
| 11 | constexpr PadIdentifier key_identifier = { | 11 | constexpr PadIdentifier key_identifier = { |
| 12 | .guid = Common::UUID{Common::INVALID_UUID}, | 12 | .guid = Common::NewUUID{}, |
| 13 | .port = 0, | 13 | .port = 0, |
| 14 | .pad = 0, | 14 | .pad = 0, |
| 15 | }; | 15 | }; |
| 16 | constexpr PadIdentifier keyboard_key_identifier = { | 16 | constexpr PadIdentifier keyboard_key_identifier = { |
| 17 | .guid = Common::UUID{Common::INVALID_UUID}, | 17 | .guid = Common::NewUUID{}, |
| 18 | .port = 1, | 18 | .port = 1, |
| 19 | .pad = 0, | 19 | .pad = 0, |
| 20 | }; | 20 | }; |
| 21 | constexpr PadIdentifier keyboard_modifier_identifier = { | 21 | constexpr PadIdentifier keyboard_modifier_identifier = { |
| 22 | .guid = Common::UUID{Common::INVALID_UUID}, | 22 | .guid = Common::NewUUID{}, |
| 23 | .port = 1, | 23 | .port = 1, |
| 24 | .pad = 1, | 24 | .pad = 1, |
| 25 | }; | 25 | }; |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index d8ae7f0c1..ae63088ba 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -20,7 +20,7 @@ constexpr int motion_wheel_y = 4; | |||
| 20 | constexpr int touch_axis_x = 10; | 20 | constexpr int touch_axis_x = 10; |
| 21 | constexpr int touch_axis_y = 11; | 21 | constexpr int touch_axis_y = 11; |
| 22 | constexpr PadIdentifier identifier = { | 22 | constexpr PadIdentifier identifier = { |
| 23 | .guid = Common::UUID{Common::INVALID_UUID}, | 23 | .guid = Common::NewUUID{}, |
| 24 | .port = 0, | 24 | .port = 0, |
| 25 | .pad = 0, | 25 | .pad = 0, |
| 26 | }; | 26 | }; |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index b031a8523..b9a8317d4 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -120,7 +120,7 @@ public: | |||
| 120 | */ | 120 | */ |
| 121 | const PadIdentifier GetPadIdentifier() const { | 121 | const PadIdentifier GetPadIdentifier() const { |
| 122 | return { | 122 | return { |
| 123 | .guid = Common::UUID{guid}, | 123 | .guid = Common::NewUUID{guid}, |
| 124 | .port = static_cast<std::size_t>(port), | 124 | .port = static_cast<std::size_t>(port), |
| 125 | .pad = 0, | 125 | .pad = 0, |
| 126 | }; | 126 | }; |
| @@ -502,7 +502,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { | |||
| 502 | Common::Input::VibrationError SDLDriver::SetRumble( | 502 | Common::Input::VibrationError SDLDriver::SetRumble( |
| 503 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | 503 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { |
| 504 | const auto joystick = | 504 | const auto joystick = |
| 505 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); | 505 | GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); |
| 506 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { | 506 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { |
| 507 | return (amplitude + std::pow(amplitude, factor)) * 0.5f * 0xFFFF; | 507 | return (amplitude + std::pow(amplitude, factor)) * 0.5f * 0xFFFF; |
| 508 | }; | 508 | }; |
| @@ -599,7 +599,7 @@ Common::ParamPackage SDLDriver::BuildParamPackageForAnalog(PadIdentifier identif | |||
| 599 | Common::ParamPackage params; | 599 | Common::ParamPackage params; |
| 600 | params.Set("engine", GetEngineName()); | 600 | params.Set("engine", GetEngineName()); |
| 601 | params.Set("port", static_cast<int>(identifier.port)); | 601 | params.Set("port", static_cast<int>(identifier.port)); |
| 602 | params.Set("guid", identifier.guid.Format()); | 602 | params.Set("guid", identifier.guid.RawString()); |
| 603 | params.Set("axis_x", axis_x); | 603 | params.Set("axis_x", axis_x); |
| 604 | params.Set("axis_y", axis_y); | 604 | params.Set("axis_y", axis_y); |
| 605 | params.Set("offset_x", offset_x); | 605 | params.Set("offset_x", offset_x); |
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 944e141bf..6d36cf5da 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp | |||
| @@ -50,7 +50,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 18> text_to_tas_but | |||
| 50 | Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) { | 50 | Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 51 | for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) { | 51 | for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) { |
| 52 | PadIdentifier identifier{ | 52 | PadIdentifier identifier{ |
| 53 | .guid = Common::UUID{}, | 53 | .guid = Common::NewUUID{}, |
| 54 | .port = player_index, | 54 | .port = player_index, |
| 55 | .pad = 0, | 55 | .pad = 0, |
| 56 | }; | 56 | }; |
| @@ -203,7 +203,7 @@ void Tas::UpdateThread() { | |||
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | PadIdentifier identifier{ | 205 | PadIdentifier identifier{ |
| 206 | .guid = Common::UUID{}, | 206 | .guid = Common::NewUUID{}, |
| 207 | .port = player_index, | 207 | .port = player_index, |
| 208 | .pad = 0, | 208 | .pad = 0, |
| 209 | }; | 209 | }; |
diff --git a/src/input_common/drivers/touch_screen.cpp b/src/input_common/drivers/touch_screen.cpp index 880781825..1030e74d9 100644 --- a/src/input_common/drivers/touch_screen.cpp +++ b/src/input_common/drivers/touch_screen.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | namespace InputCommon { | 8 | namespace InputCommon { |
| 9 | 9 | ||
| 10 | constexpr PadIdentifier identifier = { | 10 | constexpr PadIdentifier identifier = { |
| 11 | .guid = Common::UUID{Common::INVALID_UUID}, | 11 | .guid = Common::NewUUID{}, |
| 12 | .port = 0, | 12 | .port = 0, |
| 13 | .pad = 0, | 13 | .pad = 0, |
| 14 | }; | 14 | }; |
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 333173e3d..cbcfa7a4b 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -351,10 +351,10 @@ PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { | |||
| 351 | }; | 351 | }; |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | Common::UUID UDPClient::GetHostUUID(const std::string& host) const { | 354 | Common::NewUUID UDPClient::GetHostUUID(const std::string& host) const { |
| 355 | const auto ip = boost::asio::ip::make_address_v4(host); | 355 | const auto ip = boost::asio::ip::make_address_v4(host); |
| 356 | const auto hex_host = fmt::format("{:06x}", ip.to_uint()); | 356 | const auto hex_host = fmt::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint()); |
| 357 | return Common::UUID{hex_host}; | 357 | return Common::NewUUID{hex_host}; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | void UDPClient::Reset() { | 360 | void UDPClient::Reset() { |
| @@ -385,7 +385,7 @@ std::vector<Common::ParamPackage> UDPClient::GetInputDevices() const { | |||
| 385 | Common::ParamPackage identifier{}; | 385 | Common::ParamPackage identifier{}; |
| 386 | identifier.Set("engine", GetEngineName()); | 386 | identifier.Set("engine", GetEngineName()); |
| 387 | identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad)); | 387 | identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad)); |
| 388 | identifier.Set("guid", pad_identifier.guid.Format()); | 388 | identifier.Set("guid", pad_identifier.guid.RawString()); |
| 389 | identifier.Set("port", static_cast<int>(pad_identifier.port)); | 389 | identifier.Set("port", static_cast<int>(pad_identifier.port)); |
| 390 | identifier.Set("pad", static_cast<int>(pad_identifier.pad)); | 390 | identifier.Set("pad", static_cast<int>(pad_identifier.pad)); |
| 391 | devices.emplace_back(identifier); | 391 | devices.emplace_back(identifier); |
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h index e9c178139..98abeedd1 100644 --- a/src/input_common/drivers/udp_client.h +++ b/src/input_common/drivers/udp_client.h | |||
| @@ -126,7 +126,7 @@ private: | |||
| 126 | struct ClientConnection { | 126 | struct ClientConnection { |
| 127 | ClientConnection(); | 127 | ClientConnection(); |
| 128 | ~ClientConnection(); | 128 | ~ClientConnection(); |
| 129 | Common::UUID uuid{"7F000001"}; | 129 | Common::NewUUID uuid{"00000000-0000-0000-0000-00007F000001"}; |
| 130 | std::string host{"127.0.0.1"}; | 130 | std::string host{"127.0.0.1"}; |
| 131 | u16 port{26760}; | 131 | u16 port{26760}; |
| 132 | s8 active{-1}; | 132 | s8 active{-1}; |
| @@ -148,7 +148,7 @@ private: | |||
| 148 | void OnPadData(Response::PadData, std::size_t client); | 148 | void OnPadData(Response::PadData, std::size_t client); |
| 149 | void StartCommunication(std::size_t client, const std::string& host, u16 port); | 149 | void StartCommunication(std::size_t client, const std::string& host, u16 port); |
| 150 | PadIdentifier GetPadIdentifier(std::size_t pad_index) const; | 150 | PadIdentifier GetPadIdentifier(std::size_t pad_index) const; |
| 151 | Common::UUID GetHostUUID(const std::string& host) const; | 151 | Common::NewUUID GetHostUUID(const std::string& host) const; |
| 152 | 152 | ||
| 153 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; | 153 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; |
| 154 | 154 | ||
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 0508b408d..65ae1b848 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -96,7 +96,7 @@ bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { | |||
| 96 | std::lock_guard lock{mutex}; | 96 | std::lock_guard lock{mutex}; |
| 97 | const auto controller_iter = controller_list.find(identifier); | 97 | const auto controller_iter = controller_list.find(identifier); |
| 98 | if (controller_iter == controller_list.cend()) { | 98 | if (controller_iter == controller_list.cend()) { |
| 99 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 99 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 100 | identifier.pad, identifier.port); | 100 | identifier.pad, identifier.port); |
| 101 | return false; | 101 | return false; |
| 102 | } | 102 | } |
| @@ -113,7 +113,7 @@ bool InputEngine::GetHatButton(const PadIdentifier& identifier, int button, u8 d | |||
| 113 | std::lock_guard lock{mutex}; | 113 | std::lock_guard lock{mutex}; |
| 114 | const auto controller_iter = controller_list.find(identifier); | 114 | const auto controller_iter = controller_list.find(identifier); |
| 115 | if (controller_iter == controller_list.cend()) { | 115 | if (controller_iter == controller_list.cend()) { |
| 116 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 116 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 117 | identifier.pad, identifier.port); | 117 | identifier.pad, identifier.port); |
| 118 | return false; | 118 | return false; |
| 119 | } | 119 | } |
| @@ -130,7 +130,7 @@ f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const { | |||
| 130 | std::lock_guard lock{mutex}; | 130 | std::lock_guard lock{mutex}; |
| 131 | const auto controller_iter = controller_list.find(identifier); | 131 | const auto controller_iter = controller_list.find(identifier); |
| 132 | if (controller_iter == controller_list.cend()) { | 132 | if (controller_iter == controller_list.cend()) { |
| 133 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 133 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 134 | identifier.pad, identifier.port); | 134 | identifier.pad, identifier.port); |
| 135 | return 0.0f; | 135 | return 0.0f; |
| 136 | } | 136 | } |
| @@ -147,7 +147,7 @@ BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const { | |||
| 147 | std::lock_guard lock{mutex}; | 147 | std::lock_guard lock{mutex}; |
| 148 | const auto controller_iter = controller_list.find(identifier); | 148 | const auto controller_iter = controller_list.find(identifier); |
| 149 | if (controller_iter == controller_list.cend()) { | 149 | if (controller_iter == controller_list.cend()) { |
| 150 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 150 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 151 | identifier.pad, identifier.port); | 151 | identifier.pad, identifier.port); |
| 152 | return BatteryLevel::Charging; | 152 | return BatteryLevel::Charging; |
| 153 | } | 153 | } |
| @@ -159,7 +159,7 @@ BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) | |||
| 159 | std::lock_guard lock{mutex}; | 159 | std::lock_guard lock{mutex}; |
| 160 | const auto controller_iter = controller_list.find(identifier); | 160 | const auto controller_iter = controller_list.find(identifier); |
| 161 | if (controller_iter == controller_list.cend()) { | 161 | if (controller_iter == controller_list.cend()) { |
| 162 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 162 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 163 | identifier.pad, identifier.port); | 163 | identifier.pad, identifier.port); |
| 164 | return {}; | 164 | return {}; |
| 165 | } | 165 | } |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index fe2faee5a..05e45b877 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -10,13 +10,13 @@ | |||
| 10 | 10 | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/input.h" | 12 | #include "common/input.h" |
| 13 | #include "common/new_uuid.h" | ||
| 13 | #include "common/param_package.h" | 14 | #include "common/param_package.h" |
| 14 | #include "common/uuid.h" | ||
| 15 | #include "input_common/main.h" | 15 | #include "input_common/main.h" |
| 16 | 16 | ||
| 17 | // Pad Identifier of data source | 17 | // Pad Identifier of data source |
| 18 | struct PadIdentifier { | 18 | struct PadIdentifier { |
| 19 | Common::UUID guid{Common::INVALID_UUID}; | 19 | Common::NewUUID guid{}; |
| 20 | std::size_t port{}; | 20 | std::size_t port{}; |
| 21 | std::size_t pad{}; | 21 | std::size_t pad{}; |
| 22 | 22 | ||
| @@ -59,7 +59,7 @@ namespace std { | |||
| 59 | template <> | 59 | template <> |
| 60 | struct hash<PadIdentifier> { | 60 | struct hash<PadIdentifier> { |
| 61 | size_t operator()(const PadIdentifier& pad_id) const noexcept { | 61 | size_t operator()(const PadIdentifier& pad_id) const noexcept { |
| 62 | u64 hash_value = pad_id.guid.uuid[1] ^ pad_id.guid.uuid[0]; | 62 | u64 hash_value = pad_id.guid.Hash(); |
| 63 | hash_value ^= (static_cast<u64>(pad_id.port) << 32); | 63 | hash_value ^= (static_cast<u64>(pad_id.port) << 32); |
| 64 | hash_value ^= static_cast<u64>(pad_id.pad); | 64 | hash_value ^= static_cast<u64>(pad_id.pad); |
| 65 | return static_cast<size_t>(hash_value); | 65 | return static_cast<size_t>(hash_value); |
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index a7a6ad8c2..fb78093b8 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp | |||
| @@ -57,7 +57,7 @@ void MappingFactory::RegisterButton(const MappingData& data) { | |||
| 57 | Common::ParamPackage new_input; | 57 | Common::ParamPackage new_input; |
| 58 | new_input.Set("engine", data.engine); | 58 | new_input.Set("engine", data.engine); |
| 59 | if (data.pad.guid.IsValid()) { | 59 | if (data.pad.guid.IsValid()) { |
| 60 | new_input.Set("guid", data.pad.guid.Format()); | 60 | new_input.Set("guid", data.pad.guid.RawString()); |
| 61 | } | 61 | } |
| 62 | new_input.Set("port", static_cast<int>(data.pad.port)); | 62 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 63 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 63 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
| @@ -93,7 +93,7 @@ void MappingFactory::RegisterStick(const MappingData& data) { | |||
| 93 | Common::ParamPackage new_input; | 93 | Common::ParamPackage new_input; |
| 94 | new_input.Set("engine", data.engine); | 94 | new_input.Set("engine", data.engine); |
| 95 | if (data.pad.guid.IsValid()) { | 95 | if (data.pad.guid.IsValid()) { |
| 96 | new_input.Set("guid", data.pad.guid.Format()); | 96 | new_input.Set("guid", data.pad.guid.RawString()); |
| 97 | } | 97 | } |
| 98 | new_input.Set("port", static_cast<int>(data.pad.port)); | 98 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 99 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 99 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
| @@ -138,7 +138,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) { | |||
| 138 | Common::ParamPackage new_input; | 138 | Common::ParamPackage new_input; |
| 139 | new_input.Set("engine", data.engine); | 139 | new_input.Set("engine", data.engine); |
| 140 | if (data.pad.guid.IsValid()) { | 140 | if (data.pad.guid.IsValid()) { |
| 141 | new_input.Set("guid", data.pad.guid.Format()); | 141 | new_input.Set("guid", data.pad.guid.RawString()); |
| 142 | } | 142 | } |
| 143 | new_input.Set("port", static_cast<int>(data.pad.port)); | 143 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 144 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 144 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 2f3c0735a..313703f5f 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -691,7 +691,7 @@ private: | |||
| 691 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice( | 691 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice( |
| 692 | const Common::ParamPackage& params) { | 692 | const Common::ParamPackage& params) { |
| 693 | const PadIdentifier identifier = { | 693 | const PadIdentifier identifier = { |
| 694 | .guid = Common::UUID{params.Get("guid", "")}, | 694 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 695 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 695 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 696 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 696 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 697 | }; | 697 | }; |
| @@ -714,7 +714,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice( | |||
| 714 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice( | 714 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice( |
| 715 | const Common::ParamPackage& params) { | 715 | const Common::ParamPackage& params) { |
| 716 | const PadIdentifier identifier = { | 716 | const PadIdentifier identifier = { |
| 717 | .guid = Common::UUID{params.Get("guid", "")}, | 717 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 718 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 718 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 719 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 719 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 720 | }; | 720 | }; |
| @@ -736,7 +736,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 736 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); | 736 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); |
| 737 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); | 737 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); |
| 738 | const PadIdentifier identifier = { | 738 | const PadIdentifier identifier = { |
| 739 | .guid = Common::UUID{params.Get("guid", "")}, | 739 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 740 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 740 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 741 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 741 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 742 | }; | 742 | }; |
| @@ -768,7 +768,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 768 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( | 768 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( |
| 769 | const Common::ParamPackage& params) { | 769 | const Common::ParamPackage& params) { |
| 770 | const PadIdentifier identifier = { | 770 | const PadIdentifier identifier = { |
| 771 | .guid = Common::UUID{params.Get("guid", "")}, | 771 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 772 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 772 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 773 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 773 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 774 | }; | 774 | }; |
| @@ -789,7 +789,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 789 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( | 789 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( |
| 790 | const Common::ParamPackage& params) { | 790 | const Common::ParamPackage& params) { |
| 791 | const PadIdentifier identifier = { | 791 | const PadIdentifier identifier = { |
| 792 | .guid = Common::UUID{params.Get("guid", "")}, | 792 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 793 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 793 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 794 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 794 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 795 | }; | 795 | }; |
| @@ -820,7 +820,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 820 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); | 820 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); |
| 821 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); | 821 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); |
| 822 | const PadIdentifier identifier = { | 822 | const PadIdentifier identifier = { |
| 823 | .guid = Common::UUID{params.Get("guid", "")}, | 823 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 824 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 824 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 825 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 825 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 826 | }; | 826 | }; |
| @@ -857,7 +857,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 857 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( | 857 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( |
| 858 | const Common::ParamPackage& params) { | 858 | const Common::ParamPackage& params) { |
| 859 | const PadIdentifier identifier = { | 859 | const PadIdentifier identifier = { |
| 860 | .guid = Common::UUID{params.Get("guid", "")}, | 860 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 861 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 861 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 862 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 862 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 863 | }; | 863 | }; |
| @@ -869,7 +869,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( | |||
| 869 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( | 869 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( |
| 870 | Common::ParamPackage params) { | 870 | Common::ParamPackage params) { |
| 871 | const PadIdentifier identifier = { | 871 | const PadIdentifier identifier = { |
| 872 | .guid = Common::UUID{params.Get("guid", "")}, | 872 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 873 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 873 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 874 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 874 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 875 | }; | 875 | }; |
| @@ -963,7 +963,7 @@ OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) | |||
| 963 | std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create( | 963 | std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create( |
| 964 | const Common::ParamPackage& params) { | 964 | const Common::ParamPackage& params) { |
| 965 | const PadIdentifier identifier = { | 965 | const PadIdentifier identifier = { |
| 966 | .guid = Common::UUID{params.Get("guid", "")}, | 966 | .guid = Common::NewUUID{params.Get("guid", "")}, |
| 967 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 967 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| 968 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 968 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 969 | }; | 969 | }; |