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
This commit is contained in:
Jeff Brown
2012-04-23 16:12:32 -07:00
parent fd6a5245cc
commit 8bca94ad83
6 changed files with 907 additions and 11 deletions

View File

@@ -132,7 +132,7 @@ InputDeviceInfo::InputDeviceInfo() {
InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) :
mId(other.mId), mGeneration(other.mGeneration), mIdentifier(other.mIdentifier),
mSources(other.mSources),
mAlias(other.mAlias), mSources(other.mSources),
mKeyboardType(other.mKeyboardType),
mKeyCharacterMap(other.mKeyCharacterMap),
mHasVibrator(other.mHasVibrator),

View File

@@ -713,8 +713,8 @@ status_t KeyCharacterMap::Parser::parse() {
}
mTokenizer->skipDelimiters(WHITESPACE);
if (!mTokenizer->isEol()) {
ALOGE("%s: Expected end of line, got '%s'.",
if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
ALOGE("%s: Expected end of line or trailing comment, got '%s'.",
mTokenizer->getLocation().string(),
mTokenizer->peekRemainderOfLine().string());
return BAD_VALUE;
@@ -973,7 +973,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
}
mTokenizer->skipDelimiters(WHITESPACE);
} while (!mTokenizer->isEol());
} while (!mTokenizer->isEol() && mTokenizer->peekChar() != '#');
// Add the behavior.
for (size_t i = 0; i < properties.size(); i++) {

View File

@@ -185,8 +185,8 @@ status_t KeyLayoutMap::Parser::parse() {
}
mTokenizer->skipDelimiters(WHITESPACE);
if (!mTokenizer->isEol()) {
ALOGE("%s: Expected end of line, got '%s'.",
if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
ALOGE("%s: Expected end of line or trailing comment, got '%s'.",
mTokenizer->getLocation().string(),
mTokenizer->peekRemainderOfLine().string());
return BAD_VALUE;
@@ -234,7 +234,7 @@ status_t KeyLayoutMap::Parser::parseKey() {
uint32_t flags = 0;
for (;;) {
mTokenizer->skipDelimiters(WHITESPACE);
if (mTokenizer->isEol()) break;
if (mTokenizer->isEol() || mTokenizer->peekChar() == '#') break;
String8 flagToken = mTokenizer->nextToken(WHITESPACE);
uint32_t flag = getKeyFlagByLabel(flagToken.string());
@@ -332,7 +332,7 @@ status_t KeyLayoutMap::Parser::parseAxis() {
for (;;) {
mTokenizer->skipDelimiters(WHITESPACE);
if (mTokenizer->isEol()) {
if (mTokenizer->isEol() || mTokenizer->peekChar() == '#') {
break;
}
String8 keywordToken = mTokenizer->nextToken(WHITESPACE);

View File

@@ -14,7 +14,298 @@
#
# English (US) keyboard layout.
# Assumes that the base keyboard layout is already English (US).
# Unlike the default (generic) keyboard layout, English (US) does not contain any
# special ALT characters.
#
type OVERLAY
### ROW 1
key GRAVE {
label: '`'
base: '`'
shift: '~'
}
key 1 {
label: '1'
base: '1'
shift: '!'
}
key 2 {
label: '2'
base: '2'
shift: '@'
}
key 3 {
label: '3'
base: '3'
shift: '#'
}
key 4 {
label: '4'
base: '4'
shift: '$'
}
key 5 {
label: '5'
base: '5'
shift: '%'
}
key 6 {
label: '6'
base: '6'
shift: '^'
}
key 7 {
label: '7'
base: '7'
shift: '&'
}
key 8 {
label: '8'
base: '8'
shift: '*'
}
key 9 {
label: '9'
base: '9'
shift: '('
}
key 0 {
label: '0'
base: '0'
shift: ')'
}
key MINUS {
label: '-'
base: '-'
shift: '_'
}
key EQUALS {
label: '='
base: '='
shift: '+'
}
### ROW 2
key Q {
label: 'Q'
base: 'q'
shift, capslock: 'Q'
}
key W {
label: 'W'
base: 'w'
shift, capslock: 'W'
}
key E {
label: 'E'
base: 'e'
shift, capslock: 'E'
}
key R {
label: 'R'
base: 'r'
shift, capslock: 'R'
}
key T {
label: 'T'
base: 't'
shift, capslock: 'T'
}
key Y {
label: 'Y'
base: 'y'
shift, capslock: 'Y'
}
key U {
label: 'U'
base: 'u'
shift, capslock: 'U'
}
key I {
label: 'I'
base: 'i'
shift, capslock: 'I'
}
key O {
label: 'O'
base: 'o'
shift, capslock: 'O'
}
key P {
label: 'P'
base: 'p'
shift, capslock: 'P'
}
key LEFT_BRACKET {
label: '['
base: '['
shift: '{'
}
key RIGHT_BRACKET {
label: ']'
base: ']'
shift: '}'
}
key BACKSLASH {
label: '\\'
base: '\\'
shift: '|'
}
### ROW 3
key A {
label: 'A'
base: 'a'
shift, capslock: 'A'
}
key S {
label: 'S'
base: 's'
shift, capslock: 'S'
}
key D {
label: 'D'
base: 'd'
shift, capslock: 'D'
}
key F {
label: 'F'
base: 'f'
shift, capslock: 'F'
}
key G {
label: 'G'
base: 'g'
shift, capslock: 'G'
}
key H {
label: 'H'
base: 'h'
shift, capslock: 'H'
}
key J {
label: 'J'
base: 'j'
shift, capslock: 'J'
}
key K {
label: 'K'
base: 'k'
shift, capslock: 'K'
}
key L {
label: 'L'
base: 'l'
shift, capslock: 'L'
}
key SEMICOLON {
label: ';'
base: ';'
shift: ':'
}
key APOSTROPHE {
label: '\''
base: '\''
shift: '"'
}
### ROW 4
key Z {
label: 'Z'
base: 'z'
shift, capslock: 'Z'
}
key X {
label: 'X'
base: 'x'
shift, capslock: 'X'
}
key C {
label: 'C'
base: 'c'
shift, capslock: 'C'
}
key V {
label: 'V'
base: 'v'
shift, capslock: 'V'
}
key B {
label: 'B'
base: 'b'
shift, capslock: 'B'
}
key N {
label: 'N'
base: 'n'
shift, capslock: 'N'
}
key M {
label: 'M'
base: 'm'
shift, capslock: 'M'
}
key COMMA {
label: ','
base: ','
shift: '<'
}
key PERIOD {
label: '.'
base: '.'
shift: '>'
}
key SLASH {
label: '/'
base: '/'
shift: '?'
}

View File

@@ -14,7 +14,8 @@
#
# English (US), Dvorak keyboard layout.
# Assumes that the base keyboard layout is already English (US).
# Unlike the default (generic) keyboard layout, English (US) does not contain any
# special ALT characters.
#
type OVERLAY
@@ -54,3 +55,293 @@ map key 50 M
map key 51 W
map key 52 V
map key 53 Z
### ROW 1
key GRAVE {
label: '`'
base: '`'
shift: '~'
}
key 1 {
label: '1'
base: '1'
shift: '!'
}
key 2 {
label: '2'
base: '2'
shift: '@'
}
key 3 {
label: '3'
base: '3'
shift: '#'
}
key 4 {
label: '4'
base: '4'
shift: '$'
}
key 5 {
label: '5'
base: '5'
shift: '%'
}
key 6 {
label: '6'
base: '6'
shift: '^'
}
key 7 {
label: '7'
base: '7'
shift: '&'
}
key 8 {
label: '8'
base: '8'
shift: '*'
}
key 9 {
label: '9'
base: '9'
shift: '('
}
key 0 {
label: '0'
base: '0'
shift: ')'
}
key LEFT_BRACKET {
label: '['
base: '['
shift: '{'
}
key RIGHT_BRACKET {
label: ']'
base: ']'
shift: '}'
}
### ROW 2
key APOSTROPHE {
label: '\''
base: '\''
shift: '"'
}
key COMMA {
label: ','
base: ','
shift: '<'
}
key PERIOD {
label: '.'
base: '.'
shift: '>'
}
key P {
label: 'P'
base: 'p'
shift, capslock: 'P'
}
key Y {
label: 'Y'
base: 'y'
shift, capslock: 'Y'
}
key F {
label: 'F'
base: 'f'
shift, capslock: 'F'
}
key G {
label: 'G'
base: 'g'
shift, capslock: 'G'
}
key C {
label: 'C'
base: 'c'
shift, capslock: 'C'
}
key R {
label: 'R'
base: 'r'
shift, capslock: 'R'
}
key L {
label: 'L'
base: 'l'
shift, capslock: 'L'
}
key SLASH {
label: '/'
base: '/'
shift: '?'
}
key EQUALS {
label: '='
base: '='
shift: '+'
}
key BACKSLASH {
label: '\\'
base: '\\'
shift: '|'
}
### ROW 3
key A {
label: 'A'
base: 'a'
shift, capslock: 'A'
}
key O {
label: 'O'
base: 'o'
shift, capslock: 'O'
}
key E {
label: 'E'
base: 'e'
shift, capslock: 'E'
}
key U {
label: 'U'
base: 'u'
shift, capslock: 'U'
}
key I {
label: 'I'
base: 'i'
shift, capslock: 'I'
}
key D {
label: 'D'
base: 'd'
shift, capslock: 'D'
}
key H {
label: 'H'
base: 'h'
shift, capslock: 'H'
}
key T {
label: 'T'
base: 't'
shift, capslock: 'T'
}
key N {
label: 'N'
base: 'n'
shift, capslock: 'N'
}
key S {
label: 'S'
base: 's'
shift, capslock: 'S'
}
key MINUS {
label: '-'
base: '-'
shift: '_'
}
### ROW 4
key SEMICOLON {
label: ';'
base: ';'
shift: ':'
}
key Q {
label: 'Q'
base: 'q'
shift, capslock: 'Q'
}
key J {
label: 'J'
base: 'j'
shift, capslock: 'J'
}
key K {
label: 'K'
base: 'k'
shift, capslock: 'K'
}
key X {
label: 'X'
base: 'x'
shift, capslock: 'X'
}
key B {
label: 'B'
base: 'b'
shift, capslock: 'B'
}
key M {
label: 'M'
base: 'm'
shift, capslock: 'M'
}
key W {
label: 'W'
base: 'w'
shift, capslock: 'W'
}
key V {
label: 'V'
base: 'v'
shift, capslock: 'V'
}
key Z {
label: 'Z'
base: 'z'
shift, capslock: 'Z'
}

View File

@@ -13,7 +13,321 @@
# limitations under the License.
#
# German keyboard layout.
# German keyboard layout, QWERTZ style.
#
type OVERLAY
map key 12 SLASH # <20> ? \
map key 21 Z
map key 44 Y
map key 53 MINUS # - _
map key 86 PLUS # < > |
### ROW 1
key GRAVE {
label: '^'
base: '^'
shift: '\u00b0'
}
key 1 {
label: '1'
base: '1'
shift: '!'
}
key 2 {
label: '2'
base: '2'
shift: '"'
ralt: '\u00b2'
}
key 3 {
label: '3'
base: '3'
shift: '\u00a7'
ralt: '\u00b3'
}
key 4 {
label: '4'
base: '4'
shift: '$'
}
key 5 {
label: '5'
base: '5'
shift: '%'
}
key 6 {
label: '6'
base: '6'
shift: '&'
}
key 7 {
label: '7'
base: '7'
shift: '/'
ralt: '{'
}
key 8 {
label: '8'
base: '8'
shift: '('
ralt: '['
}
key 9 {
label: '9'
base: '9'
shift: ')'
ralt: ']'
}
key 0 {
label: '0'
base: '0'
shift: '='
ralt: '}'
}
key SLASH {
label: '\u00df'
base: '\u00df'
shift: '?'
ralt: '\\'
}
key EQUALS {
label: '\u00b4'
base: '\u0301'
shift: '\u0300'
}
### ROW 2
key Q {
label: 'Q'
base: 'q'
shift, capslock: 'Q'
ralt: '@'
}
key W {
label: 'W'
base: 'w'
shift, capslock: 'W'
}
key E {
label: 'E'
base: 'e'
shift, capslock: 'E'
ralt: '\u20ac'
}
key R {
label: 'R'
base: 'r'
shift, capslock: 'R'
}
key T {
label: 'T'
base: 't'
shift, capslock: 'T'
}
key Z {
label: 'Z'
base: 'z'
shift, capslock: 'Z'
}
key U {
label: 'U'
base: 'u'
shift, capslock: 'U'
}
key I {
label: 'I'
base: 'i'
shift, capslock: 'I'
}
key O {
label: 'O'
base: 'o'
shift, capslock: 'O'
}
key P {
label: 'P'
base: 'p'
shift, capslock: 'P'
}
key LEFT_BRACKET {
label: '\u00dc'
base: '\u00fc'
shift: '\u00dc'
}
key RIGHT_BRACKET {
label: '+'
base: '+'
shift: '*'
ralt: '~'
}
### ROW 3
key A {
label: 'A'
base: 'a'
shift, capslock: 'A'
}
key S {
label: 'S'
base: 's'
shift, capslock: 'S'
}
key D {
label: 'D'
base: 'd'
shift, capslock: 'D'
}
key F {
label: 'F'
base: 'f'
shift, capslock: 'F'
}
key G {
label: 'G'
base: 'g'
shift, capslock: 'G'
}
key H {
label: 'H'
base: 'h'
shift, capslock: 'H'
}
key J {
label: 'J'
base: 'j'
shift, capslock: 'J'
}
key K {
label: 'K'
base: 'k'
shift, capslock: 'K'
}
key L {
label: 'L'
base: 'l'
shift, capslock: 'L'
}
key SEMICOLON {
label: '\u00d6'
base: '\u00f6'
shift: '\u00d6'
}
key APOSTROPHE {
label: '\u00c4'
base: '\u00e4'
shift: '\u00c4'
}
key BACKSLASH {
label: '#'
base: '#'
shift: '\''
}
### ROW 4
key PLUS {
label: '<'
base: '<'
shift: '>'
ralt: '|'
}
key Y {
label: 'Y'
base: 'y'
shift, capslock: 'Y'
}
key X {
label: 'X'
base: 'x'
shift, capslock: 'X'
}
key C {
label: 'C'
base: 'c'
shift, capslock: 'C'
}
key V {
label: 'V'
base: 'v'
shift, capslock: 'V'
}
key B {
label: 'B'
base: 'b'
shift, capslock: 'B'
}
key N {
label: 'N'
base: 'n'
shift, capslock: 'N'
}
key M {
label: 'M'
base: 'm'
shift, capslock: 'M'
ralt: '\u00b5'
}
key COMMA {
label: ','
base: ','
shift: ';'
}
key PERIOD {
label: '.'
base: '.'
shift: ':'
}
key MINUS {
label: '-'
base: '-'
shift: '_'
}