From 74e1b8b7548e6d14eb9be748279e8100a766cf04 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 19 Apr 2014 01:12:13 -0400 Subject: joystick: Add an axis to allow strafing. Modern gamepads typically have 2-3 D-pads and joysticks. This means that it's desirable to be able to use one joystick for turning and another for strafing. Add another axis in addition to the current X and y axes that performs strafe movement. --- src/strife/g_game.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/strife/g_game.c') diff --git a/src/strife/g_game.c b/src/strife/g_game.c index c67d7be1..f90034ff 100644 --- a/src/strife/g_game.c +++ b/src/strife/g_game.c @@ -226,6 +226,7 @@ static int dclicks2; // joystick values are repeated static int joyxmove; static int joyymove; +static int joystrafemove; static boolean joyarray[MAX_JOY_BUTTONS + 1]; static boolean *joybuttons = &joyarray[1]; // allow [-1] @@ -468,14 +469,16 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic) if (gamekeydown[key_strafeleft] || joybuttons[joybstrafeleft] - || mousebuttons[mousebstrafeleft]) + || mousebuttons[mousebstrafeleft] + || joystrafemove < 0) { side -= sidemove[speed]; } if (gamekeydown[key_straferight] || joybuttons[joybstraferight] - || mousebuttons[mousebstraferight]) + || mousebuttons[mousebstraferight] + || joystrafemove > 0) { side += sidemove[speed]; } @@ -699,12 +702,12 @@ void G_DoLoadLevel (void) // clear cmd building stuff - memset (gamekeydown, 0, sizeof(gamekeydown)); - joyxmove = joyymove = 0; - mousex = mousey = 0; - sendpause = sendsave = paused = false; - memset(mousearray, 0, sizeof(mousearray)); - memset(joyarray, 0, sizeof(joyarray)); + memset (gamekeydown, 0, sizeof(gamekeydown)); + joyxmove = joyymove = joystrafemove = 0; + mousex = mousey = 0; + sendpause = sendsave = paused = false; + memset(mousearray, 0, sizeof(mousearray)); + memset(joyarray, 0, sizeof(joyarray)); if (testcontrols) { @@ -880,6 +883,7 @@ boolean G_Responder (event_t* ev) SetJoyButtons(ev->data1); joyxmove = ev->data2; joyymove = ev->data3; + joystrafemove = ev->data4; return true; // eat events default: -- cgit v1.2.3