ref: dc120bcc11cf046d95cb6432c5b039f76c104f34
parent: 36b34fc966988ff76bd0f93c1e5c2aac00bbdc43
author: Jonathan Dowland <[email protected]>
date: Mon Aug 15 13:20:43 EDT 2016
Add joystick virtual button for toggle automap Add a distinct logic branch to the top of the AM_Responder routines that exits out, rather than modify the rc variable/ branching logic in the rest of the routine. Use the same button bounce timeout approach used for m_menu. Additionally adjust the column widths for the setup screen for joystick configuration, to account for the width of the string "Toggle Automap".
--- a/src/doom/am_map.c
+++ b/src/doom/am_map.c
@@ -32,6 +32,7 @@
#include "m_controls.h"
#include "m_misc.h"
#include "i_system.h"
+#include "i_timer.h"
// Needs access to LFB.
#include "v_video.h"
@@ -598,10 +599,31 @@
int rc;
static int bigstate=0;
+ static int joywait = 0;
static char buffer[20];
int key;
rc = false;
+
+ if (ev->type == ev_joystick && joybautomap >= 0
+ && (ev->data1 & (1 << joybautomap)) != 0 && joywait < I_GetTime())
+ {
+ joywait = I_GetTime() + 5;
+
+ if (!automapactive)
+ {
+ AM_Start ();
+ viewactive = false;
+ }
+ else
+ {
+ bigstate = 0;
+ viewactive = true;
+ AM_Stop ();
+ }
+
+ return true;
+ }
if (!automapactive)
{
--- a/src/heretic/am_map.c
+++ b/src/heretic/am_map.c
@@ -20,6 +20,7 @@
#include "doomdef.h"
#include "deh_str.h"
+#include "i_timer.h"
#include "i_video.h"
#include "m_controls.h"
#include "p_local.h"
@@ -508,9 +509,28 @@
int rc;
int key;
static int bigstate = 0;
+ static int joywait = 0;
key = ev->data1;
rc = false;
+
+ if (ev->type == ev_joystick && joybautomap >= 0
+ && (ev->data1 & (1 << joybautomap)) != 0 && joywait < I_GetTime())
+ {
+ joywait = I_GetTime() + 5;
+
+ if (!automapactive)
+ {
+ AM_Start ();
+ viewactive = false;
+ }
+ else
+ {
+ bigstate = 0;
+ viewactive = true;
+ AM_Stop ();
+ }
+ }
if (!automapactive)
{
--- a/src/hexen/am_map.c
+++ b/src/hexen/am_map.c
@@ -20,6 +20,7 @@
#include "doomkeys.h"
#include "i_video.h"
#include "i_swap.h"
+#include "i_timer.h"
#include "m_controls.h"
#include "m_misc.h"
#include "p_local.h"
@@ -421,8 +422,32 @@
int rc;
int key;
static int bigstate = 0;
+ static int joywait = 0;
key = ev->data1;
+
+ if (ev->type == ev_joystick && joybautomap >= 0
+ && (ev->data1 & (1 << joybautomap)) != 0 && joywait < I_GetTime())
+ {
+ joywait = I_GetTime() + 5;
+
+ if (!automapactive)
+ {
+ AM_Start ();
+ SB_state = -1;
+ viewactive = false;
+ }
+ else
+ {
+ bigstate = 0;
+ viewactive = true;
+ AM_Stop ();
+ SB_state = -1;
+ }
+
+ return true;
+ }
+
rc = false;
if (!automapactive)
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1051,6 +1051,12 @@
CONFIG_VARIABLE_INT(joyb_menu_activate),
//!
+ // Joystick virtual button to toggle the automap.
+ //
+
+ CONFIG_VARIABLE_INT(joyb_toggle_automap),
+
+ //!
// Joystick virtual button that cycles to the previous weapon.
//
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -192,6 +192,7 @@
int joybnextweapon = -1;
int joybmenu = -1;
+int joybautomap = -1;
// Control whether if a mouse button is double clicked, it acts like
// "use" has been pressed
@@ -225,6 +226,7 @@
M_BindIntVariable("joyb_speed", &joybspeed);
M_BindIntVariable("joyb_menu_activate", &joybmenu);
+ M_BindIntVariable("joyb_toggle_automap", &joybautomap);
// Extra controls that are not in the Vanilla versions:
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -150,6 +150,7 @@
extern int joybnextweapon;
extern int joybmenu;
+extern int joybautomap;
extern int dclick_use;
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -141,6 +141,7 @@
{"joyb_nextweapon", -1},
{"joyb_jump", -1},
{"joyb_menu_activate", -1},
+ {"joyb_toggle_automap", -1},
{"joystick_physical_button0", 0},
{"joystick_physical_button1", 1},
{"joystick_physical_button2", 2},
@@ -822,7 +823,7 @@
window = TXT_NewWindow("Gamepad/Joystick configuration");
TXT_SetTableColumns(window, 6);
- TXT_SetColumnWidths(window, 18, 10, 2, 14, 10, 0);
+ TXT_SetColumnWidths(window, 18, 10, 1, 15, 10, 0);
TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);
TXT_AddWidgets(window,
@@ -888,6 +889,8 @@
}
AddJoystickControl(window, "Activate menu", &joybmenu);
+
+ AddJoystickControl(window, "Toggle Automap", &joybautomap);
TXT_SignalConnect(joystick_button, "pressed", CalibrateJoystick, NULL);
TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
--- a/src/setup/txt_joybinput.c
+++ b/src/setup/txt_joybinput.c
@@ -56,6 +56,7 @@
&joybnextweapon,
&joybjump,
&joybmenu,
+ &joybautomap,
};
static int PhysicalForVirtualButton(int vbutton)
--- a/src/strife/am_map.c
+++ b/src/strife/am_map.c
@@ -32,6 +32,7 @@
#include "m_cheat.h"
#include "m_controls.h"
#include "i_system.h"
+#include "i_timer.h"
// Needs access to LFB.
#include "v_video.h"
@@ -579,10 +580,32 @@
int rc;
static int bigstate=0;
+ static int joywait = 0;
static char buffer[20];
int key;
rc = false;
+
+ if (ev->type == ev_joystick && joybautomap >= 0
+ && (ev->data1 & (1 << joybautomap)) != 0 && joywait < I_GetTime())
+ {
+ joywait = I_GetTime() + 5;
+
+ if (!automapactive)
+ {
+ AM_Start ();
+ viewactive = false;
+ }
+ else
+ {
+ bigstate = 0;
+ viewactive = true;
+ AM_Stop ();
+ }
+
+ return true;
+ }
+
if (!automapactive)
{