commit 18a8d8a3b2ab7eeade733bd587531b4dac830a29
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Sep 28 17:16:51 2008 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Sun Sep 28 17:16:51 2008 +0000
Expand number of joystick buttons supported by Heretic to the number
supported by Chocolate Doom.
Subversion-branch: /branches/raven-branch
Subversion-revision: 1304
---
src/heretic/g_game.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c
index 364d25ea..54218087 100644
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -164,7 +164,7 @@ int dclicktime2, dclickstate2, dclicks2;
#define MAX_JOY_BUTTONS 20
int joyxmove, joyymove; // joystick values are repeated
-boolean joyarray[5];
+boolean joyarray[MAX_JOY_BUTTONS + 1];
boolean *joybuttons = &joyarray[1]; // allow [-1]
int savegameslot;
@@ -774,6 +774,15 @@ void G_DoLoadLevel(void)
memset(joybuttons, 0, sizeof(joybuttons));
}
+static void SetJoyButtons(unsigned int buttons_mask)
+{
+ int i;
+
+ for (i=0; i<MAX_JOY_BUTTONS; ++i)
+ {
+ joybuttons[i] = (buttons_mask & (1 << i)) != 0;
+ }
+}
/*
===============================================================================
@@ -911,10 +920,7 @@ boolean G_Responder(event_t * ev)
return (true); // eat events
case ev_joystick:
- joybuttons[0] = ev->data1 & 1;
- joybuttons[1] = ev->data1 & 2;
- joybuttons[2] = ev->data1 & 4;
- joybuttons[3] = ev->data1 & 8;
+ SetJoyButtons(ev->data1);
joyxmove = ev->data2;
joyymove = ev->data3;
return (true); // eat events