Add keys for SDL 2.0.14's new gamepad buttons

This fixes the additional buttons triggering binds for ioq3 left
and right joystick direction keys.
This commit is contained in:
Zack Middleton 2022-09-22 09:18:22 -05:00
parent 29b0cc3a4d
commit f92c293f7b
3 changed files with 22 additions and 1 deletions

View file

@ -316,6 +316,13 @@ keyname_t keynames[] =
{"PAD0_LEFTTRIGGER", K_PAD0_LEFTTRIGGER },
{"PAD0_RIGHTTRIGGER", K_PAD0_RIGHTTRIGGER },
{"PAD0_MISC1", K_PAD0_MISC1 },
{"PAD0_PADDLE1", K_PAD0_PADDLE1 },
{"PAD0_PADDLE2", K_PAD0_PADDLE2 },
{"PAD0_PADDLE3", K_PAD0_PADDLE3 },
{"PAD0_PADDLE4", K_PAD0_PADDLE4 },
{"PAD0_TOUCHPAD", K_PAD0_TOUCHPAD },
{NULL,0}
};

View file

@ -290,6 +290,13 @@ typedef enum {
K_PAD0_LEFTTRIGGER,
K_PAD0_RIGHTTRIGGER,
K_PAD0_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
K_PAD0_PADDLE1, /* Xbox Elite paddle P1 */
K_PAD0_PADDLE2, /* Xbox Elite paddle P3 */
K_PAD0_PADDLE3, /* Xbox Elite paddle P2 */
K_PAD0_PADDLE4, /* Xbox Elite paddle P4 */
K_PAD0_TOUCHPAD, /* PS4/PS5 touchpad button */
// Pseudo-key that brings the console down
K_CONSOLE,

View file

@ -657,7 +657,14 @@ static void IN_GamepadMove( void )
qboolean pressed = SDL_GameControllerGetButton(gamepad, SDL_CONTROLLER_BUTTON_A + i);
if (pressed != stick_state.buttons[i])
{
Com_QueueEvent(in_eventTime, SE_KEY, K_PAD0_A + i, pressed, 0, NULL);
#if SDL_VERSION_ATLEAST( 2, 0, 14 )
if ( i >= SDL_CONTROLLER_BUTTON_MISC1 ) {
Com_QueueEvent(in_eventTime, SE_KEY, K_PAD0_MISC1 + i - SDL_CONTROLLER_BUTTON_MISC1, pressed, 0, NULL);
} else
#endif
{
Com_QueueEvent(in_eventTime, SE_KEY, K_PAD0_A + i, pressed, 0, NULL);
}
stick_state.buttons[i] = pressed;
}
}