diff options
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 33 |
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 { | |||
| 934 | return direction; | 934 | return direction; |
| 935 | } | 935 | } |
| 936 | 936 | ||
| 937 | bool SDLDriver::IsStickInverted(const Common::ParamPackage& params) { | ||
| 938 | if (!params.Has("guid") || !params.Has("port")) { | ||
| 939 | return false; | ||
| 940 | } | ||
| 941 | const auto joystick = GetSDLJoystickByGUID(params.Get("guid", ""), params.Get("port", 0)); | ||
| 942 | if (joystick == nullptr) { | ||
| 943 | return false; | ||
| 944 | } | ||
| 945 | auto* controller = joystick->GetSDLGameController(); | ||
| 946 | if (controller == nullptr) { | ||
| 947 | return false; | ||
| 948 | } | ||
| 949 | |||
| 950 | const auto& axis_x = params.Get("axis_x", 0); | ||
| 951 | const auto& axis_y = params.Get("axis_y", 0); | ||
| 952 | const auto& binding_left_x = | ||
| 953 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTX); | ||
| 954 | const auto& binding_right_x = | ||
| 955 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX); | ||
| 956 | const auto& binding_left_y = | ||
| 957 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTY); | ||
| 958 | const auto& binding_right_y = | ||
| 959 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY); | ||
| 960 | |||
| 961 | if (axis_x != binding_left_y.value.axis && axis_x != binding_right_y.value.axis) { | ||
| 962 | return false; | ||
| 963 | } | ||
| 964 | if (axis_y != binding_left_x.value.axis && axis_y != binding_right_x.value.axis) { | ||
| 965 | return false; | ||
| 966 | } | ||
| 967 | return true; | ||
| 968 | } | ||
| 969 | |||
| 937 | } // namespace InputCommon | 970 | } // namespace InputCommon |