mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 05:11:34 +00:00
Merge branch 'joystick-juggling-two' into 'next'
Joystick additions for menu, axis defaults, and vertical look toggle See merge request STJr/SRB2!359
This commit is contained in:
commit
42cb597731
3 changed files with 73 additions and 46 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "g_game.h"
|
||||
#include "hu_stuff.h"
|
||||
#include "keys.h"
|
||||
#include "g_input.h" // JOY1
|
||||
#include "m_menu.h"
|
||||
#include "console.h"
|
||||
#include "d_netfil.h"
|
||||
|
@ -1959,7 +1960,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
|
|||
|
||||
I_OsPolling();
|
||||
key = I_GetKey();
|
||||
if (key == KEY_ESCAPE)
|
||||
if (key == KEY_ESCAPE || key == KEY_JOY1+1)
|
||||
{
|
||||
CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
|
||||
// M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
|
|
38
src/g_game.c
38
src/g_game.c
|
@ -387,7 +387,7 @@ consvar_t cv_lookaxis = {"joyaxis_look", "RStick.Y", CV_SAVE, joyaxis_cons_t, NU
|
|||
consvar_t cv_fireaxis = {"joyaxis_fire", "LAnalog", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_firenaxis = {"joyaxis_firenormal", "RAnalog", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#else
|
||||
consvar_t cv_turnaxis = {"joyaxis_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_turnaxis = {"joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#ifdef PSP
|
||||
consvar_t cv_moveaxis = {"joyaxis_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#else
|
||||
|
@ -401,17 +401,17 @@ consvar_t cv_lookaxis = {"joyaxis_look", "Alt Y-Axis", CV_SAVE, joyaxis_cons_t,
|
|||
#elif defined (PSP)
|
||||
consvar_t cv_sideaxis = {"joyaxis_side", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#else
|
||||
consvar_t cv_sideaxis = {"joyaxis_side", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_sideaxis = {"joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
#ifndef _XBOX
|
||||
#ifdef PSP
|
||||
consvar_t cv_lookaxis = {"joyaxis_look", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#else
|
||||
consvar_t cv_lookaxis = {"joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_lookaxis = {"joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
#endif
|
||||
consvar_t cv_fireaxis = {"joyaxis_fire", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_firenaxis = {"joyaxis_firenormal", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
#if defined (_WII) || defined (WMINPUT)
|
||||
|
@ -960,13 +960,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
|||
INT32 tspeed, forward, side, axis, i;
|
||||
const INT32 speed = 1;
|
||||
// these ones used for multiple conditions
|
||||
boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove;
|
||||
boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming;
|
||||
player_t *player = &players[consoleplayer];
|
||||
camera_t *thiscam = &camera;
|
||||
|
||||
static INT32 turnheld; // for accelerative turning
|
||||
static boolean keyboard_look; // true if lookup/down using keyboard
|
||||
static boolean resetdown; // don't cam reset every frame
|
||||
static boolean joyaiming; // check the last frame's value if we need to reset the camera
|
||||
|
||||
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
|
||||
|
||||
|
@ -986,6 +987,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
|||
analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle;
|
||||
gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle;
|
||||
|
||||
thisjoyaiming = (cv_chasecam.value) ? cv_chasefreelook.value : cv_alwaysfreelook.value;
|
||||
|
||||
// Reset the vertical look if we're no longer joyaiming
|
||||
if (!thisjoyaiming && joyaiming)
|
||||
localaiming = 0;
|
||||
joyaiming = thisjoyaiming;
|
||||
|
||||
axis = JoyAxis(AXISTURN);
|
||||
if (gamepadjoystickmove && axis != 0)
|
||||
{
|
||||
|
@ -1161,11 +1169,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
|||
}
|
||||
|
||||
axis = JoyAxis(AXISLOOK);
|
||||
if (analogjoystickmove && axis != 0 && cv_lookaxis.value != 0)
|
||||
if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis.value != 0)
|
||||
localaiming += (axis<<16) * screen_invert;
|
||||
|
||||
// spring back if not using keyboard neither mouselookin'
|
||||
if (!keyboard_look && cv_lookaxis.value == 0 && !mouseaiming)
|
||||
if (!keyboard_look && cv_lookaxis.value == 0 && !joyaiming && !mouseaiming)
|
||||
localaiming = 0;
|
||||
|
||||
if (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0))
|
||||
|
@ -1252,13 +1260,14 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
|||
INT32 tspeed, forward, side, axis, i;
|
||||
const INT32 speed = 1;
|
||||
// these ones used for multiple conditions
|
||||
boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove;
|
||||
boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming;
|
||||
player_t *player = &players[secondarydisplayplayer];
|
||||
camera_t *thiscam = (player->bot == 2 ? &camera : &camera2);
|
||||
|
||||
static INT32 turnheld; // for accelerative turning
|
||||
static boolean keyboard_look; // true if lookup/down using keyboard
|
||||
static boolean resetdown; // don't cam reset every frame
|
||||
static boolean joyaiming; // check the last frame's value if we need to reset the camera
|
||||
|
||||
G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver
|
||||
|
||||
|
@ -1278,6 +1287,13 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
|||
analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle;
|
||||
gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle;
|
||||
|
||||
thisjoyaiming = (cv_chasecam2.value) ? cv_chasefreelook2.value : cv_alwaysfreelook2.value;
|
||||
|
||||
// Reset the vertical look if we're no longer joyaiming
|
||||
if (!thisjoyaiming && joyaiming)
|
||||
localaiming2 = 0;
|
||||
joyaiming = thisjoyaiming;
|
||||
|
||||
axis = Joy2Axis(AXISTURN);
|
||||
if (gamepadjoystickmove && axis != 0)
|
||||
{
|
||||
|
@ -1450,11 +1466,11 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
|||
}
|
||||
|
||||
axis = Joy2Axis(AXISLOOK);
|
||||
if (analogjoystickmove && axis != 0 && cv_lookaxis2.value != 0)
|
||||
if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis2.value != 0)
|
||||
localaiming2 += (axis<<16) * screen_invert;
|
||||
|
||||
// spring back if not using keyboard neither mouselookin'
|
||||
if (!keyboard_look && cv_lookaxis2.value == 0 && !mouseaiming)
|
||||
if (!keyboard_look && cv_lookaxis2.value == 0 && !joyaiming && !mouseaiming)
|
||||
localaiming2 = 0;
|
||||
|
||||
if (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0))
|
||||
|
|
78
src/m_menu.c
78
src/m_menu.c
|
@ -1089,6 +1089,9 @@ static menuitem_t OP_Joystick1Menu[] =
|
|||
{IT_STRING | IT_CVAR, NULL, "Axis For Looking" , &cv_lookaxis , 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Axis For Firing" , &cv_fireaxis , 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Axis For NFiring" , &cv_firenaxis , 80},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 110},
|
||||
};
|
||||
|
||||
static menuitem_t OP_Joystick2Menu[] =
|
||||
|
@ -1100,6 +1103,9 @@ static menuitem_t OP_Joystick2Menu[] =
|
|||
{IT_STRING | IT_CVAR, NULL, "Axis For Looking" , &cv_lookaxis2 , 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Axis For Firing" , &cv_fireaxis2 , 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Axis For NFiring" , &cv_firenaxis2 , 80},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2, 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 110},
|
||||
};
|
||||
|
||||
static menuitem_t OP_JoystickSetMenu[] =
|
||||
|
@ -2083,42 +2089,44 @@ boolean M_Responder(event_t *ev)
|
|||
// (but still allow shift keyup so caps doesn't get stuck)
|
||||
return false;
|
||||
}
|
||||
else if (ev->type == ev_keydown)
|
||||
{
|
||||
ch = ev->data1;
|
||||
|
||||
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
||||
switch (ch)
|
||||
{
|
||||
case KEY_MOUSE1:
|
||||
case KEY_JOY1:
|
||||
case KEY_JOY1 + 2:
|
||||
ch = KEY_ENTER;
|
||||
break;
|
||||
case KEY_JOY1 + 3:
|
||||
ch = 'n';
|
||||
break;
|
||||
case KEY_MOUSE1 + 1:
|
||||
case KEY_JOY1 + 1:
|
||||
ch = KEY_BACKSPACE;
|
||||
break;
|
||||
case KEY_HAT1:
|
||||
ch = KEY_UPARROW;
|
||||
break;
|
||||
case KEY_HAT1 + 1:
|
||||
ch = KEY_DOWNARROW;
|
||||
break;
|
||||
case KEY_HAT1 + 2:
|
||||
ch = KEY_LEFTARROW;
|
||||
break;
|
||||
case KEY_HAT1 + 3:
|
||||
ch = KEY_RIGHTARROW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (menuactive)
|
||||
{
|
||||
if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
|
||||
if (ev->type == ev_keydown)
|
||||
{
|
||||
ch = ev->data1;
|
||||
|
||||
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
||||
switch (ch)
|
||||
{
|
||||
case KEY_MOUSE1:
|
||||
case KEY_JOY1:
|
||||
ch = KEY_ENTER;
|
||||
break;
|
||||
case KEY_JOY1 + 3:
|
||||
ch = 'n';
|
||||
break;
|
||||
case KEY_MOUSE1 + 1:
|
||||
case KEY_JOY1 + 1:
|
||||
ch = KEY_ESCAPE;
|
||||
break;
|
||||
case KEY_JOY1 + 2:
|
||||
ch = KEY_BACKSPACE;
|
||||
break;
|
||||
case KEY_HAT1:
|
||||
ch = KEY_UPARROW;
|
||||
break;
|
||||
case KEY_HAT1 + 1:
|
||||
ch = KEY_DOWNARROW;
|
||||
break;
|
||||
case KEY_HAT1 + 2:
|
||||
ch = KEY_LEFTARROW;
|
||||
break;
|
||||
case KEY_HAT1 + 3:
|
||||
ch = KEY_RIGHTARROW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
|
||||
{
|
||||
if (ev->data3 == -1)
|
||||
{
|
||||
|
@ -2173,6 +2181,8 @@ boolean M_Responder(event_t *ev)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (ev->type == ev_keydown) // Preserve event for other responders
|
||||
ch = ev->data1;
|
||||
|
||||
if (ch == -1)
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue