summaryrefslogtreecommitdiffstats
path: root/libs/input
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2014-04-22 15:03:51 -0700
committerMichael Wright <michaelwr@google.com>2014-04-22 16:55:36 -0700
commit872db4f11e407accccba9d37c335ef7e3597eba4 (patch)
treee527c6316160e6e2dcb062f0440fd7c4afc43eed /libs/input
parent4cbf3c53447215a31f69d3ac615ba0daa902f717 (diff)
downloadframeworks_native-872db4f11e407accccba9d37c335ef7e3597eba4.zip
frameworks_native-872db4f11e407accccba9d37c335ef7e3597eba4.tar.gz
frameworks_native-872db4f11e407accccba9d37c335ef7e3597eba4.tar.bz2
Move key attribute information out of native.
Native doesn't ever actually care about the attributes of keys, so move all of it up into the managed layer and move all of the key names down so they're defined once. Change-Id: Ic8ded13ce050b2b98744735ff50d11e8d882d7d5
Diffstat (limited to 'libs/input')
-rw-r--r--libs/input/Input.cpp87
-rw-r--r--libs/input/InputTransport.cpp2
-rw-r--r--libs/input/KeyCharacterMap.cpp1
-rw-r--r--libs/input/KeyLayoutMap.cpp1
-rw-r--r--libs/input/Keyboard.cpp42
5 files changed, 17 insertions, 116 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index d9f22e9..3a7afe9 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -21,6 +21,7 @@
#include <limits.h>
#include <input/Input.h>
+#include <input/InputEventLabels.h>
#ifdef HAVE_ANDROID_OS
#include <binder/Parcel.h>
@@ -42,82 +43,12 @@ void InputEvent::initialize(const InputEvent& from) {
// --- KeyEvent ---
-bool KeyEvent::hasDefaultAction(int32_t keyCode) {
- switch (keyCode) {
- case AKEYCODE_HOME:
- case AKEYCODE_BACK:
- case AKEYCODE_CALL:
- case AKEYCODE_ENDCALL:
- case AKEYCODE_VOLUME_UP:
- case AKEYCODE_VOLUME_DOWN:
- case AKEYCODE_VOLUME_MUTE:
- case AKEYCODE_POWER:
- case AKEYCODE_CAMERA:
- case AKEYCODE_HEADSETHOOK:
- case AKEYCODE_MENU:
- case AKEYCODE_NOTIFICATION:
- case AKEYCODE_FOCUS:
- case AKEYCODE_SEARCH:
- case AKEYCODE_MEDIA_PLAY:
- case AKEYCODE_MEDIA_PAUSE:
- case AKEYCODE_MEDIA_PLAY_PAUSE:
- case AKEYCODE_MEDIA_STOP:
- case AKEYCODE_MEDIA_NEXT:
- case AKEYCODE_MEDIA_PREVIOUS:
- case AKEYCODE_MEDIA_REWIND:
- case AKEYCODE_MEDIA_RECORD:
- case AKEYCODE_MEDIA_FAST_FORWARD:
- case AKEYCODE_MUTE:
- case AKEYCODE_BRIGHTNESS_DOWN:
- case AKEYCODE_BRIGHTNESS_UP:
- case AKEYCODE_MEDIA_AUDIO_TRACK:
- return true;
- }
-
- return false;
-}
-
-bool KeyEvent::hasDefaultAction() const {
- return hasDefaultAction(getKeyCode());
-}
-
-bool KeyEvent::isSystemKey(int32_t keyCode) {
- switch (keyCode) {
- case AKEYCODE_MENU:
- case AKEYCODE_SOFT_RIGHT:
- case AKEYCODE_HOME:
- case AKEYCODE_BACK:
- case AKEYCODE_CALL:
- case AKEYCODE_ENDCALL:
- case AKEYCODE_VOLUME_UP:
- case AKEYCODE_VOLUME_DOWN:
- case AKEYCODE_VOLUME_MUTE:
- case AKEYCODE_MUTE:
- case AKEYCODE_POWER:
- case AKEYCODE_HEADSETHOOK:
- case AKEYCODE_MEDIA_PLAY:
- case AKEYCODE_MEDIA_PAUSE:
- case AKEYCODE_MEDIA_PLAY_PAUSE:
- case AKEYCODE_MEDIA_STOP:
- case AKEYCODE_MEDIA_NEXT:
- case AKEYCODE_MEDIA_PREVIOUS:
- case AKEYCODE_MEDIA_REWIND:
- case AKEYCODE_MEDIA_RECORD:
- case AKEYCODE_MEDIA_FAST_FORWARD:
- case AKEYCODE_CAMERA:
- case AKEYCODE_FOCUS:
- case AKEYCODE_SEARCH:
- case AKEYCODE_BRIGHTNESS_DOWN:
- case AKEYCODE_BRIGHTNESS_UP:
- case AKEYCODE_MEDIA_AUDIO_TRACK:
- return true;
- }
-
- return false;
+const char* KeyEvent::getLabel(int32_t keyCode) {
+ return getLabelByKeyCode(keyCode);
}
-bool KeyEvent::isSystemKey() const {
- return isSystemKey(getKeyCode());
+int32_t KeyEvent::getKeyCodeFromLabel(const char* label) {
+ return getKeyCodeByLabel(label);
}
void KeyEvent::initialize(
@@ -591,6 +522,14 @@ bool MotionEvent::isTouchEvent(int32_t source, int32_t action) {
return false;
}
+const char* MotionEvent::getLabel(int32_t axis) {
+ return getAxisLabel(axis);
+}
+
+int32_t MotionEvent::getAxisFromLabel(const char* label) {
+ return getAxisByLabel(label);
+}
+
// --- PooledInputEventFactory ---
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 09b2e7c..a73780d 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -312,7 +312,7 @@ status_t InputPublisher::publishMotionEvent(
}
if (pointerCount > MAX_POINTERS || pointerCount < 1) {
- ALOGE("channel '%s' publisher ~ Invalid number of pointers provided: %d.",
+ ALOGE("channel '%s' publisher ~ Invalid number of pointers provided: %zu.",
mChannel->getName().string(), pointerCount);
return BAD_VALUE;
}
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp
index 15a8774..b03e01e 100644
--- a/libs/input/KeyCharacterMap.cpp
+++ b/libs/input/KeyCharacterMap.cpp
@@ -24,6 +24,7 @@
#endif
#include <android/keycodes.h>
+#include <input/InputEventLabels.h>
#include <input/Keyboard.h>
#include <input/KeyCharacterMap.h>
diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp
index 0800a31..2b2f13e 100644
--- a/libs/input/KeyLayoutMap.cpp
+++ b/libs/input/KeyLayoutMap.cpp
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <android/keycodes.h>
+#include <input/InputEventLabels.h>
#include <input/Keyboard.h>
#include <input/KeyLayoutMap.h>
#include <utils/Log.h>
diff --git a/libs/input/Keyboard.cpp b/libs/input/Keyboard.cpp
index 7d4ac92..f4d9507 100644
--- a/libs/input/Keyboard.cpp
+++ b/libs/input/Keyboard.cpp
@@ -21,7 +21,7 @@
#include <limits.h>
#include <input/Keyboard.h>
-#include <input/KeycodeLabels.h>
+#include <input/InputEventLabels.h>
#include <input/KeyLayoutMap.h>
#include <input/KeyCharacterMap.h>
#include <input/InputDevice.h>
@@ -167,46 +167,6 @@ bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier,
return strstr(deviceIdentifier.name.string(), "-keypad");
}
-static int lookupValueByLabel(const char* literal, const KeycodeLabel *list) {
- while (list->literal) {
- if (strcmp(literal, list->literal) == 0) {
- return list->value;
- }
- list++;
- }
- return list->value;
-}
-
-static const char* lookupLabelByValue(int value, const KeycodeLabel *list) {
- while (list->literal) {
- if (list->value == value) {
- return list->literal;
- }
- list++;
- }
- return NULL;
-}
-
-int32_t getKeyCodeByLabel(const char* label) {
- return int32_t(lookupValueByLabel(label, KEYCODES));
-}
-
-uint32_t getKeyFlagByLabel(const char* label) {
- return uint32_t(lookupValueByLabel(label, FLAGS));
-}
-
-int32_t getAxisByLabel(const char* label) {
- return int32_t(lookupValueByLabel(label, AXES));
-}
-
-const char* getAxisLabel(int32_t axisId) {
- return lookupLabelByValue(axisId, AXES);
-}
-
-int32_t getLedByLabel(const char* label) {
- return int32_t(lookupValueByLabel(label, LEDS));
-}
-
static int32_t setEphemeralMetaState(int32_t mask, bool down, int32_t oldMetaState) {
int32_t newMetaState;
if (down) {