diff options
Diffstat (limited to '')
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 11 | ||||
-rw-r--r-- | src/input_common/input_poller.cpp | 1 |
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: void EnableMotion() { if (sdl_controller) { SDL_GameController* controller = sdl_controller.get(); - if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL) && !has_accel) { + has_accel = SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL); + has_gyro = SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO); + if (has_accel) { SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE); - has_accel = true; } - if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO) && !has_gyro) { + if (has_gyro) { SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE); - has_gyro = true; } } } @@ -305,6 +305,7 @@ void SDLDriver::InitJoystick(int joystick_index) { auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller); PreSetController(joystick->GetPadIdentifier()); SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel()); + joystick->EnableMotion(); joystick_map[guid].emplace_back(std::move(joystick)); return; } @@ -316,6 +317,7 @@ void SDLDriver::InitJoystick(int joystick_index) { if (joystick_it != joystick_guid_list.end()) { (*joystick_it)->SetSDLJoystick(sdl_joystick, sdl_gamecontroller); + (*joystick_it)->EnableMotion(); return; } @@ -323,6 +325,7 @@ void SDLDriver::InitJoystick(int joystick_index) { auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick, sdl_gamecontroller); PreSetController(joystick->GetPadIdentifier()); SetBattery(joystick->GetPadIdentifier(), joystick->GetBatteryLevel()); + joystick->EnableMotion(); joystick_guid_list.emplace_back(std::move(joystick)); } 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( .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), .offset = std::clamp(params.Get("offset", 0.0f), -1.0f, 1.0f), .inverted = params.Get("invert", "+") == "-", + .toggle = static_cast<bool>(params.Get("toggle", false)), }; input_engine->PreSetController(identifier); input_engine->PreSetAxis(identifier, axis); |