mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
More cleverness in midend_process_key()
It now strips off modifier flags from keys that shouldn't have them and maps printable characters with MOD_CTRL to the corresponding control characters. It also catches Ctrl+Shift+Z because that obviously belongs in the midend. I've updated the JavaScript front-end to take advantage of these changes. Other front ends are unchanged and should work just as they did before.
This commit is contained in:
16
emcc.c
16
emcc.c
@ -408,19 +408,9 @@ bool key(int keycode, const char *key, const char *chr, int location,
|
||||
keyevent = keycode;
|
||||
|
||||
if (keyevent >= 0) {
|
||||
if (shift && (keyevent >= 0x100 && !IS_UI_FAKE_KEY(keyevent)))
|
||||
keyevent |= MOD_SHFT;
|
||||
|
||||
if (ctrl && !IS_UI_FAKE_KEY(keyevent)) {
|
||||
if (keyevent >= 0x100)
|
||||
keyevent |= MOD_CTRL;
|
||||
else
|
||||
keyevent &= 0x1F;
|
||||
}
|
||||
|
||||
if ('0' <= keyevent && keyevent <= '9' &&
|
||||
location == DOM_KEY_LOCATION_NUMPAD)
|
||||
keyevent |= MOD_NUM_KEYPAD;
|
||||
if (shift) keyevent |= MOD_SHFT;
|
||||
if (ctrl) keyevent |= MOD_CTRL;
|
||||
if (location == DOM_KEY_LOCATION_NUMPAD) keyevent |= MOD_NUM_KEYPAD;
|
||||
|
||||
midend_process_key(me, 0, 0, keyevent, &handled);
|
||||
post_move();
|
||||
|
Reference in New Issue
Block a user