fix: NumLock shouldn't trigger frame delay changes

Found a bug in R'n'D? Report it here!

Moderators: Flumminator, Zomis

Post Reply
filbo
Posts: 647
Joined: Fri Jun 20, 2014 10:06 am

fix: NumLock shouldn't trigger frame delay changes

Post by filbo »

Couldn't figure out why my game kept dropping to ultra-slow frame rate...

It turned out that my '1' key (toggle single-step) was also being seen as 'go to 2 frames/sec mode' despite:

debug.frame_delay.use_mod_key: true

in my options.conf. And this was because I apparently have NumLock turned on. (Can't really tell: this laptop has a numeric pad integrated into the keyboard, and for my 'convenience' the NumLock key has no visual indicator of whether it's on...)

Anyway:

Code: Select all

diff --git a/src/events.c b/src/events.c
index 25d243b..441e092 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1425,7 +1425,7 @@ void HandleKeysDebug(Key key)
 
   if (game_status == GAME_MODE_PLAYING || !setup.debug.frame_delay_game_only)
   {
-    boolean mod_key_pressed = (GetKeyModState() != KMOD_None);
+    boolean mod_key_pressed = ((GetKeyModState() & (KMOD_Shift | KMOD_Control | KMOD_Alt | KMOD_Meta)) != KMOD_None);
 
     for (i = 0; i < NUM_DEBUG_FRAME_DELAY_KEYS; i++)
     {
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: fix: NumLock shouldn't trigger frame delay changes

Post by Holger »

Wow, this is strange -- just verified it for myself, because I nearly couldn't believe it, but indeed: Activated NumLock key acts as a pressed modifier key! :-o

I think I should fix this directly in "GetKeyModState()" (to only recognize Shift/Ctrl/Alt/Meta keys as modifier keys).

Thanks for reporting this strange behaviour...
Post Reply