Change gamepad LED colors on playercolor change

This commit is contained in:
Eidolon 2023-03-06 22:54:03 -06:00
parent 86a9579e16
commit 7ed5e7a7a5
4 changed files with 46 additions and 0 deletions

View file

@ -6207,6 +6207,7 @@ static void FollowerAny_OnChange(UINT8 pnum)
return; // don't send anything there.
SendNameAndColor(pnum);
G_SetPlayerGamepadIndicatorToPlayerColor(pnum);
}
// sends the follower change for players
@ -6358,6 +6359,8 @@ static void Color_OnChange(void)
}
}
lastgoodcolor[0] = cv_playercolor[0].value;
G_SetPlayerGamepadIndicatorToPlayerColor(0);
}
/** Sends a color change for the secondary splitscreen player, unless that
@ -6386,6 +6389,8 @@ static void Color2_OnChange(void)
}
}
lastgoodcolor[1] = cv_playercolor[1].value;
G_SetPlayerGamepadIndicatorToPlayerColor(1);
}
static void Color3_OnChange(void)
@ -6409,6 +6414,8 @@ static void Color3_OnChange(void)
}
}
lastgoodcolor[2] = cv_playercolor[2].value;
G_SetPlayerGamepadIndicatorToPlayerColor(2);
}
static void Color4_OnChange(void)
@ -6432,6 +6439,8 @@ static void Color4_OnChange(void)
}
}
lastgoodcolor[3] = cv_playercolor[3].value;
G_SetPlayerGamepadIndicatorToPlayerColor(3);
}
/** Displays the result of the chat being muted or unmuted.

View file

@ -19,6 +19,8 @@
#include "d_net.h"
#include "console.h"
#include "i_joy.h" // JOYAXISRANGE
#include "r_draw.h" // GTC_ macros for assigning gamepad indicator colors
#include "v_video.h" // V_GetColor for assigning gamepad indictaor colors
#include "z_zone.h"
#define MAXMOUSESENSITIVITY 100 // sensitivity steps
@ -210,6 +212,37 @@ void G_SetDeviceForPlayer(INT32 player, INT32 device)
}
}
void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player)
{
INT32 device;
INT32 skin;
UINT16 skincolor;
UINT8 *colormap;
byteColor_t byte_color;
I_Assert(player >= 0 && player < MAXSPLITSCREENPLAYERS);
device = G_GetDeviceForPlayer(player);
if (device <= 0)
{
return;
}
skin = cv_skin[player].value;
skincolor = cv_playercolor[player].value;
colormap = R_GetTranslationColormap(skin, skincolor, GTC_MENUCACHE);
if (colormap == NULL)
{
return;
}
byte_color = V_GetColor(colormap[104]).s;
I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue);
}
INT32* G_GetDeviceGameKeyDownArray(INT32 device)
{
int i;

View file

@ -154,6 +154,8 @@ INT32 G_GetDeviceForPlayer(INT32 player);
/// Set the given player index's assigned device. If the device is in use by another player, that player is unassigned.
void G_SetDeviceForPlayer(INT32 player, INT32 device);
void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player);
/// Get the gamekeydown array (NUMINPUTS values) for the given device, or NULL if the device id is invalid.
INT32* G_GetDeviceGameKeyDownArray(INT32 device);

View file

@ -1488,6 +1488,8 @@ void M_CharacterSelectTick(void)
else
CV_StealthSet(&cv_follower[i], followers[setup_player[i].followern].name);
CV_StealthSetValue(&cv_followercolor[i], setup_player[i].followercolor);
G_SetPlayerGamepadIndicatorToPlayerColor(i);
}
CV_StealthSetValue(&cv_splitplayers, setup_numplayers);