From a6a53f6b9c898ba2d68013f803bff6c686e55923 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Feb 2025 02:06:57 +0100 Subject: [PATCH 1/3] dont pass bogus values to I_GamepadRumble and I_SetGamepadIndicatorColor - fixes rumble and led stuff not working after hotplugging - also fixes sdl2-compat breaking - i hate karts controller code --- src/g_input.c | 41 ++++++----------------------------------- src/i_system.h | 4 ++-- src/sdl/i_system.c | 14 ++++++++++---- 3 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 1f3c69464..168d51bf3 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -946,18 +946,12 @@ UINT16 G_GetSkinColor(INT32 playernum) void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) { - INT32 device; UINT16 skincolor; byteColor_t byte_color; I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); if (cv_gamepadled[playernum].value == 0) - return; - - device = cv_usejoystick[playernum].value; - - if (device <= 0) { return; } @@ -965,19 +959,14 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) skincolor = color ? color : G_GetSkinColor(playernum); byte_color = V_GetColor(colortranslations[skincolor][8]).s; - I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); + I_SetGamepadIndicatorColor(playernum, byte_color.red, byte_color.green, byte_color.blue); } static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { if (cv_gamepadled[playernum].value == 0) { - INT32 device = cv_usejoystick[playernum].value; - - if (device <= 0) - return; - - I_SetGamepadIndicatorColor(device, 0, 0, 255); + I_SetGamepadIndicatorColor(playernum, 0, 0, 255); } else G_SetPlayerGamepadIndicatorColor(playernum, 0); @@ -985,16 +974,7 @@ static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) static void G_ResetPlayerDeviceRumble(INT32 playernum) { - INT32 device_id; - - device_id = cv_usejoystick[playernum].value; - - if (device_id < 1) - { - return; - } - - I_GamepadRumble(device_id, 0, 0, 0); + I_GamepadRumble(playernum, 0, 0, 0); } void G_ResetAllDeviceRumbles(void) @@ -1006,29 +986,20 @@ void G_ResetAllDeviceRumbles(void) for (i = 0; i < devices; i++) { - INT32 device_id = cv_usejoystick[i].value; - - I_GamepadRumble(device_id, 0, 0, 0); + I_GamepadRumble(devices, 0, 0, 0); } } void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { - INT32 device_id; + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); if (cv_rumble[playernum].value == 0) { return; } - device_id = cv_usejoystick[playernum].value; - - if (device_id < 1) - { - return; - } - - I_GamepadRumble(device_id, low_strength, high_strength, duration); + I_GamepadRumble(playernum, low_strength, high_strength, duration); } // diff --git a/src/i_system.h b/src/i_system.h index baaa0d446..81cd80b68 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -234,8 +234,8 @@ INT32 I_NumJoys(void); */ const char *I_GetJoyName(INT32 joyindex); -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration); -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); +void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration); +void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue); #ifndef NOMUMBLE #include "p_mobj.h" // mobj_t diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 20514f105..6ea659b70 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1483,7 +1483,7 @@ const char *I_GetJoyName(INT32 joyindex) return joyname; } -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration) +void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; @@ -1491,9 +1491,12 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, (void)high_strength; (void)duration; #else + + INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); if (controller == NULL) { return; @@ -1503,7 +1506,7 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, #endif } -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) +void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue) { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; @@ -1511,9 +1514,12 @@ void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 b (void)green; (void)blue; #else + + INT32 device_id = I_GetJoystickDeviceIndex(JoyInfo[playernum].dev); + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id); if (controller == NULL) { return; From b398dacf29d19ab50986bf20e01b47c4e3beb29e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Feb 2025 14:43:18 +0100 Subject: [PATCH 2/3] update controller led when connecting a controller --- src/sdl/i_video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 609afc30a..2ba945467 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1238,7 +1238,10 @@ void I_GetEvent(void) //////////////////////////////////////////////////////////// for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { I_InitJoystick(i); + G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect + } //////////////////////////////////////////////////////////// From 7d62b330d0b20b449ba6e9ca6ea710d7fe269d1e Mon Sep 17 00:00:00 2001 From: chromaticpipe <127907268+chromaticpipe@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:15:16 -0600 Subject: [PATCH 3/3] Add proxy makefile at top level --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..0a17f3214 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +ifdef SILENT +MAKEFLAGS+=--no-print-directory +endif + +all : + +% :: + @$(MAKE) -C src $(MAKECMDGOALS) \ No newline at end of file