ref: 18a8d8a3b2ab7eeade733bd587531b4dac830a29
parent: 0c74071858b7dc8df708519b1efffbf18d6ad954
author: Simon Howard <fraggle@gmail.com>
date: Sun Sep 28 13:16:51 EDT 2008
Expand number of joystick buttons supported by Heretic to the number supported by Chocolate Doom. Subversion-branch: /branches/raven-branch Subversion-revision: 1304
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -164,7 +164,7 @@
#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,7 +774,16 @@
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 @@
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