summaryrefslogtreecommitdiff
path: root/include/androidfw/KeyCharacterMap.h
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2012-04-10 14:30:49 -0700
committer Jeff Brown <jeffbrown@google.com> 2012-04-10 18:23:58 -0700
commit9f25b7fdf216c9ef0bd2322cd223eeaf0d60f77f (patch)
treeb0b509a261874435cab3f5f1a727c02b399bd91c /include/androidfw/KeyCharacterMap.h
parent54ae14749bc7f9e73cfda35a8b49f9efa80a77fb (diff)
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
Diffstat (limited to 'include/androidfw/KeyCharacterMap.h')
-rw-r--r--include/androidfw/KeyCharacterMap.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/include/androidfw/KeyCharacterMap.h b/include/androidfw/KeyCharacterMap.h
index 679dd2c04fdf..3cc1cb2a01db 100644
--- a/include/androidfw/KeyCharacterMap.h
+++ b/include/androidfw/KeyCharacterMap.h
@@ -19,12 +19,17 @@
#include <stdint.h>
+#if HAVE_ANDROID_OS
+#include <binder/IBinder.h>
+#endif
+
#include <androidfw/Input.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/Tokenizer.h>
#include <utils/String8.h>
#include <utils/Unicode.h>
+#include <utils/RefBase.h>
namespace android {
@@ -32,8 +37,10 @@ namespace android {
* Describes a mapping from Android key codes to characters.
* Also specifies other functions of the keyboard such as the keyboard type
* and key modifier semantics.
+ *
+ * This object is immutable after it has been loaded.
*/
-class KeyCharacterMap {
+class KeyCharacterMap : public RefBase {
public:
enum KeyboardType {
KEYBOARD_TYPE_UNKNOWN = 0,
@@ -50,9 +57,11 @@ public:
int32_t metaState;
};
- ~KeyCharacterMap();
+ /* Loads a key character map from a file. */
+ static status_t load(const String8& filename, sp<KeyCharacterMap>* outMap);
- static status_t load(const String8& filename, KeyCharacterMap** outMap);
+ /* Returns an empty key character map. */
+ static sp<KeyCharacterMap> empty();
/* Gets the keyboard type. */
int32_t getKeyboardType() const;
@@ -92,6 +101,17 @@ public:
bool getEvents(int32_t deviceId, const char16_t* chars, size_t numChars,
Vector<KeyEvent>& outEvents) const;
+#if HAVE_ANDROID_OS
+ /* Reads a key map from a parcel. */
+ static sp<KeyCharacterMap> readFromParcel(Parcel* parcel);
+
+ /* Writes a key map to a parcel. */
+ void writeToParcel(Parcel* parcel) const;
+#endif
+
+protected:
+ virtual ~KeyCharacterMap();
+
private:
struct Behavior {
Behavior();
@@ -162,6 +182,8 @@ private:
status_t parseCharacterLiteral(char16_t* outCharacter);
};
+ static sp<KeyCharacterMap> sEmpty;
+
KeyedVector<int32_t, Key*> mKeys;
int mType;