mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-23 03:22:38 +00:00
SDL: Check if touchpad exists before getting input
Verify a touchpad is present before polling it for input. Without this check the Debug log is spammed with the message "error: Parameter 'touchpad' is invalid" if you have a controller without a touchpad. One would think every touchpad supports at least 1 finger, but in case there's some weird edge case check the finger count to be sure.
This commit is contained in:
parent
63572f15fc
commit
77744169be
1 changed files with 9 additions and 5 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue