diff options
author | Simon Howard | 2007-06-14 21:15:52 +0000 |
---|---|---|
committer | Simon Howard | 2007-06-14 21:15:52 +0000 |
commit | 5aa5e1fed5f7245a942bbfee43935d58a990deb5 (patch) | |
tree | 7ee513c22d18afe0c80f192364dd1e2d2b2f6de8 /src | |
parent | 66d22ab030630378c2feb57a5d8cd65669713c2a (diff) | |
download | chocolate-doom-5aa5e1fed5f7245a942bbfee43935d58a990deb5.tar.gz chocolate-doom-5aa5e1fed5f7245a942bbfee43935d58a990deb5.tar.bz2 chocolate-doom-5aa5e1fed5f7245a942bbfee43935d58a990deb5.zip |
Support up to 20 joystick buttons. Justification: most modern joysticks
and joypads have many more than four buttons. Keeping the limit at four
buttons restricts the player into using the first four buttons on his
joystick/pad, which could be any arbitrary four set of buttons.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 905
Diffstat (limited to 'src')
-rw-r--r-- | src/g_game.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/g_game.c b/src/g_game.c index dd2c2669..0a2d5862 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -220,10 +220,12 @@ static int dclicktime2; static boolean dclickstate2; static int dclicks2; +#define MAX_JOY_BUTTONS 20 + // joystick values are repeated static int joyxmove; static int joyymove; -static boolean joyarray[5]; +static boolean joyarray[MAX_JOY_BUTTONS + 1]; static boolean *joybuttons = &joyarray[1]; // allow [-1] static int savegameslot; @@ -392,7 +394,7 @@ void G_BuildTiccmd (ticcmd_t* cmd) // allowed an autorun effect speed = key_speed >= NUMKEYS - || joybspeed >= 20 + || joybspeed >= MAX_JOY_BUTTONS || gamekeydown[key_speed] || joybuttons[joybspeed]; @@ -657,6 +659,16 @@ void G_DoLoadLevel (void) } } + +static void SetJoyButtons(unsigned int buttons_mask) +{ + int i; + + for (i=0; i<MAX_JOY_BUTTONS; ++i) + { + joybuttons[i] = (buttons_mask & (1 << i)) != 0; + } +} // // G_Responder @@ -752,10 +764,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 |