New input handling

Events have a player ID instead of adding billions of keys for separate gamepads. Axis movement (mouse movement, analog sticks) now are counted as keys, so axes don't need to be separately implemented for all controls. Game controls emulate a Saturn controller (some of the external functions like screenshot / gif should be readded, but I got lazy)

This will allow later us to save a config for a controller that can be reused for any player slot, which is one of the main goals for profiles.

Only just enough was made to use the new input system to make it compile. Menus in this branch should aim to move to using PlayerInputDown entirely, instead of using hardcoded keys & simply remapping to those
This commit is contained in:
Sally Coolatta 2021-11-26 14:56:25 -05:00
parent bd8b960d58
commit cd8862f0bc
21 changed files with 550 additions and 1270 deletions

View file

@ -462,7 +462,7 @@ boolean AM_Responder(event_t *ev)
{ {
//faB: prevent alt-tab in win32 version to activate automap just before //faB: prevent alt-tab in win32 version to activate automap just before
// minimizing the app; doesn't do any harm to the DOS version // minimizing the app; doesn't do any harm to the DOS version
if (!gamekeydown[KEY_LALT] && !gamekeydown[KEY_RALT]) if (!gamekeydown[0][KEY_LALT] && !gamekeydown[0][KEY_RALT])
{ {
bigstate = 0; //added : 24-01-98 : toggle off large view bigstate = 0; //added : 24-01-98 : toggle off large view
AM_Start(); AM_Start();

View file

@ -2161,58 +2161,10 @@ static void CV_EnforceExecVersion(void)
CV_StealthSetValue(&cv_execversion, EXECVERSION); CV_StealthSetValue(&cv_execversion, EXECVERSION);
} }
static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr)
{
#if 1
// We don't have changed axis defaults yet
(void)v;
(void)valstr;
#else
UINT8 i;
// If ALL axis settings are previous defaults, set them to the new defaults
// EXECVERSION < 26 (2.1.21)
for (i = 0; i < 4; i++)
{
if (joyaxis_default[i])
{
if (!stricmp(v->name, "joyaxis_fire"))
{
if (joyaxis_count[i] > 7) return false;
else if (joyaxis_count[i] == 7) return true;
if (!stricmp(valstr, "None")) joyaxis_count[i]++;
else joyaxis_default[i] = false;
}
// reset all axis settings to defaults
if (joyaxis_count[i] == 7)
{
switch (i)
{
default:
COM_BufInsertText(va("%s \"%s\"\n", cv_turnaxis[0].name, cv_turnaxis[0].defaultvalue));
COM_BufInsertText(va("%s \"%s\"\n", cv_moveaxis[0].name, cv_moveaxis[0].defaultvalue));
COM_BufInsertText(va("%s \"%s\"\n", cv_brakeaxis[0].name, cv_brakeaxis[0].defaultvalue));
COM_BufInsertText(va("%s \"%s\"\n", cv_aimaxis[0].name, cv_aimaxis[0].defaultvalue));
COM_BufInsertText(va("%s \"%s\"\n", cv_lookaxis[0].name, cv_lookaxis[0].defaultvalue));
COM_BufInsertText(va("%s \"%s\"\n", cv_fireaxis[0].name, cv_fireaxis[0].defaultvalue));
COM_BufInsertText(va("%s \"%s\"\n", cv_driftaxis[0].name, cv_driftaxis[0].defaultvalue));
break;
}
joyaxis_count[i]++;
return false;
}
}
}
#endif
// we haven't reached our counts yet, or we're not default
return true;
}
static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr) static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
{ {
(void)valstr;
// True means allow the CV change, False means block it // True means allow the CV change, False means block it
// We only care about CV_SAVE because this filters the user's config files // We only care about CV_SAVE because this filters the user's config files
@ -2230,11 +2182,6 @@ static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
|| !stricmp(v->name, "mousemove2")) || !stricmp(v->name, "mousemove2"))
return false; return false;
#endif #endif
// axis defaults were changed to be friendly to 360 controllers
// if ALL axis settings are defaults, then change them to new values
if (!CV_FilterJoyAxisVars(v, valstr))
return false;
} }
return true; return true;

View file

@ -1494,7 +1494,7 @@ static void M_ConfirmConnect(event_t *ev)
#ifndef NONET #ifndef NONET
if (ev->type == ev_keydown) if (ev->type == ev_keydown)
{ {
if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[0][gc_accelerate][0] || ev->data1 == gamecontrol[0][gc_accelerate][1]) if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[0][gc_a][0] || ev->data1 == gamecontrol[0][gc_a][1])
{ {
if (totalfilesrequestednum > 0) if (totalfilesrequestednum > 0)
{ {
@ -1517,7 +1517,7 @@ static void M_ConfirmConnect(event_t *ev)
M_ClearMenus(true); M_ClearMenus(true);
} }
else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[0][gc_brake][0] || ev->data1 == gamecontrol[0][gc_brake][1]) else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[0][gc_b][0] || ev->data1 == gamecontrol[0][gc_b][1])
{ {
cl_mode = CL_ABORTED; cl_mode = CL_ABORTED;
M_ClearMenus(true); M_ClearMenus(true);
@ -1923,7 +1923,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
if (cl_mode == CL_CONFIRMCONNECT) if (cl_mode == CL_CONFIRMCONNECT)
D_ProcessEvents(); //needed for menu system to receive inputs D_ProcessEvents(); //needed for menu system to receive inputs
if ((gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1]) || cl_mode == CL_ABORTED) if ((gamekeydown[0][KEY_ESCAPE] || gamekeydown[0][KEY_JOY1+1]) || cl_mode == CL_ABORTED)
{ {
CONS_Printf(M_GetText("Network game synchronization aborted.\n")); CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
// M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING); // M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING);
@ -1931,7 +1931,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();
D_StartTitle(); D_StartTitle();
memset(gamekeydown, 0, NUMKEYS); memset(gamekeydown, 0, sizeof (gamekeydown));
return false; return false;
} }

View file

@ -25,9 +25,6 @@ typedef enum
ev_console, ev_console,
ev_mouse, ev_mouse,
ev_joystick, ev_joystick,
ev_joystick2,
ev_joystick3,
ev_joystick4,
} evtype_t; } evtype_t;
// Event structure. // Event structure.
@ -37,6 +34,7 @@ typedef struct
INT32 data1; // keys / mouse/joystick buttons INT32 data1; // keys / mouse/joystick buttons
INT32 data2; // mouse/joystick x move INT32 data2; // mouse/joystick x move
INT32 data3; // mouse/joystick y move INT32 data3; // mouse/joystick y move
INT32 device; // which player's device it belongs to
} event_t; } event_t;
// //

View file

@ -908,15 +908,6 @@ void D_StartTitle(void)
V_SetPaletteLump("PLAYPAL"); V_SetPaletteLump("PLAYPAL");
// The title screen is obviously not a tutorial! (Unless I'm mistaken) // The title screen is obviously not a tutorial! (Unless I'm mistaken)
/*
if (tutorialmode && tutorialgcs)
{
G_CopyControls(gamecontrol[0], gamecontroldefault[0][gcs_custom], gcl_full, num_gcl_full); // using gcs_custom as temp storage
M_StartMessage("Do you want to \x82save the recommended \x82movement controls?\x80\n\nPress 'Y' or 'Enter' to confirm\nPress 'N' or any key to keep \nyour current controls",
M_TutorialSaveControlResponse, MM_YESNO);
}
*/
tutorialmode = false; tutorialmode = false;
} }

View file

@ -925,15 +925,7 @@ void D_RegisterClientCommands(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
CV_RegisterVar(&cv_kickstartaccel[i]); CV_RegisterVar(&cv_kickstartaccel[i]);
CV_RegisterVar(&cv_turnaxis[i]);
CV_RegisterVar(&cv_moveaxis[i]);
CV_RegisterVar(&cv_brakeaxis[i]);
CV_RegisterVar(&cv_aimaxis[i]);
CV_RegisterVar(&cv_lookaxis[i]);
CV_RegisterVar(&cv_fireaxis[i]);
CV_RegisterVar(&cv_driftaxis[i]);
CV_RegisterVar(&cv_deadzone[i]); CV_RegisterVar(&cv_deadzone[i]);
CV_RegisterVar(&cv_digitaldeadzone[i]);
} }
// filesrch.c // filesrch.c
@ -2766,10 +2758,6 @@ static void Command_Map_f(void)
return; return;
} }
if (tutorialmode && tutorialgcs)
{
G_CopyControls(gamecontrol[0], gamecontroldefault[0][gcs_custom], gcl_full, num_gcl_full); // using gcs_custom as temp storage
}
tutorialmode = false; // warping takes us out of tutorial mode tutorialmode = false; // warping takes us out of tutorial mode
D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, fromlevelselect); D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, fromlevelselect);

