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/heretic/g_game.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/heretic') diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index 64186769..3b86fa6b 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -195,6 +195,7 @@ int dclicktime2, dclickstate2, dclicks2; #define MAX_JOY_BUTTONS 20 int joyxmove, joyymove; // joystick values are repeated +int joystrafemove; boolean joyarray[MAX_JOY_BUTTONS + 1]; boolean *joybuttons = &joyarray[1]; // allow [-1] @@ -379,10 +380,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) if (joyymove > 0) forward -= forwardmove[speed]; if (gamekeydown[key_straferight] || mousebuttons[mousebstraferight] - || joybuttons[joybstraferight]) + || joybuttons[joybstraferight] || joystrafemove > 0) side += sidemove[speed]; if (gamekeydown[key_strafeleft] || mousebuttons[mousebstrafeleft] - || joybuttons[joybstrafeleft]) + || joybuttons[joybstrafeleft] || joystrafemove < 0) side -= sidemove[speed]; // Look up/down/center keys @@ -663,7 +664,7 @@ void G_DoLoadLevel(void) // memset(gamekeydown, 0, sizeof(gamekeydown)); - joyxmove = joyymove = 0; + joyxmove = joyymove = joystrafemove = 0; mousex = mousey = 0; sendpause = sendsave = paused = false; memset(mousearray, 0, sizeof(mousearray)); @@ -879,6 +880,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