Issue with keyboards, keybinds, and numlock.


Problems running or configuring the software, commands & options, compiling, different platforms, using the interface, documentation, etc.

Shoals Surfer

Posts: 325

Joined: Tuesday, 13th October 2015, 06:02

Post Tuesday, 5th June 2018, 21:52

Issue with keyboards, keybinds, and numlock.

Offline version only.

Using a wireless keyboard. No numlock, no keyboard short command available.

Issue:
From in the game, set a macro for the end key. Example, za. set to end key as a macro.
This sets the 1 numpad key to za. as well. And, the same result if setting any macro to numpad 1.

Complaint:
I like to use the numpad to move around. And, on this keyboard the end key is right next to numpad 4, and I like it set my primary blasty spell to it. The issue prevents me from doing this, and it's driving me nuts.


What I know about this issue:
Using a simple script I checked what the keycode was for both end key and numpad 1 key, followed by all the numpad keys and pg up, pg dn, insert, delete, and home as well. The scrit returned different keycode values for each key.

Inside the offline game I checked what the game was returning for the key value of the end key and numpad 1 key, using create a macro, cntrl ~, and it returned the values -248 for both end key and numpad 1 key.

What I think is the problem source:
I think when the game is on-screen and active, numlock is off. Possibly by default.

My Issue:
With no numlock key, and I can't press numlock to turn on and can't get a differnt key code value for end/pg dn/pg up/insert/delete. Registery has the keyboard set to value of 2, so num lock should be in the on state. on-screen-keyboard only effects the on-screen-keyboard when you turn on num lock. Hence, no way to turn on or off num lock when playing the off-line game version.

Conclusion:
I'd like someone to show me a way to work around this issue if possible. I even unbinded the movement keys, but that didn't effect numpad or the end/pg dn/pg upinsert/delete keys.

Dungeon Master

Posts: 388

Joined: Monday, 18th August 2014, 20:04

Post Wednesday, 6th June 2018, 13:58

Re: Issue with keyboards, keybinds, and numlock.

Dealing with numpads and numlock is in general extremely messy, as there's a lot of variation in keyboards as well as OSs, and it's basically impossible to detect. One major issue is that in some circumstances many keyboards will send both a number key and the corresponding home/end/pgup/pgdn key, and there's no way to disable or even really detect this in software if it's happening. All this is to say is that crawl goes to great lengths to, in a cross-platform way, ignore numlock by treating numpad numbers and the home/end/etc keys the same and ignoring double keystrokes that impact these keycode pairs. A casualty of this is that for keyboards where e.g. 1 is a distinct button from end, such as most os x keyboards, the two are collapsed (and numlock doesn't matter). If it's *really* the case that your keyboard is not sending both keycodes when you hit numpad 1 (which would be somewhat unusual for a keyboard that doesn't have numlock in my experience, but these things definitely vary; though all apple keyboards behave the way I describe) it might be possible in principle for someone to add a setting that differentiates the two, but I don't personally have any way of testing such a setting.

Slime Squisher

Posts: 368

Joined: Thursday, 11th April 2013, 21:07

Post Wednesday, 6th June 2018, 14:58

Re: Issue with keyboards, keybinds, and numlock.

Maybe you're not already doing this intentionally for the reasons mentioned, but you're already using SDL2's input handling for tiles builds and it at least claims to have cross-platform support including OSX and Linux. Is SDL2 unable to handle the environmental differences in keyboard scancodes mentioned above, or could it be used for all builds here, instead of just tiles?

Dungeon Master

Posts: 388

Joined: Monday, 18th August 2014, 20:04

Post Thursday, 7th June 2018, 01:43

Re: Issue with keyboards, keybinds, and numlock.

SDL provides no specific support or handling for dealing with numpad/numlock idiosyncracies, in fact I think what we'd need to do to really handle this the way I assume fancy paid games do would be to write our own key handler (so we can deal better with keydown timing) as opposed to using the SDL one.

If you want to get a better sense of the issues, you could look at this commit.

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 10 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.