View file

@ -183,7 +183,6 @@ extern INT16 bootmap; //bootmap for loading a map on startup
extern INT16 tutorialmap; // map to load for tutorial extern INT16 tutorialmap; // map to load for tutorial
extern boolean tutorialmode; // are we in a tutorial right now? extern boolean tutorialmode; // are we in a tutorial right now?
extern INT32 tutorialgcs; // which control scheme is loaded?
extern boolean looptitle; extern boolean looptitle;

View file

@ -2684,12 +2684,13 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex
static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length) static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length)
{ {
INT32 gcs = gcs_custom; INT32 gcs = 0;
boolean suffixed = true; boolean suffixed = true;
if (!tag || !tag[0] || !tutorialmode) if (!tag || !tag[0] || !tutorialmode)
return false; return false;
/*
if (!strncmp(tag, "TAA", 3)) // Accelerate if (!strncmp(tag, "TAA", 3)) // Accelerate
gcs = G_GetControlScheme(gamecontrol[0], gcl_accelerate, num_gcl_accelerate); gcs = G_GetControlScheme(gamecontrol[0], gcl_accelerate, num_gcl_accelerate);
else if (!strncmp(tag, "TAB", 3)) // Brake else if (!strncmp(tag, "TAB", 3)) // Brake
@ -2704,14 +2705,10 @@ static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length)
gcs = G_GetControlScheme(gamecontrol[0], gcl_item, num_gcl_item); gcs = G_GetControlScheme(gamecontrol[0], gcl_item, num_gcl_item);
else else
gcs = G_GetControlScheme(gamecontrol[0], gcl_full, num_gcl_full); gcs = G_GetControlScheme(gamecontrol[0], gcl_full, num_gcl_full);
*/
switch (gcs) switch (gcs)
{ {
case gcs_kart:
// strncat(tag, "KART", length);
suffixed = false;
break;
default: default:
strncat(tag, "CUSTOM", length); strncat(tag, "CUSTOM", length);
break; break;

View file

@ -155,7 +155,6 @@ INT16 bootmap; //bootmap for loading a map on startup
INT16 tutorialmap = 0; // map to load for tutorial INT16 tutorialmap = 0; // map to load for tutorial
boolean tutorialmode = false; // are we in a tutorial right now? boolean tutorialmode = false; // are we in a tutorial right now?
INT32 tutorialgcs = gcs_custom; // which control scheme is loaded?
boolean looptitle = true; boolean looptitle = true;
@ -347,22 +346,6 @@ static void kickstartaccel3_OnChange(void);
static void kickstartaccel4_OnChange(void); static void kickstartaccel4_OnChange(void);
void SendWeaponPref(UINT8 n); void SendWeaponPref(UINT8 n);
static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"},
{1, "X-Axis"}, {2, "Y-Axis"}, {-1, "X-Axis-"}, {-2, "Y-Axis-"},
#if JOYAXISSET > 1
{3, "Z-Axis"}, {4, "X-Rudder"}, {-3, "Z-Axis-"}, {-4, "X-Rudder-"},
#endif
#if JOYAXISSET > 2
{5, "Y-Rudder"}, {6, "Z-Rudder"}, {-5, "Y-Rudder-"}, {-6, "Z-Rudder-"},
#endif
#if JOYAXISSET > 3
{7, "U-Axis"}, {8, "V-Axis"}, {-7, "U-Axis-"}, {-8, "V-Axis-"},
#endif
{0, NULL}};
#if JOYAXISSET > 4
"More Axis Sets"
#endif
// don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler.
// chat timer thingy // chat timer thingy
@ -412,55 +395,6 @@ consvar_t cv_kickstartaccel[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("kickstartaccel4", "Off", CV_SAVE|CV_CALL, CV_OnOff, kickstartaccel4_OnChange) CVAR_INIT ("kickstartaccel4", "Off", CV_SAVE|CV_CALL, CV_OnOff, kickstartaccel4_OnChange)
}; };
consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis2_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis3_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis4_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL)
};
consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_move", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis_move2", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis_move3", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis_move4", "None", CV_SAVE, joyaxis_cons_t, NULL)
};
consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_brake", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis2_brake", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis3_brake", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis4_brake", "None", CV_SAVE, joyaxis_cons_t, NULL)
};
consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis2_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis3_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis4_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL)
};
consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis2_look", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis3_look", "None", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis4_look", "None", CV_SAVE, joyaxis_cons_t, NULL)
};
consvar_t cv_fireaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis_fire2", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis_fire3", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis_fire4", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL)
};
consvar_t cv_driftaxis[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joyaxis_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis2_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis3_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL),
CVAR_INIT ("joyaxis4_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL)
};
static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = { consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL), CVAR_INIT ("joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
@ -469,13 +403,6 @@ consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joy4_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL) CVAR_INIT ("joy4_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL)
}; };
consvar_t cv_digitaldeadzone[MAXSPLITSCREENPLAYERS] = {
CVAR_INIT ("joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("joy2_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("joy3_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("joy4_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL)
};
// now automatically allocated in D_RegisterClientCommands // now automatically allocated in D_RegisterClientCommands
// so that it doesn't have to be updated depending on the value of MAXPLAYERS // so that it doesn't have to be updated depending on the value of MAXPLAYERS
char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
@ -725,74 +652,94 @@ INT16 G_SoftwareClipAimingPitch(INT32 *aiming)
return (INT16)((*aiming)>>16); return (INT16)((*aiming)>>16);
} }
INT32 PlayerJoyAxis(UINT8 player, axis_input_e axissel) static INT32 KeyValue(UINT8 p, INT32 key)
{ {
INT32 retaxis; if (key <= 0 || key >= NUMINPUTS)
INT32 axisval;
boolean flp = false;
//find what axis to get
switch (axissel)
{ {
case AXISTURN:
axisval = cv_turnaxis[player-1].value;
break;
case AXISMOVE:
axisval = cv_moveaxis[player-1].value;
break;
case AXISBRAKE:
axisval = cv_brakeaxis[player-1].value;
break;
case AXISAIM:
axisval = cv_aimaxis[player-1].value;
break;
case AXISLOOK:
axisval = cv_lookaxis[player-1].value;
break;
case AXISFIRE:
axisval = cv_fireaxis[player-1].value;
break;
case AXISDRIFT:
axisval = cv_driftaxis[player-1].value;
break;
default:
return 0;
}
if (axisval < 0) //odd -axises
{
axisval = -axisval;
flp = true;
}
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
return 0; return 0;
if (axisval%2)
{
axisval /= 2;
retaxis = joyxmove[player-1][axisval];
}
else
{
axisval--;
axisval /= 2;
retaxis = joyymove[player-1][axisval];
} }
if (retaxis < (-JOYAXISRANGE)) return gamekeydown[p][key];
retaxis = -JOYAXISRANGE; }
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick[player-1].bGamepadStyle && axissel >= AXISDIGITAL) INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, boolean menu)
{
INT32 i;
INT32 deadzone = 0;
boolean bound = false;
if (p >= MAXSPLITSCREENPLAYERS)
{ {
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone[player-1].value) >> FRACBITS; #ifdef PARANOIA
if (-jdeadzone < retaxis && retaxis < jdeadzone) CONS_Debug(DBG_GAMELOGIC, "G_PlayerInputAnalog: Invalid player ID %d\n", p);
return 0; #endif
return 0;
} }
if (flp) retaxis = -retaxis; //flip it around deadzone = (JOYAXISRANGE * cv_deadzone[p].value) / FRACUNIT;
return retaxis;
for (i = 0; i < MAXINPUTMAPPING; i++)
{
INT32 key = gamecontrol[p][gc][i];
INT32 value = 0;
if (key <= 0 || key >= NUMINPUTS)
{
continue;
}
value = KeyValue(p, key);
bound = true;
if (gc == gc_a || gc == gc_b || gc == gc_c)
{
// Handle spindash key
value = max(value, KeyValue(p, gamecontrol[p][gc_abc][i]));
}
if (value >= deadzone)
{
return value;
}
}
if (menu == true && bound == false)
{
// We don't want menus to become unnavigable if people unbind
// all of their controls, so use the default control scheme in
// this scenario.
for (i = 0; i < MAXINPUTMAPPING; i++)
{
INT32 key = gamecontroldefault[gc][i];
INT32 value = 0;
if (key <= 0 || key >= NUMINPUTS)
{
continue;
}
value = KeyValue(p, key);
if (gc == gc_a || gc == gc_b || gc == gc_c)
{
// Handle spindash key
value = max(value, KeyValue(p, gamecontroldefault[gc_abc][i]));
}
if (value >= deadzone)
{
return value;
}
}
}
return 0;
}
boolean G_PlayerInputDown(UINT8 p, INT32 gc, boolean menu)
{
return (G_PlayerInputAnalog(p, gc, menu) != 0);
} }
// Take a magnitude of two axes, and adjust it to take out the deadzone // Take a magnitude of two axes, and adjust it to take out the deadzone
@ -867,27 +814,15 @@ angle_t localangle[MAXSPLITSCREENPLAYERS];
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
{ {
const UINT8 forplayer = ssplayer-1; const UINT8 forplayer = ssplayer-1;
INT32 forward;
const INT32 lookaxis = cv_lookaxis[forplayer].value;
const boolean invertmouse = cv_invertmouse.value;
const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle;
const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle;
const boolean usejoystick = (analogjoystickmove || gamepadjoystickmove);
static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard
static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame
INT32 forward, axis;
joystickvector2_t joystickvector; joystickvector2_t joystickvector;
boolean turnleft, turnright;
player_t *player = &players[g_localplayers[forplayer]]; player_t *player = &players[g_localplayers[forplayer]];
camera_t *thiscam = &camera[forplayer]; //camera_t *thiscam = &camera[forplayer];
boolean *kbl = &keyboard_look[forplayer]; //boolean *kbl = &keyboard_look[forplayer];
boolean *rd = &resetdown[forplayer]; //boolean *rd = &resetdown[forplayer];
const boolean mouseaiming = player->spectator; //const boolean mouseaiming = player->spectator;
(void)realtics; (void)realtics;
@ -924,10 +859,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
return; return;
} }
turnright = PlayerInputDown(ssplayer, gc_turnright); joystickvector.xaxis = G_PlayerInputAnalog(forplayer, gc_right, false) - G_PlayerInputAnalog(forplayer, gc_left, false);
turnleft = PlayerInputDown(ssplayer, gc_turnleft);
joystickvector.xaxis = PlayerJoyAxis(ssplayer, AXISTURN);
joystickvector.yaxis = 0; joystickvector.yaxis = 0;
G_HandleAxisDeadZone(forplayer, &joystickvector); G_HandleAxisDeadZone(forplayer, &joystickvector);
@ -935,138 +867,92 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// use it for aiming to throw items forward/backward and the vote screen // use it for aiming to throw items forward/backward and the vote screen
// This mean that the turn axis will still be gradient but up/down will be 0 // This mean that the turn axis will still be gradient but up/down will be 0
// until the stick is pushed far enough // until the stick is pushed far enough
joystickvector.yaxis = PlayerJoyAxis(ssplayer, AXISAIM); joystickvector.yaxis = G_PlayerInputAnalog(forplayer, gc_down, false) - G_PlayerInputAnalog(forplayer, gc_up, false);
if (encoremode) if (encoremode)
{ {
turnright ^= turnleft; // swap these using three XORs
turnleft ^= turnright;
turnright ^= turnleft;
joystickvector.xaxis = -joystickvector.xaxis; joystickvector.xaxis = -joystickvector.xaxis;
} }
if (gamepadjoystickmove && joystickvector.xaxis != 0)
{
turnright = turnright || (joystickvector.xaxis > 0);
turnleft = turnleft || (joystickvector.xaxis < 0);
}
forward = 0; forward = 0;
cmd->turning = 0; cmd->turning = 0;
// let movement keys cancel each other out if (joystickvector.xaxis != 0)
if (turnright && !(turnleft))
{
cmd->turning -= KART_FULLTURN;
}
else if (turnleft && !(turnright))
{
cmd->turning += KART_FULLTURN;
}
if (analogjoystickmove && joystickvector.xaxis != 0)
{ {
cmd->turning -= (joystickvector.xaxis * KART_FULLTURN) >> 10; cmd->turning -= (joystickvector.xaxis * KART_FULLTURN) >> 10;
} }
// Specator mouse turning
if (player->spectator)
{
cmd->turning -= (mousex * 8) * (encoremode ? -1 : 1);
}
if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls
{ {
axis = PlayerJoyAxis(ssplayer, AXISMOVE); if (G_PlayerInputDown(forplayer, gc_a, false))
if (PlayerInputDown(ssplayer, gc_accelerate) || (usejoystick && axis > 0)) {
cmd->buttons |= BT_ACCELERATE; cmd->buttons |= BT_ACCELERATE;
axis = PlayerJoyAxis(ssplayer, AXISBRAKE); }
if (PlayerInputDown(ssplayer, gc_brake) || (usejoystick && axis > 0))
if (G_PlayerInputDown(forplayer, gc_b, false))
{
cmd->buttons |= BT_BRAKE; cmd->buttons |= BT_BRAKE;
axis = PlayerJoyAxis(ssplayer, AXISAIM); }
if (PlayerInputDown(ssplayer, gc_aimforward) || (usejoystick && axis < 0))
if (joystickvector.yaxis < 0)
{
forward += MAXPLMOVE; forward += MAXPLMOVE;
if (PlayerInputDown(ssplayer, gc_aimbackward) || (usejoystick && axis > 0)) }
if (joystickvector.yaxis > 0)
{
forward -= MAXPLMOVE; forward -= MAXPLMOVE;
}
} }
else else
{ {
// forward with key or button // SRB2kart - we use an accel/brake instead of forward/backward. // forward with key or button // SRB2kart - we use an accel/brake instead of forward/backward.
axis = PlayerJoyAxis(ssplayer, AXISMOVE); fixed_t value = G_PlayerInputAnalog(forplayer, gc_a, false);
if (PlayerInputDown(ssplayer, gc_accelerate) || (gamepadjoystickmove && axis > 0)) if (value != 0)
{ {
cmd->buttons |= BT_ACCELERATE; cmd->buttons |= BT_ACCELERATE;
forward = MAXPLMOVE; // 50 forward += ((value * MAXPLMOVE) >> 10);
}
else if (analogjoystickmove && axis > 0)
{
cmd->buttons |= BT_ACCELERATE;
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
forward += ((axis * MAXPLMOVE) >> 10);
} }
axis = PlayerJoyAxis(ssplayer, AXISBRAKE); value = G_PlayerInputAnalog(forplayer, gc_b, false);
if (PlayerInputDown(ssplayer, gc_brake) || (gamepadjoystickmove && axis > 0)) if (value != 0)
{ {
cmd->buttons |= BT_BRAKE; cmd->buttons |= BT_BRAKE;
if (cmd->buttons & BT_ACCELERATE || cmd->forwardmove <= 0) forward -= ((value * MAXPLMOVE) >> 10);
forward -= MAXPLMOVE;
}
else if (analogjoystickmove && axis > 0)
{
cmd->buttons |= BT_BRAKE;
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
if (cmd->buttons & BT_ACCELERATE || cmd->forwardmove <= 0)
forward -= ((axis * MAXPLMOVE) >> 10);
} }
// But forward/backward IS used for aiming. // But forward/backward IS used for aiming.
if (PlayerInputDown(ssplayer, gc_aimforward) || (joystickvector.yaxis < 0)) if (joystickvector.yaxis < 0)
{
cmd->buttons |= BT_FORWARD; cmd->buttons |= BT_FORWARD;
if (PlayerInputDown(ssplayer, gc_aimbackward) || (joystickvector.yaxis > 0)) }
if (joystickvector.yaxis > 0)
{
cmd->buttons |= BT_BACKWARD; cmd->buttons |= BT_BACKWARD;
}
} }
// fire with any button/key // fire with any button/key
axis = PlayerJoyAxis(ssplayer, AXISFIRE); if (G_PlayerInputDown(forplayer, gc_c, false))
if (PlayerInputDown(ssplayer, gc_fire) || (usejoystick && axis > 0)) {
cmd->buttons |= BT_ATTACK; cmd->buttons |= BT_ATTACK;
}
// drift with any button/key // drift with any button/key
axis = PlayerJoyAxis(ssplayer, AXISDRIFT); if (G_PlayerInputDown(forplayer, gc_x, false))
if (PlayerInputDown(ssplayer, gc_drift) || (usejoystick && axis > 0)) {
cmd->buttons |= BT_DRIFT; cmd->buttons |= BT_DRIFT;
}
// Spindash with any button/key
// Simply holds all of the inputs for you.
axis = PlayerJoyAxis(ssplayer, AXISSPINDASH);
if (PlayerInputDown(ssplayer, gc_spindash) || (usejoystick && axis > 0))
cmd->buttons |= (BT_ACCELERATE|BT_BRAKE|BT_DRIFT);
// rear view with any button/key // rear view with any button/key
axis = PlayerJoyAxis(ssplayer, AXISLOOKBACK); if (G_PlayerInputDown(forplayer, gc_y, false))
if (PlayerInputDown(ssplayer, gc_lookback) || (usejoystick && axis > 0))
cmd->buttons |= BT_LOOKBACK;
// Lua scriptable buttons
if (PlayerInputDown(ssplayer, gc_custom1))
cmd->buttons |= BT_CUSTOM1;
if (PlayerInputDown(ssplayer, gc_custom2))
cmd->buttons |= BT_CUSTOM2;
if (PlayerInputDown(ssplayer, gc_custom3))
cmd->buttons |= BT_CUSTOM3;
// Reset camera
if (PlayerInputDown(ssplayer, gc_camreset))
{ {
if (thiscam->chase && *rd == false) cmd->buttons |= BT_LOOKBACK;
P_ResetCamera(player, thiscam);
*rd = true;
} }
else
*rd = false;
// spectator aiming shit, ahhhh... // spectator aiming shit, ahhhh...
/*
{ {
INT32 player_invert = invertmouse ? -1 : 1; INT32 player_invert = invertmouse ? -1 : 1;
INT32 screen_invert = INT32 screen_invert =
@ -1074,15 +960,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
&& (!thiscam->chase)) //because chasecam's not inverted && (!thiscam->chase)) //because chasecam's not inverted
? -1 : 1; // set to -1 or 1 to multiply ? -1 : 1; // set to -1 or 1 to multiply
// mouse look stuff (mouse look is not the same as mouse aim)
if (mouseaiming && player->spectator)
{
*kbl = false;
// looking up/down
cmd->aiming += (mlooky<<19)*player_invert*screen_invert;
}
axis = PlayerJoyAxis(ssplayer, AXISLOOK); axis = PlayerJoyAxis(ssplayer, AXISLOOK);
if (analogjoystickmove && axis != 0 && lookaxis && player->spectator) if (analogjoystickmove && axis != 0 && lookaxis && player->spectator)
cmd->aiming += (axis<<16) * screen_invert; cmd->aiming += (axis<<16) * screen_invert;
@ -1108,11 +985,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (PlayerInputDown(ssplayer, gc_centerview)) // No need to put a spectator limit on this one though :V if (PlayerInputDown(ssplayer, gc_centerview)) // No need to put a spectator limit on this one though :V
cmd->aiming = 0; cmd->aiming = 0;
} }
*/
mousex = mousey = mlooky = 0;
cmd->forwardmove += (SINT8)forward; cmd->forwardmove += (SINT8)forward;
cmd->flags = 0; cmd->flags = 0;
if (chat_on || CON_Ready()) if (chat_on || CON_Ready())
@ -1210,7 +1085,7 @@ static void kickstartaccel4_OnChange(void)
// //
void G_DoLoadLevel(boolean resetplayer) void G_DoLoadLevel(boolean resetplayer)
{ {
INT32 i, j; INT32 i;
// Make sure objectplace is OFF when you first start the level! // Make sure objectplace is OFF when you first start the level!
OP_ResetObjectplace(); OP_ResetObjectplace();
@ -1270,12 +1145,6 @@ void G_DoLoadLevel(boolean resetplayer)
// clear cmd building stuff // clear cmd building stuff
memset(gamekeydown, 0, sizeof (gamekeydown)); memset(gamekeydown, 0, sizeof (gamekeydown));
for (i = 0;i < JOYAXISSET; i++)
{
for (j = 0; j < MAXSPLITSCREENPLAYERS; j++)
joyxmove[j][i] = joyymove[j][i] = 0;
}
mousex = mousey = 0;
// clear hud messages remains (usually from game startup) // clear hud messages remains (usually from game startup)
CON_ClearHUD(); CON_ClearHUD();
@ -1361,7 +1230,7 @@ static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS];
// //
boolean G_Responder(event_t *ev) boolean G_Responder(event_t *ev)
{ {
UINT8 i; //INT32 i;
// any other key pops up menu if in demos // any other key pops up menu if in demos
if (gameaction == ga_nothing && !demo.quitafterplaying && if (gameaction == ga_nothing && !demo.quitafterplaying &&
@ -1456,7 +1325,7 @@ boolean G_Responder(event_t *ev)
// allow spy mode changes even during the demo // allow spy mode changes even during the demo
if (gamestate == GS_LEVEL && ev->type == ev_keydown if (gamestate == GS_LEVEL && ev->type == ev_keydown
&& (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[0][gc_viewpoint][0] || ev->data1 == gamecontrol[0][gc_viewpoint][1])) && (ev->data1 == KEY_F12 /*|| ev->data1 == gamecontrol[0][gc_viewpoint][0] || ev->data1 == gamecontrol[0][gc_viewpoint][1]*/))
{ {
if (!demo.playback && (r_splitscreen || !netgame)) if (!demo.playback && (r_splitscreen || !netgame))
g_localplayers[0] = consoleplayer; g_localplayers[0] = consoleplayer;
@ -1474,6 +1343,7 @@ boolean G_Responder(event_t *ev)
if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback && !demo.freecam) if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback && !demo.freecam)
{ {
/*
if (ev->data1 == gamecontrol[1][gc_viewpoint][0] || ev->data1 == gamecontrol[1][gc_viewpoint][1]) if (ev->data1 == gamecontrol[1][gc_viewpoint][0] || ev->data1 == gamecontrol[1][gc_viewpoint][1])
{ {
G_AdjustView(2, 1, true); G_AdjustView(2, 1, true);
@ -1489,12 +1359,13 @@ boolean G_Responder(event_t *ev)
G_AdjustView(4, 1, true); G_AdjustView(4, 1, true);
return true; return true;
} }
*/
// Allow pausing // Allow pausing
if ( if (
ev->data1 == gamecontrol[0][gc_pause][0] //ev->data1 == gamecontrol[0][gc_pause][0]
|| ev->data1 == gamecontrol[0][gc_pause][1] //|| ev->data1 == gamecontrol[0][gc_pause][1]
|| ev->data1 == KEY_PAUSE ev->data1 == KEY_PAUSE
) )
{ {
paused = !paused; paused = !paused;
@ -1528,9 +1399,9 @@ boolean G_Responder(event_t *ev)
switch (ev->type) switch (ev->type)
{ {
case ev_keydown: case ev_keydown:
if (ev->data1 == gamecontrol[0][gc_pause][0] if (//ev->data1 == gamecontrol[0][gc_pause][0]
|| ev->data1 == gamecontrol[0][gc_pause][1] //|| ev->data1 == gamecontrol[0][gc_pause][1]
|| ev->data1 == KEY_PAUSE) ev->data1 == KEY_PAUSE)
{ {
if (modeattacking && !demo.playback && (gamestate == GS_LEVEL)) if (modeattacking && !demo.playback && (gamestate == GS_LEVEL))
{ {
@ -1560,6 +1431,7 @@ boolean G_Responder(event_t *ev)
} }
} }
/*
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
if (ev->data1 == gamecontrol[i][gc_camtoggle][0] if (ev->data1 == gamecontrol[i][gc_camtoggle][0]
@ -1572,6 +1444,7 @@ boolean G_Responder(event_t *ev)
} }
} }
} }
*/
return true; return true;
@ -1584,15 +1457,6 @@ boolean G_Responder(event_t *ev)
case ev_joystick: case ev_joystick:
return true; // eat events return true; // eat events
case ev_joystick2:
return true; // eat events
case ev_joystick3:
return true; // eat events
case ev_joystick4:
return true; // eat events
default: default:
break; break;
} }

View file

@ -55,15 +55,7 @@ extern consvar_t cv_pauseifunfocused;
extern consvar_t cv_invertmouse; extern consvar_t cv_invertmouse;
extern consvar_t cv_kickstartaccel[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_kickstartaccel[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_fireaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_driftaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_digitaldeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
@ -93,29 +85,12 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n);
INT32 G_ClipAimingPitch(INT32 *aiming); INT32 G_ClipAimingPitch(INT32 *aiming);
INT16 G_SoftwareClipAimingPitch(INT32 *aiming); INT16 G_SoftwareClipAimingPitch(INT32 *aiming);
typedef enum
{
AXISNONE = 0,
AXISTURN,
AXISMOVE,
AXISBRAKE,
AXISLOOK,
AXISDIGITAL, // axes below this use digital deadzone
AXISFIRE = AXISDIGITAL,
AXISDRIFT,
AXISSPINDASH,
AXISLOOKBACK,
AXISAIM,
} axis_input_e;
INT32 PlayerJoyAxis(UINT8 player, axis_input_e axissel);
extern angle_t localangle[MAXSPLITSCREENPLAYERS]; extern angle_t localangle[MAXSPLITSCREENPLAYERS];
extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed
INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, boolean menu);
boolean G_PlayerInputDown(UINT8 p, INT32 gc, boolean menu);
// //
// GAME // GAME
// //

File diff suppressed because it is too large Load diff

View file

@ -27,106 +27,65 @@
#define JOYHATS 4 // 4 hats #define JOYHATS 4 // 4 hats
#define JOYAXISSET 4 // 4 Sets of 2 axises #define JOYAXISSET 4 // 4 Sets of 2 axises
#define MAXINPUTMAPPING 4
// //
// mouse and joystick buttons are handled as 'virtual' keys // mouse and joystick buttons are handled as 'virtual' keys
// //
typedef enum typedef enum
{ {
KEY_MOUSE1 = NUMKEYS, KEY_JOY1 = NUMKEYS,
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
KEY_HAT1 = KEY_JOY1 + JOYBUTTONS, KEY_HAT1 = KEY_JOY1 + JOYBUTTONS,
KEY_AXIS1 = KEY_HAT1 + JOYHATS*4,
KEY_DBLMOUSE1 =KEY_HAT1 + JOYHATS*4, // double clicks KEY_MOUSE1 = KEY_AXIS1 + JOYAXISSET*4,
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS, KEY_MOUSEMOVE = KEY_MOUSE1 + MOUSEBUTTONS,
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS, KEY_MOUSEWHEELUP = KEY_MOUSEMOVE + 4,
KEY_2MOUSE1 = KEY_DBLHAT1 + JOYHATS*4,
KEY_2JOY1 = KEY_2MOUSE1 + MOUSEBUTTONS,
KEY_2HAT1 = KEY_2JOY1 + JOYBUTTONS,
KEY_DBL2MOUSE1 = KEY_2HAT1 + JOYHATS*4,
KEY_DBL2JOY1 = KEY_DBL2MOUSE1 + MOUSEBUTTONS,
KEY_DBL2HAT1 = KEY_DBL2JOY1 + JOYBUTTONS,
KEY_3JOY1 = KEY_DBL2HAT1 + JOYHATS*4,
KEY_3HAT1 = KEY_3JOY1 + JOYBUTTONS,
KEY_DBL3JOY1 = KEY_3HAT1 + JOYHATS*4,
KEY_DBL3HAT1 = KEY_DBL3JOY1 + JOYBUTTONS,
KEY_4JOY1 = KEY_DBL3HAT1 + JOYHATS*4,
KEY_4HAT1 = KEY_4JOY1 + JOYBUTTONS,
KEY_DBL4JOY1 = KEY_4HAT1 + JOYHATS*4,
KEY_DBL4HAT1 = KEY_DBL4JOY1 + JOYBUTTONS,
KEY_MOUSEWHEELUP = KEY_DBL4HAT1 + JOYHATS*4,
KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1, KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1,
KEY_2MOUSEWHEELUP = KEY_MOUSEWHEELDOWN + 1,
KEY_2MOUSEWHEELDOWN = KEY_2MOUSEWHEELUP + 1,
NUMINPUTS = KEY_2MOUSEWHEELDOWN + 1, NUMINPUTS = KEY_MOUSEWHEELDOWN + 1,
} key_input_e; } key_input_e;
typedef enum typedef enum
{ {
gc_null = 0, // a key/button mapped to gc_null has no effect gc_null = 0, // a key/button mapped to gc_null has no effect
gc_aimforward,
gc_aimbackward, // The actual gamepad
gc_turnleft, gc_up,
gc_turnright, gc_down,
gc_accelerate, gc_left,
gc_drift, gc_right,
gc_brake, gc_a,
gc_spindash, gc_b,
gc_fire, gc_c,
gc_lookback, gc_x,
gc_camreset, gc_y,
gc_camtoggle, gc_z,
gc_spectate, gc_l,
gc_lookup, gc_r,
gc_lookdown, gc_start,
gc_centerview,
gc_talkkey, // special keys
gc_teamkey, gc_abc,
gc_scores,
gc_console, gc_console,
gc_pause,
gc_systemmenu,
gc_screenshot,
gc_recordgif,
gc_viewpoint,
gc_custom1, // Lua scriptable
gc_custom2, // Lua scriptable
gc_custom3, // Lua scriptable
num_gamecontrols num_gamecontrols
} gamecontrols_e; } gamecontrols_e;
typedef enum
{
gcs_custom,
gcs_kart, // Kart doesn't really need this code, like, at all? But I don't feel like removing it.
num_gamecontrolschemes
} gamecontrolschemes_e;
// mouse values are used once // mouse values are used once
extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens, cv_mouseysens;
extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_mousesens2, cv_mouseysens2;
extern consvar_t cv_controlperkey; extern consvar_t cv_controlperkey;
extern INT32 mousex, mousey; // current state of the keys: JOYAXISRANGE or 0 when boolean.
extern INT32 mlooky; //mousey with mlookSensitivity // Or anything inbetween for analog values
extern INT32 gamekeydown[MAXSPLITSCREENPLAYERS][NUMINPUTS];
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
// current state of the keys: true if pushed
extern UINT8 gamekeydown[NUMINPUTS];
// two key codes (or virtual key) per game control // two key codes (or virtual key) per game control
extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][MAXINPUTMAPPING];
extern INT32 gamecontroldefault[MAXSPLITSCREENPLAYERS][num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention extern INT32 gamecontroldefault[num_gamecontrols][MAXINPUTMAPPING]; // default control storage
#define PlayerInputDown(p, gc) (gamekeydown[gamecontrol[p-1][gc][0]] || gamekeydown[gamecontrol[p-1][gc][1]])
/*
#define num_gcl_accelerate 1 #define num_gcl_accelerate 1
#define num_gcl_brake 1 #define num_gcl_brake 1
#define num_gcl_drift 1 #define num_gcl_drift 1
@ -142,6 +101,7 @@ extern const INT32 gcl_spindash[num_gcl_spindash];
extern const INT32 gcl_movement[num_gcl_movement]; extern const INT32 gcl_movement[num_gcl_movement];
extern const INT32 gcl_item[num_gcl_item]; extern const INT32 gcl_item[num_gcl_item];
extern const INT32 gcl_full[num_gcl_full]; extern const INT32 gcl_full[num_gcl_full];
*/
// peace to my little coder fingers! // peace to my little coder fingers!
// check a gamecontrol being active or not // check a gamecontrol being active or not
@ -154,16 +114,16 @@ const char *G_KeynumToString(INT32 keynum);
INT32 G_KeyStringtoNum(const char *keystr); INT32 G_KeyStringtoNum(const char *keystr);
// detach any keys associated to the given game control // detach any keys associated to the given game control
void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); void G_ClearControlKeys(INT32 (*setupcontrols)[MAXINPUTMAPPING], INT32 control);
void G_ClearAllControlKeys(void); void G_ClearAllControlKeys(void);
void Command_Setcontrol_f(void); void Command_Setcontrol_f(void);
void Command_Setcontrol2_f(void); void Command_Setcontrol2_f(void);
void Command_Setcontrol3_f(void); void Command_Setcontrol3_f(void);
void Command_Setcontrol4_f(void); void Command_Setcontrol4_f(void);
void G_DefineDefaultControls(void); void G_DefineDefaultControls(void);
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen); INT32 G_GetControlScheme(INT32 (*fromcontrols)[MAXINPUTMAPPING], const INT32 *gclist, INT32 gclen);
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen); void G_CopyControls(INT32 (*setupcontrols)[MAXINPUTMAPPING], INT32 (*fromcontrols)[MAXINPUTMAPPING], const INT32 *gclist, INT32 gclen);
void G_SaveKeySetting(FILE *f, INT32 (*fromcontrolsa)[2], INT32 (*fromcontrolsb)[2], INT32 (*fromcontrolsc)[2], INT32 (*fromcontrolsd)[2]); void G_SaveKeySetting(FILE *f, INT32 (*fromcontrolsa)[MAXINPUTMAPPING], INT32 (*fromcontrolsb)[MAXINPUTMAPPING], INT32 (*fromcontrolsc)[MAXINPUTMAPPING], INT32 (*fromcontrolsd)[MAXINPUTMAPPING]);
INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify); INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify);
#endif #endif

View file

@ -916,10 +916,12 @@ void HU_Ticker(void)
hu_tick++; hu_tick++;
hu_tick &= 7; // currently only to blink chat input cursor hu_tick &= 7; // currently only to blink chat input cursor
/*
if (PlayerInputDown(1, gc_scores)) if (PlayerInputDown(1, gc_scores))
hu_showscores = !chat_on; hu_showscores = !chat_on;
else else
hu_showscores = false; hu_showscores = false;
*/
hu_keystrokes = false; hu_keystrokes = false;
} }
@ -1112,6 +1114,7 @@ boolean HU_Responder(event_t *ev)
if (!chat_on) if (!chat_on)
{ {
// enter chat mode // enter chat mode
#if 0
if ((ev->data1 == gamecontrol[0][gc_talkkey][0] || ev->data1 == gamecontrol[0][gc_talkkey][1]) if ((ev->data1 == gamecontrol[0][gc_talkkey][0] || ev->data1 == gamecontrol[0][gc_talkkey][1])
&& netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise.
{ {
@ -1132,6 +1135,7 @@ boolean HU_Responder(event_t *ev)
typelines = 1; typelines = 1;
return true; return true;
} }
#endif
} }
else // if chat_on else // if chat_on
{ {
@ -1147,8 +1151,8 @@ boolean HU_Responder(event_t *ev)
// Ignore non-keyboard keys, except when the talk key is bound // Ignore non-keyboard keys, except when the talk key is bound
if (ev->data1 >= KEY_MOUSE1 if (ev->data1 >= KEY_MOUSE1
&& (ev->data1 != gamecontrol[0][gc_talkkey][0] /*&& (ev->data1 != gamecontrol[0][gc_talkkey][0]
&& ev->data1 != gamecontrol[0][gc_talkkey][1])) && ev->data1 != gamecontrol[0][gc_talkkey][1])*/)
return false; return false;
c = CON_ShiftChar(c); c = CON_ShiftChar(c);
@ -1210,9 +1214,9 @@ boolean HU_Responder(event_t *ev)
I_UpdateMouseGrab(); I_UpdateMouseGrab();
} }
else if (c == KEY_ESCAPE else if (c == KEY_ESCAPE
|| ((c == gamecontrol[0][gc_talkkey][0] || c == gamecontrol[0][gc_talkkey][1] /*|| ((c == gamecontrol[0][gc_talkkey][0] || c == gamecontrol[0][gc_talkkey][1]
|| c == gamecontrol[0][gc_teamkey][0] || c == gamecontrol[0][gc_teamkey][1]) || c == gamecontrol[0][gc_teamkey][0] || c == gamecontrol[0][gc_teamkey][1])
&& c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle. && c >= KEY_MOUSE1)*/) // If it's not a keyboard key, then the chat button is used as a toggle.
{ {
chat_on = false; chat_on = false;
c_input = 0; // reset input cursor c_input = 0; // reset input cursor

View file

@ -835,9 +835,9 @@ boolean M_Responder(event_t *ev)
if (ch == -1) if (ch == -1)
return false; return false;
else if (ch == gamecontrol[0][gc_systemmenu][0] || ch == gamecontrol[0][gc_systemmenu][1]) // allow remappable ESC key /*else if (ch == gamecontrol[0][gc_systemmenu][0] || ch == gamecontrol[0][gc_systemmenu][1]) // allow remappable ESC key
ch = KEY_ESCAPE; ch = KEY_ESCAPE;*/
else if ((ch == gamecontrol[0][gc_accelerate][0] || ch == gamecontrol[0][gc_accelerate][1]) && ch >= KEY_MOUSE1) else if ((ch == gamecontrol[0][gc_a][0] || ch == gamecontrol[0][gc_a][1]) && ch >= KEY_MOUSE1)
ch = KEY_ENTER; ch = KEY_ENTER;
// F-Keys // F-Keys
@ -917,7 +917,7 @@ boolean M_Responder(event_t *ev)
return false; return false;
} }
if ((ch == gamecontrol[0][gc_brake][0] || ch == gamecontrol[0][gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game if ((ch == gamecontrol[0][gc_b][0] || ch == gamecontrol[0][gc_b][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game
ch = KEY_ESCAPE; ch = KEY_ESCAPE;
routine = currentMenu->menuitems[itemOn].itemaction; routine = currentMenu->menuitems[itemOn].itemaction;
@ -961,12 +961,11 @@ boolean M_Responder(event_t *ev)
else else
{ {
// dirty hack: for customising controls, I want only buttons/keys, not moves // dirty hack: for customising controls, I want only buttons/keys, not moves
if (ev->type == ev_mouse if (ev->type == ev_mouse || ev->type == ev_joystick)
|| ev->type == ev_joystick {
|| ev->type == ev_joystick2
|| ev->type == ev_joystick3
|| ev->type == ev_joystick4)
return true; return true;
}
if (routine) if (routine)
{ {
void (*otherroutine)(event_t *sev) = currentMenu->menuitems[itemOn].itemaction; void (*otherroutine)(event_t *sev) = currentMenu->menuitems[itemOn].itemaction;

View file

@ -624,7 +624,7 @@ void Command_LoadConfig_f(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
G_CopyControls(gamecontrol[i], gamecontroldefault[i][gcs_kart], NULL, 0); G_CopyControls(gamecontrol[i], gamecontroldefault, NULL, 0);
} }
// temporarily reset execversion to default // temporarily reset execversion to default
@ -678,7 +678,7 @@ void M_FirstLoadConfig(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
G_CopyControls(gamecontrol[i], gamecontroldefault[i][gcs_kart], NULL, 0); G_CopyControls(gamecontrol[i], gamecontroldefault, NULL, 0);
} }
// register execversion here before we load any configs // register execversion here before we load any configs
@ -780,15 +780,7 @@ void M_SaveConfig(const char *filename)
if (!dedicated) if (!dedicated)
{ {
if (tutorialmode && tutorialgcs) G_SaveKeySetting(f, gamecontrol[0], gamecontrol[1], gamecontrol[2], gamecontrol[3]);
{
// using gcs_custom as temp storage
G_SaveKeySetting(f, gamecontroldefault[0][gcs_custom], gamecontrol[1], gamecontrol[2], gamecontrol[3]);
}
else
{
G_SaveKeySetting(f, gamecontrol[0], gamecontrol[1], gamecontrol[2], gamecontrol[3]);
}
} }
fclose(f); fclose(f);
@ -1771,9 +1763,9 @@ boolean M_ScreenshotResponder(event_t *ev)
if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus!
return false; return false;
if (ch == KEY_F8 || ch == gamecontrol[0][gc_screenshot][0] || ch == gamecontrol[0][gc_screenshot][1]) // remappable F8 if (ch == KEY_F8 /*|| ch == gamecontrol[0][gc_screenshot][0] || ch == gamecontrol[0][gc_screenshot][1]*/) // remappable F8
M_ScreenShot(); M_ScreenShot();
else if (ch == KEY_F9 || ch == gamecontrol[0][gc_recordgif][0] || ch == gamecontrol[0][gc_recordgif][1]) // remappable F9 else if (ch == KEY_F9 /*|| ch == gamecontrol[0][gc_recordgif][0] || ch == gamecontrol[0][gc_recordgif][1]*/) // remappable F9
((moviemode) ? M_StopMovie : M_StartMovie)(); ((moviemode) ? M_StopMovie : M_StartMovie)();
else else
return false; return false;

View file

@ -676,7 +676,7 @@ void P_Ticker(boolean run)
G_WriteAllGhostTics(); G_WriteAllGhostTics();
if (cv_recordmultiplayerdemos.value && (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE)) if (cv_recordmultiplayerdemos.value && (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE))
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && PlayerInputDown(1, gc_lookback)) if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && G_PlayerInputDown(0, gc_y, false))
demo.savemode = DSM_TITLEENTRY; demo.savemode = DSM_TITLEENTRY;
} }
else if (demo.playback) // Use Ghost data for consistency checks. else if (demo.playback) // Use Ghost data for consistency checks.

View file

@ -2583,12 +2583,14 @@ void P_InitCameraCmd(void)
static ticcmd_t *P_CameraCmd(camera_t *cam) static ticcmd_t *P_CameraCmd(camera_t *cam)
{ {
/*
INT32 forward, axis; //i INT32 forward, axis; //i
// these ones used for multiple conditions // these ones used for multiple conditions
boolean turnleft, turnright, mouseaiming; boolean turnleft, turnright, mouseaiming;
boolean invertmouse, lookaxis, usejoystick, kbl; boolean invertmouse, lookaxis, usejoystick, kbl;
INT32 player_invert; INT32 player_invert;
INT32 screen_invert; INT32 screen_invert;
*/
ticcmd_t *cmd = &cameracmd; ticcmd_t *cmd = &cameracmd;
(void)cam; (void)cam;
@ -2596,6 +2598,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
if (!demo.playback) if (!demo.playback)
return cmd; // empty cmd, no. return cmd; // empty cmd, no.
/*
kbl = democam.keyboardlook; kbl = democam.keyboardlook;
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
@ -2640,7 +2643,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
cmd->turning -= (mousex * 8) * (encoremode ? -1 : 1); cmd->turning -= (mousex * 8) * (encoremode ? -1 : 1);
axis = PlayerJoyAxis(1, AXISMOVE); axis = PlayerJoyAxis(1, AXISMOVE);
if (PlayerInputDown(1, gc_accelerate) || (usejoystick && axis > 0)) if (PlayerInputDown(1, gc_a) || (usejoystick && axis > 0))
cmd->buttons |= BT_ACCELERATE; cmd->buttons |= BT_ACCELERATE;
axis = PlayerJoyAxis(1, AXISBRAKE); axis = PlayerJoyAxis(1, AXISBRAKE);
if (PlayerInputDown(1, gc_brake) || (usejoystick && axis > 0)) if (PlayerInputDown(1, gc_brake) || (usejoystick && axis > 0))
@ -2686,8 +2689,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
if (PlayerInputDown(1, gc_centerview)) // No need to put a spectator limit on this one though :V if (PlayerInputDown(1, gc_centerview)) // No need to put a spectator limit on this one though :V
cmd->aiming = 0; cmd->aiming = 0;
mousex = mousey = mlooky = 0;
cmd->forwardmove += (SINT8)forward; cmd->forwardmove += (SINT8)forward;
if (cmd->forwardmove > MAXPLMOVE) if (cmd->forwardmove > MAXPLMOVE)
@ -2701,6 +2702,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
cmd->turning = -KART_FULLTURN; cmd->turning = -KART_FULLTURN;
democam.keyboardlook = kbl; democam.keyboardlook = kbl;
*/
return cmd; return cmd;
} }

View file

@ -1079,7 +1079,7 @@ void I_ShutdownJoystick(UINT8 index)
void I_GetJoystickEvents(UINT8 index) void I_GetJoystickEvents(UINT8 index)
{ {
static event_t event = {0,0,0,0}; static event_t event = {0,0,0,0,0};
INT32 i = 0; INT32 i = 0;
UINT64 joyhats = 0; UINT64 joyhats = 0;
#if 0 #if 0

View file

@ -526,13 +526,14 @@ static inline void SDLJoyRemap(event_t *event)
(void)event; (void)event;
} }
static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which, UINT8 pid)
{ {
// -32768 to 32767 // -32768 to 32767
INT32 raxis = axis/32; INT32 raxis = axis/32;
if (which == ev_joystick) if (which == ev_joystick)
{ {
if (Joystick[0].bGamepadStyle) if (Joystick[pid].bGamepadStyle)
{ {
// gamepad control type, on or off, live or die // gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2)) if (raxis < -(JOYAXISRANGE/2))
@ -544,7 +545,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
} }
else else
{ {
raxis = JoyInfo[0].scale!=1?((raxis/JoyInfo[0].scale)*JoyInfo[0].scale):raxis; raxis = JoyInfo[pid].scale!=1?((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale):raxis;
#ifdef SDL_JDEADZONE #ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
@ -552,69 +553,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
#endif #endif
} }
} }
else if (which == ev_joystick2)
{
if (Joystick[1].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
raxis = -1;
else if (raxis > (JOYAXISRANGE/2))
raxis = 1;
else raxis = 0;
}
else
{
raxis = JoyInfo[1].scale!=1?((raxis/JoyInfo[1].scale)*JoyInfo[1].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
raxis = 0;
#endif
}
}
else if (which == ev_joystick3)
{
if (Joystick[2].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
raxis = -1;
else if (raxis > (JOYAXISRANGE/2))
raxis = 1;
else raxis = 0;
}
else
{
raxis = JoyInfo[2].scale!=1?((raxis/JoyInfo[2].scale)*JoyInfo[2].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
raxis = 0;
#endif
}
}
else if (which == ev_joystick4)
{
if (Joystick[3].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
raxis = -1;
else if (raxis > (JOYAXISRANGE/2))
raxis = 1;
else raxis = 0;
}
else
{
raxis = JoyInfo[3].scale!=1?((raxis/JoyInfo[3].scale)*JoyInfo[3].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
raxis = 0;
#endif
}
}
return raxis; return raxis;
} }
@ -679,7 +618,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
{ {
SDLforceUngrabMouse(); SDLforceUngrabMouse();
} }
memset(gamekeydown, 0, NUMKEYS); // TODO this is a scary memset memset(gamekeydown, 0, sizeof(gamekeydown)); // TODO this is a scary memset
if (MOUSE_MENU) if (MOUSE_MENU)
{ {
@ -692,6 +631,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
{ {
event_t event; event_t event;
event.device = 0; // TODO: properly set a device
if (type == SDL_KEYUP) if (type == SDL_KEYUP)
{ {
event.type = ev_keyup; event.type = ev_keyup;
@ -773,6 +715,8 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
/// \todo inputEvent.button.which /// \todo inputEvent.button.which
if (USE_MOUSEINPUT) if (USE_MOUSEINPUT)
{ {
event.device = 0; // TODO: properly set a device
if (type == SDL_MOUSEBUTTONUP) if (type == SDL_MOUSEBUTTONUP)
{ {
event.type = ev_keyup; event.type = ev_keyup;
@ -805,6 +749,8 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
SDL_memset(&event, 0, sizeof(event_t)); SDL_memset(&event, 0, sizeof(event_t));
event.device = 0; // TODO: properly set a device
if (evt.y > 0) if (evt.y > 0)
{ {
event.data1 = KEY_MOUSEWHEELUP; event.data1 = KEY_MOUSEWHEELUP;
@ -832,45 +778,46 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS]; SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
UINT8 i; UINT8 i;
// Determine the Joystick IDs for each current open joystick event.device = INT32_MAX;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
evt.axis++;
event.data1 = event.data2 = event.data3 = INT32_MAX; event.data1 = event.data2 = event.data3 = INT32_MAX;
if (evt.which == joyid[0]) // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
event.type = ev_joystick; joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
if (evt.which == joyid[i])
{
event.device = i;
}
} }
else if (evt.which == joyid[1])
evt.axis++;
if (event.device == INT32_MAX)
{ {
event.type = ev_joystick2; return;
} }
else if (evt.which == joyid[2])
{
event.type = ev_joystick3;
}
else if (evt.which == joyid[3])
{
event.type = ev_joystick4;
}
else return;
//axis //axis
if (evt.axis > JOYAXISSET*2) if (evt.axis > JOYAXISSET*2)
{
return; return;
//vaule }
//vaule[sic]
if (evt.axis%2) if (evt.axis%2)
{ {
event.data1 = evt.axis / 2; event.data1 = evt.axis / 2;
event.data2 = SDLJoyAxis(evt.value, event.type); event.data2 = SDLJoyAxis(evt.value, event.type, event.device);
} }
else else
{ {
evt.axis--; evt.axis--;
event.data1 = evt.axis / 2; event.data1 = evt.axis / 2;
event.data3 = SDLJoyAxis(evt.value, event.type); event.data3 = SDLJoyAxis(evt.value, event.type, event.device);
} }
D_PostEvent(&event); D_PostEvent(&event);
} }
@ -881,30 +828,30 @@ static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS]; SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
UINT8 i; UINT8 i;
event.device = INT32_MAX;
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev); joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
if (evt.hat >= JOYHATS) if (evt.which == joyid[i])
return; // ignore hats with too high an index {
event.device = i;
}
}
if (evt.which == joyid[0]) if (event.device == INT32_MAX)
{ {
event.data1 = KEY_HAT1 + (evt.hat*4); return;
} }
else if (evt.which == joyid[1])
if (evt.hat >= JOYHATS)
{ {
event.data1 = KEY_2HAT1 + (evt.hat*4); return; // ignore hats with too high an index
} }
else if (evt.which == joyid[2])
{ event.data1 = KEY_HAT1 + (evt.hat*4);
event.data1 = KEY_3HAT1 + (evt.hat*4);
}
else if (evt.which == joyid[3])
{
event.data1 = KEY_4HAT1 + (evt.hat*4);
}
else return;
// NOTE: UNFINISHED // NOTE: UNFINISHED
} }
@ -916,27 +863,26 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS]; SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
UINT8 i; UINT8 i;
event.device = INT32_MAX;
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev); joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
if (evt.which == joyid[0]) if (evt.which == joyid[i])
{ {
event.data1 = KEY_JOY1; event.device = i;
}
} }
else if (evt.which == joyid[1])
if (event.device == INT32_MAX)
{ {
event.data1 = KEY_2JOY1; return;
} }
else if (evt.which == joyid[2])
{ event.data1 = KEY_JOY1;
event.data1 = KEY_3JOY1;
}
else if (evt.which == joyid[3])
{
event.data1 = KEY_4JOY1;
}
else return;
if (type == SDL_JOYBUTTONUP) if (type == SDL_JOYBUTTONUP)
{ {
event.type = ev_keyup; event.type = ev_keyup;
@ -945,15 +891,26 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
{ {
event.type = ev_keydown; event.type = ev_keydown;
} }
else return; else
{
return;
}
if (evt.button < JOYBUTTONS) if (evt.button < JOYBUTTONS)
{ {
event.data1 += evt.button; event.data1 += evt.button;
} }
else return; else
{
return;
}
SDLJoyRemap(&event); SDLJoyRemap(&event);
if (event.type != ev_console) D_PostEvent(&event);
if (event.type != ev_console)
{
D_PostEvent(&event);
}
} }
@ -1175,7 +1132,10 @@ void I_GetEvent(void)
// In order to make wheels act like buttons, we have to set their state to Up. // In order to make wheels act like buttons, we have to set their state to Up.
// This is because wheel messages don't have an up/down state. // This is because wheel messages don't have an up/down state.
gamekeydown[KEY_MOUSEWHEELDOWN] = gamekeydown[KEY_MOUSEWHEELUP] = 0; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
gamekeydown[i][KEY_MOUSEWHEELDOWN] = gamekeydown[i][KEY_MOUSEWHEELUP] = 0;
}
} }
void I_StartupMouse(void) void I_StartupMouse(void)

View file

@ -393,6 +393,7 @@ void I_OsPolling(void)
{ {
MSG msg; MSG msg;
HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); HANDLE ci = GetStdHandle(STD_INPUT_HANDLE);
INT32 i;
// we need to dispatch messages to the window // we need to dispatch messages to the window
// so the window procedure can respond to messages and PostEvent() for keys // so the window procedure can respond to messages and PostEvent() for keys
@ -419,8 +420,8 @@ void I_OsPolling(void)
I_GetEvent(); I_GetEvent();
// reset "emulated keys" // reset "emulated keys"
gamekeydown[KEY_MOUSEWHEELUP] = 0; gamekeydown[0][KEY_MOUSEWHEELUP] = 0;
gamekeydown[KEY_MOUSEWHEELDOWN] = 0; gamekeydown[0][KEY_MOUSEWHEELDOWN] = 0;
} }
// =========================================================================================== // ===========================================================================================

View file

@ -40,7 +40,7 @@
#include "lua_hud.h" #include "lua_hud.h"
#include "m_random.h" // M_RandomKey #include "m_random.h" // M_RandomKey
#include "g_input.h" // PlayerInputDown #include "g_input.h" // G_PlayerInputDown
#include "k_battle.h" #include "k_battle.h"
#include "k_pwrlv.h" #include "k_pwrlv.h"
#include "k_grandprix.h" #include "k_grandprix.h"
@ -619,7 +619,7 @@ void Y_Ticker(void)
if (demo.recording) if (demo.recording)
{ {
if (demo.savemode == DSM_NOTSAVING && PlayerInputDown(1, gc_lookback)) if (demo.savemode == DSM_NOTSAVING && G_PlayerInputDown(0, gc_y, false))
demo.savemode = DSM_TITLEENTRY; demo.savemode = DSM_TITLEENTRY;
if (demo.savemode == DSM_WILLSAVE || demo.savemode == DSM_WILLAUTOSAVE) if (demo.savemode == DSM_WILLSAVE || demo.savemode == DSM_WILLAUTOSAVE)
@ -1478,13 +1478,13 @@ void Y_VoteTicker(void)
&& !voteclient.playerinfo[i].delay && !voteclient.playerinfo[i].delay
&& pickedvote == -1 && votes[p] == -1) && pickedvote == -1 && votes[p] == -1)
{ {
if (PlayerInputDown(i+1, gc_aimforward) || PlayerJoyAxis(i+1, AXISAIM) < 0) if (G_PlayerInputDown(i, gc_up, false))
{ {
voteclient.playerinfo[i].selection--; voteclient.playerinfo[i].selection--;
pressed = true; pressed = true;
} }
if ((PlayerInputDown(i+1, gc_aimbackward) || PlayerJoyAxis(i+1, AXISAIM) > 0) && !pressed) if (G_PlayerInputDown(i, gc_down, false) && pressed == false)
{ {
voteclient.playerinfo[i].selection++; voteclient.playerinfo[i].selection++;
pressed = true; pressed = true;
@ -1495,7 +1495,7 @@ void Y_VoteTicker(void)
if (voteclient.playerinfo[i].selection > 3) if (voteclient.playerinfo[i].selection > 3)
voteclient.playerinfo[i].selection = 0; voteclient.playerinfo[i].selection = 0;
if ((PlayerInputDown(i+1, gc_accelerate) || PlayerJoyAxis(i+1, AXISMOVE) > 0) && !pressed) if (G_PlayerInputDown(i, gc_a, false) && pressed == false)
{ {
D_ModifyClientVote(consoleplayer, voteclient.playerinfo[i].selection, i); D_ModifyClientVote(consoleplayer, voteclient.playerinfo[i].selection, i);
pressed = true; pressed = true;