Skip to content

Technical

polemon edited this page Jan 30, 2016 · 24 revisions

Key map

The device maps internal raw key settings to what comes out of the device rather weirdly.

The labels of the following map, are the values written to the device as internal keycode. The cell values is what the keyboard sends as X keycode. The equivalent kbd codes (such as when using showkey or evtest on a linux console, instead of a terminal emulator in an X session), is the values minus 8.

| | 0x-0 | 0x-1 | 0x-2 | 0x-3 | 0x-4 | 0x-5 | 0x-6 | 0x-7 | 0x-8 | 0x-9 | 0x-a | 0x-b | 0x-c | 0x-d | 0x-e | 0x-f | |-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:| | 0x0- | None | None | None | None | 38 | 56 | 54 | 40 | 26 | 41 | 42 | 43 | 31 | 44 | 45 | 46 | | 0x1- | 58 | 57 | 32 | 33 | 24 | 27 | 39 | 28 | 30 | 55 | 25 | 53 | 29 | 52 | 10 | 11 | | 0x2- | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 36 | 9 | 22 | 23 | 65 | 20 | 21 | 34 | | 0x3- | 35 | 51 | 51 | 47 | 48 | 49 | 59 | 60 | 61 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | | 0x4- | 73 | 74 | 75 | 76 | 95 | 96 | 107 | 78 | 127 | 118 | 110 | 112 | 119 | 115 | 117 | 114 | | 0x5- | 113 | 116 | 111 | 77 | 106 | 63 | 82 | 86 | 104 | 87 | 88 | 89 | 83 | 84 | 85 | 79 | | 0x6- | 88 | 81 | 90 | 91 | 94 | 135 | 124 | 125 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | | 0x7- | 199 | 200 | 201 | 202 | 142 | 146 | 138 | 140 | 136 | 137 | 139 | 145 | 141 | 143 | 144 | 121 | | 0x8- | 123 | 122 | 248 | 248 | 248 | 129 | 248 | 97 | 101 | 132 | 100 | 102 | 103 | 248 | 248 | 248 | | 0x9- | 130 | 131 | 98 | 99 | 93 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 119 | 248 | 248 | 248 | | 0xa- | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | | 0xb- | 248 | 248 | 248 | 248 | 248 | 248 | 187 | 188 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | | 0xc- | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | | 0xd- | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | 119 | 248 | 248 | 248 | 248 | 248 | 248 | 248 | | 0xe- | 37 | 50 | 64 | 133 | 105 | 62 | 108 | 134 | 172 | 174 | 173 | 171 | 169 | 123 | 122 | 121 | | 0xf- | 158 | 166 | 167 | 136 | 144 | 185 | 186 | 184 | 150 | 160 | 181 | 148 | 248 | 248 | 248 | 248 | | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ | ............ |

Example: raw value 0x21 makes the switch send keycode 13 in X, which on a standard US "QWERTY" keyboard, is a '3'. In a Linux console (text mode), the sent keycode would be 5 (13 - 8 as mentioned above).

Note that values 0x31 and 0x32, both send 51 (which is most often mapped to '|')!

Also note, how there is quite a number of repetitions beyond 0x7f. The keycode table above, applies as it is to key press event. The table is a bit different, when the switch sends a string. [TODO] describe string character table

Mod key map

The device supports eight different mod keys in total, which can be sent with a key command when sending an event.

The map for that is a bit pattern. The keycodes in the following table are again X keycodes. The corresponding kbd keycodes is the one on the table, minus 8 just as described above.

pattern keycode
0000 0000 None
0000 0001 37
0000 0010 50
0000 0100 64
0000 1000 133
0001 0000 105
0010 0000 62
0100 0000 108
1000 0000 134

The original Windows software from the manufacturer, did not mention the upper nibble mod keys. It's not possible to set these via the software.

Mouse button map

pattern keycode USB event
xxxx x000 None None
0000 0001 button 1 BTN_LEFT
0000 0010 button 3 BTN_MIDDLE
0000 0100 button 2 BTN_RIGHT

Technically, the mouse wheel sends button events as well. Hoever this is dealt with a little differently here.

The Mouse wheel is considered like a third axis, with a positive and negative deflection. Depending on the deflection, that many actual button events are sent.

I:green_heart::snake:

Clone this wiki locally