|
1 |
| -/* |
2 |
| - KeyboardLayout.h |
3 |
| -
|
4 |
| - This file is not part of the public API. It is meant to be included |
5 |
| - only in Keyboard.cpp and the keyboard layout files. Layout files map |
6 |
| - ASCII character codes to keyboard scan codes (technically, to USB HID |
7 |
| - Usage codes), possibly altered by the SHIFT or ALT_GR modifiers. |
8 |
| - Non-ACSII characters (anything outside the 7-bit range NUL..DEL) are |
9 |
| - not supported. |
10 |
| -
|
11 |
| - == Creating your own layout == |
12 |
| -
|
13 |
| - In order to create your own layout file, copy an existing layout that |
14 |
| - is similar to yours, then modify it to use the correct keys. The |
15 |
| - layout is an array in ASCII order. Each entry contains a scan code, |
16 |
| - possibly modified by "|SHIFT" or "|ALT_GR", as in this excerpt from |
17 |
| - the Italian layout: |
18 |
| -
|
19 |
| - 0x35, // bslash |
20 |
| - 0x30|ALT_GR, // ] |
21 |
| - 0x2e|SHIFT, // ^ |
22 |
| -
|
23 |
| - Do not change the control characters (those before scan code 0x2c, |
24 |
| - corresponding to space). Do not attempt to grow the table past DEL. Do |
25 |
| - not use both SHIFT and ALT_GR on the same character: this is not |
26 |
| - supported. Unsupported characters should have 0x00 as scan code. |
27 |
| -
|
28 |
| - For a keyboard with an ISO physical layout, use the scan codes below: |
29 |
| -
|
30 |
| - +---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ |
31 |
| - |35 |1e |1f |20 |21 |22 |23 |24 |25 |26 |27 |2d |2e |BackSp | |
32 |
| - +---+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-----+ |
33 |
| - | Tab |14 |1a |08 |15 |17 |1c |18 |0c |12 |13 |2f |30 | Ret | |
34 |
| - +-----++--++--++--++--++--++--++--++--++--++--++--++--++ | |
35 |
| - |CapsL |04 |16 |07 |09 |0a |0b |0d |0e |0f |33 |34 |31 | | |
36 |
| - +----+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+----+ |
37 |
| - |Shi.|32 |1d |1b |06 |19 |05 |11 |10 |36 |37 |38 | Shift | |
38 |
| - +----+---++--+-+-+---+---+---+---+---+--++---+---++----+----+ |
39 |
| - |Ctrl|Win |Alt | |AlGr|Win |Menu|Ctrl| |
40 |
| - +----+----+----+------------------------+----+----+----+----+ |
41 |
| -
|
42 |
| - The ANSI layout is identical except that key 0x31 is above (rather |
43 |
| - than next to) Return, and there is not key 0x32. |
44 |
| -
|
45 |
| - Give a unique name to the layout array, then declare it in Keyboard.h |
46 |
| - with a line of the form: |
47 |
| -
|
48 |
| - extern const uint8_t KeyboardLayout_xx_YY[]; |
49 |
| -
|
50 |
| - == Encoding details == |
51 |
| -
|
52 |
| - All scan codes are less than 0x80, which makes bit 7 available to |
53 |
| - signal that a modifier (Shift or AltGr) is needed to generate the |
54 |
| - character. With only one exception, keys that are used with modifiers |
55 |
| - have scan codes that are less than 0x40. This makes bit 6 available |
56 |
| - to signal whether the modifier is Shift or AltGr. The exception is |
57 |
| - 0x64, the key next next to Left Shift on the ISO layout (and absent |
58 |
| - from the ANSI layout). We handle it by replacing its value by 0x32 in |
59 |
| - the layout arrays. |
60 |
| -*/ |
61 |
| - |
62 |
| -#include <Arduino.h> |
63 |
| - |
64 |
| -// Modifier keys for _asciimap[] table (not to be used directly) |
65 |
| -#define SHIFT 0x80 |
66 |
| -#define ALT_GR 0x40 |
67 |
| -#define ISO_KEY 0x64 |
68 |
| -#define ISO_REPLACEMENT 0x32 |
| 1 | +/* |
| 2 | + KeyboardLayout.h |
| 3 | +
|
| 4 | + This file is not part of the public API. It is meant to be included |
| 5 | + only in Keyboard.cpp and the keyboard layout files. Layout files map |
| 6 | + ASCII character codes to keyboard scan codes (technically, to USB HID |
| 7 | + Usage codes), possibly altered by the SHIFT or ALT_GR modifiers. |
| 8 | + Non-ACSII characters (anything outside the 7-bit range NUL..DEL) are |
| 9 | + not supported. |
| 10 | +
|
| 11 | + == Creating your own layout == |
| 12 | +
|
| 13 | + In order to create your own layout file, copy an existing layout that |
| 14 | + is similar to yours, then modify it to use the correct keys. The |
| 15 | + layout is an array in ASCII order. Each entry contains a scan code, |
| 16 | + possibly modified by "|SHIFT" or "|ALT_GR", as in this excerpt from |
| 17 | + the Italian layout: |
| 18 | +
|
| 19 | + 0x35, // bslash |
| 20 | + 0x30|ALT_GR, // ] |
| 21 | + 0x2e|SHIFT, // ^ |
| 22 | +
|
| 23 | + Do not change the control characters (those before scan code 0x2c, |
| 24 | + corresponding to space). Do not attempt to grow the table past DEL. Do |
| 25 | + not use both SHIFT and ALT_GR on the same character: this is not |
| 26 | + supported. Unsupported characters should have 0x00 as scan code. |
| 27 | +
|
| 28 | + For a keyboard with an ISO physical layout, use the scan codes below: |
| 29 | +
|
| 30 | + +---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ |
| 31 | + |35 |1e |1f |20 |21 |22 |23 |24 |25 |26 |27 |2d |2e |BackSp | |
| 32 | + +---+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-----+ |
| 33 | + | Tab |14 |1a |08 |15 |17 |1c |18 |0c |12 |13 |2f |30 | Ret | |
| 34 | + +-----++--++--++--++--++--++--++--++--++--++--++--++--++ | |
| 35 | + |CapsL |04 |16 |07 |09 |0a |0b |0d |0e |0f |33 |34 |31 | | |
| 36 | + +----+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+----+ |
| 37 | + |Shi.|32 |1d |1b |06 |19 |05 |11 |10 |36 |37 |38 | Shift | |
| 38 | + +----+---++--+-+-+---+---+---+---+---+--++---+---++----+----+ |
| 39 | + |Ctrl|Win |Alt | |AlGr|Win |Menu|Ctrl| |
| 40 | + +----+----+----+------------------------+----+----+----+----+ |
| 41 | +
|
| 42 | + The ANSI layout is identical except that key 0x31 is above (rather |
| 43 | + than next to) Return, and there is not key 0x32. |
| 44 | +
|
| 45 | + Give a unique name to the layout array, then declare it in Keyboard.h |
| 46 | + with a line of the form: |
| 47 | +
|
| 48 | + extern const uint8_t KeyboardLayout_xx_YY[]; |
| 49 | +
|
| 50 | + == Encoding details == |
| 51 | +
|
| 52 | + All scan codes are less than 0x80, which makes bit 7 available to |
| 53 | + signal that a modifier (Shift or AltGr) is needed to generate the |
| 54 | + character. With only one exception, keys that are used with modifiers |
| 55 | + have scan codes that are less than 0x40. This makes bit 6 available |
| 56 | + to signal whether the modifier is Shift or AltGr. The exception is |
| 57 | + 0x64, the key next next to Left Shift on the ISO layout (and absent |
| 58 | + from the ANSI layout). We handle it by replacing its value by 0x32 in |
| 59 | + the layout arrays. |
| 60 | +*/ |
| 61 | + |
| 62 | +#include <Arduino.h> |
| 63 | + |
| 64 | +// Modifier keys for _asciimap[] table (not to be used directly) |
| 65 | +#define SHIFT 0x80 |
| 66 | +#define ALT_GR 0x40 |
| 67 | +#define ISO_KEY 0x64 |
| 68 | +#define ISO_REPLACEMENT 0x32 |
0 commit comments