Merge pull request #13625 from Dentomologist/sdl_verify_touchpad_present_before_getting_input

SDL: Check if touchpad exists before getting input
This commit is contained in:
Jordan Woyak
2025-05-02 21:08:49 -05:00
committed by GitHub

View File

@ -362,11 +362,15 @@ public:
const int touchpad_index = 0; const int touchpad_index = 0;
const int finger_index = 0; const int finger_index = 0;
Uint8 state = 0; if (SDL_GameControllerGetNumTouchpads(m_gamecontroller) > touchpad_index &&
SDL_GameControllerGetTouchpadFinger(m_gamecontroller, touchpad_index, finger_index, &state, SDL_GameControllerGetNumTouchpadFingers(m_gamecontroller, touchpad_index) > finger_index)
&m_touchpad_x, &m_touchpad_y, &m_touchpad_pressure); {
m_touchpad_x = m_touchpad_x * 2 - 1; Uint8 state = 0;
m_touchpad_y = m_touchpad_y * 2 - 1; 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; return Core::DeviceRemoval::Keep;
} }