diff --git a/src/g_input.c b/src/g_input.c index 959dc5416..460f21899 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -913,18 +913,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; } @@ -932,19 +926,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); @@ -952,16 +941,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) @@ -973,29 +953,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 3b6913c00..1f5226fee 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -238,8 +238,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 d40359c8a..4a64a7c5d 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1486,7 +1486,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; @@ -1494,9 +1494,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; @@ -1506,7 +1509,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; @@ -1514,9 +1517,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;