update led status in main loop

makes this whole ordeal alot less hacky tbh
player color always gets updated if it changes
still allows for directly setting led color elsewhere by using G_SetPlayerGamepadIndicatorColor directly
hoping crap doesent cost any perf but honestly shouldnt
This commit is contained in:
Alug committed 2024-08-04 14:51:19 +02:00
1 parent d9123c50d6
commit eb3c68df88
6 files changed
+33 -18

No files matched your search

+28
View File
@@ -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();
-10
View File
@@ -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.
-6
View File
@@ -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
+2 -2
View File
@@ -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;
+2
View File
@@ -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);
+1
View File
@@ -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;