From 49ccac530b5a798e3c4a79b66b51b8546a0deed1 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 11 Apr 2012 18:27:33 -0700 Subject: Refactor key code mapping. Added handling for EV_MSC / MSC_SCAN which typically reports the HID usage associated with a key. This will enable key maps to map keys with HID usages that Linux does not natively recognize. Removed keyCode and flags fields from EventHub RawEvent since they don't necessarily make sense in isolation now that we pay attention to HID usage codes too. Removed the fallback code for mapping keys and axes. In practice, an input device should be self-sufficient. We should not ever need to look at the built-in keyboard's key map. In fact, there usually isn't a built-in keyboard anyhow. This code was originally working around a problem where we weren't loading the key map for touch screens with virtual keys, which has long since been fixed. Change-Id: I0a319bdec44be9514f795526347397e94d53a127 --- include/androidfw/KeyLayoutMap.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/androidfw/KeyLayoutMap.h') diff --git a/include/androidfw/KeyLayoutMap.h b/include/androidfw/KeyLayoutMap.h index 54086805306d..e7f22a260c3b 100644 --- a/include/androidfw/KeyLayoutMap.h +++ b/include/androidfw/KeyLayoutMap.h @@ -64,7 +64,8 @@ class KeyLayoutMap : public RefBase { public: static status_t load(const String8& filename, sp* outMap); - status_t mapKey(int32_t scanCode, int32_t* keyCode, uint32_t* flags) const; + status_t mapKey(int32_t scanCode, int32_t usageCode, + int32_t* outKeyCode, uint32_t* outFlags) const; status_t findScanCodesForKey(int32_t keyCode, Vector* outScanCodes) const; status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const; @@ -78,11 +79,14 @@ private: uint32_t flags; }; - KeyedVector mKeys; + KeyedVector mKeysByScanCode; + KeyedVector mKeysByUsageCode; KeyedVector mAxes; KeyLayoutMap(); + const Key* getKey(int32_t scanCode, int32_t usageCode) const; + class Parser { KeyLayoutMap* mMap; Tokenizer* mTokenizer; -- cgit v1.2.3-59-g8ed1b