From f3d3b03870a6842e104c67ce6fc7edfde89d77ec Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 9 Aug 2010 17:53:10 +0000 Subject: Add weapon cycling bindings for mouse and joystick buttons. Add weapon cycling bindings to configuration file and setup tool. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1953 --- src/g_game.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- src/m_config.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index 1e163716..bf9560db 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -198,6 +198,9 @@ int mousebstraferight = -1; int mousebbackward = -1; int mousebuse = -1; +int mousebprevweapon = -1; +int mousebnextweapon = -1; + // Control whether if a mouse button is double clicked, it acts like // "use" has been pressed @@ -210,6 +213,9 @@ int joybspeed = 2; int joybstrafeleft = -1; int joybstraferight = -1; +int joybprevweapon = -1; +int joybnextweapon = -1; + // fraggle: Disallow mouse and joystick movement to cause forward/backward // motion. Specified with the '-novert' command line parameter. // This is an int to allow saving to config file @@ -262,11 +268,13 @@ static const struct #define SLOWTURNTICS 6 #define NUMKEYS 256 +#define MAX_JOY_BUTTONS 20 +#define MAX_MOUSE_BUTTONS 3 static boolean gamekeydown[NUMKEYS]; static int turnheld; // for accelerative turning -static boolean mousearray[4]; +static boolean mousearray[MAX_MOUSE_BUTTONS + 1]; static boolean *mousebuttons = &mousearray[1]; // allow [-1] // mouse values are used once @@ -280,8 +288,6 @@ static int dclicktime2; static boolean dclickstate2; static int dclicks2; -#define MAX_JOY_BUTTONS 20 - // joystick values are repeated static int joyxmove; static int joyymove; @@ -815,7 +821,6 @@ void G_DoLoadLevel (void) players[consoleplayer].message = "Press escape to quit."; } } - static void SetJoyButtons(unsigned int buttons_mask) { @@ -823,10 +828,54 @@ static void SetJoyButtons(unsigned int buttons_mask) for (i=0; idata1 & 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/m_config.c b/src/m_config.c index b2e52e7f..2065700e 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -148,6 +148,8 @@ extern int key_weapon5; extern int key_weapon6; extern int key_weapon7; extern int key_weapon8; +extern int key_prevweapon; +extern int key_nextweapon; extern int key_message_refresh; extern int key_demo_quit; @@ -164,6 +166,9 @@ extern int mousebstraferight; extern int mousebbackward; extern int mousebuse; +extern int mousebprevweapon; +extern int mousebnextweapon; + extern int dclick_use; extern int joybfire; @@ -173,6 +178,9 @@ extern int joybspeed; extern int joybstrafeleft; extern int joybstraferight; +extern int joybprevweapon; +extern int joybnextweapon; + extern int viewwidth; extern int viewheight; @@ -747,6 +755,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(joyb_straferight, joybstraferight), + //! + // Joystick button to cycle to the previous weapon. + // + + CONFIG_VARIABLE_INT(joyb_prevweapon, joybprevweapon), + + //! + // Joystick button to cycle to the next weapon. + // + + CONFIG_VARIABLE_INT(joyb_nextweapon, joybnextweapon), + //! // Mouse button to strafe left. // @@ -771,6 +791,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(mouseb_backward, mousebbackward), + //! + // Mouse button to cycle to the previous weapon. + // + + CONFIG_VARIABLE_INT(mouseb_prevweapon, mousebprevweapon), + + //! + // Mouse button to cycle to the next weapon. + // + + CONFIG_VARIABLE_INT(mouseb_nextweapon, mousebnextweapon), + //! // If non-zero, double-clicking a mouse button acts like pressing // the "use" key to use an object in-game, eg. a door or switch. @@ -1061,6 +1093,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_KEY(key_weapon8, key_weapon8), + //! + // Key to cycle to the previous weapon. + // + + CONFIG_VARIABLE_KEY(key_prevweapon, key_prevweapon), + + //! + // Key to cycle to the next weapon. + // + + CONFIG_VARIABLE_KEY(key_nextweapon, key_nextweapon), + //! // Key to re-display last message. // -- cgit v1.2.3