Skip to content

Commit 6a9610f

Browse files
Only auto-repeat navigational keys in menus
This reduces sound spam and, for gamepads, rumble spam. Particularly noticeable while holding +altmodifier when changing bindings.
1 parent 7a2038a commit 6a9610f

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Quake/keys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ void Key_EventWithKeycode (int key, qboolean down, int keycode)
12751275
Key_Message (key);
12761276
break;
12771277
case key_menu:
1278-
M_Keydown (key);
1278+
M_Keydown (key, wasdown);
12791279
break;
12801280
case key_game:
12811281
case key_console:
@@ -1403,7 +1403,7 @@ void Key_EventWithKeycode (int key, qboolean down, int keycode)
14031403
Key_Message (key);
14041404
break;
14051405
case key_menu:
1406-
M_Keydown (key);
1406+
M_Keydown (key, wasdown);
14071407
break;
14081408

14091409
case key_game:

Quake/menu.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7253,7 +7253,7 @@ void M_Draw (void)
72537253
}
72547254

72557255

7256-
void M_Keydown (int key)
7256+
void M_Keydown (int key, qboolean repeat)
72577257
{
72587258
if (!bind_grab && !ui_mouse.value && M_IsMouseKey (key))
72597259
return;
@@ -7272,6 +7272,24 @@ void M_Keydown (int key)
72727272
}
72737273
}
72747274

7275+
// only allow repeat events for a few navigational keys
7276+
// this reduces sound spam and, for gamepads, rumble spam
7277+
// (particularly noticeable while holding the alt modifier when changing bindings)
7278+
if (repeat)
7279+
{
7280+
switch (key)
7281+
{
7282+
case K_UPARROW:
7283+
case K_DOWNARROW:
7284+
case K_LEFTARROW:
7285+
case K_RIGHTARROW:
7286+
case K_ESCAPE:
7287+
break;
7288+
default:
7289+
return;
7290+
}
7291+
}
7292+
72757293
switch (M_GetBaseState (m_state))
72767294
{
72777295
default:

Quake/menu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extern qboolean m_entersound;
6161
// menus
6262
//
6363
void M_Init (void);
64-
void M_Keydown (int key);
64+
void M_Keydown (int key, qboolean repeat);
6565
void M_Charinput (int key);
6666
void M_Mousemove (int x, int y);
6767
enum textmode_t M_TextEntry (void);

0 commit comments

Comments
 (0)