diff options
Diffstat (limited to 'src/input_common/drivers')
| -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 | 19 | ||||
| -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 |
14 files changed, 42 insertions, 39 deletions
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..0cda9df62 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"); |
| @@ -403,10 +403,11 @@ SDLDriver::SDLDriver(const std::string& input_engine_) : InputEngine(input_engin | |||
| 403 | 403 | ||
| 404 | // Use hidapi driver for joycons. This will allow joycons to be detected as a GameController and | 404 | // Use hidapi driver for joycons. This will allow joycons to be detected as a GameController and |
| 405 | // not a generic one | 405 | // not a generic one |
| 406 | SDL_SetHint("SDL_JOYSTICK_HIDAPI_JOY_CONS", "1"); | 406 | SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); |
| 407 | 407 | ||
| 408 | // Turn off Pro controller home led | 408 | // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native |
| 409 | SDL_SetHint("SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED", "0"); | 409 | // driver on Linux. |
| 410 | SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX, "0"); | ||
| 410 | 411 | ||
| 411 | // If the frontend is going to manage the event loop, then we don't start one here | 412 | // If the frontend is going to manage the event loop, then we don't start one here |
| 412 | start_thread = SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == 0; | 413 | start_thread = SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == 0; |
| @@ -491,8 +492,9 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { | |||
| 491 | } | 492 | } |
| 492 | return devices; | 493 | return devices; |
| 493 | } | 494 | } |
| 494 | Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | 495 | |
| 495 | const Common::Input::VibrationStatus vibration) { | 496 | Common::Input::VibrationError SDLDriver::SetRumble( |
| 497 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | ||
| 496 | const auto joystick = | 498 | const auto joystick = |
| 497 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); | 499 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); |
| 498 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { | 500 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { |
| @@ -526,6 +528,7 @@ Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifi | |||
| 526 | 528 | ||
| 527 | return Common::Input::VibrationError::None; | 529 | return Common::Input::VibrationError::None; |
| 528 | } | 530 | } |
| 531 | |||
| 529 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, | 532 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |
| 530 | s32 axis, float value) const { | 533 | s32 axis, float value) const { |
| 531 | Common::ParamPackage params{}; | 534 | 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 | ||