Open cookiengineer opened 6 years ago
Here's a quick summary from my implementation notes, with expected keycodes and fired-by-nidium ones. Those might help with debugging and tracing down the bug:
const _KEYMAP = {
// 45: 'insert', // XXX: nidium fires incorrect 73
// 46: 'delete', // XXX: nidium fires incorrect 127
// 112: 'f1', // XXX: nidium fires incorrect 58
// 113: 'f2', // XXX: nidium fires incorrect 59
// 114: 'f3', // XXX: nidium fires incorrect 60
// 115: 'f4', // XXX: nidium fires incorrect 187
// 116: 'f5', // XXX: nidium fires incorrect 62
// 117: 'f6', // XXX: nidium fires incorrect 63
// 118: 'f7', // XXX: nidium fires incorrect 64
// 119: 'f8', // XXX: nidium fires incorrect 65
// 120: 'f9', // XXX: nidium fires incorrect 66
// 121: 'f10', // XXX: nidium fires incorrect 67
// 122: 'f11', // XXX: nidium fires incorrect 68
// 123: 'f12' // XXX: nidium fires incorrect 69
};
// Specialmap is structured like this (assuming en_US layout and/or OS keymap settings):
// entry[0] is normal press
// entry[1] is while pressing shift
const _SPECIALMAP = {
48: [ '0', ')' ],
49: [ '1', '!' ],
50: [ '2', '@' ],
51: [ '3', '#' ],
52: [ '4', '$' ],
53: [ '5', '%' ],
54: [ '6', '^' ],
55: [ '7', '&' ],
56: [ '8', '*' ],
// 57: [ '9', '(' ], // XXX: nidium fires incorrect 20
// 186: [ ';', ':' ], // XXX: nidium fires incorrect 59
187: [ '=', '+' ],
188: [ ',', '<' ],
189: [ '-', '_' ]
// 190: [ '.', '>' ], // XXX: nidium fires incorrect 46
// 191: [ '/', '?' ], // XXX: nidium fires incorrect 47
// 192: [ '`', '~' ], // XXX: nidium fires incorrect 96
// 219: [ '[', '{' ], // XXX: nidium fires incirrect 91
// 220: [ '\\', '|' ], // XXX: nidium fires incorrect 92
// 221: [ ']', '}' ], // XXX: nidium fires incorrect 93
// 222: [ '\'', '"' ] // XXX: nidium fires incorrect 39
};
The keyCodes violate pretty much any API available, with random offsets. Here's a list of what I've found out so far:
Violations to ASCII charset:
F1
-F12
are offseted incorrectly, so F1 to F3 work correctly (with incorrect keyCodes 58-60)F4
has the keyCode187
(=
or+
) which doesn't make any sense.F5
and upwards are identical keyCodes asa
and later letters on the keyboard, so they do conflict with the ASCII range and therefore cannot be used in their current state.9
orshift-9
will lead to keycode20
(capslock) which is incorrect and should be57
.page-up
will lead to keycode75
("k") which is incorrect and should be33
.page-down
will lead to keycode78
("n") which is incorrect and should be34
.pos1
(orbegin
orhome
) will lead to keycode74
("j") which is incorrect.end
will lead to keycode77
("m") which is incorrect and should be35
.insert
(orins
) will lead to keycode73
("i") which is incorrect and should be45
.delete
(orentf
) will lead to keycode127
which is incorrect and should be46
.Additional Notes:
The F1-F12 keys normally have the keycodes
112
(F1) to123
(F12) to not conflict with the ASCII key range.The special characters (0-9 keys on keyboard) are typically in the range of
48
-57
, because of ASCII charset compatibility. In nidium, this is incorrect, too.Other special characters (
[];'\,./
keys) typically are in the range of186-192
and219-222
, in nidium those are totally incorrect (and seemingly randomly), too. Violations from previously mentioned numbers to wrong ASCII charset and others is the case in nidium.Overall, there's plenty of bugs in the keycode API and special characters (like shift-1, or
[
etc.) have totally different keycodes than the specs have. As those are too complicated and too exhausting to list, I am just posting my temporary working-except-above-bugs key mappings file here in the lychee.Input implementation. Take a look in my implementation for the_KEYMAP
and_SPECIALMAP
constants if direct link to line does not work.