summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-05-02 21:08:49 -0500
committerGitHub <noreply@github.com>2025-05-02 21:08:49 -0500
commita736d2ed5f570f818d71968cc17511e27972af6f (patch)
treed894aeb09656bc9bdd86ccbcb82a4193d9d0eab2 /Source/Core/InputCommon/ControllerInterface
parent63572f15fc92363307914614ec5ad409570f8f50 (diff)
parent77744169bedd4638f812e52aaac0097c64005eaa (diff)
Merge pull request #13625 from Dentomologist/sdl_verify_touchpad_present_before_getting_input
SDL: Check if touchpad exists before getting input
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.h b/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.h
index e71e3f4e52..4f03ea7d4a 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.h
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.h
@@ -362,11 +362,15 @@ public:
const int touchpad_index = 0;
const int finger_index = 0;
- Uint8 state = 0;
- SDL_GameControllerGetTouchpadFinger(m_gamecontroller, touchpad_index, finger_index, &state,
- &m_touchpad_x, &m_touchpad_y, &m_touchpad_pressure);
- m_touchpad_x = m_touchpad_x * 2 - 1;
- m_touchpad_y = m_touchpad_y * 2 - 1;
+ if (SDL_GameControllerGetNumTouchpads(m_gamecontroller) > touchpad_index &&
+ SDL_GameControllerGetNumTouchpadFingers(m_gamecontroller, touchpad_index) > finger_index)
+ {
+ Uint8 state = 0;
+ SDL_GameControllerGetTouchpadFinger(m_gamecontroller, touchpad_index, finger_index, &state,
+ &m_touchpad_x, &m_touchpad_y, &m_touchpad_pressure);
+ m_touchpad_x = m_touchpad_x * 2 - 1;
+ m_touchpad_y = m_touchpad_y * 2 - 1;
+ }
return Core::DeviceRemoval::Keep;
}