4 ms·
I think the first part largely comes down to an agreement of the second part so I'm going to skip to that for the moment, if it doesn't resolve with the second
by zamadatix 5y ago
I think the first part largely comes down to an agreement of the second part so I'm going to skip to that for the moment, if it doesn't resolve with the second issue remind me and I'll come back to it.
To the second part: say you have a positional input set in the game, e.g. "WASD" except which letters it actually is don't matter (because of either preference mapping or keyboard layout) just that they are positional inputs mapped to movement (up/left/down/right for your average WASD user), in such a case you also have positional support keys e.g. in an FPS commonly "action", "grenade", "strafe", "crouch", and so on. A sane default will usually have these all clustered together and laid out in a way the user can press common combinations easily (worth noting sane defaults aren't universal, what is good positioning for a particular binding in one game may be poor positioning in another that plays differently or has different mechanics) and a good game will allow these inputs to be remapped (be it for personal preference or accessibility). For the default mappings if you say "press F to pay respects" without an idea where "F" is because you don't have the keymap for the user either one of two things is going to happen when it's not the same as the developer's keymap:
1) You're using scancodes and the user actually needs to press "Q" or another random letter but you don't know how to tell them that because you don't have the keymap
2) You're using keycodes and the default mapping is completely garbage for the user. This will commonly lead to...
2a) The user goes to configure a custom positional mapping but because of 1) when they try to configure a custom mapping for the "Q" on their keyboard it shows "F" in the mapping (though works as expected) making custom mappings a PITA to configure.
The way keycodes help the developer in these instances are:
1) You can display the actual letter for the default mappings, regardless if the user's keymap matches yours/your assumptions
2) You can display the actual letter for custom rebinds both in config and gameplay
3) If the user changes from DVORAK to QWERTY neither the developer or the user need to change anything for it to keep the positions/display the right letters
.
Now can this be misused to break things? Absolutely, a bad developer could misunderstand when to use keycodes vs when to use scancodes and in turn recreate a the problem class from 1). At the same time on native apps I can't say I've ever run into that vs the deluge of games and apps with positional bindings (typically content creation) that assume I'm QWERTY and look for the keycode. As for Office desktop as an example the character bindings still follow the character, e.g. I press ctrl+v to paste (which would be ctrl+o on a QWERTY layout) even though it has the ability to query the keymap for positional shortcuts.