Skip to content

Commit 0fe26f7

Browse files
committed
feat(usb_kb): add keyboard layouts. new pt_br layout
1 parent 9f3010f commit 0fe26f7

20 files changed

+1776
-0
lines changed

Diff for: libraries/USB/src/keyboardLayout/KeyboardLayout.h

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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
+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* Danish keyboard layout.
3+
*/
4+
5+
#include "KeyboardLayout.h"
6+
7+
extern const uint8_t KeyboardLayout_da_DK[128] =
8+
{
9+
0x00, // NUL
10+
0x00, // SOH
11+
0x00, // STX
12+
0x00, // ETX
13+
0x00, // EOT
14+
0x00, // ENQ
15+
0x00, // ACK
16+
0x00, // BEL
17+
0x2a, // BS Backspace
18+
0x2b, // TAB Tab
19+
0x28, // LF Enter
20+
0x00, // VT
21+
0x00, // FF
22+
0x00, // CR
23+
0x00, // SO
24+
0x00, // SI
25+
0x00, // DEL
26+
0x00, // DC1
27+
0x00, // DC2
28+
0x00, // DC3
29+
0x00, // DC4
30+
0x00, // NAK
31+
0x00, // SYN
32+
0x00, // ETB
33+
0x00, // CAN
34+
0x00, // EM
35+
0x00, // SUB
36+
0x00, // ESC
37+
0x00, // FS
38+
0x00, // GS
39+
0x00, // RS
40+
0x00, // US
41+
42+
0x2c, // ' '
43+
0x1e|SHIFT, // !
44+
0x1f|SHIFT, // "
45+
0x20|SHIFT, // #
46+
0x21|ALT_GR, // $
47+
0x22|SHIFT, // %
48+
0x23|SHIFT, // &
49+
0x31, // '
50+
0x25|SHIFT, // (
51+
0x26|SHIFT, // )
52+
0x31|SHIFT, // *
53+
0x2d, // +
54+
0x36, // ,
55+
0x38, // -
56+
0x37, // .
57+
0x24|SHIFT, // /
58+
0x27, // 0
59+
0x1e, // 1
60+
0x1f, // 2
61+
0x20, // 3
62+
0x21, // 4
63+
0x22, // 5
64+
0x23, // 6
65+
0x24, // 7
66+
0x25, // 8
67+
0x26, // 9
68+
0x37|SHIFT, // :
69+
0x36|SHIFT, // ;
70+
0x32, // <
71+
0x27|SHIFT, // =
72+
0x32|SHIFT, // >
73+
0x2d|SHIFT, // ?
74+
0x1f|ALT_GR, // @
75+
0x04|SHIFT, // A
76+
0x05|SHIFT, // B
77+
0x06|SHIFT, // C
78+
0x07|SHIFT, // D
79+
0x08|SHIFT, // E
80+
0x09|SHIFT, // F
81+
0x0a|SHIFT, // G
82+
0x0b|SHIFT, // H
83+
0x0c|SHIFT, // I
84+
0x0d|SHIFT, // J
85+
0x0e|SHIFT, // K
86+
0x0f|SHIFT, // L
87+
0x10|SHIFT, // M
88+
0x11|SHIFT, // N
89+
0x12|SHIFT, // O
90+
0x13|SHIFT, // P
91+
0x14|SHIFT, // Q
92+
0x15|SHIFT, // R
93+
0x16|SHIFT, // S
94+
0x17|SHIFT, // T
95+
0x18|SHIFT, // U
96+
0x19|SHIFT, // V
97+
0x1a|SHIFT, // W
98+
0x1b|SHIFT, // X
99+
0x1c|SHIFT, // Y
100+
0x1d|SHIFT, // Z
101+
0x25|ALT_GR, // [
102+
0x32|ALT_GR, // bslash
103+
0x26|ALT_GR, // ]
104+
0x00, // ^ not supported (requires dead key + space)
105+
0x38|SHIFT, // _
106+
0x00, // ` not supported (requires dead key + space)
107+
0x04, // a
108+
0x05, // b
109+
0x06, // c
110+
0x07, // d
111+
0x08, // e
112+
0x09, // f
113+
0x0a, // g
114+
0x0b, // h
115+
0x0c, // i
116+
0x0d, // j
117+
0x0e, // k
118+
0x0f, // l
119+
0x10, // m
120+
0x11, // n
121+
0x12, // o
122+
0x13, // p
123+
0x14, // q
124+
0x15, // r
125+
0x16, // s
126+
0x17, // t
127+
0x18, // u
128+
0x19, // v
129+
0x1a, // w
130+
0x1b, // x
131+
0x1c, // y
132+
0x1d, // z
133+
0x24|ALT_GR, // {
134+
0x2e|ALT_GR, // |
135+
0x27|ALT_GR, // }
136+
0x00, // ~ not supported (requires dead key + space)
137+
0x00 // DEL
138+
};
+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* German keyboard layout.
3+
*/
4+
5+
#include "KeyboardLayout.h"
6+
7+
extern const uint8_t KeyboardLayout_de_DE[128] PROGMEM =
8+
{
9+
0x00, // NUL
10+
0x00, // SOH
11+
0x00, // STX
12+
0x00, // ETX
13+
0x00, // EOT
14+
0x00, // ENQ
15+
0x00, // ACK
16+
0x00, // BEL
17+
0x2a, // BS Backspace
18+
0x2b, // TAB Tab
19+
0x28, // LF Enter
20+
0x00, // VT
21+
0x00, // FF
22+
0x00, // CR
23+
0x00, // SO
24+
0x00, // SI
25+
0x00, // DEL
26+
0x00, // DC1
27+
0x00, // DC2
28+
0x00, // DC3
29+
0x00, // DC4
30+
0x00, // NAK
31+
0x00, // SYN
32+
0x00, // ETB
33+
0x00, // CAN
34+
0x00, // EM
35+
0x00, // SUB
36+
0x00, // ESC
37+
0x00, // FS
38+
0x00, // GS
39+
0x00, // RS
40+
0x00, // US
41+
42+
0x2c, // ' '
43+
0x1e|SHIFT, // !
44+
0x1f|SHIFT, // "
45+
0x31, // #
46+
0x21|SHIFT, // $
47+
0x22|SHIFT, // %
48+
0x23|SHIFT, // &
49+
0x31|SHIFT, // '
50+
0x25|SHIFT, // (
51+
0x26|SHIFT, // )
52+
0x30|SHIFT, // *
53+
0x30, // +
54+
0x36, // ,
55+
0x38, // -
56+
0x37, // .
57+
0x24|SHIFT, // /
58+
0x27, // 0
59+
0x1e, // 1
60+
0x1f, // 2
61+
0x20, // 3
62+
0x21, // 4
63+
0x22, // 5
64+
0x23, // 6
65+
0x24, // 7
66+
0x25, // 8
67+
0x26, // 9
68+
0x37|SHIFT, // :
69+
0x36|SHIFT, // ;
70+
0x32, // <
71+
0x27|SHIFT, // =
72+
0x32|SHIFT, // >
73+
0x2d|SHIFT, // ?
74+
0x14|ALT_GR, // @
75+
0x04|SHIFT, // A
76+
0x05|SHIFT, // B
77+
0x06|SHIFT, // C
78+
0x07|SHIFT, // D
79+
0x08|SHIFT, // E
80+
0x09|SHIFT, // F
81+
0x0a|SHIFT, // G
82+
0x0b|SHIFT, // H
83+
0x0c|SHIFT, // I
84+
0x0d|SHIFT, // J
85+
0x0e|SHIFT, // K
86+
0x0f|SHIFT, // L
87+
0x10|SHIFT, // M
88+
0x11|SHIFT, // N
89+
0x12|SHIFT, // O
90+
0x13|SHIFT, // P
91+
0x14|SHIFT, // Q
92+
0x15|SHIFT, // R
93+
0x16|SHIFT, // S
94+
0x17|SHIFT, // T
95+
0x18|SHIFT, // U
96+
0x19|SHIFT, // V
97+
0x1a|SHIFT, // W
98+
0x1b|SHIFT, // X
99+
0x1d|SHIFT, // Y
100+
0x1c|SHIFT, // Z
101+
0x25|ALT_GR, // [
102+
0x2d|ALT_GR, // bslash
103+
0x26|ALT_GR, // ]
104+
0x00, // ^ not supported (requires dead key + space)
105+
0x38|SHIFT, // _
106+
0x00, // ` not supported (requires dead key + space)
107+
0x04, // a
108+
0x05, // b
109+
0x06, // c
110+
0x07, // d
111+
0x08, // e
112+
0x09, // f
113+
0x0a, // g
114+
0x0b, // h
115+
0x0c, // i
116+
0x0d, // j
117+
0x0e, // k
118+
0x0f, // l
119+
0x10, // m
120+
0x11, // n
121+
0x12, // o
122+
0x13, // p
123+
0x14, // q
124+
0x15, // r
125+
0x16, // s
126+
0x17, // t
127+
0x18, // u
128+
0x19, // v
129+
0x1a, // w
130+
0x1b, // x
131+
0x1d, // y
132+
0x1c, // z
133+
0x24|ALT_GR, // {
134+
0x32|ALT_GR, // |
135+
0x27|ALT_GR, // }
136+
0x30|ALT_GR, // ~
137+
0x00 // DEL
138+
};

0 commit comments

Comments
 (0)