small fixes for gamepad indicator led stuff
- skincolors are uint8 type not uint16 - ensure desired colour is within skincolor range - rename G_GetSkinColor to G_GetSkinColorForGamepad - replace pointless array with single variable for current color in D_DeviceLEDTick - remove pointless call to G_GetSkinColorForGamepad when hotplugging gamepads (G_SetPlayerGamepadIndicatorColor will call it itself when 0/skincolor_none is passed)
This commit is contained in:
1 parent
495ad5ce06
commit
43ec517cdd
6 files changed
+75
-58
No files matched your search
+6
-6
@@ -166,12 +166,12 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
||||
boolean capslock = 0; // gee i wonder what this does.
|
||||
|
||||
static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {};
|
||||
static UINT8 curcolor[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
static void D_DeviceLEDTick(void)
|
||||
{
|
||||
UINT8 i;
|
||||
static UINT16 color[MAXSPLITSCREENPLAYERS] = {};
|
||||
static UINT8 newcolor = UINT8_MAX;
|
||||
|
||||
if (numcontrollers == 0)
|
||||
{
|
||||
@@ -183,13 +183,13 @@ static void D_DeviceLEDTick(void)
|
||||
if (!cv_usejoystick[i].value || !cv_gamepadled[i].value)
|
||||
continue;
|
||||
|
||||
color[i] = G_GetSkinColor(i);
|
||||
newcolor = G_GetSkinColorForGamepad(i);
|
||||
|
||||
if (curcolor[i] == color[i]) // dont update if same colour
|
||||
if (curcolor[i] == newcolor) // dont update if same colour
|
||||
continue;
|
||||
|
||||
G_SetPlayerGamepadIndicatorColor(i, color[i]);
|
||||
curcolor[i] = color[i];
|
||||
G_SetPlayerGamepadIndicatorColor(i, newcolor);
|
||||
curcolor[i] = newcolor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-10
@@ -875,11 +875,13 @@ static const char *gamecontrolname[num_gamecontrols] =
|
||||
|
||||
#include "k_kart.h"
|
||||
|
||||
UINT16 G_GetSkinColor(INT32 playernum)
|
||||
UINT8 G_GetSkinColorForGamepad(INT32 playernum)
|
||||
{
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
player_t *player = &players[displayplayers[playernum]];
|
||||
const player_t *player = &players[displayplayers[playernum]];
|
||||
|
||||
if (player)
|
||||
{
|
||||
@@ -897,13 +899,13 @@ UINT16 G_GetSkinColor(INT32 playernum)
|
||||
switch (playernum)
|
||||
{
|
||||
case 0:
|
||||
return cv_playercolor.value;
|
||||
return (UINT8)cv_playercolor.value;
|
||||
case 1:
|
||||
return cv_playercolor2.value;
|
||||
return (UINT8)cv_playercolor2.value;
|
||||
case 2:
|
||||
return cv_playercolor3.value;
|
||||
return (UINT8)cv_playercolor3.value;
|
||||
case 3:
|
||||
return cv_playercolor4.value;
|
||||
return (UINT8)cv_playercolor4.value;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -911,19 +913,23 @@ UINT16 G_GetSkinColor(INT32 playernum)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color)
|
||||
// Sets the Indicator LED on supported gamepads to a desired skincolor
|
||||
// pass SKINCOLOR_NONE/0 to set the players skin color
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
|
||||
{
|
||||
UINT16 skincolor;
|
||||
UINT8 skincolor;
|
||||
byteColor_t byte_color;
|
||||
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_gamepadled[playernum].value == 0)
|
||||
if (cv_gamepadled[playernum].value == 0
|
||||
|| color >= MAXTRANSLATIONS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
skincolor = color ? color : G_GetSkinColor(playernum);
|
||||
// so we can override this
|
||||
skincolor = color ? color : G_GetSkinColorForGamepad(playernum);
|
||||
byte_color = V_GetColor(colortranslations[skincolor][8]).s;
|
||||
|
||||
I_SetGamepadIndicatorColor(playernum, byte_color.red, byte_color.green, byte_color.blue);
|
||||
@@ -936,7 +942,9 @@ static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum)
|
||||
I_SetGamepadIndicatorColor(playernum, 0, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
G_SetPlayerGamepadIndicatorColor(playernum, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void G_ResetPlayerDeviceRumble(INT32 playernum)
|
||||
|
||||
+5
-5
@@ -131,14 +131,14 @@ extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2];
|
||||
#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol[2][gc][0]] || gamekeydown[gamecontrol[2][gc][1]])
|
||||
#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol[3][gc][0]] || gamekeydown[gamecontrol[3][gc][1]])
|
||||
|
||||
// peace to my little coder fingers!
|
||||
// check a gamecontrol being active or not
|
||||
|
||||
UINT16 G_GetSkinColor(INT32 playernum);
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color);
|
||||
UINT8 G_GetSkinColorForGamepad(INT32 playernum);
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color);
|
||||
void G_ResetAllDeviceRumbles(void);
|
||||
void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration);
|
||||
|
||||
// peace to my little coder fingers!
|
||||
// check a gamecontrol being active or not
|
||||
|
||||
// remaps the input event to a game control.
|
||||
void G_MapEventsToControls(event_t *ev);
|
||||
void G_ResetControls(void);
|
||||
|
||||
+10
-1
@@ -3056,7 +3056,13 @@ static int lib_gSetPlayerGamepadIndicatorColor(lua_State *L)
|
||||
{
|
||||
INT32 player = -1;
|
||||
player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player
|
||||
UINT16 color = (UINT16)luaL_checkinteger(L, 2); // skincolor
|
||||
UINT8 color = (UINT8)luaL_checkinteger(L, 2); // skincolor
|
||||
|
||||
if (!plr)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
||||
if (color >= MAXTRANSLATIONS)
|
||||
return luaL_error(L, "color %d out of range (0 - %d).", color, MAXTRANSLATIONS-1);
|
||||
|
||||
for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i)
|
||||
{
|
||||
@@ -3084,6 +3090,9 @@ static int lib_gPlayerDeviceRumble(lua_State *L)
|
||||
UINT16 high_strength = (UINT16)luaL_checkinteger(L, 3); // high frequency rumble motor strenght
|
||||
UINT32 duration = (UINT32)luaL_optinteger(L, 4, 84); // duration of rumble in ms
|
||||
|
||||
if (!plr)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
||||
for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i)
|
||||
{
|
||||
if (plr - players == displayplayers[i])
|
||||
|
||||
+35
-35
@@ -641,7 +641,7 @@ static boolean M_ChangeStringCvar(INT32 choice)
|
||||
|
||||
if (M_TextInputHandle(&menuinput, choice))
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
CV_Set(cv, menuinput.buffer);
|
||||
|
||||
return true;
|
||||
@@ -3545,7 +3545,7 @@ static void M_HandleAddons(INT32 choice)
|
||||
|
||||
if (M_TextInputHandle(&menusearch, choice))
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
|
||||
char *tempname = NULL;
|
||||
if (dirmenu && dirmenu[dir_on[menudepthleft]])
|
||||
@@ -4012,7 +4012,7 @@ static boolean M_HandleReplayHutQuery(INT32 choice)
|
||||
|
||||
if (M_TextInputHandle(&replayqueryinput, choice))
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
|
||||
// Restart search only if we actually modified input and not just moved in it
|
||||
if (memcmp(tmp, replayqueryinput_buffer, MAXREPLAYQUERY+1))
|
||||
@@ -7449,7 +7449,7 @@ static void M_SetupMultiHandler(INT32 choice)
|
||||
{
|
||||
if (--setupm_pselect < 1)
|
||||
setupm_pselect = cv_splitplayers.value;
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -7458,23 +7458,23 @@ static void M_SetupMultiHandler(INT32 choice)
|
||||
{
|
||||
if (++setupm_pselect > cv_splitplayers.value)
|
||||
setupm_pselect = 1;
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_DOWNARROW:
|
||||
M_NextOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
case KEY_UPARROW:
|
||||
M_PrevOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
case KEY_ENTER:
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
currentMenu->lastOn = itemOn;
|
||||
switch (setupm_pselect)
|
||||
{
|
||||
@@ -7556,16 +7556,16 @@ static void M_HandleConnectIP(INT32 choice)
|
||||
{
|
||||
case KEY_DOWNARROW:
|
||||
M_NextOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
case KEY_UPARROW:
|
||||
M_PrevOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
case KEY_ENTER:
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
currentMenu->lastOn = itemOn;
|
||||
M_ConnectIP(1);
|
||||
break;
|
||||
@@ -7579,7 +7579,7 @@ static void M_HandleConnectIP(INT32 choice)
|
||||
case KEY_BACKSPACE:
|
||||
case KEY_DEL:
|
||||
if (M_TextInputHandle(&setupm_input_ip, choice))
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -7589,7 +7589,7 @@ static void M_HandleConnectIP(INT32 choice)
|
||||
|| (choice >= 199 && choice <= 211 && choice != 202 && choice != 206))*/ //numpad too!
|
||||
{
|
||||
if (M_TextInputHandle(&setupm_input_ip, choice))
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -8315,7 +8315,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
else
|
||||
M_NextOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
}
|
||||
else if (gridselect) //grid skin select menu
|
||||
@@ -8355,7 +8355,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
break;
|
||||
}
|
||||
M_NextOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
case KEY_UPARROW:
|
||||
@@ -8371,7 +8371,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
else
|
||||
M_PrevOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
}
|
||||
else if (gridselect)
|
||||
@@ -8408,18 +8408,18 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
else
|
||||
M_PrevOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
}
|
||||
M_PrevOpt();
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
break;
|
||||
|
||||
case KEY_LEFTARROW:
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
else if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
|
||||
{
|
||||
@@ -8433,7 +8433,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
else //player skin
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
|
||||
if (setupm_skinxpos > 0)
|
||||
setupm_skinxpos--;
|
||||
@@ -8466,14 +8466,14 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
if (itemOn == 1) //player skin
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
setupm_fakeskin--;
|
||||
}
|
||||
else if (itemOn == 2) // player color
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
setupm_fakecolor--;
|
||||
G_SetPlayerGamepadIndicatorColor(setupm_playernum, setupm_fakecolor);
|
||||
G_SetPlayerGamepadIndicatorColor(setupm_playernum, (UINT8)setupm_fakecolor);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -8481,7 +8481,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
else if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
|
||||
{
|
||||
@@ -8491,11 +8491,11 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
setupm_skinselect++;
|
||||
else
|
||||
setupm_skinselect = 0;
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
}
|
||||
else //player skin
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
if (setupm_skinxpos < MAXSTAT - 1)
|
||||
setupm_skinxpos++;
|
||||
else
|
||||
@@ -8530,14 +8530,14 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
if (itemOn == 1) //player skin
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
setupm_fakeskin++;
|
||||
}
|
||||
else if (itemOn == 2) // player color
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
setupm_fakecolor++;
|
||||
G_SetPlayerGamepadIndicatorColor(setupm_playernum, setupm_fakecolor);
|
||||
G_SetPlayerGamepadIndicatorColor(setupm_playernum, (UINT8)setupm_fakecolor);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -8556,7 +8556,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
else if (gridselect && itemOn == 1)
|
||||
{
|
||||
@@ -8572,9 +8572,9 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
UINT8 col = skins[setupm_fakeskin].prefcolor;
|
||||
if (setupm_fakecolor != col)
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
setupm_fakecolor = col;
|
||||
G_SetPlayerGamepadIndicatorColor(setupm_playernum, setupm_fakecolor);
|
||||
G_SetPlayerGamepadIndicatorColor(setupm_playernum, (UINT8)setupm_fakecolor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -8585,7 +8585,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -8608,7 +8608,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
{
|
||||
setupm_skinlockedselect = true;
|
||||
setupm_skinselect = 0;
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
}
|
||||
}
|
||||
else if (gridselect && itemOn == 1 && setupm_skinselect < numskins)
|
||||
@@ -8622,7 +8622,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
if (M_TextInputHandle(&setupm_input, choice))
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
S_StartSound(NULL, sfx_menu1); // Tails
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1006,7 +1006,7 @@ static void Impl_HandleControllerAddedEvent(SDL_Event evt)
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
I_InitJoystick(i);
|
||||
G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect
|
||||
G_SetPlayerGamepadIndicatorColor(i, 0); // gotta update the controller led again on reconnect
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in new issue
Block a user