summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-04-22 07:21:59 +0200
committerGitHub <noreply@github.com>2022-04-22 07:21:59 +0200
commit764e5c7fe50bbbc64898fb657cfc5b1f8360454b (patch)
treeee42eede68cb935595769104e0b94d55b1530141 /src/input_common/drivers/sdl_driver.cpp
parentMerge pull request #8222 from german77/sixaxis_test (diff)
parentinput_common: Map sticks correctly when mapped sideways (diff)
downloadyuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.tar
yuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.tar.gz
yuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.tar.bz2
yuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.tar.lz
yuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.tar.xz
yuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.tar.zst
yuzu-764e5c7fe50bbbc64898fb657cfc5b1f8360454b.zip
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index b3e4c3f64..a5c63e74a 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -934,4 +934,37 @@ u8 SDLDriver::GetHatButtonId(const std::string& direction_name) const {
return direction;
}
+bool SDLDriver::IsStickInverted(const Common::ParamPackage& params) {
+ if (!params.Has("guid") || !params.Has("port")) {
+ return false;
+ }
+ const auto joystick = GetSDLJoystickByGUID(params.Get("guid", ""), params.Get("port", 0));
+ if (joystick == nullptr) {
+ return false;
+ }
+ auto* controller = joystick->GetSDLGameController();
+ if (controller == nullptr) {
+ return false;
+ }
+
+ const auto& axis_x = params.Get("axis_x", 0);
+ const auto& axis_y = params.Get("axis_y", 0);
+ const auto& binding_left_x =
+ SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTX);
+ const auto& binding_right_x =
+ SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX);
+ const auto& binding_left_y =
+ SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTY);
+ const auto& binding_right_y =
+ SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY);
+
+ if (axis_x != binding_left_y.value.axis && axis_x != binding_right_y.value.axis) {
+ return false;
+ }
+ if (axis_y != binding_left_x.value.axis && axis_y != binding_right_x.value.axis) {
+ return false;
+ }
+ return true;
+}
+
} // namespace InputCommon