OpenTTD

Tasklist

FS#5504 - Numpad keys behave in unexpected ways

Attached to Project: OpenTTD
Opened by fonsinchen (fonsinchen) - Saturday, 16 March 2013, 08:44 GMT
Last edited by andythenorth (andythenorth) - Wednesday, 23 August 2017, 07:28 GMT
Type Bug
Category Interface
Status With patch
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No

Details

Steps to reproduce, in any game, using the default hotkeys.cfg (with numbers mapped to road building tools):
1. Open the road building tool bar.
2. Click "rename" in some station view window.
3. Make sure the renaming text field is focused.
4. Type some numbers on the numpad, toggling numlock in between.

Expected results:
The numbers typed with numlock on should appear as numbers in the text field. The numbers typed with numlock off should either be ignored or trigger the actions of the cursor keys associated with the typed number keys.

Observed results:
The numbers typed with numlock on appear correctly. The numbers typed with numlock off trigger the road building tools.
This task depends upon

Comment by frosch (frosch) - Sunday, 17 March 2013, 13:30 GMT
Attached diff fixes this for SDL. (all other video drivers would need similar treatment)

The idea behind the fix is to stronger distinguish whether a key is meant as hotkey or with its normal semantical meaning.
- Hotkeys are identified via their physical position on the keyboard, i.e. their scancode. Numpad keys are separate keys, their meaning does not change with numlock.
- The semantical meaning of numpad keys changes with numlock. When numlock is enabled, they match the numerical keys. When numlock is disabled, they match the cursor keys.

The patch distinguishes these meanings via 'key' and 'keycode'. 'key' holds the semantical meaning of a key, which are mostly unicode characters, but also special codes for cursor keys, backspace and such. 'keycode' otoh also refers to the scancode.

Editboxes and the console almost exclusively use 'key' now. While 'keycode' is only uses by Hotkeys.

Loading...