Skip to content

Commit 8bca94a

Browse files
author
Jeff Brown
committed
More work on international keyboards.
Changed the English US keymaps to implement a strict US key map with no additional ALT functions. Fixed a bug copying the alias in the InputDevice copy constructor. Added support for end of line comments in KCM and KL files. Added the German keyboard layout. Sorted the keys in the keyboard layout files by physical arrangement to make it easier to maintain them. Bug: 6110399 Change-Id: If44d83de5b98f2bf0016cbb8e12264387b286aaa
1 parent fd6a524 commit 8bca94a

File tree

6 files changed

+907
-11
lines changed

6 files changed

+907
-11
lines changed

libs/androidfw/InputDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ InputDeviceInfo::InputDeviceInfo() {
132132

133133
InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) :
134134
mId(other.mId), mGeneration(other.mGeneration), mIdentifier(other.mIdentifier),
135-
mSources(other.mSources),
135+
mAlias(other.mAlias), mSources(other.mSources),
136136
mKeyboardType(other.mKeyboardType),
137137
mKeyCharacterMap(other.mKeyCharacterMap),
138138
mHasVibrator(other.mHasVibrator),

libs/androidfw/KeyCharacterMap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,8 @@ status_t KeyCharacterMap::Parser::parse() {
713713
}
714714

715715
mTokenizer->skipDelimiters(WHITESPACE);
716-
if (!mTokenizer->isEol()) {
717-
ALOGE("%s: Expected end of line, got '%s'.",
716+
if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
717+
ALOGE("%s: Expected end of line or trailing comment, got '%s'.",
718718
mTokenizer->getLocation().string(),
719719
mTokenizer->peekRemainderOfLine().string());
720720
return BAD_VALUE;
@@ -973,7 +973,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
973973
}
974974

975975
mTokenizer->skipDelimiters(WHITESPACE);
976-
} while (!mTokenizer->isEol());
976+
} while (!mTokenizer->isEol() && mTokenizer->peekChar() != '#');
977977

