summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Redestig <johan.redestig@sonyericsson.com>2011-02-25 16:45:17 +0100
committerJohan Redestig <johan.redestig@sonyericsson.com>2011-03-08 16:27:46 +0100
commit141c8b5195094a3009848a96aa5b922171e908e8 (patch)
treef25c80195e1318380ba80f4a22c3ab5dca7ae00e
parent1de4a2ca58df9bd21e054742f52e0af7a2ed5864 (diff)
downloadframeworks_base-141c8b5195094a3009848a96aa5b922171e908e8.zip
frameworks_base-141c8b5195094a3009848a96aa5b922171e908e8.tar.gz
frameworks_base-141c8b5195094a3009848a96aa5b922171e908e8.tar.bz2
Implement support for ALT and SHIFT modifiers
The spec for keymaps and keboard input at http://source.android.com/porting/keymaps_keyboard_input.html mentions the stand alone ALT and SHIFT modifiers: SHIFT: While pressed, the shift key modifier is set ALT: While pressed, the alt key modifier is set This commit implements support for these. Change-Id: I5854ef3df541740cc3443b474a9c41183eb7561c Ex: key 305 BACK ALT
-rw-r--r--libs/ui/InputDispatcher.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index 421ad663..92ed0b1 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -37,7 +37,9 @@
// Log debug messages about the app switch latency optimization.
#define DEBUG_APP_SWITCH 0
+#include <android/input.h>
#include <cutils/log.h>
+#include <ui/Input.h>
#include <ui/InputDispatcher.h>
#include <ui/PowerManager.h>
@@ -2092,6 +2094,26 @@ void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t sou
return;
}
+ /* According to http://source.android.com/porting/keymaps_keyboard_input.html
+ * Key definitions: Key definitions follow the syntax key SCANCODE KEYCODE [FLAGS...],
+ * where SCANCODE is a number, KEYCODE is defined in your specific keylayout file
+ * (android.keylayout.xxx), and potential FLAGS are defined as follows:
+ * SHIFT: While pressed, the shift key modifier is set
+ * ALT: While pressed, the alt key modifier is set
+ * CAPS: While pressed, the caps lock key modifier is set
+ * Since KeyEvent.java doesn't check if Cap lock is ON and we don't have a
+ * modifer state for cap lock, we will not support it.
+ */
+ if (policyFlags & POLICY_FLAG_ALT) {
+ metaState |= AMETA_ALT_ON | AMETA_ALT_LEFT_ON;
+ }
+ if (policyFlags & POLICY_FLAG_ALT_GR) {
+ metaState |= AMETA_ALT_ON | AMETA_ALT_RIGHT_ON;
+ }
+ if (policyFlags & POLICY_FLAG_SHIFT) {
+ metaState |= AMETA_SHIFT_ON | AMETA_SHIFT_LEFT_ON;
+ }
+
policyFlags |= POLICY_FLAG_TRUSTED;
mPolicy->interceptKeyBeforeQueueing(eventTime, deviceId, action, /*byref*/ flags,
keyCode, scanCode, /*byref*/ policyFlags);