diff --git a/src/d_main.c b/src/d_main.c index 7c6105a28..b167bc60a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -217,7 +217,7 @@ static void D_DeviceLEDTick(void) static UINT16 color[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; - if (dedicated || I_NumJoys() == 0) + if (dedicated || numcontrollers == 0) { return; } diff --git a/src/i_system.h b/src/i_system.h index 81cd80b68..2154d5db0 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -226,6 +226,8 @@ void I_InitJoystick4(void); */ INT32 I_NumJoys(void); +extern INT32 numcontrollers; + /** \brief The *I_GetJoyName function \param joyindex which joystick diff --git a/src/p_tick.c b/src/p_tick.c index 5a55d23e3..717bffdc0 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -373,7 +373,7 @@ static void P_DeviceRumbleTick(void) { UINT8 i; - if (dedicated || I_NumJoys() == 0 || gamestate != GS_LEVEL) + if (dedicated || numcontrollers == 0 || gamestate != GS_LEVEL) { return; } diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 65239b6a4..5e5df2c11 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -201,6 +201,8 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif +INT32 numcontrollers = 0; + #ifdef HAVE_LIBBACKTRACE #include // TODO - move this to some header file instead @@ -1397,6 +1399,8 @@ void I_InitJoystick(UINT8 index) joystick_started[index] = 0; } + numcontrollers = I_NumJoys(); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { if (JoyInfo[i].dev == newcontroller) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2ba945467..820186c0f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1243,6 +1243,8 @@ void I_GetEvent(void) G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect } + numcontrollers = I_NumJoys(); + //////////////////////////////////////////////////////////// for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)