978978
// Add the behavior.
979979
for (size_t i = 0; i < properties.size(); i++) {

libs/androidfw/KeyLayoutMap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ status_t KeyLayoutMap::Parser::parse() {
185185
}
186186

187187
mTokenizer->skipDelimiters(WHITESPACE);
188-
if (!mTokenizer->isEol()) {
189-
ALOGE("%s: Expected end of line, got '%s'.",
188+
if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
189+
ALOGE("%s: Expected end of line or trailing comment, got '%s'.",
190190
mTokenizer->getLocation().string(),
191191
mTokenizer->peekRemainderOfLine().string());
192192
return BAD_VALUE;
@@ -234,7 +234,7 @@ status_t KeyLayoutMap::Parser::parseKey() {
234234
uint32_t flags = 0;
235235
for (;;) {
236236
mTokenizer->skipDelimiters(WHITESPACE);
237-
if (mTokenizer->isEol()) break;
237+
if (mTokenizer->isEol() || mTokenizer->peekChar() == '#') break;
238238

239239
String8 flagToken = mTokenizer->nextToken(WHITESPACE);
240240
uint32_t flag = getKeyFlagByLabel(flagToken.string());
@@ -332,7 +332,7 @@ status_t KeyLayoutMap::Parser::parseAxis() {
332332

333333
for (;;) {
334334
mTokenizer->skipDelimiters(WHITESPACE);
335-
if (mTokenizer->isEol()) {
335+
if (mTokenizer->isEol() || mTokenizer->peekChar() == '#') {
336336
break;
337337
}
338338
String8 keywordToken = mTokenizer->nextToken(WHITESPACE);

packages/InputDevices/res/raw/keyboard_layout_english_us.kcm

Lines changed: 292 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,298 @@
1414

1515
#
1616
# English (US) keyboard layout.
17-
# Assumes that the base keyboard layout is already English (US).
17+
# Unlike the default (generic) keyboard layout, English (US) does not contain any
18+
# special ALT characters.
1819
#
1920

2021
type OVERLAY
22+
23+
### ROW 1
24+
25+
key GRAVE {
26+
label: '`'
27+
base: '`'
28+
shift: '~'
29+
}
30+
31+
key 1 {
32+
label: '1'
33+
base: '1'
34+
shift: '!'
35+
}
36+
37+
key 2 {
38+
label: '2'
39+
base: '2'
40+
shift: '@'
41+
}
42+
43+
key 3 {
44+
label: '3'
45+
base: '3'
46+
shift: '#'
47+
}
48+
49+
key 4 {
50+
label: '4'
51+
base: '4'
52+
shift: '$'
53+
}
54+
55+
key 5 {
56+
label: '5'
57+
base: '5'
58+
shift: '%'
59+
}
60+
61+
key 6 {
62+
label: '6'
63+
base: '6'
64+
shift: '^'
65+
}
66+
67+
key 7 {
68+
label: '7'
69+
base: '7'
70+
shift: '&'
71+
}
72+
73+
key 8 {
74+
label: '8'
75+
base: '8'
76+
shift: '*'
77+
}
78+
79+
key 9 {
80+
label: '9'
81+
base: '9'
82+
shift: '('
83+
}
84+
85+
key 0 {
86+
label: '0'
87+
base: '0'
88+
shift: ')'
89+
}
90+
91+
key MINUS {
92+
label: '-'
93+
base: '-'
94+
shift: '_'
95+
}
96+
97+
key EQUALS {
98+
label: '='
99+
base: '='
100+
shift: '+'
101+
}
102+
103+
### ROW 2
104+
105+
key Q {
106+
label: 'Q'
107+
base: 'q'
108+
shift, capslock: 'Q'
109+
}
110+
111+
key W {
112+
label: 'W'
113+
base: 'w'
114+
shift, capslock: 'W'
115+
}
116+
117+
key E {
118+
label: 'E'
119+
base: 'e'
120+
shift, capslock: 'E'
121+
}
122+
123+
key R {
124+
label: 'R'
125+
base: 'r'
126+
shift, capslock: 'R'
127+
}
128+
129+
key T {
130+
label: 'T'
131+
base: 't'
132+
shift, capslock: 'T'
133+
}
134+
135+
key Y {
136+
label: 'Y'
137+
base: 'y'
138+
shift, capslock: 'Y'
139+
}
140+
141+
key U {
142+
label: 'U'
143+
base: 'u'
144+
shift, capslock: 'U'
145+
}
146+
147+
key I {
148+
label: 'I'
149+
base: 'i'
150+
shift, capslock: 'I'
151+
}
152+
153+
key O {
154+
label: 'O'
155+
base: 'o'
156+
shift, capslock: 'O'
157+
}
158+
159+
key P {
160+
label: 'P'
161+
base: 'p'
162+
shift, capslock: 'P'
163+
}
164+
165+
key LEFT_BRACKET {
166+
label: '['
167+
base: '['
168+
shift: '{'
169+
}
170+
171+
key RIGHT_BRACKET {
172+
label: ']'
173+
base: ']'
174+
shift: '}'
175+
}
176+
177+
key BACKSLASH {
178+
label: '\\'
179+
base: '\\'
180+
shift: '|'
181+
}
182+
183+
### ROW 3
184+
185+
key A {
186+
label: 'A'
187+
base: 'a'
188+
shift, capslock: 'A'
189+
}
190+
191+
key S {
192+
label: 'S'
193+
base: 's'
194+
shift, capslock: 'S'
195+
}
196+
197+
key D {
198+
label: 'D'
199+
base: 'd'
200+
shift, capslock: 'D'
201+
}
202+
203+
key F {
204+
label: 'F'
205+
base: 'f'
206+
shift, capslock: 'F'
207+
}
208+
209+
key G {
210+
label: 'G'
211+
base: 'g'
212+
shift, capslock: 'G'
213+
}
214+
215+
key H {
216+
label: 'H'
217+
base: 'h'
218+
shift, capslock: 'H'
219+
}
220+
221+
key J {
222+
label: 'J'
223+
base: 'j'
224+
shift, capslock: 'J'
225+
}
226+
227+
key K {
228+
label: 'K'
229+
base: 'k'
230+
shift, capslock: 'K'
231+
}
232+
233+
key L {
234+
label: 'L'
235+
base: 'l'
236+
shift, capslock: 'L'
237+
}
238+
239+
key SEMICOLON {
240+
label: ';'
241+
base: ';'
242+
shift: ':'
243+
}
244+
245+
key APOSTROPHE {
246+
label: '\''
247+
base: '\''
248+
shift: '"'
249+
}
250+
251+
### ROW 4
252+
253+
key Z {
254+
label: 'Z'
255+
base: 'z'
256+
shift, capslock: 'Z'
257+
}
258+
259+
key X {
260+
label: 'X'
261+
base: 'x'
262+
shift, capslock: 'X'
263+
}
264+
265+
key C {
266+
label: 'C'
267+
base: 'c'
268+
shift, capslock: 'C'
269+
}
270+
271+
key V {
272+
label: 'V'
273+
base: 'v'
274+
shift, capslock: 'V'
275+
}
276+
277+
key B {
278+
label: 'B'
279+
base: 'b'
280+
shift, capslock: 'B'
281+
}
282+
283+
key N {
284+
label: 'N'
285+
base: 'n'
286+
shift, capslock: 'N'
287+
}
288+
289+
key M {
290+
label: 'M'
291+
base: 'm'
292+
shift, capslock: 'M'
293+
}
294+
295+
key COMMA {
296+
label: ','
297+
base: ','
298+
shift: '<'
299+
}
300+
301+
key PERIOD {
302+
label: '.'
303+
base: '.'
304+
shift: '>'
305+
}
306+
307+
key SLASH {
308+
label: '/'
309+
base: '/'
310+
shift: '?'
311+
}

0 commit comments

Comments
 (0)