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
diff --git a/include/androidfw/KeyLayoutMap.h b/include/androidfw/KeyLayoutMap.h
index 5408680..e7f22a2 100644
--- a/include/androidfw/KeyLayoutMap.h
+++ b/include/androidfw/KeyLayoutMap.h
@@ -64,7 +64,8 @@
 public:
     static status_t load(const String8& filename, sp<KeyLayoutMap>* 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<int32_t>* outScanCodes) const;
 
     status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const;
@@ -78,11 +79,14 @@
         uint32_t flags;
     };
 
-    KeyedVector<int32_t, Key> mKeys;
+    KeyedVector<int32_t, Key> mKeysByScanCode;
+    KeyedVector<int32_t, Key> mKeysByUsageCode;
     KeyedVector<int32_t, AxisInfo> mAxes;
 
     KeyLayoutMap();
 
+    const Key* getKey(int32_t scanCode, int32_t usageCode) const;
+
     class Parser {
         KeyLayoutMap* mMap;
         Tokenizer* mTokenizer;