summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp19
1 files changed, 11 insertions, 8 deletions
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
390SDLDriver::SDLDriver(const std::string& input_engine_) : InputEngine(input_engine_) { 390SDLDriver::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}
494Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, 495
495 const Common::Input::VibrationStatus vibration) { 496Common::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
529Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, 532Common::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{};