diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-04-17 18:50:05 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-04-17 18:50:05 -0700 |
commit | 4a3862f6b0a8971b6ab5b1c46735b28e7604d0db (patch) | |
tree | 4091176054868659d2fa6bec36540f56c08bd116 /services | |
parent | 6ec6f79e1ac1714e3b837796e99f07ff88f66601 (diff) | |
download | frameworks_base-4a3862f6b0a8971b6ab5b1c46735b28e7604d0db.zip frameworks_base-4a3862f6b0a8971b6ab5b1c46735b28e7604d0db.tar.gz frameworks_base-4a3862f6b0a8971b6ab5b1c46735b28e7604d0db.tar.bz2 |
Add Dvorak keyboard layout.
Added support for mapping both scan codes and HID usages to
KeyLayoutMap and KeyCharacterMap. Keyboard overlays can
now influence how key events are mapped to key codes.
Bug: 6110399
Change-Id: I6619fd2d3e1337c55928f89869dbc45b535c7ccf
Diffstat (limited to 'services')
-rw-r--r-- | services/input/EventHub.cpp | 26 | ||||
-rw-r--r-- | services/input/EventHub.h | 7 |
2 files changed, 24 insertions, 9 deletions
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp index b788e16..326dc32 100644 --- a/services/input/EventHub.cpp +++ b/services/input/EventHub.cpp @@ -443,11 +443,22 @@ status_t EventHub::mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, AutoMutex _l(mLock); Device* device = getDeviceLocked(deviceId); - if (device && device->keyMap.haveKeyLayout()) { - status_t err = device->keyMap.keyLayoutMap->mapKey( - scanCode, usageCode, outKeycode, outFlags); - if (err == NO_ERROR) { - return NO_ERROR; + if (device) { + // Check the key character map first. + sp<KeyCharacterMap> kcm = device->getKeyCharacterMap(); + if (kcm != NULL) { + if (!kcm->mapKey(scanCode, usageCode, outKeycode)) { + *outFlags = 0; + return NO_ERROR; + } + } + + // Check the key layout next. + if (device->keyMap.haveKeyLayout()) { + if (!device->keyMap.keyLayoutMap->mapKey( + scanCode, usageCode, outKeycode, outFlags)) { + return NO_ERROR; + } } } @@ -531,10 +542,7 @@ sp<KeyCharacterMap> EventHub::getKeyCharacterMap(int32_t deviceId) const { AutoMutex _l(mLock); Device* device = getDeviceLocked(deviceId); if (device) { - if (device->combinedKeyMap != NULL) { - return device->combinedKeyMap; - } - return device->keyMap.keyCharacterMap; + return device->getKeyCharacterMap(); } return NULL; } diff --git a/services/input/EventHub.h b/services/input/EventHub.h index f885f4d..afc12ef 100644 --- a/services/input/EventHub.h +++ b/services/input/EventHub.h @@ -335,6 +335,13 @@ private: void close(); inline bool isVirtual() const { return fd < 0; } + + const sp<KeyCharacterMap>& getKeyCharacterMap() const { + if (combinedKeyMap != NULL) { + return combinedKeyMap; + } + return keyMap.keyCharacterMap; + } }; status_t openDeviceLocked(const char *devicePath); |