summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp11
-rw-r--r--src/input_common/input_poller.cpp1
2 files changed, 8 insertions, 4 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index de388ec4c..5cc1ccbd9 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -40,13 +40,13 @@ public:
40 void EnableMotion() { 40 void EnableMotion() {
41 if (sdl_controller) { 41 if (sdl_controller) {
42 SDL_GameController* controller = sdl_controller.get(); 42 SDL_GameController* controller = sdl_controller.get();
43 if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL) && !has_accel) { 43 has_accel = SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL);
44 has_gyro = SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO);
45 if (has_accel) {
44 SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE); 46 SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE);
45 has_accel = true;
46 } 47 }
47 if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO) && !has_gyro) { 48 if (has_gyro) {
48 SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE); 49 SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE);
49 has_gyro = true;
50 } 50 }
51 } 51 }
52 } 52 }
@@ -305,6 +305,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
305 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller); 305 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
306 PreSetController(joystick->GetPadIdentifier()); 306 PreSetController(joystick->GetPadIdentifier());
307 SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel()); 307 SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel());
308 joystick->EnableMotion();
308 joystick_map[guid].emplace_back(std::move(joystick)); 309 joystick_map[guid].emplace_back(std::move(joystick));
309 return; 310 return;
310 } 311 }
@@ -316,6 +317,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
316 317
317 if (joystick_it != joystick_guid_list.end()) { 318 if (joystick_it != joystick_guid_list.end()) {
318 (*joystick_it)->SetSDLJoystick(sdl_joystick, sdl_gamecontroller); 319 (*joystick_it)->SetSDLJoystick(sdl_joystick, sdl_gamecontroller);
320 (*joystick_it)->EnableMotion();
319 return; 321 return;
320 } 322 }
321 323
@@ -323,6 +325,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
323 auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick, sdl_gamecontroller); 325 auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick, sdl_gamecontroller);
324 PreSetController(joystick->GetPadIdentifier()); 326 PreSetController(joystick->GetPadIdentifier());
325 SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel()); 327 SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel());
328 joystick->EnableMotion();
326 joystick_guid_list.emplace_back(std::move(joystick)); 329 joystick_guid_list.emplace_back(std::move(joystick));
327} 330}
328 331
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 133422d5c..ffb9b945e 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -824,6 +824,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
824 .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), 824 .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f),
825 .offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f), 825 .offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f),
826 .inverted = params.Get("invert", "+") == "-", 826 .inverted = params.Get("invert", "+") == "-",
827 .toggle = static_cast<bool>(params.Get("toggle", false)),
827 }; 828 };
828 input_engine->PreSetController(identifier); 829 input_engine->PreSetController(identifier);
829 input_engine->PreSetAxis(identifier, axis); 830 input_engine->PreSetAxis(identifier, axis);