Skip to content

Commit

Permalink
add a key binding to toggle vertical mouse movement (novert)
Browse files Browse the repository at this point in the history
Thanks Looper for the suggestion!
  • Loading branch information
fabiangreffrath committed Nov 26, 2018
1 parent 0a38d42 commit f3006c9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/doom/g_game.c
Expand Up @@ -347,6 +347,7 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic)
int forward;
int side;
int look;
static char autorunmsg[48];

memset(cmd, 0, sizeof(ticcmd_t));

Expand Down Expand Up @@ -411,7 +412,6 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic)
// [crispy] toggle "always run"
if (gamekeydown[key_toggleautorun])
{
static char autorunmsg[24];
static int joybspeed_old = 2;

if (joybspeed >= MAX_JOY_BUTTONS)
Expand All @@ -433,6 +433,21 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic)
gamekeydown[key_toggleautorun] = false;
}

// [crispy] Toggle vertical mouse movement
if (gamekeydown[key_togglenovert])
{
novert = !novert;

M_snprintf(autorunmsg, sizeof(autorunmsg),
"vertical mouse movement %s%s",
crstr[CR_GREEN],
!novert ? "ON" : "OFF");
players[consoleplayer].message = autorunmsg;
S_StartSound(NULL, sfx_swtchn);

gamekeydown[key_togglenovert] = false;
}

// let movement keys cancel each other out
if (strafe)
{
Expand Down
7 changes: 7 additions & 0 deletions src/m_config.c
Expand Up @@ -1762,6 +1762,13 @@ static default_t extra_defaults_list[] =

CONFIG_VARIABLE_KEY(key_toggleautorun),

//!
// @game doom
// Toggle vertical mouse movement.
//

CONFIG_VARIABLE_KEY(key_togglenovert),

//!
// @game doom
// Invert vertical mouse movement.
Expand Down
2 changes: 2 additions & 0 deletions src/m_controls.c
Expand Up @@ -43,6 +43,7 @@ int key_use = ' ';
int key_strafe = KEY_RALT;
int key_speed = KEY_RSHIFT;
int key_toggleautorun = KEY_CAPSLOCK; // [crispy]
int key_togglenovert = 0; // [crispy]

//
// Heretic keyboard controls
Expand Down Expand Up @@ -271,6 +272,7 @@ void M_BindBaseControls(void)
M_BindIntVariable("mouseb_reverse", &mousebreverse); // [crispy]
M_BindIntVariable("key_reverse", &key_reverse); // [crispy]
M_BindIntVariable("key_toggleautorun", &key_toggleautorun); // [crispy]
M_BindIntVariable("key_togglenovert", &key_togglenovert); // [crispy]
}

void M_BindHereticControls(void)
Expand Down
1 change: 1 addition & 0 deletions src/m_controls.h
Expand Up @@ -36,6 +36,7 @@ extern int key_speed;

extern int key_jump;
extern int key_toggleautorun;
extern int key_togglenovert;

extern int key_flyup;
extern int key_flydown;
Expand Down
3 changes: 2 additions & 1 deletion src/setup/keyboard.c
Expand Up @@ -35,7 +35,7 @@ static int always_run = 0;

static int *controls[] = { &key_left, &key_right, &key_up, &key_down,
&key_alt_up, &key_alt_down,
&key_reverse, &key_toggleautorun,
&key_reverse, &key_toggleautorun, &key_togglenovert,
&key_strafeleft, &key_straferight, &key_fire,
&key_alt_strafeleft, &key_alt_straferight,
&key_use, &key_strafe, &key_speed, &key_jump,
Expand Down Expand Up @@ -223,6 +223,7 @@ static void ConfigExtraKeys(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
AddKeyControl(table, "Strafe Left (alt.)", &key_alt_strafeleft);
AddKeyControl(table, "Strafe Right (alt.)", &key_alt_straferight);
AddKeyControl(table, "Toggle always run", &key_toggleautorun);
AddKeyControl(table, "Toggle vert. mouse", &key_togglenovert);
AddKeyControl(table, "Quick Reverse", &key_reverse);
}
else
Expand Down

0 comments on commit f3006c9

Please sign in to comment.