From 9f25b7fdf216c9ef0bd2322cd223eeaf0d60f77f Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 10 Apr 2012 14:30:49 -0700 Subject: Request key maps from input manager service. Instead of each application loading the KeyCharacterMap from the file system, get them from the input manager service as part of the InputDevice object. Refactored InputManager to be a proper singleton instead of having a bunch of static methods. InputManager now maintains a cache of all InputDevice objects that it has loaded. Currently we never invalidate the cache which can cause InputDevice to return stale motion ranges if the device is reconfigured. This will be fixed in a future change. Added a fake InputDevice with ID -1 to represent the virtual keyboard. Change-Id: If7a695839ad0972317a5aab89e9d1e42ace28eb7 --- include/androidfw/KeyLayoutMap.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include/androidfw/KeyLayoutMap.h') diff --git a/include/androidfw/KeyLayoutMap.h b/include/androidfw/KeyLayoutMap.h index 5a6f55035463..54086805306d 100644 --- a/include/androidfw/KeyLayoutMap.h +++ b/include/androidfw/KeyLayoutMap.h @@ -21,6 +21,7 @@ #include #include #include +#include namespace android { @@ -56,18 +57,21 @@ struct AxisInfo { /** * Describes a mapping from keyboard scan codes and joystick axes to Android key codes and axes. + * + * This object is immutable after it has been loaded. */ -class KeyLayoutMap { +class KeyLayoutMap : public RefBase { public: - ~KeyLayoutMap(); - - static status_t load(const String8& filename, KeyLayoutMap** outMap); + static status_t load(const String8& filename, sp* outMap); status_t mapKey(int32_t scanCode, int32_t* keyCode, uint32_t* flags) const; status_t findScanCodesForKey(int32_t keyCode, Vector* outScanCodes) const; status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const; +protected: + virtual ~KeyLayoutMap(); + private: struct Key { int32_t keyCode; -- cgit v1.2.3-59-g8ed1b