26 buttons instead of 21

is this a bad idea
This commit is contained in:
minenice55 2026-02-13 13:32:25 -05:00
parent af933c086a
commit 04d68a1d37
2 changed files with 17 additions and 25 deletions

View file

@ -29,11 +29,11 @@ extern "C" {
#define MOUSEBUTTONS 8 #define MOUSEBUTTONS 8
#define JOYBUTTONS 21 // 21 buttons, to match SDL_GameControllerButton #define JOYBUTTONS SDL_GAMEPAD_BUTTON_COUNT // 26 buttons, to match SDL_GameControllerButton
#define JOYANALOGS 4 // 4 analog stick axes (2 sticks * 2 axes) #define JOYANALOGS 4 // 4 analog stick axes (2 sticks * 2 axes)
#define JOYTRIGGERS 2 // 2 trigger axes, positive only #define JOYTRIGGERS 2 // 2 trigger axes, positive only
#define JOYAXISES (JOYANALOGS + JOYTRIGGERS) #define JOYAXISES (JOYANALOGS + JOYTRIGGERS)
#define JOYAXISKEYS ((2 * JOYANALOGS) + JOYTRIGGERS) #define JOYAXISKEYS ((2 * JOYANALOGS) + JOYTRIGGERS)
#define MAXINPUTMAPPING 4 #define MAXINPUTMAPPING 4
@ -43,7 +43,7 @@ extern "C" {
typedef enum typedef enum
{ {
KEY_JOY1 = NUMKEYS, KEY_JOY1 = NUMKEYS,
KEY_HAT1 = KEY_JOY1 + 11, // macro for SDL_CONTROLLER_BUTTON_DPAD_UP KEY_HAT1 = KEY_JOY1 + SDL_GAMEPAD_BUTTON_DPAD_UP, // macro for SDL_CONTROLLER_BUTTON_DPAD_UP
KEY_AXIS1 = KEY_JOY1 + JOYBUTTONS, KEY_AXIS1 = KEY_JOY1 + JOYBUTTONS,
JOYINPUTEND = KEY_AXIS1 + JOYAXISKEYS, JOYINPUTEND = KEY_AXIS1 + JOYAXISKEYS,

View file

@ -1067,13 +1067,9 @@ void I_JoyScale4(void)
// Cheat to get the device index for a game controller handle // Cheat to get the device index for a game controller handle
INT32 I_GetJoystickID(SDL_Gamepad *dev) INT32 I_GetJoystickID(SDL_Gamepad *dev)
{ {
SDL_Joystick *joystick = NULL; if (dev)
joystick = SDL_GetGamepadJoystick(dev);
if (joystick)
{ {
return SDL_GetJoystickID(joystick); return SDL_GetGamepadID(dev);
} }
return -1; return -1;
@ -1081,13 +1077,9 @@ INT32 I_GetJoystickID(SDL_Gamepad *dev)
INT32 I_GetJoystickIDForPlayer(UINT8 pnum) INT32 I_GetJoystickIDForPlayer(UINT8 pnum)
{ {
SDL_Joystick *joystick = NULL; if (JoyInfo[pnum].dev)
joystick = SDL_GetGamepadJoystick(JoyInfo[pnum].dev);
if (joystick)
{ {
return SDL_GetJoystickID(joystick); return SDL_GetGamepadID(JoyInfo[pnum].dev);
} }
return -1; return -1;
@ -1215,7 +1207,7 @@ static int joy_open(int playerIndex, int joyID)
if (joyID <= 0) if (joyID <= 0)
return -1; return -1;
joystick_list = SDL_GetJoysticks(&num_joy); joystick_list = SDL_GetGamepads(&num_joy);
if (!joystick_list || num_joy == 0) if (!joystick_list || num_joy == 0)
{ {
@ -1336,7 +1328,7 @@ void I_InitJoystick(UINT8 index)
} }
} }
joystick_list = SDL_GetJoysticks(&num_joy); joystick_list = SDL_GetGamepads(&num_joy);
if (joystick_list && cv_usejoystick[index].value > 0 && cv_usejoystick[index].value <= num_joy) if (joystick_list && cv_usejoystick[index].value > 0 && cv_usejoystick[index].value <= num_joy)
{ {
@ -1439,8 +1431,8 @@ static void I_ShutdownInput(void)
INT32 I_NumJoys(void) INT32 I_NumJoys(void)
{ {
INT32 num_joy = 0; INT32 num_joy = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
SDL_GetJoysticks(&num_joy); SDL_GetGamepads(&num_joy);
return num_joy; return num_joy;
} }
@ -1454,12 +1446,12 @@ const char *I_GetJoyName(INT32 joyid)
joyname[0] = 0; joyname[0] = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
{ {
if (joyid <= 0) if (joyid <= 0)
return joyname; return joyname;
joystick_list = SDL_GetJoysticks(&num_joy); joystick_list = SDL_GetGamepads(&num_joy);
if (!joystick_list || joyid > num_joy) if (!joystick_list || joyid > num_joy)
{ {
@ -1471,7 +1463,7 @@ const char *I_GetJoyName(INT32 joyid)
SDL_JoystickID joystick_id = joystick_list[joyid - 1]; SDL_JoystickID joystick_id = joystick_list[joyid - 1];
SDL_free(joystick_list); SDL_free(joystick_list);
tempname = SDL_GetJoystickNameForID(joystick_id); tempname = SDL_GetGamepadNameForID(joystick_id);
if (tempname) if (tempname)
{ {
strncpy(joyname, tempname, 254); strncpy(joyname, tempname, 254);