diff options
author | Simon Howard | 2013-12-26 08:00:51 -0800 |
---|---|---|
committer | Simon Howard | 2013-12-26 08:00:51 -0800 |
commit | 9ec3bb73ce95b11dbc5cac344acd4bfa22a81181 (patch) | |
tree | 29f30cc466525d6e58a18b771d7c52698ec3d715 | |
parent | b9690ac0bbe2b5af137aeb09261aac4478f3fbf8 (diff) | |
parent | 5a35c4381b1559e5d12709f9692de4984f9c64e6 (diff) | |
download | chocolate-doom-9ec3bb73ce95b11dbc5cac344acd4bfa22a81181.tar.gz chocolate-doom-9ec3bb73ce95b11dbc5cac344acd4bfa22a81181.tar.bz2 chocolate-doom-9ec3bb73ce95b11dbc5cac344acd4bfa22a81181.zip |
Merge pull request #318 from svdijk/bugfix
Heretic/Hexen/Strife bugfixes from Sander van Dijk.
-rw-r--r-- | src/heretic/g_game.c | 52 | ||||
-rw-r--r-- | src/hexen/g_game.c | 64 | ||||
-rw-r--r-- | src/setup/keyboard.c | 2 |
3 files changed, 104 insertions, 14 deletions
diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index e9302e83..20858cb7 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -185,7 +185,7 @@ int turnheld; // for accelerative turning int lookheld; -boolean mousearray[4]; +boolean mousearray[MAX_MOUSE_BUTTONS + 1]; boolean *mousebuttons = &mousearray[1]; // allow [-1] int mousex, mousey; // mouse values are used once @@ -681,7 +681,51 @@ static void SetJoyButtons(unsigned int buttons_mask) for (i=0; i<MAX_JOY_BUTTONS; ++i) { - joybuttons[i] = (buttons_mask & (1 << i)) != 0; + int button_on = (buttons_mask & (1 << i)) != 0; + + // Detect button press: + + if (!joybuttons[i] && button_on) + { + // Weapon cycling: + + if (i == joybprevweapon) + { + next_weapon = -1; + } + else if (i == joybnextweapon) + { + next_weapon = 1; + } + } + + joybuttons[i] = button_on; + } +} + +static void SetMouseButtons(unsigned int buttons_mask) +{ + int i; + + for (i=0; i<MAX_MOUSE_BUTTONS; ++i) + { + unsigned int button_on = (buttons_mask & (1 << i)) != 0; + + // Detect button press: + + if (!mousebuttons[i] && button_on) + { + if (i == mousebprevweapon) + { + next_weapon = -1; + } + else if (i == mousebnextweapon) + { + next_weapon = 1; + } + } + + mousebuttons[i] = button_on; } } @@ -826,9 +870,7 @@ boolean G_Responder(event_t * ev) return (false); // always let key up events filter down case ev_mouse: - mousebuttons[0] = ev->data1 & 1; - mousebuttons[1] = ev->data1 & 2; - mousebuttons[2] = ev->data1 & 4; + SetMouseButtons(ev->data1); mousex = ev->data2 * (mouseSensitivity + 5) / 10; mousey = ev->data3 * (mouseSensitivity + 5) / 10; return (true); // eat events diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index a304d0f6..a448134b 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -152,7 +152,7 @@ int turnheld; // for accelerative turning int lookheld; -boolean mousearray[4]; +boolean mousearray[MAX_MOUSE_BUTTONS + 1]; boolean *mousebuttons = &mousearray[1]; // allow [-1] int mousex, mousey; // mouse values are used once @@ -671,6 +671,59 @@ void G_DoLoadLevel(void) } } +static void SetJoyButtons(unsigned int buttons_mask) +{ + int i; + + for (i=0; i<MAX_JOY_BUTTONS; ++i) + { + int button_on = (buttons_mask & (1 << i)) != 0; + + // Detect button press: + + if (!joybuttons[i] && button_on) + { + // Weapon cycling: + + if (i == joybprevweapon) + { + next_weapon = -1; + } + else if (i == joybnextweapon) + { + next_weapon = 1; + } + } + + joybuttons[i] = button_on; + } +} + +static void SetMouseButtons(unsigned int buttons_mask) +{ + int i; + + for (i=0; i<MAX_MOUSE_BUTTONS; ++i) + { + unsigned int button_on = (buttons_mask & (1 << i)) != 0; + + // Detect button press: + + if (!mousebuttons[i] && button_on) + { + if (i == mousebprevweapon) + { + next_weapon = -1; + } + else if (i == mousebnextweapon) + { + next_weapon = 1; + } + } + + mousebuttons[i] = button_on; + } +} /* =============================================================================== @@ -814,18 +867,13 @@ boolean G_Responder(event_t * ev) return (false); // always let key up events filter down case ev_mouse: - mousebuttons[0] = ev->data1 & 1; - mousebuttons[1] = ev->data1 & 2; - mousebuttons[2] = ev->data1 & 4; + SetMouseButtons(ev->data1); mousex = ev->data2 * (mouseSensitivity + 5) / 10; mousey = ev->data3 * (mouseSensitivity + 5) / 10; 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 diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index 6b1667e1..0e576870 100644 --- a/src/setup/keyboard.c +++ b/src/setup/keyboard.c @@ -43,7 +43,7 @@ static int *controls[] = { &key_left, &key_right, &key_up, &key_down, &key_flyup, &key_flydown, &key_flycenter, &key_lookup, &key_lookdown, &key_lookcenter, &key_invleft, &key_invright, &key_invquery, - &key_invuse, &key_invpop, &key_invkey, + &key_invuse, &key_invpop, &key_mission, &key_invkey, &key_invhome, &key_invend, &key_invdrop, &key_useartifact, &key_pause, &key_usehealth, &key_weapon1, &key_weapon2, &key_weapon3, |