ref: f0b710024a2820cd062163db29fddccc03cdf5a3
parent: 74e1b8b7548e6d14eb9be748279e8100a766cf04
author: Simon Howard <[email protected]>
date: Fri Apr 18 21:35:40 EDT 2014
joystick: Add joystick button to toggle menu. When using a joystick or gamepad it's nice to be able to bring up the menu without having to reach for the keyboard. This makes modern gamepads more useful/usable.
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -1524,6 +1524,11 @@
key = key_menu_back;
joywait = I_GetTime() + 5;
}
+ if (joybmenu >= 0 && (ev->data1 & (1 << joybmenu)) != 0)
+ {
+ key = key_menu_activate;
+ joywait = I_GetTime() + 5;
+ }
}
else
{
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -1080,6 +1080,17 @@
return true;
}
+ // Allow the menu to be activated from a joystick button if a button
+ // is bound for joybmenu.
+ if (event->type == ev_joystick)
+ {
+ if (joybmenu >= 0 && (event->data1 & (1 << joybmenu)) != 0)
+ {
+ MN_ActivateMenu();
+ return true;
+ }
+ }
+
if (event->type != ev_keydown)
{
return false;
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -1175,6 +1175,17 @@
return true;
}
+ // Allow the menu to be activated from a joystick button if a button
+ // is bound for joybmenu.
+ if (event->type == ev_joystick)
+ {
+ if (joybmenu >= 0 && (event->data1 & (1 << joybmenu)) != 0)
+ {
+ MN_ActivateMenu();
+ return true;
+ }
+ }
+
// Only care about keypresses beyond this point.
if (event->type != ev_keydown)
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -951,6 +951,12 @@
CONFIG_VARIABLE_INT(joyb_straferight),
//!
+ // Joystick button to activate the game menu.
+ //
+
+ CONFIG_VARIABLE_INT(joyb_menu_activate),
+
+ //!
// Joystick button to cycle to the previous weapon.
//
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -186,10 +186,10 @@
// Joystick controls
//
-int joybfire = 0;
-int joybstrafe = 1;
-int joybuse = 3;
-int joybspeed = 2;
+int joybfire = 0;
+int joybstrafe = 1;
+int joybuse = 3;
+int joybspeed = 2;
int joybstrafeleft = -1;
int joybstraferight = -1;
@@ -199,6 +199,8 @@
int joybprevweapon = -1;
int joybnextweapon = -1;
+int joybmenu = -1;
+
// Control whether if a mouse button is double clicked, it acts like
// "use" has been pressed
@@ -210,25 +212,27 @@
void M_BindBaseControls(void)
{
- M_BindVariable("key_right", &key_right),
- M_BindVariable("key_left", &key_left),
- M_BindVariable("key_up", &key_up),
- M_BindVariable("key_down", &key_down),
- M_BindVariable("key_strafeleft", &key_strafeleft),
- M_BindVariable("key_straferight", &key_straferight),
- M_BindVariable("key_fire", &key_fire),
- M_BindVariable("key_use", &key_use),
- M_BindVariable("key_strafe", &key_strafe),
- M_BindVariable("key_speed", &key_speed),
+ M_BindVariable("key_right", &key_right);
+ M_BindVariable("key_left", &key_left);
+ M_BindVariable("key_up", &key_up);
+ M_BindVariable("key_down", &key_down);
+ M_BindVariable("key_strafeleft", &key_strafeleft);
+ M_BindVariable("key_straferight", &key_straferight);
+ M_BindVariable("key_fire", &key_fire);
+ M_BindVariable("key_use", &key_use);
+ M_BindVariable("key_strafe", &key_strafe);
+ M_BindVariable("key_speed", &key_speed);
- M_BindVariable("mouseb_fire", &mousebfire),
- M_BindVariable("mouseb_strafe", &mousebstrafe),
- M_BindVariable("mouseb_forward", &mousebforward),
+ M_BindVariable("mouseb_fire", &mousebfire);
+ M_BindVariable("mouseb_strafe", &mousebstrafe);
+ M_BindVariable("mouseb_forward", &mousebforward);
- M_BindVariable("joyb_fire", &joybfire),
- M_BindVariable("joyb_strafe", &joybstrafe),
- M_BindVariable("joyb_use", &joybuse),
- M_BindVariable("joyb_speed", &joybspeed),
+ M_BindVariable("joyb_fire", &joybfire);
+ M_BindVariable("joyb_strafe", &joybstrafe);
+ M_BindVariable("joyb_use", &joybuse);
+ M_BindVariable("joyb_speed", &joybspeed);
+
+ M_BindVariable("joyb_menu_activate", &joybmenu);
// Extra controls that are not in the Vanilla versions:
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -157,6 +157,8 @@
extern int joybprevweapon;
extern int joybnextweapon;
+extern int joybmenu;
+
extern int dclick_use;
void M_BindBaseControls(void);
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -72,7 +72,8 @@
static int *all_joystick_buttons[] = {
&joybstraferight, &joybstrafeleft, &joybfire, &joybspeed,
- &joybuse, &joybstrafe, &joybprevweapon, &joybnextweapon, &joybjump
+ &joybuse, &joybstrafe, &joybprevweapon, &joybnextweapon, &joybjump,
+ &joybmenu,
};
//
--- a/src/strife/m_menu.c
+++ b/src/strife/m_menu.c
@@ -1778,6 +1778,11 @@
key = key_menu_back;
joywait = I_GetTime() + 5;
}
+ if (joybmenu >= 0 && (ev->data1 & (1 << joybmenu)) != 0)
+ {
+ key = key_menu_activate;
+ joywait = I_GetTime() + 5;
+ }
}
else
{