diff --git a/src/d_main.c b/src/d_main.c index 79f564e1f..ade74830c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -170,6 +170,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 @@ -839,6 +864,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 3103b4fc8..140bc7076 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6065,8 +6065,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 @@ -6086,8 +6084,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 @@ -6110,8 +6106,6 @@ static void Color2_OnChange(void) CV_StealthSetValue(&cv_playercolor2, players[displayplayers[1]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(1, 0); } static void Color3_OnChange(void) @@ -6129,8 +6123,6 @@ static void Color3_OnChange(void) CV_StealthSetValue(&cv_playercolor3, players[displayplayers[2]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(2, 0); } static void Color4_OnChange(void) @@ -6148,8 +6140,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 89d299c28..e05e7fcc0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2136,8 +2136,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; - - G_SetPlayerGamepadIndicatorColor(viewnum-1, 0); } // @@ -8544,12 +8542,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 f5763dc09..cd43e40bf 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3022,6 +3022,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;