diff options
| -rw-r--r-- | src/common/input.h | 6 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 6 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.h | 8 | ||||
| -rw-r--r-- | src/input_common/drivers/keyboard.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/keyboard.h | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 12 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.h | 14 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.h | 6 | ||||
| -rw-r--r-- | src/input_common/drivers/touch_screen.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/touch_screen.h | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.h | 6 | ||||
| -rw-r--r-- | src/input_common/input_engine.cpp | 86 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 53 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 4 |
18 files changed, 109 insertions, 114 deletions
diff --git a/src/common/input.h b/src/common/input.h index eaee0bdea..0b92449bc 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -266,11 +266,9 @@ class OutputDevice { | |||
| 266 | public: | 266 | public: |
| 267 | virtual ~OutputDevice() = default; | 267 | virtual ~OutputDevice() = default; |
| 268 | 268 | ||
| 269 | virtual void SetLED([[maybe_unused]] LedStatus led_status) { | 269 | virtual void SetLED([[maybe_unused]] const LedStatus& led_status) {} |
| 270 | return; | ||
| 271 | } | ||
| 272 | 270 | ||
| 273 | virtual VibrationError SetVibration([[maybe_unused]] VibrationStatus vibration_status) { | 271 | virtual VibrationError SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) { |
| 274 | return VibrationError::NotSupported; | 272 | return VibrationError::NotSupported; |
| 275 | } | 273 | } |
| 276 | 274 | ||
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 8b6574223..7ab4540a8 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -69,7 +69,7 @@ private: | |||
| 69 | libusb_device_handle* handle{}; | 69 | libusb_device_handle* handle{}; |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | GCAdapter::GCAdapter(const std::string& input_engine_) : InputEngine(input_engine_) { | 72 | GCAdapter::GCAdapter(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 73 | if (usb_adapter_handle) { | 73 | if (usb_adapter_handle) { |
| 74 | return; | 74 | return; |
| 75 | } | 75 | } |
| @@ -325,8 +325,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) { | |||
| 325 | return true; | 325 | return true; |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | Common::Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, | 328 | Common::Input::VibrationError GCAdapter::SetRumble( |
| 329 | const Common::Input::VibrationStatus vibration) { | 329 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { |
| 330 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; | 330 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; |
| 331 | const auto processed_amplitude = | 331 | const auto processed_amplitude = |
| 332 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); | 332 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); |
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index 8dc51d2e5..7ce1912a3 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -22,13 +22,13 @@ namespace InputCommon { | |||
| 22 | class LibUSBContext; | 22 | class LibUSBContext; |
| 23 | class LibUSBDeviceHandle; | 23 | class LibUSBDeviceHandle; |
| 24 | 24 | ||
| 25 | class GCAdapter : public InputCommon::InputEngine { | 25 | class GCAdapter : public InputEngine { |
| 26 | public: | 26 | public: |
| 27 | explicit GCAdapter(const std::string& input_engine_); | 27 | explicit GCAdapter(std::string input_engine_); |
| 28 | ~GCAdapter(); | 28 | ~GCAdapter() override; |
| 29 | 29 | ||
| 30 | Common::Input::VibrationError SetRumble( | 30 | Common::Input::VibrationError SetRumble( |
| 31 | const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; | 31 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; |
| 32 | 32 | ||
| 33 | /// Used for automapping features | 33 | /// Used for automapping features |
| 34 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 34 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
diff --git a/src/input_common/drivers/keyboard.cpp b/src/input_common/drivers/keyboard.cpp index 23b0c0ccf..4c1e5bbec 100644 --- a/src/input_common/drivers/keyboard.cpp +++ b/src/input_common/drivers/keyboard.cpp | |||
| @@ -24,7 +24,7 @@ constexpr PadIdentifier keyboard_modifier_identifier = { | |||
| 24 | .pad = 1, | 24 | .pad = 1, |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | Keyboard::Keyboard(const std::string& input_engine_) : InputEngine(input_engine_) { | 27 | Keyboard::Keyboard(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 28 | // Keyboard is broken into 3 diferent sets: | 28 | // Keyboard is broken into 3 diferent sets: |
| 29 | // key: Unfiltered intended for controllers. | 29 | // key: Unfiltered intended for controllers. |
| 30 | // keyboard_key: Allows only Settings::NativeKeyboard::Keys intended for keyboard emulation. | 30 | // keyboard_key: Allows only Settings::NativeKeyboard::Keys intended for keyboard emulation. |
diff --git a/src/input_common/drivers/keyboard.h b/src/input_common/drivers/keyboard.h index ad123b136..3856c882c 100644 --- a/src/input_common/drivers/keyboard.h +++ b/src/input_common/drivers/keyboard.h | |||
| @@ -12,9 +12,9 @@ namespace InputCommon { | |||
| 12 | * A button device factory representing a keyboard. It receives keyboard events and forward them | 12 | * A button device factory representing a keyboard. It receives keyboard events and forward them |
| 13 | * to all button devices it created. | 13 | * to all button devices it created. |
| 14 | */ | 14 | */ |
| 15 | class Keyboard final : public InputCommon::InputEngine { | 15 | class Keyboard final : public InputEngine { |
| 16 | public: | 16 | public: |
| 17 | explicit Keyboard(const std::string& input_engine_); | 17 | explicit Keyboard(std::string input_engine_); |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * Sets the status of all buttons bound with the key to pressed | 20 | * Sets the status of all buttons bound with the key to pressed |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 752118e97..aa69216c8 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -24,7 +24,7 @@ constexpr PadIdentifier identifier = { | |||
| 24 | .pad = 0, | 24 | .pad = 0, |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | Mouse::Mouse(const std::string& input_engine_) : InputEngine(input_engine_) { | 27 | Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 28 | PreSetController(identifier); | 28 | PreSetController(identifier); |
| 29 | PreSetAxis(identifier, mouse_axis_x); | 29 | PreSetAxis(identifier, mouse_axis_x); |
| 30 | PreSetAxis(identifier, mouse_axis_y); | 30 | PreSetAxis(identifier, mouse_axis_y); |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 4a1fd2fd9..040446178 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -27,9 +27,9 @@ enum class MouseButton { | |||
| 27 | * A button device factory representing a keyboard. It receives keyboard events and forward them | 27 | * A button device factory representing a keyboard. It receives keyboard events and forward them |
| 28 | * to all button devices it created. | 28 | * to all button devices it created. |
| 29 | */ | 29 | */ |
| 30 | class Mouse final : public InputCommon::InputEngine { | 30 | class Mouse final : public InputEngine { |
| 31 | public: | 31 | public: |
| 32 | explicit Mouse(const std::string& input_engine_); | 32 | explicit Mouse(std::string input_engine_); |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * Signals that mouse has moved. | 35 | * Signals that mouse has moved. |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 1052ed394..e33a5ff31 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -88,7 +88,7 @@ public: | |||
| 88 | return true; | 88 | return true; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | BasicMotion GetMotion() { | 91 | const BasicMotion& GetMotion() const { |
| 92 | return motion; | 92 | return motion; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| @@ -367,7 +367,7 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { | |||
| 367 | if (joystick->UpdateMotion(event.csensor)) { | 367 | if (joystick->UpdateMotion(event.csensor)) { |
| 368 | const PadIdentifier identifier = joystick->GetPadIdentifier(); | 368 | const PadIdentifier identifier = joystick->GetPadIdentifier(); |
| 369 | SetMotion(identifier, 0, joystick->GetMotion()); | 369 | SetMotion(identifier, 0, joystick->GetMotion()); |
| 370 | }; | 370 | } |
| 371 | } | 371 | } |
| 372 | break; | 372 | break; |
| 373 | } | 373 | } |
| @@ -387,7 +387,7 @@ void SDLDriver::CloseJoysticks() { | |||
| 387 | joystick_map.clear(); | 387 | joystick_map.clear(); |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | SDLDriver::SDLDriver(const std::string& input_engine_) : InputEngine(input_engine_) { | 390 | SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 391 | if (!Settings::values.enable_raw_input) { | 391 | if (!Settings::values.enable_raw_input) { |
| 392 | // Disable raw input. When enabled this setting causes SDL to die when a web applet opens | 392 | // Disable raw input. When enabled this setting causes SDL to die when a web applet opens |
| 393 | SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0"); | 393 | SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0"); |
| @@ -491,8 +491,9 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { | |||
| 491 | } | 491 | } |
| 492 | return devices; | 492 | return devices; |
| 493 | } | 493 | } |
| 494 | Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | 494 | |
| 495 | const Common::Input::VibrationStatus vibration) { | 495 | Common::Input::VibrationError SDLDriver::SetRumble( |
| 496 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | ||
| 496 | const auto joystick = | 497 | const auto joystick = |
| 497 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); | 498 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); |
| 498 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { | 499 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { |
| @@ -526,6 +527,7 @@ Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifi | |||
| 526 | 527 | ||
| 527 | return Common::Input::VibrationError::None; | 528 | return Common::Input::VibrationError::None; |
| 528 | } | 529 | } |
| 530 | |||
| 529 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, | 531 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |
| 530 | s32 axis, float value) const { | 532 | s32 axis, float value) const { |
| 531 | Common::ParamPackage params{}; | 533 | Common::ParamPackage params{}; |
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index d03ff4b84..e9a5d2e26 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -19,19 +19,19 @@ using SDL_GameController = struct _SDL_GameController; | |||
| 19 | using SDL_Joystick = struct _SDL_Joystick; | 19 | using SDL_Joystick = struct _SDL_Joystick; |
| 20 | using SDL_JoystickID = s32; | 20 | using SDL_JoystickID = s32; |
| 21 | 21 | ||
| 22 | namespace InputCommon { | ||
| 23 | |||
| 24 | class SDLJoystick; | ||
| 25 | |||
| 22 | using ButtonBindings = | 26 | using ButtonBindings = |
| 23 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 17>; | 27 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 17>; |
| 24 | using ZButtonBindings = | 28 | using ZButtonBindings = |
| 25 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>; | 29 | std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>; |
| 26 | 30 | ||
| 27 | namespace InputCommon { | 31 | class SDLDriver : public InputEngine { |
| 28 | |||
| 29 | class SDLJoystick; | ||
| 30 | |||
| 31 | class SDLDriver : public InputCommon::InputEngine { | ||
| 32 | public: | 32 | public: |
| 33 | /// Initializes and registers SDL device factories | 33 | /// Initializes and registers SDL device factories |
| 34 | SDLDriver(const std::string& input_engine_); | 34 | explicit SDLDriver(std::string input_engine_); |
| 35 | 35 | ||
| 36 | /// Unregisters SDL device factories and shut them down. | 36 | /// Unregisters SDL device factories and shut them down. |
| 37 | ~SDLDriver() override; | 37 | ~SDLDriver() override; |
| @@ -59,7 +59,7 @@ public: | |||
| 59 | u8 GetHatButtonId(const std::string& direction_name) const override; | 59 | u8 GetHatButtonId(const std::string& direction_name) const override; |
| 60 | 60 | ||
| 61 | Common::Input::VibrationError SetRumble( | 61 | Common::Input::VibrationError SetRumble( |
| 62 | const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; | 62 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override; |
| 63 | 63 | ||
| 64 | private: | 64 | private: |
| 65 | void InitJoystick(int joystick_index); | 65 | void InitJoystick(int joystick_index); |
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 2094c1feb..5bdd5dac3 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp | |||
| @@ -46,7 +46,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_but | |||
| 46 | {"KEY_ZR", TasButton::TRIGGER_ZR}, | 46 | {"KEY_ZR", TasButton::TRIGGER_ZR}, |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | Tas::Tas(const std::string& input_engine_) : InputCommon::InputEngine(input_engine_) { | 49 | Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 50 | for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) { | 50 | for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) { |
| 51 | PadIdentifier identifier{ | 51 | PadIdentifier identifier{ |
| 52 | .guid = Common::UUID{}, | 52 | .guid = Common::UUID{}, |
diff --git a/src/input_common/drivers/tas_input.h b/src/input_common/drivers/tas_input.h index 3996fe3a8..4b4e6c417 100644 --- a/src/input_common/drivers/tas_input.h +++ b/src/input_common/drivers/tas_input.h | |||
| @@ -81,10 +81,10 @@ enum class TasState { | |||
| 81 | Stopped, | 81 | Stopped, |
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | class Tas final : public InputCommon::InputEngine { | 84 | class Tas final : public InputEngine { |
| 85 | public: | 85 | public: |
| 86 | explicit Tas(const std::string& input_engine_); | 86 | explicit Tas(std::string input_engine_); |
| 87 | ~Tas(); | 87 | ~Tas() override; |
| 88 | 88 | ||
| 89 | /** | 89 | /** |
| 90 | * Changes the input status that will be stored in each frame | 90 | * Changes the input status that will be stored in each frame |
diff --git a/src/input_common/drivers/touch_screen.cpp b/src/input_common/drivers/touch_screen.cpp index 45b3086f6..880781825 100644 --- a/src/input_common/drivers/touch_screen.cpp +++ b/src/input_common/drivers/touch_screen.cpp | |||
| @@ -13,7 +13,7 @@ constexpr PadIdentifier identifier = { | |||
| 13 | .pad = 0, | 13 | .pad = 0, |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | TouchScreen::TouchScreen(const std::string& input_engine_) : InputEngine(input_engine_) { | 16 | TouchScreen::TouchScreen(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 17 | PreSetController(identifier); | 17 | PreSetController(identifier); |
| 18 | } | 18 | } |
| 19 | 19 | ||
diff --git a/src/input_common/drivers/touch_screen.h b/src/input_common/drivers/touch_screen.h index 25c11e8bf..bf395c40b 100644 --- a/src/input_common/drivers/touch_screen.h +++ b/src/input_common/drivers/touch_screen.h | |||
| @@ -12,9 +12,9 @@ namespace InputCommon { | |||
| 12 | * A button device factory representing a keyboard. It receives keyboard events and forward them | 12 | * A button device factory representing a keyboard. It receives keyboard events and forward them |
| 13 | * to all button devices it created. | 13 | * to all button devices it created. |
| 14 | */ | 14 | */ |
| 15 | class TouchScreen final : public InputCommon::InputEngine { | 15 | class TouchScreen final : public InputEngine { |
| 16 | public: | 16 | public: |
| 17 | explicit TouchScreen(const std::string& input_engine_); | 17 | explicit TouchScreen(std::string input_engine_); |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * Signals that mouse has moved. | 20 | * Signals that mouse has moved. |
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index fdee0f2d5..4ab991a7d 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -136,7 +136,7 @@ static void SocketLoop(Socket* socket) { | |||
| 136 | socket->Loop(); | 136 | socket->Loop(); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | UDPClient::UDPClient(const std::string& input_engine_) : InputEngine(input_engine_) { | 139 | UDPClient::UDPClient(std::string input_engine_) : InputEngine(std::move(input_engine_)) { |
| 140 | LOG_INFO(Input, "Udp Initialization started"); | 140 | LOG_INFO(Input, "Udp Initialization started"); |
| 141 | ReloadSockets(); | 141 | ReloadSockets(); |
| 142 | } | 142 | } |
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h index 5d483f26b..1adc947c4 100644 --- a/src/input_common/drivers/udp_client.h +++ b/src/input_common/drivers/udp_client.h | |||
| @@ -49,10 +49,10 @@ struct DeviceStatus { | |||
| 49 | * A button device factory representing a keyboard. It receives keyboard events and forward them | 49 | * A button device factory representing a keyboard. It receives keyboard events and forward them |
| 50 | * to all button devices it created. | 50 | * to all button devices it created. |
| 51 | */ | 51 | */ |
| 52 | class UDPClient final : public InputCommon::InputEngine { | 52 | class UDPClient final : public InputEngine { |
| 53 | public: | 53 | public: |
| 54 | explicit UDPClient(const std::string& input_engine_); | 54 | explicit UDPClient(std::string input_engine_); |
| 55 | ~UDPClient(); | 55 | ~UDPClient() override; |
| 56 | 56 | ||
| 57 | void ReloadSockets(); | 57 | void ReloadSockets(); |
| 58 | 58 | ||
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 2b2105376..9c17ca4f7 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -10,41 +10,31 @@ namespace InputCommon { | |||
| 10 | 10 | ||
| 11 | void InputEngine::PreSetController(const PadIdentifier& identifier) { | 11 | void InputEngine::PreSetController(const PadIdentifier& identifier) { |
| 12 | std::lock_guard lock{mutex}; | 12 | std::lock_guard lock{mutex}; |
| 13 | if (!controller_list.contains(identifier)) { | 13 | controller_list.try_emplace(identifier); |
| 14 | controller_list.insert_or_assign(identifier, ControllerData{}); | ||
| 15 | } | ||
| 16 | } | 14 | } |
| 17 | 15 | ||
| 18 | void InputEngine::PreSetButton(const PadIdentifier& identifier, int button) { | 16 | void InputEngine::PreSetButton(const PadIdentifier& identifier, int button) { |
| 19 | std::lock_guard lock{mutex}; | 17 | std::lock_guard lock{mutex}; |
| 20 | ControllerData& controller = controller_list.at(identifier); | 18 | ControllerData& controller = controller_list.at(identifier); |
| 21 | if (!controller.buttons.contains(button)) { | 19 | controller.buttons.try_emplace(button, false); |
| 22 | controller.buttons.insert_or_assign(button, false); | ||
| 23 | } | ||
| 24 | } | 20 | } |
| 25 | 21 | ||
| 26 | void InputEngine::PreSetHatButton(const PadIdentifier& identifier, int button) { | 22 | void InputEngine::PreSetHatButton(const PadIdentifier& identifier, int button) { |
| 27 | std::lock_guard lock{mutex}; | 23 | std::lock_guard lock{mutex}; |
| 28 | ControllerData& controller = controller_list.at(identifier); | 24 | ControllerData& controller = controller_list.at(identifier); |
| 29 | if (!controller.hat_buttons.contains(button)) { | 25 | controller.hat_buttons.try_emplace(button, u8{0}); |
| 30 | controller.hat_buttons.insert_or_assign(button, u8{0}); | ||
| 31 | } | ||
| 32 | } | 26 | } |
| 33 | 27 | ||
| 34 | void InputEngine::PreSetAxis(const PadIdentifier& identifier, int axis) { | 28 | void InputEngine::PreSetAxis(const PadIdentifier& identifier, int axis) { |
| 35 | std::lock_guard lock{mutex}; | 29 | std::lock_guard lock{mutex}; |
| 36 | ControllerData& controller = controller_list.at(identifier); | 30 | ControllerData& controller = controller_list.at(identifier); |
| 37 | if (!controller.axes.contains(axis)) { | 31 | controller.axes.try_emplace(axis, 0.0f); |
| 38 | controller.axes.insert_or_assign(axis, 0.0f); | ||
| 39 | } | ||
| 40 | } | 32 | } |
| 41 | 33 | ||
| 42 | void InputEngine::PreSetMotion(const PadIdentifier& identifier, int motion) { | 34 | void InputEngine::PreSetMotion(const PadIdentifier& identifier, int motion) { |
| 43 | std::lock_guard lock{mutex}; | 35 | std::lock_guard lock{mutex}; |
| 44 | ControllerData& controller = controller_list.at(identifier); | 36 | ControllerData& controller = controller_list.at(identifier); |
| 45 | if (!controller.motions.contains(motion)) { | 37 | controller.motions.try_emplace(motion); |
| 46 | controller.motions.insert_or_assign(motion, BasicMotion{}); | ||
| 47 | } | ||
| 48 | } | 38 | } |
| 49 | 39 | ||
| 50 | void InputEngine::SetButton(const PadIdentifier& identifier, int button, bool value) { | 40 | void InputEngine::SetButton(const PadIdentifier& identifier, int button, bool value) { |
| @@ -91,7 +81,7 @@ void InputEngine::SetBattery(const PadIdentifier& identifier, BatteryLevel value | |||
| 91 | TriggerOnBatteryChange(identifier, value); | 81 | TriggerOnBatteryChange(identifier, value); |
| 92 | } | 82 | } |
| 93 | 83 | ||
| 94 | void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, BasicMotion value) { | 84 | void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value) { |
| 95 | { | 85 | { |
| 96 | std::lock_guard lock{mutex}; | 86 | std::lock_guard lock{mutex}; |
| 97 | ControllerData& controller = controller_list.at(identifier); | 87 | ControllerData& controller = controller_list.at(identifier); |
| @@ -104,85 +94,93 @@ void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, BasicMo | |||
| 104 | 94 | ||
| 105 | bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { | 95 | bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { |
| 106 | std::lock_guard lock{mutex}; | 96 | std::lock_guard lock{mutex}; |
| 107 | if (!controller_list.contains(identifier)) { | 97 | const auto controller_iter = controller_list.find(identifier); |
| 98 | if (controller_iter == controller_list.cend()) { | ||
| 108 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 99 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), |
| 109 | identifier.pad, identifier.port); | 100 | identifier.pad, identifier.port); |
| 110 | return false; | 101 | return false; |
| 111 | } | 102 | } |
| 112 | ControllerData controller = controller_list.at(identifier); | 103 | const ControllerData& controller = controller_iter->second; |
| 113 | if (!controller.buttons.contains(button)) { | 104 | const auto button_iter = controller.buttons.find(button); |
| 105 | if (button_iter == controller.buttons.cend()) { | ||
| 114 | LOG_ERROR(Input, "Invalid button {}", button); | 106 | LOG_ERROR(Input, "Invalid button {}", button); |
| 115 | return false; | 107 | return false; |
| 116 | } | 108 | } |
| 117 | return controller.buttons.at(button); | 109 | return button_iter->second; |
| 118 | } | 110 | } |
| 119 | 111 | ||
| 120 | bool InputEngine::GetHatButton(const PadIdentifier& identifier, int button, u8 direction) const { | 112 | bool InputEngine::GetHatButton(const PadIdentifier& identifier, int button, u8 direction) const { |
| 121 | std::lock_guard lock{mutex}; | 113 | std::lock_guard lock{mutex}; |
| 122 | if (!controller_list.contains(identifier)) { | 114 | const auto controller_iter = controller_list.find(identifier); |
| 115 | if (controller_iter == controller_list.cend()) { | ||
| 123 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 116 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), |
| 124 | identifier.pad, identifier.port); | 117 | identifier.pad, identifier.port); |
| 125 | return false; | 118 | return false; |
| 126 | } | 119 | } |
| 127 | ControllerData controller = controller_list.at(identifier); | 120 | const ControllerData& controller = controller_iter->second; |
| 128 | if (!controller.hat_buttons.contains(button)) { | 121 | const auto hat_iter = controller.hat_buttons.find(button); |
| 122 | if (hat_iter == controller.hat_buttons.cend()) { | ||
| 129 | LOG_ERROR(Input, "Invalid hat button {}", button); | 123 | LOG_ERROR(Input, "Invalid hat button {}", button); |
| 130 | return false; | 124 | return false; |
| 131 | } | 125 | } |
| 132 | return (controller.hat_buttons.at(button) & direction) != 0; | 126 | return (hat_iter->second & direction) != 0; |
| 133 | } | 127 | } |
| 134 | 128 | ||
| 135 | f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const { | 129 | f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const { |
| 136 | std::lock_guard lock{mutex}; | 130 | std::lock_guard lock{mutex}; |
| 137 | if (!controller_list.contains(identifier)) { | 131 | const auto controller_iter = controller_list.find(identifier); |
| 132 | if (controller_iter == controller_list.cend()) { | ||
| 138 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 133 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), |
| 139 | identifier.pad, identifier.port); | 134 | identifier.pad, identifier.port); |
| 140 | return 0.0f; | 135 | return 0.0f; |
| 141 | } | 136 | } |
| 142 | ControllerData controller = controller_list.at(identifier); | 137 | const ControllerData& controller = controller_iter->second; |
| 143 | if (!controller.axes.contains(axis)) { | 138 | const auto axis_iter = controller.axes.find(axis); |
| 139 | if (axis_iter == controller.axes.cend()) { | ||
| 144 | LOG_ERROR(Input, "Invalid axis {}", axis); | 140 | LOG_ERROR(Input, "Invalid axis {}", axis); |
| 145 | return 0.0f; | 141 | return 0.0f; |
| 146 | } | 142 | } |
| 147 | return controller.axes.at(axis); | 143 | return axis_iter->second; |
| 148 | } | 144 | } |
| 149 | 145 | ||
| 150 | BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const { | 146 | BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const { |
| 151 | std::lock_guard lock{mutex}; | 147 | std::lock_guard lock{mutex}; |
| 152 | if (!controller_list.contains(identifier)) { | 148 | const auto controller_iter = controller_list.find(identifier); |
| 149 | if (controller_iter == controller_list.cend()) { | ||
| 153 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 150 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), |
| 154 | identifier.pad, identifier.port); | 151 | identifier.pad, identifier.port); |
| 155 | return BatteryLevel::Charging; | 152 | return BatteryLevel::Charging; |
| 156 | } | 153 | } |
| 157 | ControllerData controller = controller_list.at(identifier); | 154 | const ControllerData& controller = controller_iter->second; |
| 158 | return controller.battery; | 155 | return controller.battery; |
| 159 | } | 156 | } |
| 160 | 157 | ||
| 161 | BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) const { | 158 | BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) const { |
| 162 | std::lock_guard lock{mutex}; | 159 | std::lock_guard lock{mutex}; |
| 163 | if (!controller_list.contains(identifier)) { | 160 | const auto controller_iter = controller_list.find(identifier); |
| 161 | if (controller_iter == controller_list.cend()) { | ||
| 164 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 162 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), |
| 165 | identifier.pad, identifier.port); | 163 | identifier.pad, identifier.port); |
| 166 | return {}; | 164 | return {}; |
| 167 | } | 165 | } |
| 168 | ControllerData controller = controller_list.at(identifier); | 166 | const ControllerData& controller = controller_iter->second; |
| 169 | return controller.motions.at(motion); | 167 | return controller.motions.at(motion); |
| 170 | } | 168 | } |
| 171 | 169 | ||
| 172 | void InputEngine::ResetButtonState() { | 170 | void InputEngine::ResetButtonState() { |
| 173 | for (std::pair<PadIdentifier, ControllerData> controller : controller_list) { | 171 | for (const auto& controller : controller_list) { |
| 174 | for (std::pair<int, bool> button : controller.second.buttons) { | 172 | for (const auto& button : controller.second.buttons) { |
| 175 | SetButton(controller.first, button.first, false); | 173 | SetButton(controller.first, button.first, false); |
| 176 | } | 174 | } |
| 177 | for (std::pair<int, bool> button : controller.second.hat_buttons) { | 175 | for (const auto& button : controller.second.hat_buttons) { |
| 178 | SetHatButton(controller.first, button.first, false); | 176 | SetHatButton(controller.first, button.first, false); |
| 179 | } | 177 | } |
| 180 | } | 178 | } |
| 181 | } | 179 | } |
| 182 | 180 | ||
| 183 | void InputEngine::ResetAnalogState() { | 181 | void InputEngine::ResetAnalogState() { |
| 184 | for (std::pair<PadIdentifier, ControllerData> controller : controller_list) { | 182 | for (const auto& controller : controller_list) { |
| 185 | for (std::pair<int, float> axis : controller.second.axes) { | 183 | for (const auto& axis : controller.second.axes) { |
| 186 | SetAxis(controller.first, axis.first, 0.0); | 184 | SetAxis(controller.first, axis.first, 0.0); |
| 187 | } | 185 | } |
| 188 | } | 186 | } |
| @@ -190,7 +188,7 @@ void InputEngine::ResetAnalogState() { | |||
| 190 | 188 | ||
| 191 | void InputEngine::TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value) { | 189 | void InputEngine::TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value) { |
| 192 | std::lock_guard lock{mutex_callback}; | 190 | std::lock_guard lock{mutex_callback}; |
| 193 | for (const std::pair<int, InputIdentifier> poller_pair : callback_list) { | 191 | for (const auto& poller_pair : callback_list) { |
| 194 | const InputIdentifier& poller = poller_pair.second; | 192 | const InputIdentifier& poller = poller_pair.second; |
| 195 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Button, button)) { | 193 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Button, button)) { |
| 196 | continue; | 194 | continue; |
| @@ -218,7 +216,7 @@ void InputEngine::TriggerOnButtonChange(const PadIdentifier& identifier, int but | |||
| 218 | 216 | ||
| 219 | void InputEngine::TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value) { | 217 | void InputEngine::TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value) { |
| 220 | std::lock_guard lock{mutex_callback}; | 218 | std::lock_guard lock{mutex_callback}; |
| 221 | for (const std::pair<int, InputIdentifier> poller_pair : callback_list) { | 219 | for (const auto& poller_pair : callback_list) { |
| 222 | const InputIdentifier& poller = poller_pair.second; | 220 | const InputIdentifier& poller = poller_pair.second; |
| 223 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::HatButton, button)) { | 221 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::HatButton, button)) { |
| 224 | continue; | 222 | continue; |
| @@ -247,7 +245,7 @@ void InputEngine::TriggerOnHatButtonChange(const PadIdentifier& identifier, int | |||
| 247 | 245 | ||
| 248 | void InputEngine::TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value) { | 246 | void InputEngine::TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value) { |
| 249 | std::lock_guard lock{mutex_callback}; | 247 | std::lock_guard lock{mutex_callback}; |
| 250 | for (const std::pair<int, InputIdentifier> poller_pair : callback_list) { | 248 | for (const auto& poller_pair : callback_list) { |
| 251 | const InputIdentifier& poller = poller_pair.second; | 249 | const InputIdentifier& poller = poller_pair.second; |
| 252 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Analog, axis)) { | 250 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Analog, axis)) { |
| 253 | continue; | 251 | continue; |
| @@ -274,7 +272,7 @@ void InputEngine::TriggerOnAxisChange(const PadIdentifier& identifier, int axis, | |||
| 274 | void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier, | 272 | void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier, |
| 275 | [[maybe_unused]] BatteryLevel value) { | 273 | [[maybe_unused]] BatteryLevel value) { |
| 276 | std::lock_guard lock{mutex_callback}; | 274 | std::lock_guard lock{mutex_callback}; |
| 277 | for (const std::pair<int, InputIdentifier> poller_pair : callback_list) { | 275 | for (const auto& poller_pair : callback_list) { |
| 278 | const InputIdentifier& poller = poller_pair.second; | 276 | const InputIdentifier& poller = poller_pair.second; |
| 279 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Battery, 0)) { | 277 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Battery, 0)) { |
| 280 | continue; | 278 | continue; |
| @@ -286,9 +284,9 @@ void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier, | |||
| 286 | } | 284 | } |
| 287 | 285 | ||
| 288 | void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int motion, | 286 | void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int motion, |
| 289 | BasicMotion value) { | 287 | const BasicMotion& value) { |
| 290 | std::lock_guard lock{mutex_callback}; | 288 | std::lock_guard lock{mutex_callback}; |
| 291 | for (const std::pair<int, InputIdentifier> poller_pair : callback_list) { | 289 | for (const auto& poller_pair : callback_list) { |
| 292 | const InputIdentifier& poller = poller_pair.second; | 290 | const InputIdentifier& poller = poller_pair.second; |
| 293 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Motion, motion)) { | 291 | if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Motion, motion)) { |
| 294 | continue; | 292 | continue; |
| @@ -342,7 +340,7 @@ const std::string& InputEngine::GetEngineName() const { | |||
| 342 | 340 | ||
| 343 | int InputEngine::SetCallback(InputIdentifier input_identifier) { | 341 | int InputEngine::SetCallback(InputIdentifier input_identifier) { |
| 344 | std::lock_guard lock{mutex_callback}; | 342 | std::lock_guard lock{mutex_callback}; |
| 345 | callback_list.insert_or_assign(last_callback_key, input_identifier); | 343 | callback_list.insert_or_assign(last_callback_key, std::move(input_identifier)); |
| 346 | return last_callback_key++; | 344 | return last_callback_key++; |
| 347 | } | 345 | } |
| 348 | 346 | ||
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 02272b3f8..390581c94 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -23,15 +23,15 @@ struct PadIdentifier { | |||
| 23 | friend constexpr bool operator==(const PadIdentifier&, const PadIdentifier&) = default; | 23 | friend constexpr bool operator==(const PadIdentifier&, const PadIdentifier&) = default; |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | // Basic motion data containing data from the sensors and a timestamp in microsecons | 26 | // Basic motion data containing data from the sensors and a timestamp in microseconds |
| 27 | struct BasicMotion { | 27 | struct BasicMotion { |
| 28 | float gyro_x; | 28 | float gyro_x{}; |
| 29 | float gyro_y; | 29 | float gyro_y{}; |
| 30 | float gyro_z; | 30 | float gyro_z{}; |
| 31 | float accel_x; | 31 | float accel_x{}; |
| 32 | float accel_y; | 32 | float accel_y{}; |
| 33 | float accel_z; | 33 | float accel_z{}; |
| 34 | u64 delta_timestamp; | 34 | u64 delta_timestamp{}; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | // Stages of a battery charge | 37 | // Stages of a battery charge |
| @@ -102,9 +102,7 @@ struct InputIdentifier { | |||
| 102 | 102 | ||
| 103 | class InputEngine { | 103 | class InputEngine { |
| 104 | public: | 104 | public: |
| 105 | explicit InputEngine(const std::string& input_engine_) : input_engine(input_engine_) { | 105 | explicit InputEngine(std::string input_engine_) : input_engine{std::move(input_engine_)} {} |
| 106 | callback_list.clear(); | ||
| 107 | } | ||
| 108 | 106 | ||
| 109 | virtual ~InputEngine() = default; | 107 | virtual ~InputEngine() = default; |
| 110 | 108 | ||
| @@ -116,14 +114,12 @@ public: | |||
| 116 | 114 | ||
| 117 | // Sets a led pattern for a controller | 115 | // Sets a led pattern for a controller |
| 118 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, | 116 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, |
| 119 | [[maybe_unused]] const Common::Input::LedStatus led_status) { | 117 | [[maybe_unused]] const Common::Input::LedStatus& led_status) {} |
| 120 | return; | ||
| 121 | } | ||
| 122 | 118 | ||
| 123 | // Sets rumble to a controller | 119 | // Sets rumble to a controller |
| 124 | virtual Common::Input::VibrationError SetRumble( | 120 | virtual Common::Input::VibrationError SetRumble( |
| 125 | [[maybe_unused]] const PadIdentifier& identifier, | 121 | [[maybe_unused]] const PadIdentifier& identifier, |
| 126 | [[maybe_unused]] const Common::Input::VibrationStatus vibration) { | 122 | [[maybe_unused]] const Common::Input::VibrationStatus& vibration) { |
| 127 | return Common::Input::VibrationError::NotSupported; | 123 | return Common::Input::VibrationError::NotSupported; |
| 128 | } | 124 | } |
| 129 | 125 | ||
| @@ -140,36 +136,36 @@ public: | |||
| 140 | /// Used for automapping features | 136 | /// Used for automapping features |
| 141 | virtual std::vector<Common::ParamPackage> GetInputDevices() const { | 137 | virtual std::vector<Common::ParamPackage> GetInputDevices() const { |
| 142 | return {}; | 138 | return {}; |
| 143 | }; | 139 | } |
| 144 | 140 | ||
| 145 | /// Retrieves the button mappings for the given device | 141 | /// Retrieves the button mappings for the given device |
| 146 | virtual InputCommon::ButtonMapping GetButtonMappingForDevice( | 142 | virtual ButtonMapping GetButtonMappingForDevice( |
| 147 | [[maybe_unused]] const Common::ParamPackage& params) { | 143 | [[maybe_unused]] const Common::ParamPackage& params) { |
| 148 | return {}; | 144 | return {}; |
| 149 | }; | 145 | } |
| 150 | 146 | ||
| 151 | /// Retrieves the analog mappings for the given device | 147 | /// Retrieves the analog mappings for the given device |
| 152 | virtual InputCommon::AnalogMapping GetAnalogMappingForDevice( | 148 | virtual AnalogMapping GetAnalogMappingForDevice( |
| 153 | [[maybe_unused]] const Common::ParamPackage& params) { | 149 | [[maybe_unused]] const Common::ParamPackage& params) { |
| 154 | return {}; | 150 | return {}; |
| 155 | }; | 151 | } |
| 156 | 152 | ||
| 157 | /// Retrieves the motion mappings for the given device | 153 | /// Retrieves the motion mappings for the given device |
| 158 | virtual InputCommon::MotionMapping GetMotionMappingForDevice( | 154 | virtual MotionMapping GetMotionMappingForDevice( |
| 159 | [[maybe_unused]] const Common::ParamPackage& params) { | 155 | [[maybe_unused]] const Common::ParamPackage& params) { |
| 160 | return {}; | 156 | return {}; |
| 161 | }; | 157 | } |
| 162 | 158 | ||
| 163 | /// Retrieves the name of the given input. | 159 | /// Retrieves the name of the given input. |
| 164 | virtual Common::Input::ButtonNames GetUIName( | 160 | virtual Common::Input::ButtonNames GetUIName( |
| 165 | [[maybe_unused]] const Common::ParamPackage& params) const { | 161 | [[maybe_unused]] const Common::ParamPackage& params) const { |
| 166 | return Common::Input::ButtonNames::Engine; | 162 | return Common::Input::ButtonNames::Engine; |
| 167 | }; | 163 | } |
| 168 | 164 | ||
| 169 | /// Retrieves the index number of the given hat button direction | 165 | /// Retrieves the index number of the given hat button direction |
| 170 | virtual u8 GetHatButtonId([[maybe_unused]] const std::string& direction_name) const { | 166 | virtual u8 GetHatButtonId([[maybe_unused]] const std::string& direction_name) const { |
| 171 | return 0; | 167 | return 0; |
| 172 | }; | 168 | } |
| 173 | 169 | ||
| 174 | void PreSetController(const PadIdentifier& identifier); | 170 | void PreSetController(const PadIdentifier& identifier); |
| 175 | void PreSetButton(const PadIdentifier& identifier, int button); | 171 | void PreSetButton(const PadIdentifier& identifier, int button); |
| @@ -194,7 +190,7 @@ protected: | |||
| 194 | void SetHatButton(const PadIdentifier& identifier, int button, u8 value); | 190 | void SetHatButton(const PadIdentifier& identifier, int button, u8 value); |
| 195 | void SetAxis(const PadIdentifier& identifier, int axis, f32 value); | 191 | void SetAxis(const PadIdentifier& identifier, int axis, f32 value); |
| 196 | void SetBattery(const PadIdentifier& identifier, BatteryLevel value); | 192 | void SetBattery(const PadIdentifier& identifier, BatteryLevel value); |
| 197 | void SetMotion(const PadIdentifier& identifier, int motion, BasicMotion value); | 193 | void SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value); |
| 198 | 194 | ||
| 199 | virtual std::string GetHatButtonName([[maybe_unused]] u8 direction_value) const { | 195 | virtual std::string GetHatButtonName([[maybe_unused]] u8 direction_value) const { |
| 200 | return "Unknown"; | 196 | return "Unknown"; |
| @@ -206,14 +202,15 @@ private: | |||
| 206 | std::unordered_map<int, u8> hat_buttons; | 202 | std::unordered_map<int, u8> hat_buttons; |
| 207 | std::unordered_map<int, float> axes; | 203 | std::unordered_map<int, float> axes; |
| 208 | std::unordered_map<int, BasicMotion> motions; | 204 | std::unordered_map<int, BasicMotion> motions; |
| 209 | BatteryLevel battery; | 205 | BatteryLevel battery{}; |
| 210 | }; | 206 | }; |
| 211 | 207 | ||
| 212 | void TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value); | 208 | void TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value); |
| 213 | void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value); | 209 | void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value); |
| 214 | void TriggerOnAxisChange(const PadIdentifier& identifier, int button, f32 value); | 210 | void TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value); |
| 215 | void TriggerOnBatteryChange(const PadIdentifier& identifier, BatteryLevel value); | 211 | void TriggerOnBatteryChange(const PadIdentifier& identifier, BatteryLevel value); |
| 216 | void TriggerOnMotionChange(const PadIdentifier& identifier, int motion, BasicMotion value); | 212 | void TriggerOnMotionChange(const PadIdentifier& identifier, int motion, |
| 213 | const BasicMotion& value); | ||
| 217 | 214 | ||
| 218 | bool IsInputIdentifierEqual(const InputIdentifier& input_identifier, | 215 | bool IsInputIdentifierEqual(const InputIdentifier& input_identifier, |
| 219 | const PadIdentifier& identifier, EngineInputType type, | 216 | const PadIdentifier& identifier, EngineInputType type, |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 7e4eafded..c56d5e0c2 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -668,12 +668,12 @@ public: | |||
| 668 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | 668 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) |
| 669 | : identifier(identifier_), input_engine(input_engine_) {} | 669 | : identifier(identifier_), input_engine(input_engine_) {} |
| 670 | 670 | ||
| 671 | virtual void SetLED(Common::Input::LedStatus led_status) { | 671 | virtual void SetLED(const Common::Input::LedStatus& led_status) { |
| 672 | input_engine->SetLeds(identifier, led_status); | 672 | input_engine->SetLeds(identifier, led_status); |
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | virtual Common::Input::VibrationError SetVibration( | 675 | virtual Common::Input::VibrationError SetVibration( |
| 676 | Common::Input::VibrationStatus vibration_status) { | 676 | const Common::Input::VibrationStatus& vibration_status) { |
| 677 | return input_engine->SetRumble(identifier, vibration_status); | 677 | return input_engine->SetRumble(identifier, vibration_status); |
| 678 | } | 678 | } |
| 679 | 679 | ||