New input handling (port of cd8862f0)
More or less a port with gamecontrols left untouched. Some notable differences: * ev_joystick now has a separate data1 for each axis, rather than having you check which of data2/3 is INT32_MAX and which one isn't (pissed me off when updating menu code...) * Gutted the 1.6 upgrade code, since we're not upgrading from anything :P * G_GetControlForKey, a helper for menu code * Turn smoothing code left unused as a reminder to fix it * Various small fixes so this commit is playable and doesn't segfault Menu changes: * Max 4 binds, joystick axes are now bindable like any other button * The gamepad options submenu has been replaced by its two remaining options after the removal of axis cvars (gamepad select and deadzone) See cd8862f0's message for more details
This commit is contained in:
parent
3e68d31e63
commit
f419ccee57
19 changed files with 600 additions and 1527 deletions
|
|
@ -449,7 +449,7 @@ boolean AM_Responder(event_t *ev)
|
|||
{
|
||||
//faB: prevent alt-tab in win32 version to activate automap just before
|
||||
// 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
|
||||
AM_Start();
|
||||
|
|
|
|||
115
src/command.c
115
src/command.c
|
|
@ -59,7 +59,6 @@ static void COM_Choose_f(void);
|
|||
static void COM_ChooseWeighted_f(void);
|
||||
|
||||
static void CV_EnforceExecVersion(void);
|
||||
static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr);
|
||||
|
||||
static boolean CV_Command(void);
|
||||
consvar_t *CV_FindVar(const char *name);
|
||||
|
|
@ -2265,95 +2264,6 @@ static void CV_EnforceExecVersion(void)
|
|||
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;
|
||||
}
|
||||
|
||||
// Block the Xbox DInput default axes and reset to the current defaults
|
||||
static boolean CV_FilterJoyAxisVars2(consvar_t *v, const char *valstr)
|
||||
{
|
||||
if (!stricmp(v->name, "joyaxis_turn") && !stricmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_turn") && !stricmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_turn") && !stricmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_turn") && !stricmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis_fire") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_fire") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_fire") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_fire") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis_drift") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_drift") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_drift") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_drift") && !stricmp(valstr, "None"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
|
||||
{
|
||||
// True means allow the CV change, False means block it
|
||||
|
|
@ -2363,29 +2273,8 @@ static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
|
|||
if (!(v->flags & CV_SAVE))
|
||||
return true;
|
||||
|
||||
if (GETMAJOREXECVERSION(cv_execversion.value) < 2) // 2 = 1.0.2
|
||||
{
|
||||
#if 0
|
||||
// We don't have changed saved cvars yet
|
||||
if (!stricmp(v->name, "alwaysmlook")
|
||||
|| !stricmp(v->name, "alwaysmlook2")
|
||||
|| !stricmp(v->name, "mousemove")
|
||||
|| !stricmp(v->name, "mousemove2"))
|
||||
return false;
|
||||
#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;
|
||||
}
|
||||
|
||||
if (GETMAJOREXECVERSION(cv_execversion.value) < 10) // 10 = 1.6
|
||||
{
|
||||
// axis defaults changed again to SDL game controllers
|
||||
if (!CV_FilterJoyAxisVars2(v, valstr))
|
||||
return false;
|
||||
}
|
||||
// nothing to see here...
|
||||
(void)valstr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1950,8 +1950,8 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
||||
G_MapEventsToControls(&events[eventtail]);
|
||||
|
||||
if (gamekeydown[KEY_ESCAPE]
|
||||
|| gamekeydown[KEY_JOY1+1])
|
||||
if (gamekeydown[0][KEY_ESCAPE]
|
||||
|| gamekeydown[0][KEY_JOY1+1])
|
||||
cl_mode = CL_ABORTED;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ typedef enum
|
|||
ev_console,
|
||||
ev_mouse,
|
||||
ev_joystick,
|
||||
ev_joystick2,
|
||||
ev_joystick3,
|
||||
ev_joystick4,
|
||||
} evtype_t;
|
||||
|
||||
// Event structure.
|
||||
|
|
|
|||
|
|
@ -1046,7 +1046,7 @@ void D_StartTitle(void)
|
|||
F_InitMenuPresValues();
|
||||
|
||||
// clear cmd building stuff
|
||||
memset(gamekeydown, 0, NUMKEYS);
|
||||
memset(gamekeydown, 0, sizeof(gamekeydown));
|
||||
|
||||
F_StartTitleScreen();
|
||||
|
||||
|
|
@ -1057,15 +1057,6 @@ void D_StartTitle(void)
|
|||
V_SetPaletteLump("PLAYPAL");
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1056,16 +1056,7 @@ void D_RegisterClientCommands(void)
|
|||
{
|
||||
CV_RegisterVar(&cv_kickstartaccel[i]);
|
||||
CV_RegisterVar(&cv_shrinkme[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_lookbackaxis[i]);
|
||||
CV_RegisterVar(&cv_deadzone[i]);
|
||||
CV_RegisterVar(&cv_digitaldeadzone[i]);
|
||||
}
|
||||
|
||||
// filesrch.c
|
||||
|
|
@ -3080,10 +3071,6 @@ static void Command_Map_f(void)
|
|||
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
|
||||
|
||||
D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, fromlevelselect);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ extern char * bootmap; //bootmap for loading a map on startup
|
|||
|
||||
extern char * tutorialmap; // map to load for tutorial
|
||||
extern boolean tutorialmode; // are we in a tutorial right now?
|
||||
extern INT32 tutorialgcs; // which control scheme is loaded?
|
||||
|
||||
extern boolean looptitle;
|
||||
|
||||
|
|
|
|||
|
|
@ -2040,12 +2040,13 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex
|
|||
|
||||
static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length)
|
||||
{
|
||||
INT32 gcs = gcs_custom;
|
||||
INT32 gcs = 0;
|
||||
boolean suffixed = true;
|
||||
|
||||
if (!tag || !tag[0] || !tutorialmode)
|
||||
return false;
|
||||
|
||||
/*
|
||||
if (!strncmp(tag, "TAA", 3)) // Accelerate
|
||||
gcs = G_GetControlScheme(gamecontrol[0], gcl_accelerate, num_gcl_accelerate);
|
||||
else if (!strncmp(tag, "TAB", 3)) // Brake
|
||||
|
|
@ -2058,14 +2059,10 @@ static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length)
|
|||
gcs = G_GetControlScheme(gamecontrol[0], gcl_item, num_gcl_item);
|
||||
else
|
||||
gcs = G_GetControlScheme(gamecontrol[0], gcl_full, num_gcl_full);
|
||||
*/
|
||||
|
||||
switch (gcs)
|
||||
{
|
||||
case gcs_kart:
|
||||
// strncat(tag, "KART", length);
|
||||
suffixed = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
strncat(tag, "CUSTOM", length);
|
||||
break;
|
||||
|
|
|
|||
406
src/g_game.c
406
src/g_game.c
|
|
@ -157,7 +157,6 @@ char * bootmap = NULL; //bootmap for loading a map on startup
|
|||
|
||||
char * tutorialmap = NULL; // map to load for tutorial
|
||||
boolean tutorialmode = false; // are we in a tutorial right now?
|
||||
INT32 tutorialgcs = gcs_custom; // which control scheme is loaded?
|
||||
|
||||
boolean looptitle = true;
|
||||
|
||||
|
|
@ -343,22 +342,6 @@ INT16 prevmap, nextmap;
|
|||
INT16 kartmap2native[NEXTMAP_SPECIAL] = {0}, nativemap2kart[NEXTMAP_SPECIAL] = {0};
|
||||
INT16 nextexnum = NUMMAPS;
|
||||
|
||||
static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"},
|
||||
{1, "Left X"}, {2, "Left Y"}, {-1, "Left X-"}, {-2, "Left Y-"},
|
||||
#if JOYAXISSET > 1
|
||||
{3, "Right X"}, {4, "Right Y"}, {-3, "Right X-"}, {-4, "Right Y-"},
|
||||
#endif
|
||||
#if JOYAXISSET > 2
|
||||
{5, "L Trigger"}, {6, "R Trigger"}, {-5, "L Trigger-"}, {-6, "R Trigger-"},
|
||||
#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.
|
||||
|
||||
// chat timer thingy
|
||||
|
|
@ -453,62 +436,6 @@ consvar_t cv_shrinkme[MAXSPLITSCREENPLAYERS] = {
|
|||
CVAR_INIT ("shrinkme4", "Off", CV_CALL, CV_OnOff, weaponPrefChange4)
|
||||
};
|
||||
|
||||
consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS] = {
|
||||
CVAR_INIT ("joyaxis_turn", "Left X", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis2_turn", "Left X", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis3_turn", "Left X", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis4_turn", "Left X", 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", "Left Y", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis2_aim", "Left Y", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis3_aim", "Left Y", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis4_aim", "Left Y", 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", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis_fire2", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis_fire3", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis_fire4", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL)
|
||||
};
|
||||
|
||||
consvar_t cv_driftaxis[MAXSPLITSCREENPLAYERS] = {
|
||||
CVAR_INIT ("joyaxis_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis2_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis3_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis4_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL)
|
||||
};
|
||||
|
||||
consvar_t cv_lookbackaxis[MAXSPLITSCREENPLAYERS] = {
|
||||
CVAR_INIT ("joyaxis_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis2_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis3_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL),
|
||||
CVAR_INIT ("joyaxis4_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL)
|
||||
};
|
||||
|
||||
static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = {
|
||||
CVAR_INIT ("joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
|
||||
|
|
@ -517,13 +444,6 @@ consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = {
|
|||
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
|
||||
// so that it doesn't have to be updated depending on the value of MAXPLAYERS
|
||||
char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
||||
|
|
@ -843,77 +763,108 @@ INT16 G_SoftwareClipAimingPitch(INT32 *aiming)
|
|||
return (INT16)((*aiming)>>16);
|
||||
}
|
||||
|
||||
INT32 PlayerJoyAxis(UINT8 player, axis_input_e axissel)
|
||||
// returns the first gamecontrol that matches the given key
|
||||
// used by menu code (that boolean is kinda pointless...)
|
||||
INT32 G_GetControlForKey(UINT8 p, INT32 key, boolean menu)
|
||||
{
|
||||
INT32 retaxis;
|
||||
INT32 axisval;
|
||||
boolean flp = false;
|
||||
|
||||
//find what axis to get
|
||||
switch (axissel)
|
||||
INT32 i, gc;
|
||||
for (gc = 0; gc < num_gamecontrols; gc++)
|
||||
{
|
||||
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;
|
||||
case AXISLOOKBACK:
|
||||
axisval = cv_lookbackaxis[player-1].value;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
INT32 (*map)[][MAXINPUTMAPPING] = &gamecontrol[p];
|
||||
|
||||
if (axisval < 0) //odd -axises
|
||||
{
|
||||
axisval = -axisval;
|
||||
flp = true;
|
||||
// if this control isn't bound, switch to defaults
|
||||
if (menu)
|
||||
{
|
||||
for (i = 0; i < MAXINPUTMAPPING; i++)
|
||||
if ((*map)[gc][i])
|
||||
goto bound;
|
||||
map = &gamecontroldefault;
|
||||
}
|
||||
bound:
|
||||
|
||||
for (i = 0; i < MAXINPUTMAPPING; i++)
|
||||
if ((*map)[gc][i] == key)
|
||||
return gc;
|
||||
}
|
||||
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
|
||||
return gc_null;
|
||||
}
|
||||
|
||||
static INT32 KeyValue(UINT8 p, INT32 key)
|
||||
{
|
||||
if (key <= 0 || key >= NUMINPUTS)
|
||||
{
|
||||
return 0;
|
||||
|
||||
if (axisval%2)
|
||||
{
|
||||
axisval /= 2;
|
||||
retaxis = joyxmove[player-1][axisval];
|
||||
}
|
||||
else
|
||||
{
|
||||
axisval--;
|
||||
axisval /= 2;
|
||||
retaxis = joyymove[player-1][axisval];
|
||||
}
|
||||
|
||||
if (retaxis < (-JOYAXISRANGE))
|
||||
retaxis = -JOYAXISRANGE;
|
||||
if (retaxis > (+JOYAXISRANGE))
|
||||
retaxis = +JOYAXISRANGE;
|
||||
return gamekeydown[p][key];
|
||||
}
|
||||
|
||||
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;
|
||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
||||
return 0;
|
||||
#ifdef PARANOIA
|
||||
CONS_Debug(DBG_GAMELOGIC, "G_PlayerInputAnalog: Invalid player ID %d\n", p);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flp) retaxis = -retaxis; //flip it around
|
||||
return retaxis;
|
||||
deadzone = (JOYAXISRANGE * cv_deadzone[p].value) / FRACUNIT;
|
||||
|
||||
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 (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 (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
|
||||
|
|
@ -1006,29 +957,21 @@ static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4};
|
|||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
{
|
||||
const UINT8 forplayer = ssplayer-1;
|
||||
|
||||
|
||||
const INT32 baseturnspeed = 1;
|
||||
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 INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning
|
||||
static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard
|
||||
static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame
|
||||
|
||||
INT32 forward, axis, side, tspeed;
|
||||
INT32 forward, side, tspeed;
|
||||
|
||||
joystickvector2_t joystickvector;
|
||||
|
||||
boolean turnleft, turnright;
|
||||
|
||||
player_t *player = &players[g_localplayers[forplayer]];
|
||||
camera_t *thiscam = &camera[forplayer];
|
||||
boolean *kbl = &keyboard_look[forplayer];
|
||||
boolean *rd = &resetdown[forplayer];
|
||||
const boolean mouseaiming = player->spectator;
|
||||
|
||||
if (demo.playback) return;
|
||||
|
||||
|
|
@ -1063,10 +1006,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
return;
|
||||
}
|
||||
|
||||
turnright = PlayerInputDown(ssplayer, gc_turnright);
|
||||
turnleft = PlayerInputDown(ssplayer, gc_turnleft);
|
||||
|
||||
joystickvector.xaxis = PlayerJoyAxis(ssplayer, AXISTURN);
|
||||
joystickvector.xaxis = G_PlayerInputAnalog(forplayer, gc_turnright, false) - G_PlayerInputAnalog(forplayer, gc_turnleft, false);
|
||||
joystickvector.yaxis = 0;
|
||||
G_HandleAxisDeadZone(forplayer, &joystickvector);
|
||||
|
||||
|
|
@ -1074,26 +1014,18 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
// 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
|
||||
// until the stick is pushed far enough
|
||||
joystickvector.yaxis = PlayerJoyAxis(ssplayer, AXISAIM);
|
||||
joystickvector.yaxis = G_PlayerInputAnalog(forplayer, gc_aimbackward, false) - G_PlayerInputAnalog(forplayer, gc_aimforward, false);
|
||||
|
||||
if (encoremode)
|
||||
{
|
||||
turnright ^= turnleft; // swap these using three XORs
|
||||
turnleft ^= turnright;
|
||||
turnright ^= turnleft;
|
||||
joystickvector.xaxis = -joystickvector.xaxis;
|
||||
}
|
||||
|
||||
if (gamepadjoystickmove && joystickvector.xaxis != 0)
|
||||
{
|
||||
turnright = turnright || (joystickvector.xaxis > 0);
|
||||
turnleft = turnleft || (joystickvector.xaxis < 0);
|
||||
}
|
||||
forward = side = 0;
|
||||
|
||||
|
||||
// use two stage accelerative turning
|
||||
// on the keyboard and joystick
|
||||
if (turnleft || turnright)
|
||||
if (joystickvector.xaxis != 0)
|
||||
turnheld[forplayer] += realtics;
|
||||
else
|
||||
turnheld[forplayer] = 0;
|
||||
|
|
@ -1105,122 +1037,97 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
|
||||
cmd->turning = 0;
|
||||
|
||||
// let movement keys cancel each other out
|
||||
if (turnright && !(turnleft))
|
||||
if (joystickvector.xaxis != 0)
|
||||
{
|
||||
cmd->turning -= angleturn[tspeed];
|
||||
side += 4;
|
||||
}
|
||||
else if (turnleft && !(turnright))
|
||||
{
|
||||
cmd->turning += angleturn[tspeed];
|
||||
side -= 4;
|
||||
}
|
||||
|
||||
if (analogjoystickmove && joystickvector.xaxis != 0)
|
||||
{
|
||||
cmd->turning -= (joystickvector.xaxis * KART_FULLTURN) >> 10;
|
||||
side += ((joystickvector.xaxis * 2) >> 10);
|
||||
cmd->turning -= (joystickvector.xaxis * KART_FULLTURN) / JOYAXISRANGE;
|
||||
side += (joystickvector.xaxis * 4) / JOYAXISRANGE;
|
||||
}
|
||||
|
||||
// Specator mouse turning
|
||||
if (player->spectator)
|
||||
{
|
||||
INT32 mousex = gamekeydown[0][KEY_MOUSEMOVE+3] - gamekeydown[0][KEY_MOUSEMOVE+2];
|
||||
cmd->turning -= (mousex * 8) * (encoremode ? -1 : 1);
|
||||
}
|
||||
|
||||
if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls
|
||||
{
|
||||
axis = PlayerJoyAxis(ssplayer, AXISMOVE);
|
||||
if (PlayerInputDown(ssplayer, gc_accelerate) || (usejoystick && axis > 0))
|
||||
if (G_PlayerInputDown(forplayer, gc_accelerate, false))
|
||||
{
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
axis = PlayerJoyAxis(ssplayer, AXISBRAKE);
|
||||
if (PlayerInputDown(ssplayer, gc_brake) || (usejoystick && axis > 0))
|
||||
}
|
||||
|
||||
if (G_PlayerInputDown(forplayer, gc_brake, false))
|
||||
{
|
||||
cmd->buttons |= BT_BRAKE;
|
||||
axis = PlayerJoyAxis(ssplayer, AXISAIM);
|
||||
if (PlayerInputDown(ssplayer, gc_aimforward) || (usejoystick && axis < 0))
|
||||
}
|
||||
|
||||
if (joystickvector.yaxis < 0)
|
||||
{
|
||||
forward += MAXPLMOVE;
|
||||
if (PlayerInputDown(ssplayer, gc_aimbackward) || (usejoystick && axis > 0))
|
||||
}
|
||||
|
||||
if (joystickvector.yaxis > 0)
|
||||
{
|
||||
forward -= MAXPLMOVE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// forward with key or button // SRB2kart - we use an accel/brake instead of forward/backward.
|
||||
axis = PlayerJoyAxis(ssplayer, AXISMOVE);
|
||||
if (PlayerInputDown(ssplayer, gc_accelerate) || (gamepadjoystickmove && axis > 0))
|
||||
fixed_t value = G_PlayerInputAnalog(forplayer, gc_accelerate, false);
|
||||
if (value != 0)
|
||||
{
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
forward = MAXPLMOVE; // 50
|
||||
forward += (value * MAXPLMOVE) / JOYAXISRANGE;
|
||||
}
|
||||
else if (analogjoystickmove && axis > 0)
|
||||
{
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
||||
forward += ((axis * MAXPLMOVE) / (JOYAXISRANGE-1));
|
||||
}
|
||||
else if (player->sneakertimer)
|
||||
|
||||
if (player->sneakertimer)
|
||||
forward = MAXPLMOVE; // 50
|
||||
|
||||
axis = PlayerJoyAxis(ssplayer, AXISBRAKE);
|
||||
if (PlayerInputDown(ssplayer, gc_brake) || (gamepadjoystickmove && axis > 0))
|
||||
value = G_PlayerInputAnalog(forplayer, gc_brake, false);
|
||||
if (value != 0)
|
||||
{
|
||||
cmd->buttons |= BT_BRAKE;
|
||||
forward -= 25; // 25 - Halved value so clutching is possible
|
||||
}
|
||||
else if (analogjoystickmove && axis > 0)
|
||||
{
|
||||
cmd->buttons |= BT_BRAKE;
|
||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
||||
forward -= ((axis * 25) / (JOYAXISRANGE-1));
|
||||
forward -= (value * 25) / JOYAXISRANGE;
|
||||
}
|
||||
|
||||
// But forward/backward IS used for aiming.
|
||||
if (PlayerInputDown(ssplayer, gc_aimforward))
|
||||
if (joystickvector.yaxis != 0)
|
||||
{
|
||||
cmd->buttons |= BT_FORWARD;
|
||||
cmd->throwdir += KART_FULLTURN;
|
||||
}
|
||||
if (PlayerInputDown(ssplayer, gc_aimbackward))
|
||||
{
|
||||
cmd->buttons |= BT_BACKWARD;
|
||||
cmd->throwdir -= KART_FULLTURN;
|
||||
}
|
||||
|
||||
if (analogjoystickmove && joystickvector.yaxis != 0)
|
||||
{
|
||||
cmd->throwdir -= (joystickvector.yaxis * KART_FULLTURN) >> 10;
|
||||
if (joystickvector.yaxis < 0)
|
||||
cmd->buttons |= BT_FORWARD;
|
||||
else if (joystickvector.yaxis > 0)
|
||||
cmd->buttons |= BT_BACKWARD;
|
||||
cmd->throwdir -= (joystickvector.yaxis * KART_FULLTURN) / JOYAXISRANGE;
|
||||
cmd->buttons |= joystickvector.yaxis < 0 ? BT_FORWARD : BT_BACKWARD;
|
||||
}
|
||||
}
|
||||
|
||||
// fire with any button/key
|
||||
axis = PlayerJoyAxis(ssplayer, AXISFIRE);
|
||||
if (PlayerInputDown(ssplayer, gc_fire) || (usejoystick && axis > 0))
|
||||
if (G_PlayerInputDown(forplayer, gc_fire, false))
|
||||
{
|
||||
cmd->buttons |= BT_ATTACK;
|
||||
}
|
||||
|
||||
// drift with any button/key
|
||||
axis = PlayerJoyAxis(ssplayer, AXISDRIFT);
|
||||
if (PlayerInputDown(ssplayer, gc_drift) || (usejoystick && axis > 0))
|
||||
if (G_PlayerInputDown(forplayer, gc_drift, false))
|
||||
{
|
||||
cmd->buttons |= BT_DRIFT;
|
||||
}
|
||||
|
||||
// rear view with any button/key
|
||||
axis = PlayerJoyAxis(ssplayer, AXISLOOKBACK);
|
||||
if (PlayerInputDown(ssplayer, gc_lookback) || (usejoystick && axis > 0))
|
||||
if (G_PlayerInputDown(forplayer, gc_lookback, false))
|
||||
{
|
||||
cmd->buttons |= BT_LOOKBACK;
|
||||
}
|
||||
|
||||
// Lua scriptable buttons
|
||||
if (PlayerInputDown(ssplayer, gc_custom1))
|
||||
if (G_PlayerInputDown(forplayer, gc_custom1, false))
|
||||
cmd->buttons |= BT_CUSTOM1;
|
||||
if (PlayerInputDown(ssplayer, gc_custom2))
|
||||
if (G_PlayerInputDown(forplayer, gc_custom2, false))
|
||||
cmd->buttons |= BT_CUSTOM2;
|
||||
if (PlayerInputDown(ssplayer, gc_custom3))
|
||||
if (G_PlayerInputDown(forplayer, gc_custom3, false))
|
||||
cmd->buttons |= BT_CUSTOM3;
|
||||
|
||||
// Reset camera
|
||||
if (PlayerInputDown(ssplayer, gc_camreset))
|
||||
if (G_PlayerInputDown(forplayer, gc_camreset, false))
|
||||
{
|
||||
if (thiscam->chase && *rd == false)
|
||||
P_ResetCamera(player, thiscam);
|
||||
|
|
@ -1231,13 +1138,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
|
||||
// spectator aiming shit, ahhhh...
|
||||
{
|
||||
INT32 player_invert = invertmouse ? -1 : 1;
|
||||
INT32 screen_invert =
|
||||
(player->mo && (player->mo->eflags & MFE_VERTICALFLIP)
|
||||
&& (!thiscam->chase)) //because chasecam's not inverted
|
||||
? -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;
|
||||
|
|
@ -1245,12 +1152,16 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
// looking up/down
|
||||
cmd->aiming += (mlooky<<19)*player_invert*screen_invert;
|
||||
}
|
||||
*/
|
||||
|
||||
axis = PlayerJoyAxis(ssplayer, AXISLOOK);
|
||||
if (analogjoystickmove && axis != 0 && lookaxis && player->spectator)
|
||||
// TODO: cmd->aiming does nothing for some reason, kinda hard to test
|
||||
INT32 axis = G_PlayerInputAnalog(forplayer, gc_lookup, false) - G_PlayerInputAnalog(forplayer, gc_lookdown, false);
|
||||
|
||||
if (axis != 0 && player->spectator)
|
||||
cmd->aiming += (axis<<16) * screen_invert;
|
||||
|
||||
// spring back if not using keyboard neither mouselookin'
|
||||
/*
|
||||
if (*kbl == false && !lookaxis && !mouseaiming)
|
||||
cmd->aiming = 0;
|
||||
|
||||
|
|
@ -1267,16 +1178,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
*kbl = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (PlayerInputDown(ssplayer, gc_centerview)) // No need to put a spectator limit on this one though :V
|
||||
if (G_PlayerInputDown(forplayer, gc_centerview, false)) // // No need to put a spectator limit on this one though :V
|
||||
cmd->aiming = 0;
|
||||
}
|
||||
|
||||
mousex = mousey = mlooky = 0;
|
||||
|
||||
cmd->forwardmove += (SINT8)forward;
|
||||
cmd->sidemove += (SINT8)side;
|
||||
|
||||
cmd->flags = 0;
|
||||
|
||||
if (chat_on || CON_Ready())
|
||||
|
|
@ -1395,7 +1304,7 @@ void weaponPrefChange4(void)
|
|||
void G_DoLoadLevel(boolean resetplayer)
|
||||
{
|
||||
boolean doAutomate = false;
|
||||
INT32 i,j;
|
||||
INT32 i;
|
||||
|
||||
// Make sure objectplace is OFF when you first start the level!
|
||||
OP_ResetObjectplace();
|
||||
|
|
@ -1460,12 +1369,6 @@ void G_DoLoadLevel(boolean resetplayer)
|
|||
|
||||
// clear cmd building stuff
|
||||
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)
|
||||
CON_ClearHUD();
|
||||
|
|
@ -1782,15 +1685,6 @@ boolean G_Responder(event_t *ev)
|
|||
case ev_joystick:
|
||||
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:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
33
src/g_game.h
33
src/g_game.h
|
|
@ -78,17 +78,7 @@ extern consvar_t cv_invertmouse;
|
|||
|
||||
extern consvar_t cv_kickstartaccel[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_shrinkme[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_lookbackaxis[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;
|
||||
|
||||
|
|
@ -127,28 +117,13 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n);
|
|||
INT32 G_ClipAimingPitch(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,
|
||||
AXISLOOKBACK,
|
||||
AXISAIM,
|
||||
} axis_input_e;
|
||||
|
||||
INT32 PlayerJoyAxis(UINT8 player, axis_input_e axissel);
|
||||
|
||||
extern angle_t localangle[MAXSPLITSCREENPLAYERS];
|
||||
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);
|
||||
INT32 G_GetControlForKey(UINT8 p, INT32 key, boolean menu);
|
||||
|
||||
//
|
||||
// GAME
|
||||
//
|
||||
|
|
|
|||
872
src/g_input.c
872
src/g_input.c
File diff suppressed because it is too large
Load diff
|
|
@ -31,45 +31,23 @@ extern "C" {
|
|||
#define JOYHATS 4 // 4 hats
|
||||
#define JOYAXISSET 4 // 4 Sets of 2 axises
|
||||
|
||||
#define MAXINPUTMAPPING 4
|
||||
|
||||
//
|
||||
// mouse and joystick buttons are handled as 'virtual' keys
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
KEY_MOUSE1 = NUMKEYS,
|
||||
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
|
||||
KEY_JOY1 = NUMKEYS,
|
||||
KEY_HAT1 = KEY_JOY1 + JOYBUTTONS,
|
||||
KEY_AXIS1 = KEY_HAT1 + JOYHATS*4,
|
||||
|
||||
KEY_DBLMOUSE1 =KEY_HAT1 + JOYHATS*4, // double clicks
|
||||
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS,
|
||||
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
|
||||
|
||||
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_MOUSE1 = KEY_AXIS1 + JOYAXISSET*4,
|
||||
KEY_MOUSEMOVE = KEY_MOUSE1 + MOUSEBUTTONS,
|
||||
KEY_MOUSEWHEELUP = KEY_MOUSEMOVE + 4,
|
||||
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;
|
||||
|
||||
typedef enum
|
||||
|
|
@ -105,31 +83,20 @@ typedef enum
|
|||
num_gamecontrols
|
||||
} 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
|
||||
extern consvar_t cv_mousesens, cv_mouseysens;
|
||||
extern consvar_t cv_mousesens2, cv_mouseysens2;
|
||||
extern consvar_t cv_controlperkey, cv_turnsmooth;
|
||||
|
||||
extern INT32 mousex, mousey;
|
||||
extern INT32 mlooky; //mousey with mlookSensitivity
|
||||
|
||||
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
|
||||
|
||||
// current state of the keys: true if pushed
|
||||
extern UINT8 gamekeydown[NUMINPUTS];
|
||||
// current state of the keys: JOYAXISRANGE or 0 when boolean.
|
||||
// Or anything inbetween for analog values
|
||||
extern INT32 gamekeydown[MAXSPLITSCREENPLAYERS][NUMINPUTS];
|
||||
|
||||
// two key codes (or virtual key) per game control
|
||||
extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2];
|
||||
extern INT32 gamecontroldefault[MAXSPLITSCREENPLAYERS][num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention
|
||||
#define PlayerInputDown(p, gc) (gamekeydown[gamecontrol[p-1][gc][0]] || gamekeydown[gamecontrol[p-1][gc][1]])
|
||||
extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][MAXINPUTMAPPING];
|
||||
extern INT32 gamecontroldefault[num_gamecontrols][MAXINPUTMAPPING]; // default control storage
|
||||
|
||||
/*
|
||||
#define num_gcl_accelerate 1
|
||||
#define num_gcl_brake 1
|
||||
#define num_gcl_drift 1
|
||||
|
|
@ -143,6 +110,7 @@ extern const INT32 gcl_drift[num_gcl_drift];
|
|||
extern const INT32 gcl_movement[num_gcl_movement];
|
||||
extern const INT32 gcl_item[num_gcl_item];
|
||||
extern const INT32 gcl_full[num_gcl_full];
|
||||
*/
|
||||
|
||||
// peace to my little coder fingers!
|
||||
// check a gamecontrol being active or not
|
||||
|
|
@ -155,16 +123,16 @@ const char *G_KeynumToString(INT32 keynum);
|
|||
INT32 G_KeyStringtoNum(const char *keystr);
|
||||
|
||||
// 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 Command_Setcontrol_f(void);
|
||||
void Command_Setcontrol2_f(void);
|
||||
void Command_Setcontrol3_f(void);
|
||||
void Command_Setcontrol4_f(void);
|
||||
void G_DefineDefaultControls(void);
|
||||
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen);
|
||||
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen);
|
||||
void G_SaveKeySetting(FILE *f, INT32 (*fromcontrolsa)[2], INT32 (*fromcontrolsb)[2], INT32 (*fromcontrolsc)[2], INT32 (*fromcontrolsd)[2]);
|
||||
INT32 G_GetControlScheme(INT32 (*fromcontrols)[MAXINPUTMAPPING], 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)[MAXINPUTMAPPING], INT32 (*fromcontrolsb)[MAXINPUTMAPPING], INT32 (*fromcontrolsc)[MAXINPUTMAPPING], INT32 (*fromcontrolsd)[MAXINPUTMAPPING]);
|
||||
INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -1048,7 +1048,7 @@ void HU_Ticker(void)
|
|||
hu_tick++;
|
||||
hu_tick &= 7; // currently only to blink chat input cursor
|
||||
|
||||
if (PlayerInputDown(1, gc_scores))
|
||||
if (G_PlayerInputDown(0, gc_scores, false))
|
||||
hu_showscores = !chat_on;
|
||||
else
|
||||
hu_showscores = false;
|
||||
|
|
|
|||
334
src/m_menu.c
334
src/m_menu.c
|
|
@ -178,7 +178,7 @@ static INT16 skullAnimCounter = 10; // skull animation counter
|
|||
static tic_t followertimer = 0; // Used for smooth follower floating
|
||||
|
||||
static UINT8 setupcontrolplayer;
|
||||
static INT32 (*setupcontrols)[2]; // pointer to the gamecontrols of the player being edited
|
||||
static INT32 (*setupcontrols)[MAXINPUTMAPPING]; // pointer to the gamecontrols of the player being edited
|
||||
|
||||
// shhh... what am I doing... nooooo!
|
||||
static INT32 vidm_testingmode = 0;
|
||||
|
|
@ -288,7 +288,6 @@ static void M_SetupMultiHandler(INT32 choice);
|
|||
// Controls
|
||||
menu_t OP_ControlsDef, OP_AllControlsDef;
|
||||
menu_t OP_MouseOptionsDef;
|
||||
menu_t OP_Joystick1Def, OP_Joystick2Def, OP_Joystick3Def, OP_Joystick4Def;
|
||||
static void M_VideoModeMenu(INT32 choice);
|
||||
static void M_Setup1PControlsMenu(INT32 choice);
|
||||
static void M_Setup2PControlsMenu(INT32 choice);
|
||||
|
|
@ -394,6 +393,9 @@ static void M_HandleSetupMultiPlayer(INT32 choice);
|
|||
static void M_HandleVideoMode(INT32 choice);
|
||||
static void M_HandleMonitorToggles(INT32 choice);
|
||||
|
||||
// uhhhhhh hack?
|
||||
static void M_ChangecontrolResponse(event_t *ev);
|
||||
|
||||
// Consvar onchange functions
|
||||
static void Newgametype_OnChange(void);
|
||||
static void Dummymenuplayer_OnChange(void);
|
||||
|
|
@ -1098,8 +1100,10 @@ static menuitem_t OP_ControlsMenu[] =
|
|||
|
||||
static menuitem_t OP_AllControlsMenu[] =
|
||||
{
|
||||
{IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", {.submenu = &OP_Joystick1Def}, 0},
|
||||
{IT_CALL|IT_STRING, NULL, "Reset to defaults", {.routine = M_ResetControls}, 8},
|
||||
//{IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", {.submenu = &OP_Joystick1Def}, 0},
|
||||
{IT_CALL|IT_STRING, NULL, "Select Gamepad...", {.routine = M_Setup1PJoystickMenu}, 0},
|
||||
{IT_CVAR|IT_STRING, NULL, "Deadzone" , {.cvar = &cv_deadzone[0]}, 8},
|
||||
{IT_CALL|IT_STRING, NULL, "Reset to defaults", {.routine = M_ResetControls}, 16},
|
||||
//{IT_SPACE, NULL, NULL, NULL, 0},
|
||||
{IT_HEADER, NULL, "Gameplay Controls", {NULL}, 0},
|
||||
{IT_SPACE, NULL, NULL, {NULL}, 0},
|
||||
|
|
@ -1138,62 +1142,6 @@ static menuitem_t OP_AllControlsMenu[] =
|
|||
{IT_CONTROL, NULL, "Custom Action 3", {.routine = M_ChangeControl}, gc_custom3 },
|
||||
};
|
||||
|
||||
static menuitem_t OP_Joystick1Menu[] =
|
||||
{
|
||||
{IT_STRING | IT_CALL, NULL, "Select Gamepad..." , {.routine = M_Setup1PJoystickMenu}, 10},
|
||||
{IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , {.cvar = &cv_aimaxis[0]} , 30},
|
||||
{IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , {.cvar = &cv_turnaxis[0]} , 40},
|
||||
{IT_STRING | IT_CVAR, NULL, "Accelerate" , {.cvar = &cv_moveaxis[0]} , 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Brake" , {.cvar = &cv_brakeaxis[0]} , 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Drift" , {.cvar = &cv_driftaxis[0]} , 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Use Item" , {.cvar = &cv_fireaxis[0]} , 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Look Backward" , {.cvar = &cv_lookbackaxis[0]} , 90},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , {.cvar = &cv_lookaxis[0]} , 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "Deadzone" , {.cvar = &cv_deadzone[0]} , 110},
|
||||
};
|
||||
|
||||
static menuitem_t OP_Joystick2Menu[] =
|
||||
{
|
||||
{IT_STRING | IT_CALL, NULL, "Select Gamepad..." , {.routine = M_Setup2PJoystickMenu}, 10},
|
||||
{IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , {.cvar = &cv_aimaxis[1]} , 30},
|
||||
{IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , {.cvar = &cv_turnaxis[1]} , 40},
|
||||
{IT_STRING | IT_CVAR, NULL, "Accelerate" , {.cvar = &cv_moveaxis[1]} , 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Brake" , {.cvar = &cv_brakeaxis[1]} , 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Drift" , {.cvar = &cv_driftaxis[1]} , 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Use Item" , {.cvar = &cv_fireaxis[1]} , 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Look Backward" , {.cvar = &cv_lookbackaxis[0]} , 90},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , {.cvar = &cv_lookaxis[1]} , 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "Deadzone" , {.cvar = &cv_deadzone[1]} , 110},
|
||||
};
|
||||
|
||||
static menuitem_t OP_Joystick3Menu[] =
|
||||
{
|
||||
{IT_STRING | IT_CALL, NULL, "Select Gamepad..." , {.routine = M_Setup3PJoystickMenu}, 10},
|
||||
{IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , {.cvar = &cv_aimaxis[2]} , 30},
|
||||
{IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , {.cvar = &cv_turnaxis[2]} , 40},
|
||||
{IT_STRING | IT_CVAR, NULL, "Accelerate" , {.cvar = &cv_moveaxis[2]} , 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Brake" , {.cvar = &cv_brakeaxis[2]} , 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Drift" , {.cvar = &cv_driftaxis[2]} , 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Use Item" , {.cvar = &cv_fireaxis[2]} , 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Look Backward" , {.cvar = &cv_lookbackaxis[0]} , 90},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , {.cvar = &cv_lookaxis[2]} , 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "Deadzone" , {.cvar = &cv_deadzone[2]} , 110},
|
||||
};
|
||||
|
||||
static menuitem_t OP_Joystick4Menu[] =
|
||||
{
|
||||
{IT_STRING | IT_CALL, NULL, "Select Gamepad..." , {.routine = M_Setup4PJoystickMenu}, 10},
|
||||
{IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , {.cvar = &cv_aimaxis[3]} , 30},
|
||||
{IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , {.cvar = &cv_turnaxis[3]} , 40},
|
||||
{IT_STRING | IT_CVAR, NULL, "Accelerate" , {.cvar = &cv_moveaxis[3]} , 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Brake" , {.cvar = &cv_brakeaxis[3]} , 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Drift" , {.cvar = &cv_driftaxis[3]} , 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Use Item" , {.cvar = &cv_fireaxis[3]} , 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Look Backward" , {.cvar = &cv_lookbackaxis[0]} , 90},
|
||||
{IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , {.cvar = &cv_lookaxis[3]} , 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "Deadzone" , {.cvar = &cv_deadzone[3]} , 110},
|
||||
};
|
||||
|
||||
static menuitem_t OP_JoystickSetMenu[] =
|
||||
{
|
||||
{IT_CALL | IT_NOTHING, "None", NULL, {.routine = M_AssignJoystick}, LINEHEIGHT+5},
|
||||
|
|
@ -1966,16 +1914,12 @@ menu_t OP_MainDef =
|
|||
|
||||
menu_t OP_ControlsDef = DEFAULTMENUSTYLE(MN_NONE, "M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30);
|
||||
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(MN_NONE, OP_AllControlsMenu, &OP_ControlsDef);
|
||||
menu_t OP_Joystick1Def = DEFAULTMENUSTYLE(MN_NONE, "M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 30);
|
||||
menu_t OP_Joystick2Def = DEFAULTMENUSTYLE(MN_NONE, "M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 30);
|
||||
menu_t OP_Joystick3Def = DEFAULTMENUSTYLE(MN_NONE, "M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 30);
|
||||
menu_t OP_Joystick4Def = DEFAULTMENUSTYLE(MN_NONE, "M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 30);
|
||||
menu_t OP_JoystickSetDef =
|
||||
{
|
||||
MN_NONE,
|
||||
"M_CONTRO",
|
||||
sizeof (OP_JoystickSetMenu)/sizeof (menuitem_t),
|
||||
&OP_Joystick1Def,
|
||||
&OP_AllControlsDef,
|
||||
OP_JoystickSetMenu,
|
||||
M_DrawJoystick,
|
||||
50, 40,
|
||||
|
|
@ -2531,8 +2475,7 @@ boolean M_Responder(event_t *ev)
|
|||
{
|
||||
INT32 ch = -1;
|
||||
// INT32 i;
|
||||
static tic_t joywait = 0, joywaitaccel = 0, mousewait = 0;
|
||||
static INT32 pjoyx = 0, pjoyy = 0, pjoyaccel = 0;
|
||||
static tic_t mousewait = 0;
|
||||
static INT32 pmousex = 0, pmousey = 0;
|
||||
static INT32 lastx = 0, lasty = 0;
|
||||
void (*routine)(INT32 choice); // for some casting problem
|
||||
|
|
@ -2560,15 +2503,9 @@ boolean M_Responder(event_t *ev)
|
|||
switch (ch)
|
||||
{
|
||||
case KEY_MOUSE1:
|
||||
//case KEY_JOY1:
|
||||
//case KEY_JOY1 + 2:
|
||||
ch = KEY_ENTER;
|
||||
break;
|
||||
/*case KEY_JOY1 + 3: // Brake can function as 'n' for message boxes now.
|
||||
ch = 'n';
|
||||
break;*/
|
||||
case KEY_MOUSE1 + 1:
|
||||
//case KEY_JOY1 + 1:
|
||||
ch = KEY_BACKSPACE;
|
||||
break;
|
||||
case KEY_HAT1:
|
||||
|
|
@ -2583,83 +2520,30 @@ boolean M_Responder(event_t *ev)
|
|||
case KEY_HAT1 + 3:
|
||||
ch = KEY_RIGHTARROW;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (menuactive)
|
||||
{
|
||||
tic_t thistime = I_GetTime();
|
||||
if (ev->type == ev_joystick)
|
||||
if (ev->type == ev_joystick && ev->device == 0)
|
||||
{
|
||||
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone[0].value) >> FRACBITS;
|
||||
|
||||
INT32 accelaxis = abs(cv_moveaxis->value);
|
||||
if (ev->data1 == 0)
|
||||
const INT32 jdeadzone = (JOYAXISRANGE * cv_deadzone[0].value) / FRACUNIT;
|
||||
static INT32 lastjoy[JOYAXISSET*2] = {0};
|
||||
|
||||
if (abs(ev->data2) <= jdeadzone)
|
||||
{
|
||||
if (ev->data3 != INT32_MAX)
|
||||
{
|
||||
if (Joystick[0].bGamepadStyle || abs(ev->data3) > jdeadzone)
|
||||
{
|
||||
if (joywait < thistime
|
||||
&& (pjoyy == 0 || (ev->data3 < 0) != (pjoyy < 0))) // no previous direction OR change direction
|
||||
{
|
||||
ch = (ev->data3 < 0) ? KEY_UPARROW : KEY_DOWNARROW;
|
||||
joywait = thistime + NEWTICRATE/7;
|
||||
}
|
||||
pjoyy = ev->data3;
|
||||
|
||||
}
|
||||
else
|
||||
pjoyy = 0;
|
||||
}
|
||||
|
||||
|
||||
if (ev->data2 != INT32_MAX && joywait < thistime)
|
||||
{
|
||||
if (Joystick[0].bGamepadStyle || abs(ev->data2) > jdeadzone)
|
||||
{
|
||||
if (joywait < thistime
|
||||
&& (pjoyx == 0 || (ev->data2 < 0) != (pjoyx < 0))) // no previous direction OR change direction
|
||||
{
|
||||
ch = (ev->data2 < 0) ? KEY_LEFTARROW : KEY_RIGHTARROW;
|
||||
joywait = thistime + NEWTICRATE/7;
|
||||
}
|
||||
pjoyx = ev->data2;
|
||||
}
|
||||
else
|
||||
pjoyx = 0;
|
||||
}
|
||||
lastjoy[ev->data1] = 0;
|
||||
return false;
|
||||
}
|
||||
else if (!(accelaxis > JOYAXISSET*2 || accelaxis == 0))
|
||||
{
|
||||
// The following borrows heavily from Joy1Axis.
|
||||
const boolean xmode = (accelaxis%2);
|
||||
INT32 retaxis = 0;
|
||||
if (!xmode)
|
||||
accelaxis--;
|
||||
accelaxis /= 2;
|
||||
if (ev->data1 == accelaxis)
|
||||
{
|
||||
const INT32 jacceldeadzone = xmode ? jdeadzone : jdeadzone;
|
||||
retaxis = xmode ? ev->data2 : ev->data3;
|
||||
if (retaxis != INT32_MAX)
|
||||
{
|
||||
if (cv_moveaxis[0].value < 0)
|
||||
retaxis = -retaxis;
|
||||
|
||||
if (Joystick[0].bGamepadStyle || retaxis > jacceldeadzone)
|
||||
{
|
||||
if (joywaitaccel < thistime && retaxis > pjoyaccel) // only on upwards event
|
||||
{
|
||||
ch = KEY_ENTER;
|
||||
joywaitaccel = thistime + NEWTICRATE/3;
|
||||
}
|
||||
pjoyaccel = retaxis;
|
||||
}
|
||||
else
|
||||
pjoyaccel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// no previous direction OR change direction
|
||||
if (lastjoy[ev->data1] == 0 || (ev->data2 < 0) != (lastjoy[ev->data1] < 0))
|
||||
ch = KEY_AXIS1 + ev->data1*2 + (ev->data2 >= 0);
|
||||
else
|
||||
ch = 0;
|
||||
|
||||
lastjoy[ev->data1] = ev->data2;
|
||||
}
|
||||
else if (ev->type == ev_mouse && mousewait < I_GetTime())
|
||||
{
|
||||
|
|
@ -2693,12 +2577,34 @@ boolean M_Responder(event_t *ev)
|
|||
}
|
||||
}
|
||||
|
||||
// remap to keyboard keys if needed
|
||||
if (ch >= KEY_JOY1)
|
||||
{
|
||||
static INT32 joyremap[][2] = {
|
||||
{ gc_systemmenu, KEY_ESCAPE },
|
||||
{ gc_aimforward, KEY_UPARROW },
|
||||
{ gc_aimbackward, KEY_DOWNARROW },
|
||||
{ gc_turnleft, KEY_LEFTARROW },
|
||||
{ gc_turnright, KEY_RIGHTARROW },
|
||||
{ gc_brake, KEY_ESCAPE },
|
||||
{ gc_accelerate, KEY_ENTER },
|
||||
};
|
||||
|
||||
INT32 gc = G_GetControlForKey(0, ch, true);
|
||||
if (gc != gc_null && !(gc == gc_brake && !menuactive)) // don't open the menu with brake!
|
||||
{
|
||||
for (size_t r = 0; r < sizeof(joyremap)/sizeof(*joyremap); r++)
|
||||
{
|
||||
if (gc != joyremap[r][0])
|
||||
continue;
|
||||
ch = joyremap[r][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ch == -1)
|
||||
return false;
|
||||
else if (ch == gamecontrol[0][gc_systemmenu][0] || ch == gamecontrol[0][gc_systemmenu][1]) // allow remappable ESC key
|
||||
ch = KEY_ESCAPE;
|
||||
else if ((ch == gamecontrol[0][gc_accelerate][0] || ch == gamecontrol[0][gc_accelerate][1]) && ch >= KEY_MOUSE1)
|
||||
ch = KEY_ENTER;
|
||||
|
||||
// F-Keys
|
||||
if (!menuactive)
|
||||
|
|
@ -2775,9 +2681,6 @@ boolean M_Responder(event_t *ev)
|
|||
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
|
||||
ch = KEY_ESCAPE;
|
||||
|
||||
routine = currentMenu->menuitems[itemOn].itemaction.routine;
|
||||
|
||||
// Handle menuitems which need a specific key handling
|
||||
|
|
@ -2805,13 +2708,12 @@ boolean M_Responder(event_t *ev)
|
|||
}
|
||||
else
|
||||
{
|
||||
// dirty hack: for customising controls, I want only buttons/keys, not moves
|
||||
if (ev->type == ev_mouse
|
||||
|| ev->type == ev_joystick
|
||||
|| ev->type == ev_joystick2
|
||||
|| ev->type == ev_joystick3
|
||||
|| ev->type == ev_joystick4)
|
||||
// dirty hack: for customising controls, I want only buttons/keys/axes, not mouse
|
||||
if (ev->type == ev_mouse || (ev->type == ev_joystick && currentMenu->menuitems[itemOn].itemaction.eventhandler != M_ChangecontrolResponse))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (routine)
|
||||
{
|
||||
currentMenu->menuitems[itemOn].itemaction.eventhandler(ev);
|
||||
|
|
@ -10449,28 +10351,24 @@ void M_SetupJoystickMenu(INT32 choice)
|
|||
static void M_Setup1PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrolplayer = 1;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick1Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
||||
static void M_Setup2PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrolplayer = 2;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick2Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
||||
static void M_Setup3PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrolplayer = 3;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick3Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
||||
static void M_Setup4PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrolplayer = 4;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick4Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
||||
|
|
@ -10526,7 +10424,7 @@ static void M_Setup1PControlsMenu(INT32 choice)
|
|||
currentMenu->lastOn = itemOn;
|
||||
|
||||
// Set proper gamepad options
|
||||
OP_AllControlsMenu[0].itemaction.submenu = &OP_Joystick1Def;
|
||||
OP_AllControlsMenu[0].itemaction.routine = M_Setup1PJoystickMenu;
|
||||
|
||||
// Unhide P1-only controls
|
||||
OP_AllControlsMenu[16].status = IT_CONTROL; // Chat
|
||||
|
|
@ -10558,7 +10456,7 @@ static void M_Setup2PControlsMenu(INT32 choice)
|
|||
currentMenu->lastOn = itemOn;
|
||||
|
||||
// Set proper gamepad options
|
||||
OP_AllControlsMenu[0].itemaction.submenu = &OP_Joystick2Def;
|
||||
OP_AllControlsMenu[0].itemaction.routine = M_Setup2PJoystickMenu;
|
||||
|
||||
// Hide P1-only controls
|
||||
OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Chat
|
||||
|
|
@ -10590,7 +10488,7 @@ static void M_Setup3PControlsMenu(INT32 choice)
|
|||
currentMenu->lastOn = itemOn;
|
||||
|
||||
// Set proper gamepad options
|
||||
OP_AllControlsMenu[0].itemaction.submenu = &OP_Joystick3Def;
|
||||
OP_AllControlsMenu[0].itemaction.routine = M_Setup3PJoystickMenu;
|
||||
|
||||
// Hide P1-only controls
|
||||
OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Chat
|
||||
|
|
@ -10622,7 +10520,7 @@ static void M_Setup4PControlsMenu(INT32 choice)
|
|||
currentMenu->lastOn = itemOn;
|
||||
|
||||
// Set proper gamepad options
|
||||
OP_AllControlsMenu[0].itemaction.submenu = &OP_Joystick4Def;
|
||||
OP_AllControlsMenu[0].itemaction.routine = M_Setup4PJoystickMenu;
|
||||
|
||||
// Hide P1-only controls
|
||||
OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Chat
|
||||
|
|
@ -10651,9 +10549,9 @@ static void M_Setup4PControlsMenu(INT32 choice)
|
|||
// Draws the Customise Controls menu
|
||||
static void M_DrawControl(void)
|
||||
{
|
||||
char tmp[50];
|
||||
char tmp[32*MAXINPUTMAPPING]; // should be enough :^)
|
||||
INT32 x, y, i, max, cursory = 0, iter;
|
||||
INT32 keys[2];
|
||||
INT32 key;
|
||||
|
||||
x = currentMenu->x;
|
||||
y = currentMenu->y;
|
||||
|
|
@ -10724,26 +10622,21 @@ static void M_DrawControl(void)
|
|||
if (currentMenu->menuitems[i].status == IT_CONTROL)
|
||||
{
|
||||
V_DrawString(x, y, ((i == itemOn) ? highlightflags : 0), currentMenu->menuitems[i].text);
|
||||
keys[0] = setupcontrols[currentMenu->menuitems[i].alphaKey][0];
|
||||
keys[1] = setupcontrols[currentMenu->menuitems[i].alphaKey][1];
|
||||
|
||||
tmp[0] ='\0';
|
||||
if (keys[0] == KEY_NULL && keys[1] == KEY_NULL)
|
||||
for (iter = 0; iter < MAXINPUTMAPPING; iter++)
|
||||
{
|
||||
key = setupcontrols[currentMenu->menuitems[i].alphaKey][iter];
|
||||
if (key != KEY_NULL)
|
||||
{
|
||||
if (tmp[0] != '\0')
|
||||
strcat(tmp, ", ");
|
||||
strcat(tmp, G_KeynumToString(key));
|
||||
}
|
||||
}
|
||||
if (tmp[0] == '\0')
|
||||
strcpy(tmp, "---");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keys[0] != KEY_NULL)
|
||||
strcat (tmp, G_KeynumToString (keys[0]));
|
||||
|
||||
if (keys[0] != KEY_NULL && keys[1] != KEY_NULL)
|
||||
strcat(tmp,", ");
|
||||
|
||||
if (keys[1] != KEY_NULL)
|
||||
strcat (tmp, G_KeynumToString (keys[1]));
|
||||
|
||||
}
|
||||
V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, highlightflags, tmp);
|
||||
}
|
||||
/*else if (currentMenu->menuitems[i].status == IT_GRAYEDOUT2)
|
||||
|
|
@ -10751,7 +10644,11 @@ static void M_DrawControl(void)
|
|||
else if ((currentMenu->menuitems[i].status == IT_HEADER) && (i != max-1))
|
||||
V_DrawString(19, y+6, highlightflags, currentMenu->menuitems[i].text);
|
||||
else if (currentMenu->menuitems[i].status & IT_STRING)
|
||||
{
|
||||
V_DrawString(x, y, ((i == itemOn) ? highlightflags : 0), currentMenu->menuitems[i].text);
|
||||
if (currentMenu->menuitems[i].status & IT_CVAR)
|
||||
V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, highlightflags, currentMenu->menuitems[i].itemaction.cvar->string);
|
||||
}
|
||||
|
||||
y += SMALLLINEHEIGHT;
|
||||
}
|
||||
|
|
@ -10771,68 +10668,46 @@ static void M_ChangecontrolResponse(event_t *ev)
|
|||
INT32 found;
|
||||
INT32 ch = ev->data1;
|
||||
|
||||
if (ev->type == ev_joystick)
|
||||
ch = ev->data1*2 + KEY_AXIS1 + (ev->data2 > 0);
|
||||
|
||||
// ESCAPE cancels; dummy out PAUSE
|
||||
if (ch != KEY_ESCAPE && ch != KEY_PAUSE)
|
||||
{
|
||||
|
||||
switch (ev->type)
|
||||
{
|
||||
// ignore mouse/joy movements, just get buttons
|
||||
case ev_mouse:
|
||||
case ev_joystick:
|
||||
case ev_joystick2:
|
||||
case ev_joystick3:
|
||||
case ev_joystick4:
|
||||
ch = KEY_NULL; // no key
|
||||
break;
|
||||
|
||||
// keypad arrows are converted for the menu in cursor arrows
|
||||
// so use the event instead of ch
|
||||
case ev_keydown:
|
||||
ch = ev->data1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// keypad arrows are converted for the menu in cursor arrows
|
||||
// so use the event instead of ch
|
||||
if (ev->type == ev_keydown)
|
||||
ch = ev->data1;
|
||||
|
||||
control = controltochange;
|
||||
|
||||
// check if we already entered this key
|
||||
found = -1;
|
||||
if (setupcontrols[control][0] ==ch)
|
||||
found = 0;
|
||||
else if (setupcontrols[control][1] ==ch)
|
||||
found = 1;
|
||||
for (found = MAXINPUTMAPPING-1; found >= 0; found--)
|
||||
if (setupcontrols[control][found] == ch)
|
||||
break;
|
||||
|
||||
if (found >= 0)
|
||||
{
|
||||
// replace mouse and joy clicks by double clicks
|
||||
/*
|
||||
if (ch >= KEY_MOUSE1 && ch <= KEY_MOUSE1+MOUSEBUTTONS)
|
||||
setupcontrols[control][found] = ch-KEY_MOUSE1+KEY_DBLMOUSE1;
|
||||
else if (ch >= KEY_JOY1 && ch <= KEY_JOY1+JOYBUTTONS)
|
||||
setupcontrols[control][found] = ch-KEY_JOY1+KEY_DBLJOY1;
|
||||
else if (ch >= KEY_2MOUSE1 && ch <= KEY_2MOUSE1+MOUSEBUTTONS)
|
||||
setupcontrols[control][found] = ch-KEY_2MOUSE1+KEY_DBL2MOUSE1;
|
||||
else if (ch >= KEY_2JOY1 && ch <= KEY_2JOY1+JOYBUTTONS)
|
||||
setupcontrols[control][found] = ch-KEY_2JOY1+KEY_DBL2JOY1;
|
||||
else if (ch >= KEY_3JOY1 && ch <= KEY_3JOY1+JOYBUTTONS)
|
||||
setupcontrols[control][found] = ch-KEY_3JOY1+KEY_DBL3JOY1;
|
||||
else if (ch >= KEY_4JOY1 && ch <= KEY_4JOY1+JOYBUTTONS)
|
||||
setupcontrols[control][found] = ch-KEY_4JOY1+KEY_DBL4JOY1;
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if change key1 or key2, or replace the two by the new
|
||||
found = 0;
|
||||
if (setupcontrols[control][0] == KEY_NULL)
|
||||
found++;
|
||||
if (setupcontrols[control][1] == KEY_NULL)
|
||||
found++;
|
||||
if (found == 2)
|
||||
{
|
||||
found = 0;
|
||||
setupcontrols[control][1] = KEY_NULL; //replace key 1,clear key2
|
||||
}
|
||||
// find an empty slot for this key
|
||||
for (found = 0; found < MAXINPUTMAPPING; found++)
|
||||
if (setupcontrols[control][found] == KEY_NULL)
|
||||
break;
|
||||
|
||||
// no slots? shift down the other keys to make room (last one out)
|
||||
if (found == MAXINPUTMAPPING)
|
||||
for (found = 0; found < MAXINPUTMAPPING-1; found++)
|
||||
setupcontrols[control][found] = setupcontrols[control][found+1];
|
||||
|
||||
(void)G_CheckDoubleUsage(ch, true);
|
||||
setupcontrols[control][found] = ch;
|
||||
}
|
||||
|
|
@ -10892,17 +10767,10 @@ static void M_ResetControlsResponse(INT32 ch)
|
|||
}
|
||||
|
||||
// Setup original defaults
|
||||
G_CopyControls(gamecontrol[p], gamecontroldefault[p][gcs_kart], NULL, 0);
|
||||
G_CopyControls(gamecontrol[p], gamecontroldefault, NULL, 0);
|
||||
|
||||
// Setup gamepad option defaults (yucky)
|
||||
CV_StealthSet(&cv_usejoystick[p], cv_usejoystick[p].defaultvalue);
|
||||
CV_StealthSet(&cv_turnaxis[p], cv_turnaxis[p].defaultvalue);
|
||||
CV_StealthSet(&cv_moveaxis[p], cv_moveaxis[p].defaultvalue);
|
||||
CV_StealthSet(&cv_brakeaxis[p], cv_brakeaxis[p].defaultvalue);
|
||||
CV_StealthSet(&cv_aimaxis[p], cv_aimaxis[p].defaultvalue);
|
||||
CV_StealthSet(&cv_lookaxis[p], cv_lookaxis[p].defaultvalue);
|
||||
CV_StealthSet(&cv_fireaxis[p], cv_fireaxis[p].defaultvalue);
|
||||
CV_StealthSet(&cv_driftaxis[p], cv_driftaxis[p].defaultvalue);
|
||||
|
||||
S_StartSound(NULL, sfx_s224);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ void Command_LoadConfig_f(void)
|
|||
|
||||
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
|
||||
|
|
@ -534,7 +534,7 @@ void M_FirstLoadConfig(void)
|
|||
|
||||
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
|
||||
|
|
@ -636,15 +636,7 @@ void M_SaveConfig(const char *filename)
|
|||
|
||||
if (!dedicated)
|
||||
{
|
||||
if (tutorialmode && tutorialgcs)
|
||||
{
|
||||
// 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]);
|
||||
}
|
||||
G_SaveKeySetting(f, gamecontrol[0], gamecontrol[1], gamecontrol[2], gamecontrol[3]);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
|
|
|||
|
|
@ -884,11 +884,10 @@ void P_Ticker(boolean run)
|
|||
|
||||
if (demo.recording)
|
||||
{
|
||||
INT32 axis = PlayerJoyAxis(AXISLOOKBACK, 1);
|
||||
G_WriteAllGhostTics();
|
||||
|
||||
if (cv_recordmultiplayerdemos.value && (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE))
|
||||
if ((demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && PlayerInputDown(1, gc_lookback)) || (cv_usejoystick[0].value && axis > 0))
|
||||
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && G_PlayerInputDown(0, gc_lookback, false))
|
||||
demo.savemode = DSM_TITLEENTRY;
|
||||
}
|
||||
else if (demo.playback) // Use Ghost data for consistency checks.
|
||||
|
|
|
|||
|
|
@ -2723,12 +2723,14 @@ void P_InitCameraCmd(void)
|
|||
|
||||
static ticcmd_t *P_CameraCmd(camera_t *cam)
|
||||
{
|
||||
/*
|
||||
INT32 forward, side, axis; //i
|
||||
// these ones used for multiple conditions
|
||||
boolean turnleft, turnright, mouseaiming;
|
||||
boolean invertmouse, lookaxis, usejoystick, kbl;
|
||||
INT32 player_invert;
|
||||
INT32 screen_invert;
|
||||
*/
|
||||
ticcmd_t *cmd = &cameracmd;
|
||||
|
||||
(void)cam;
|
||||
|
|
@ -2736,6 +2738,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
|
|||
if (!demo.playback)
|
||||
return cmd; // empty cmd, no.
|
||||
|
||||
/*
|
||||
kbl = democam.keyboardlook;
|
||||
|
||||
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
|
||||
|
|
@ -2828,8 +2831,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
|
||||
cmd->aiming = 0;
|
||||
|
||||
mousex = mousey = mlooky = 0;
|
||||
|
||||
cmd->forwardmove += (SINT8)forward;
|
||||
cmd->sidemove += (SINT8)side;
|
||||
|
||||
|
|
@ -2849,6 +2850,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
|
|||
cmd->turning = -KART_FULLTURN;
|
||||
|
||||
democam.keyboardlook = kbl;
|
||||
*/
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -541,13 +541,14 @@ static inline void SDLJoyRemap(event_t *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
|
||||
INT32 raxis = axis/32;
|
||||
|
||||
if (which == ev_joystick)
|
||||
{
|
||||
if (Joystick[0].bGamepadStyle)
|
||||
if (Joystick[pid].bGamepadStyle)
|
||||
{
|
||||
// gamepad control type, on or off, live or die
|
||||
if (raxis < -(JOYAXISRANGE/2))
|
||||
|
|
@ -559,7 +560,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
|||
}
|
||||
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
|
||||
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
|
||||
|
|
@ -567,69 +568,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
|||
#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;
|
||||
}
|
||||
|
||||
|
|
@ -702,7 +641,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
|
@ -715,6 +654,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||
{
|
||||
event_t event;
|
||||
|
||||
event.device = 0; // TODO: properly set a device
|
||||
|
||||
if (type == SDL_KEYUP)
|
||||
{
|
||||
event.type = ev_keyup;
|
||||
|
|
@ -796,6 +738,8 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
|||
/// \todo inputEvent.button.which
|
||||
if (USE_MOUSEINPUT)
|
||||
{
|
||||
event.device = 0; // TODO: properly set a device
|
||||
|
||||
if (type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
event.type = ev_keyup;
|
||||
|
|
@ -828,6 +772,8 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
|||
|
||||
SDL_memset(&event, 0, sizeof(event_t));
|
||||
|
||||
event.device = 0; // TODO: properly set a device
|
||||
|
||||
if (evt.y > 0)
|
||||
{
|
||||
event.data1 = KEY_MOUSEWHEELUP;
|
||||
|
|
@ -854,65 +800,55 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
|||
event_t event;
|
||||
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
|
||||
UINT8 i;
|
||||
INT32 value;
|
||||
|
||||
event.device = INT32_MAX;
|
||||
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
||||
event.type = ev_joystick;
|
||||
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev));
|
||||
|
||||
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
||||
if (evt.which == joyid[i])
|
||||
{
|
||||
event.device = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.which == joyid[0])
|
||||
if (event.device == INT32_MAX)
|
||||
{
|
||||
event.type = ev_joystick;
|
||||
}
|
||||
else if (evt.which == joyid[1])
|
||||
{
|
||||
event.type = ev_joystick2;
|
||||
}
|
||||
else if (evt.which == joyid[2])
|
||||
{
|
||||
event.type = ev_joystick3;
|
||||
}
|
||||
else if (evt.which == joyid[3])
|
||||
{
|
||||
event.type = ev_joystick4;
|
||||
}
|
||||
else return;
|
||||
//axis
|
||||
if (evt.axis > JOYAXISSET*2)
|
||||
return;
|
||||
//value
|
||||
value = SDLJoyAxis(evt.value, event.type);
|
||||
}
|
||||
|
||||
//axis
|
||||
switch (evt.axis)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
event.data1 = 0;
|
||||
event.data2 = value;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
event.data1 = 0;
|
||||
event.data3 = value;
|
||||
event.data1 = 1;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||
event.data1 = 1;
|
||||
event.data2 = value;
|
||||
event.data1 = 2;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||
event.data1 = 1;
|
||||
event.data3 = value;
|
||||
event.data1 = 3;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
event.data1 = 2;
|
||||
event.data2 = value;
|
||||
event.data1 = 4;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
event.data1 = 2;
|
||||
event.data3 = value;
|
||||
event.data1 = 5;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
//value
|
||||
event.data2 = SDLJoyAxis(evt.value, event.type, event.device);
|
||||
|
||||
D_PostEvent(&event);
|
||||
}
|
||||
|
||||
|
|
@ -923,30 +859,30 @@ static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
|
|||
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
|
||||
UINT8 i;
|
||||
|
||||
event.device = INT32_MAX;
|
||||
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
|
||||
|
||||
if (evt.hat >= JOYHATS)
|
||||
return; // ignore hats with too high an index
|
||||
if (evt.which == joyid[i])
|
||||
{
|
||||
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_3HAT1 + (evt.hat*4);
|
||||
}
|
||||
else if (evt.which == joyid[3])
|
||||
{
|
||||
event.data1 = KEY_4HAT1 + (evt.hat*4);
|
||||
}
|
||||
else return;
|
||||
|
||||
event.data1 = KEY_HAT1 + (evt.hat*4);
|
||||
|
||||
// NOTE: UNFINISHED
|
||||
}
|
||||
|
|
@ -958,9 +894,19 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
|||
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
|
||||
UINT8 i;
|
||||
|
||||
event.device = INT32_MAX;
|
||||
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
||||
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev));
|
||||
|
||||
if (evt.which == joyid[i])
|
||||
{
|
||||
event.device = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP
|
||||
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN
|
||||
|
|
@ -971,23 +917,11 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
|||
return;
|
||||
}
|
||||
|
||||
if (evt.which == joyid[0])
|
||||
if (event.device == INT32_MAX)
|
||||
{
|
||||
event.data1 = KEY_JOY1;
|
||||
return;
|
||||
}
|
||||
else if (evt.which == joyid[1])
|
||||
{
|
||||
event.data1 = KEY_2JOY1;
|
||||
}
|
||||
else if (evt.which == joyid[2])
|
||||
{
|
||||
event.data1 = KEY_3JOY1;
|
||||
}
|
||||
else if (evt.which == joyid[3])
|
||||
{
|
||||
event.data1 = KEY_4JOY1;
|
||||
}
|
||||
else return;
|
||||
|
||||
if (type == SDL_CONTROLLERBUTTONUP)
|
||||
{
|
||||
event.type = ev_keyup;
|
||||
|
|
@ -996,15 +930,26 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
|||
{
|
||||
event.type = ev_keydown;
|
||||
}
|
||||
else return;
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.button < JOYBUTTONS)
|
||||
{
|
||||
event.data1 += evt.button;
|
||||
event.data1 = KEY_JOY1 + evt.button;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
else return;
|
||||
|
||||
SDLJoyRemap(&event);
|
||||
if (event.type != ev_console) D_PostEvent(&event);
|
||||
|
||||
if (event.type != ev_console)
|
||||
{
|
||||
D_PostEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1221,6 +1166,7 @@ void I_GetEvent(void)
|
|||
SDL_GetWindowSize(window, &wwidth, &wheight);
|
||||
//SDL_memset(&event, 0, sizeof(event_t));
|
||||
event.type = ev_mouse;
|
||||
event.device = 0; // TODO device
|
||||
event.data1 = 0;
|
||||
event.data2 = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth));
|
||||
event.data3 = (INT32)lround(mousemovey * ((float)wheight / (float)realheight));
|
||||
|
|
@ -1229,7 +1175,10 @@ void I_GetEvent(void)
|
|||
|
||||
// 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.
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
#include "lua_hudlib_drawlist.h"
|
||||
|
||||
#include "m_random.h" // M_RandomKey
|
||||
#include "g_input.h" // PlayerInputDown
|
||||
#include "g_input.h" // G_PlayerInputDown
|
||||
#include "k_battle.h"
|
||||
#include "k_boss.h"
|
||||
#include "k_pwrlv.h"
|
||||
|
|
@ -831,9 +831,7 @@ void Y_Ticker(void)
|
|||
|
||||
if (demo.recording)
|
||||
{
|
||||
INT32 axis = PlayerJoyAxis(AXISLOOKBACK, 1);
|
||||
|
||||
if (demo.savemode == DSM_NOTSAVING && (PlayerInputDown(1, gc_lookback) || (cv_usejoystick->value && axis > 0)))
|
||||
if (demo.savemode == DSM_NOTSAVING && G_PlayerInputDown(0, gc_lookback, false))
|
||||
demo.savemode = DSM_TITLEENTRY;
|
||||
|
||||
if (demo.savemode == DSM_WILLSAVE || demo.savemode == DSM_WILLAUTOSAVE)
|
||||
|
|
@ -1646,13 +1644,13 @@ void Y_VoteTicker(void)
|
|||
&& !voteclient.playerinfo[i].delay
|
||||
&& pickedvote == -1 && votes[p] == -1)
|
||||
{
|
||||
if (PlayerInputDown(i+1, gc_aimforward) || PlayerJoyAxis(i+1, AXISAIM) < 0)
|
||||
if (G_PlayerInputDown(i, gc_aimforward, false))
|
||||
{
|
||||
voteclient.playerinfo[i].selection--;
|
||||
pressed = true;
|
||||
}
|
||||
|
||||
if ((PlayerInputDown(i+1, gc_aimbackward) || PlayerJoyAxis(i+1, AXISAIM) > 0) && !pressed)
|
||||
if (G_PlayerInputDown(i, gc_aimbackward, false) && pressed == false)
|
||||
{
|
||||
voteclient.playerinfo[i].selection++;
|
||||
pressed = true;
|
||||
|
|
@ -1663,7 +1661,7 @@ void Y_VoteTicker(void)
|
|||
if (voteclient.playerinfo[i].selection > 3)
|
||||
voteclient.playerinfo[i].selection = 0;
|
||||
|
||||
if ((PlayerInputDown(i+1, gc_accelerate) || PlayerJoyAxis(i+1, AXISMOVE) > 0) && !pressed)
|
||||
if (G_PlayerInputDown(i, gc_accelerate, false) && pressed == false)
|
||||
{
|
||||
D_ModifyClientVote(consoleplayer, voteclient.playerinfo[i].selection, i);
|
||||
pressed = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue