summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@google.com>2015-09-17 18:04:50 -0700
committerDmitry Torokhov <dtor@google.com>2015-09-29 13:26:30 -0700
commit115f93eeebf7f33b56ed090de70d6e8c733e5d88 (patch)
tree5cfb07f29be5d8a907e903b9ff5304213b73fbb7 /include
parentce92ce9bef5942435bb49474f0e5e4b29cfc5e97 (diff)
downloadframeworks_native-115f93eeebf7f33b56ed090de70d6e8c733e5d88.zip
frameworks_native-115f93eeebf7f33b56ed090de70d6e8c733e5d88.tar.gz
frameworks_native-115f93eeebf7f33b56ed090de70d6e8c733e5d88.tar.bz2
Allow defining replacement key events in keymap
Currently keyboard maps allow to assign character sequences to key events and allow specifying a so-called "fallback" key events that are re-injected into input stream if target application indicates that it was not able to handle the original key event. Unfortunately there is no way to perform substitution before handing the event to applicationis. This change adds a new keymap keyword "replace" that allows users query "replacement" actions for key (if any), with the intent that such replacement happens early in the event handling process. Bug: 24504154 Change-Id: I3e6a2476c856524171df00ad22ff56f2018c1278
Diffstat (limited to 'include')
-rw-r--r--include/input/KeyCharacterMap.h8
-rw-r--r--include/input/Keyboard.h7
2 files changed, 15 insertions, 0 deletions
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h
index e70666a..3f0914b 100644
--- a/include/input/KeyCharacterMap.h
+++ b/include/input/KeyCharacterMap.h
@@ -124,6 +124,11 @@ public:
* the mapping in some way. */
status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKeyCode) const;
+ /* Tries to find a replacement key code for a given key code and meta state
+ * in character map. */
+ void tryRemapKey(int32_t scanCode, int32_t metaState,
+ int32_t* outKeyCode, int32_t* outMetaState) const;
+
#if HAVE_ANDROID_OS
/* Reads a key map from a parcel. */
static sp<KeyCharacterMap> readFromParcel(Parcel* parcel);
@@ -151,6 +156,9 @@ private:
/* The fallback keycode if the key is not handled. */
int32_t fallbackKeyCode;
+
+ /* The replacement keycode if the key has to be replaced outright. */
+ int32_t replacementKeyCode;
};
struct Key {
diff --git a/include/input/Keyboard.h b/include/input/Keyboard.h
index 519bb22..d4903e9 100644
--- a/include/input/Keyboard.h
+++ b/include/input/Keyboard.h
@@ -88,6 +88,13 @@ extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentif
extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
/**
+ * Normalizes the meta state such that if either the left or right modifier
+ * meta state bits are set then the result will also include the universal
+ * bit for that modifier.
+ */
+extern int32_t normalizeMetaState(int32_t oldMetaState);
+
+/**
* Returns true if a key is a meta key like ALT or CAPS_LOCK.
*/
extern bool isMetaKey(int32_t keyCode);