diff --git a/src/d_main.c b/src/d_main.c index 766335768..7c426fcba 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -171,6 +171,31 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right boolean capslock = 0; // gee i wonder what this does. +static inline void D_DeviceLEDTick(void) +{ + UINT8 i; + UINT16 color[MAXSPLITSCREENPLAYERS]; + UINT16 curcolor[MAXSPLITSCREENPLAYERS]; + + // no gamepads connected + if (I_NumJoys() == 0) + return; + + for (i = 0; i <= splitscreen; i++) + { + if (G_GetDeviceForPlayer(i) == 0) + continue; + + color[i] = G_GetSkinColor(i); + + if (curcolor[i] == color[i]) // dont update if same colour + continue; + + G_SetPlayerGamepadIndicatorColor(i, color[i]); + curcolor[i] = color[i]; + } +} + // // D_ProcessEvents // Send all the events of the given timestamp down the responder chain @@ -842,6 +867,9 @@ void D_SRB2Loop(void) else menuInputDelayTimer = 0; + if (!dedicated && renderisnewtic) // idk does this need dedi check?? + D_DeviceLEDTick(); + // Fully completed frame made. finishprecise = I_GetPreciseTime(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4d66c8788..1c411df73 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6069,8 +6069,6 @@ static void Command_SkinSearch(void) */ static void Color_OnChange(void) { - G_SetPlayerGamepadIndicatorColor(0, 0); // i want this to always change so its here - if (!Playing()) return; // do whatever you want @@ -6090,8 +6088,6 @@ static void Color_OnChange(void) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); } - - G_SetPlayerGamepadIndicatorColor(0, 0); // update again } /** Sends a color change for the secondary splitscreen player, unless that @@ -6114,8 +6110,6 @@ static void Color2_OnChange(void) CV_StealthSetValue(&cv_playercolor2, players[displayplayers[1]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(1, 0); } static void Color3_OnChange(void) @@ -6133,8 +6127,6 @@ static void Color3_OnChange(void) CV_StealthSetValue(&cv_playercolor3, players[displayplayers[2]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(2, 0); } static void Color4_OnChange(void) @@ -6152,8 +6144,6 @@ static void Color4_OnChange(void) CV_StealthSetValue(&cv_playercolor4, players[displayplayers[3]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(3, 0); } /** Displays the result of the chat being muted or unmuted. diff --git a/src/g_game.c b/src/g_game.c index 38670d0b0..1b18443e5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2143,8 +2143,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; - - G_SetPlayerGamepadIndicatorColor(viewnum-1, 0); } // @@ -8492,12 +8490,8 @@ boolean G_DemoTitleResponder(event_t *ev) // void G_SetGamestate(gamestate_t newstate) { - SINT8 i; gamestate = newstate; - for (i = 0; i <= splitscreen; i++) - G_SetPlayerGamepadIndicatorColor(i, 0); // dumb hack but works - #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); #endif diff --git a/src/g_input.c b/src/g_input.c index f7057d4e4..00a57d7bc 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -865,7 +865,7 @@ static const char *gamecontrolname[num_gamecontrols] = #include "k_kart.h" -static INT32 G_GetDeviceForPlayer(INT32 player) +INT32 G_GetDeviceForPlayer(INT32 player) { switch (player) { @@ -887,7 +887,7 @@ static INT32 G_GetDeviceForPlayer(INT32 player) } } -static UINT16 G_GetSkinColor(INT32 player) +inline UINT16 G_GetSkinColor(INT32 player) { if (players[displayplayers[player]].skincolor && gamestate == GS_LEVEL) return players[displayplayers[player]].skincolor; diff --git a/src/g_input.h b/src/g_input.h index 92444cccc..8522be618 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -132,6 +132,8 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not +UINT16 G_GetSkinColor(INT32 player); +INT32 G_GetDeviceForPlayer(INT32 player); void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color); void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a771b8d75..c725c0e54 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3040,6 +3040,7 @@ static int lib_gSetPlayerGamepadIndicatorColor(lua_State *L) // Not a local player if (player == -1) return 0; + // pls update with color 0 when youre done with changing led stuff so it can get player color again G_SetPlayerGamepadIndicatorColor(player, color); return 0;