summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup/configfile.c6
-rw-r--r--setup/joystick.c4
-rw-r--r--setup/joystick.h2
-rw-r--r--setup/keyboard.c7
-rw-r--r--setup/keyboard.h2
-rw-r--r--setup/mouse.c6
-rw-r--r--setup/mouse.h2
-rw-r--r--setup/txt_keyinput.c2
-rw-r--r--src/g_game.c65
-rw-r--r--src/m_config.c44
10 files changed, 129 insertions, 11 deletions
diff --git a/setup/configfile.c b/setup/configfile.c
index 5fe1d958..2a3cb845 100644
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -286,11 +286,15 @@ static default_t extra_defaults_list[] =
{"joystick_y_invert", &joystick_y_invert, DEFAULT_INT, 0, 0},
{"joyb_strafeleft", &joybstrafeleft, DEFAULT_INT, 0, 0},
{"joyb_straferight", &joybstraferight, DEFAULT_INT, 0, 0},
+ {"joyb_prevweapon", &joybprevweapon, DEFAULT_INT, 0, 0},
+ {"joyb_nextweapon", &joybnextweapon, DEFAULT_INT, 0, 0},
{"dclick_use", &dclick_use, DEFAULT_INT, 0, 0},
{"mouseb_strafeleft", &mousebstrafeleft, DEFAULT_INT, 0, 0},
{"mouseb_straferight", &mousebstraferight, DEFAULT_INT, 0, 0},
{"mouseb_use", &mousebuse, DEFAULT_INT, 0, 0},
{"mouseb_backward", &mousebbackward, DEFAULT_INT, 0, 0},
+ {"mouseb_prevweapon", &mousebprevweapon, DEFAULT_INT, 0, 0},
+ {"mouseb_nextweapon", &mousebnextweapon, DEFAULT_INT, 0, 0},
{"use_libsamplerate", &use_libsamplerate, DEFAULT_INT, 0, 0},
{"key_pause", &key_pause, DEFAULT_KEY, 0, 0},
@@ -338,6 +342,8 @@ static default_t extra_defaults_list[] =
{"key_weapon6", &key_weapon6, DEFAULT_KEY, 0, 0},
{"key_weapon7", &key_weapon7, DEFAULT_KEY, 0, 0},
{"key_weapon8", &key_weapon8, DEFAULT_KEY, 0, 0},
+ {"key_prevweapon", &key_prevweapon, DEFAULT_KEY, 0, 0},
+ {"key_nextweapon", &key_nextweapon, DEFAULT_KEY, 0, 0},
{"key_message_refresh", &key_message_refresh, DEFAULT_KEY, 0, 0},
{"key_demo_quit", &key_demo_quit, DEFAULT_KEY, 0, 0},
{"key_multi_msg", &key_multi_msg, DEFAULT_KEY, 0, 0},
diff --git a/setup/joystick.c b/setup/joystick.c
index 867fa5c2..825cd8b5 100644
--- a/setup/joystick.c
+++ b/setup/joystick.c
@@ -50,6 +50,8 @@ int joybuse = 2;
int joybspeed = 3;
int joybstrafeleft = -1;
int joybstraferight = -1;
+int joybprevweapon = -1;
+int joybnextweapon = -1;
// Joystick to use, as an SDL joystick index:
@@ -430,6 +432,8 @@ void ConfigJoystick(void)
AddJoystickControl(button_table, "Strafe Left", &joybstrafeleft);
AddJoystickControl(button_table, "Strafe Right", &joybstraferight);
+ AddJoystickControl(button_table, "Previous weapon", &joybprevweapon);
+ AddJoystickControl(button_table, "Next weapon", &joybnextweapon);
TXT_SignalConnect(joystick_button, "pressed", CalibrateJoystick, NULL);
TXT_SignalConnect(window, "closed", JoystickWindowClosed, NULL);
diff --git a/setup/joystick.h b/setup/joystick.h
index 39cf0bf4..5d3973c5 100644
--- a/setup/joystick.h
+++ b/setup/joystick.h
@@ -29,6 +29,8 @@ extern int joybuse;
extern int joybspeed;
extern int joybstrafeleft;
extern int joybstraferight;
+extern int joybprevweapon;
+extern int joybnextweapon;
extern int joystick_index;
extern int joystick_x_axis;
diff --git a/setup/keyboard.c b/setup/keyboard.c
index bcf5ec7a..81976f85 100644
--- a/setup/keyboard.c
+++ b/setup/keyboard.c
@@ -90,6 +90,8 @@ int key_weapon5 = '5';
int key_weapon6 = '6';
int key_weapon7 = '7';
int key_weapon8 = '8';
+int key_prevweapon = 0;
+int key_nextweapon = 0;
int key_message_refresh = KEY_ENTER;
int key_demo_quit = 'q';
@@ -109,7 +111,8 @@ static int *controls[] = { &key_left, &key_right, &key_up, &key_down,
&key_pause,
&key_weapon1, &key_weapon2, &key_weapon3,
&key_weapon4, &key_weapon5, &key_weapon6,
- &key_weapon7, &key_weapon8, NULL };
+ &key_weapon7, &key_weapon8,
+ &key_prevweapon, &key_nextweapon, NULL };
static int *menu_nav[] = { &key_menu_activate, &key_menu_up, &key_menu_down,
&key_menu_left, &key_menu_right, &key_menu_back,
@@ -240,6 +243,8 @@ static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
AddKeyControl(table, "Weapon 6", &key_weapon6);
AddKeyControl(table, "Weapon 7", &key_weapon7);
AddKeyControl(table, "Weapon 8", &key_weapon8);
+ AddKeyControl(table, "Previous weapon", &key_prevweapon);
+ AddKeyControl(table, "Next weapon", &key_nextweapon);
TXT_AddWidgets(table, TXT_NewStrut(0, 1),
TXT_NewStrut(0, 1),
diff --git a/setup/keyboard.h b/setup/keyboard.h
index f934116f..73510861 100644
--- a/setup/keyboard.h
+++ b/setup/keyboard.h
@@ -95,6 +95,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;
diff --git a/setup/mouse.c b/setup/mouse.c
index 49266d48..559231b0 100644
--- a/setup/mouse.c
+++ b/setup/mouse.c
@@ -44,6 +44,8 @@ int mousebstrafeleft = -1;
int mousebstraferight = -1;
int mousebbackward = -1;
int mousebuse = -1;
+int mousebprevweapon = -1;
+int mousebnextweapon = -1;
int dclick_use = 1;
@@ -55,6 +57,8 @@ static int *all_mouse_buttons[] = {
&mousebstraferight,
&mousebbackward,
&mousebuse,
+ &mousebprevweapon,
+ &mousebnextweapon
};
static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
@@ -104,6 +108,8 @@ static void ConfigExtraButtons(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
AddMouseControl(buttons_table, "Use", &mousebuse);
AddMouseControl(buttons_table, "Strafe left", &mousebstrafeleft);
AddMouseControl(buttons_table, "Strafe right", &mousebstraferight);
+ AddMouseControl(buttons_table, "Previous weapon", &mousebprevweapon);
+ AddMouseControl(buttons_table, "Next weapon", &mousebnextweapon);
}
void ConfigMouse(void)
diff --git a/setup/mouse.h b/setup/mouse.h
index f0a39ade..48270caa 100644
--- a/setup/mouse.h
+++ b/setup/mouse.h
@@ -37,6 +37,8 @@ extern int mousebstraferight;
extern int mousebbackward;
extern int mousebuse;
extern int dclick_use;
+extern int mousebprevweapon;
+extern int mousebnextweapon;
void ConfigMouse(void);
diff --git a/setup/txt_keyinput.c b/setup/txt_keyinput.c
index e385cc59..483c325f 100644
--- a/setup/txt_keyinput.c
+++ b/setup/txt_keyinput.c
@@ -111,7 +111,7 @@ static void TXT_KeyInputDrawer(TXT_UNCAST_ARG(key_input), int selected)
if (*key_input->variable == 0)
{
- strcpy(buf, "");
+ strcpy(buf, "(none)");
}
else
{
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; 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;
+ }
+}
+
//
// G_Responder
// Get info needed to make ticcmd_ts for the players.
@@ -927,9 +976,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/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;
@@ -748,6 +756,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.
//
@@ -772,6 +792,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.
//
@@ -1062,6 +1094,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.
//