Use proper gamepad retrival function for rumble and add LED ticker
This commit is contained in:
parent
a1fa9d604f
commit
f7bf52bcfa
6 changed files with 51 additions and 28 deletions
|
|
@ -197,6 +197,38 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right
|
|||
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
||||
boolean capslock = 0; // gee i wonder what this does.
|
||||
|
||||
static UINT8 curcolor[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
static void D_DeviceLEDTick(void)
|
||||
{
|
||||
UINT8 i;
|
||||
static UINT8 newcolor = UINT8_MAX;
|
||||
|
||||
if (numcontrollers == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (!cv_usejoystick[i].value || !cv_gamepadled[i].value)
|
||||
continue;
|
||||
|
||||
newcolor = G_GetSkinColorForGamepad(i);
|
||||
|
||||
if (curcolor[i] == newcolor) // dont update if same colour
|
||||
continue;
|
||||
|
||||
G_SetPlayerGamepadIndicatorColor(i, newcolor);
|
||||
curcolor[i] = newcolor;
|
||||
}
|
||||
}
|
||||
|
||||
void D_ResetDeviceLED(void)
|
||||
{
|
||||
memset(curcolor, 0, sizeof(curcolor));
|
||||
}
|
||||
|
||||
static boolean recursioncheck = false;
|
||||
|
||||
//
|
||||
|
|
@ -1056,6 +1088,11 @@ void D_SRB2Loop(void)
|
|||
}
|
||||
|
||||
renderisnewtic = true;
|
||||
|
||||
if (!dedicated)
|
||||
{
|
||||
D_DeviceLEDTick();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1222,6 +1259,9 @@ void D_StartTitle(void)
|
|||
|
||||
// The title screen is obviously not a tutorial! (Unless I'm mistaken)
|
||||
tutorialmode = false;
|
||||
|
||||
// map palettes affect this
|
||||
D_ResetDeviceLED();
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ void D_ProcessEvents(void);
|
|||
|
||||
const char *D_Home(void);
|
||||
|
||||
void D_ResetDeviceLED(void);
|
||||
|
||||
//
|
||||
// BASE LEVEL
|
||||
//
|
||||
|
|
|
|||
|
|
@ -500,29 +500,7 @@ static const char *gamecontrolname[num_gamecontrols] =
|
|||
|
||||
#define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t))
|
||||
|
||||
static INT32 G_GetDeviceForPlayer(INT32 player)
|
||||
{
|
||||
switch (player)
|
||||
{
|
||||
case 0:
|
||||
return cv_usejoystick[0].value;
|
||||
break;
|
||||
case 1:
|
||||
return cv_usejoystick[1].value;
|
||||
break;
|
||||
case 2:
|
||||
return cv_usejoystick[2].value;
|
||||
break;
|
||||
case 3:
|
||||
return cv_usejoystick[3].value;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UINT16 G_GetSkinColor(INT32 playernum)
|
||||
skincolornum_t G_GetSkinColorForGamepad(INT32 playernum)
|
||||
{
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
|
|
@ -560,7 +538,7 @@ UINT16 G_GetSkinColor(INT32 playernum)
|
|||
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color)
|
||||
{
|
||||
UINT16 skincolor;
|
||||
skincolornum_t skincolor;
|
||||
RGBA_t byte_color;
|
||||
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
|
@ -570,7 +548,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color)
|
|||
return;
|
||||
}
|
||||
|
||||
skincolor = color ? color : G_GetSkinColor(playernum);
|
||||
skincolor = color ? color : G_GetSkinColorForGamepad(playernum);
|
||||
byte_color = V_GetColor(skincolors[skincolor].ramp[8]);
|
||||
|
||||
I_SetGamepadIndicatorColor(playernum, byte_color.s.red, byte_color.s.green, byte_color.s.blue);
|
||||
|
|
@ -590,7 +568,7 @@ static void G_ResetPlayerDeviceRumble(INT32 player)
|
|||
{
|
||||
INT32 device_id;
|
||||
|
||||
device_id = G_GetDeviceForPlayer(player);
|
||||
device_id = G_GetDevicePlayer(player);
|
||||
|
||||
if (device_id < 1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "d_event.h"
|
||||
#include "keys.h"
|
||||
#include "command.h"
|
||||
#include "info.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -128,7 +129,7 @@ extern const INT32 gcl_full[num_gcl_full];
|
|||
// peace to my little coder fingers!
|
||||
// check a gamecontrol being active or not
|
||||
|
||||
UINT16 G_GetSkinColor(INT32 playernum);
|
||||
skincolornum_t G_GetSkinColorForGamepad(INT32 playernum);
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color);
|
||||
void G_ResetAllDeviceRumbles(void);
|
||||
void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration);
|
||||
|
|
|
|||
|
|
@ -9077,6 +9077,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
|
||||
G_AddMapToBuffer(gamemap-1);
|
||||
|
||||
D_ResetDeviceLED();
|
||||
|
||||
P_MapEnd(); // g_tm.thing is no longer needed from this point onwards
|
||||
|
||||
// Took me 3 hours to figure out why my progression kept on getting overwritten with the titlemap...
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ void I_GetEvent(void)
|
|||
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, G_GetSkinColorForGamepad(i)); // gotta update the controller led again on reconnect
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in a new issue