add splitscreen support to gamepad led

also add more proper device check
This commit is contained in:
Alug committed 2024-07-29 21:41:18 +02:00
1 parent 55c6aa78e5
commit a6d08a12b5
5 files changed
+83 -13

No files matched your search

+8 -2
View File
@@ -6066,7 +6066,7 @@ static void Command_SkinSearch(void)
*/
static void Color_OnChange(void)
{
G_SetPlayerGamepadIndicatorToPlayerColor(0); // i want this to always change so its here
G_SetPlayerGamepadIndicatorToPlayerColor(0, 0); // i want this to always change so its here
if (!Playing())
return; // do whatever you want
@@ -6088,7 +6088,7 @@ static void Color_OnChange(void)
players[consoleplayer].skincolor);
}
G_SetPlayerGamepadIndicatorToPlayerColor(0); // update again
G_SetPlayerGamepadIndicatorToPlayerColor(0, 0); // update again
}
/** Sends a color change for the secondary splitscreen player, unless that
@@ -6111,6 +6111,8 @@ static void Color2_OnChange(void)
CV_StealthSetValue(&cv_playercolor2,
players[displayplayers[1]].skincolor);
}
G_SetPlayerGamepadIndicatorToPlayerColor(1, 0);
}
static void Color3_OnChange(void)
@@ -6128,6 +6130,8 @@ static void Color3_OnChange(void)
CV_StealthSetValue(&cv_playercolor3,
players[displayplayers[2]].skincolor);
}
G_SetPlayerGamepadIndicatorToPlayerColor(2, 0);
}
static void Color4_OnChange(void)
@@ -6145,6 +6149,8 @@ static void Color4_OnChange(void)
CV_StealthSetValue(&cv_playercolor4,
players[displayplayers[3]].skincolor);
}
G_SetPlayerGamepadIndicatorToPlayerColor(3, 0);
}
/** Displays the result of the chat being muted or unmuted.
+4 -2
View File
@@ -2153,7 +2153,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
if (viewnum == 1 && demo.playback)
consoleplayer = displayplayers[0];
G_SetPlayerGamepadIndicatorToPlayerColor(0);
G_SetPlayerGamepadIndicatorToPlayerColor(viewnum-1, 0);
}
//
@@ -8481,9 +8481,11 @@ boolean G_DemoTitleResponder(event_t *ev)
//
void G_SetGamestate(gamestate_t newstate)
{
SINT8 i;
gamestate = newstate;
G_SetPlayerGamepadIndicatorToPlayerColor(0); // dumb hack but works
for (i = 0; i <= splitscreen; i++)
G_SetPlayerGamepadIndicatorToPlayerColor(i, 0); // dumb hack but works
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
+57 -5
View File
@@ -826,25 +826,77 @@ static const char *gamecontrolname[num_gamecontrols] =
#include "k_kart.h"
static UINT16 G_GetSkinColor(void)
static INT32 G_GetDeviceForPlayer(INT32 player)
{
return ((gamestate == GS_LEVEL) ? players[displayplayers[0]].skincolor : cv_playercolor.value);
switch (player)
{
case 0:
return cv_usejoystick.value;
break;
case 1:
return cv_usejoystick2.value;
break;
case 2:
return cv_usejoystick3.value;
break;
case 3:
return cv_usejoystick4.value;
break;
default:
return 0;
break;
}
}
static UINT16 G_GetSkinColor(INT32 player)
{
if (gamestate == GS_LEVEL)
return players[displayplayers[player]].skincolor;
switch (player)
{
case 0:
return cv_playercolor.value;
break;
case 1:
return cv_playercolor2.value;
break;
case 2:
return cv_playercolor3.value;
break;
case 3:
return cv_playercolor4.value;
break;
default:
return 0;
break;
}
}
// ehhhhhh ill maybe add splitscreen support eventually lol
void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color)
void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color)
{
INT32 device;
UINT16 skincolor;
byteColor_t byte_color;
I_Assert(player >= 0 && player < MAXSPLITSCREENPLAYERS);
device = G_GetDeviceForPlayer(player);
if (device <= 0)
{
return;
}
if (color)
skincolor = color;
else
skincolor = G_GetSkinColor();
skincolor = G_GetSkinColor(player);
byte_color = V_GetColor(colortranslations[skincolor][8]).s;
I_SetGamepadIndicatorColor(1, byte_color.red, byte_color.green, byte_color.blue);
I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue);
}
void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength)
+1 -1
View File
@@ -131,7 +131,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2];
// peace to my little coder fingers!
// check a gamecontrol being active or not
void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color);
void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color);
void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength);
// remaps the input event to a game control.
+13 -3
View File
@@ -10415,6 +10415,8 @@ static UINT8 setupm_skinypos;
static INT32 setupm_skinselect;
static boolean setupm_skinlockedselect;
static UINT8 setupm_playernum; //brap
#define SELECTEDSTATSCOUNT skinstatscount[setupm_skinxpos][setupm_skinypos]
#define LASTSELECTEDSTAT skinstats[setupm_skinxpos][setupm_skinypos][skinstatscount[setupm_skinxpos][setupm_skinypos]]
@@ -11256,7 +11258,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
{
S_StartSound(NULL,sfx_menu1); // Tails
setupm_fakecolor--;
G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor);
G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor);
}
break;
@@ -11312,7 +11314,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
{
S_StartSound(NULL,sfx_menu1); // Tails
setupm_fakecolor++;
G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor);
G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor);
}
break;
@@ -11352,7 +11354,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
{
S_StartSound(NULL,sfx_menu1); // Tails
setupm_fakecolor = col;
G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor);
G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor);
}
}
break;
@@ -11486,6 +11488,8 @@ static void M_SetupMultiPlayer(INT32 choice)
setupm_skinypos = 0;
setupm_skinlockedselect = false;
setupm_playernum = 0;
// For whatever reason this doesn't work right if you just use ->value
setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string);
if (setupm_fakeskin == -1)
@@ -11525,6 +11529,8 @@ static void M_SetupMultiPlayer2(INT32 choice)
setupm_skinypos = 0;
setupm_skinlockedselect = false;
setupm_playernum = 1;
// For whatever reason this doesn't work right if you just use ->value
setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string);
if (setupm_fakeskin == -1)
@@ -11564,6 +11570,8 @@ static void M_SetupMultiPlayer3(INT32 choice)
setupm_skinypos = 0;
setupm_skinlockedselect = false;
setupm_playernum = 2;
// For whatever reason this doesn't work right if you just use ->value
setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string);
if (setupm_fakeskin == -1)
@@ -11603,6 +11611,8 @@ static void M_SetupMultiPlayer4(INT32 choice)
setupm_skinypos = 0;
setupm_skinlockedselect = false;
setupm_playernum = 3;
// For whatever reason this doesn't work right if you just use ->value
setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string);
if (setupm_fakeskin == -1)