summaryrefslogtreecommitdiff
path: root/core/java/android/view/MotionEvent.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-09-12 17:55:08 -0700
committerJeff Brown <jeffbrown@google.com>2010-10-15 16:00:07 -0700
commit497a92cc5ba2176b8a8484b0a7da040eac0e887b (patch)
tree2d9bd7a2ef24754fa83a36f440ee45fd8a32b9fb /core/java/android/view/MotionEvent.java
parentcd9afc3722a1edebf0e6f7172627930052c81ce4 (diff)
Add keycodes and meta-key modifiers to support external keyboards.
Added new key maps for external keyboards. These maps are intended to be shared across devices by inheriting the "keyboards.mk" product makefile as part of the device's product definition. One of the trickier changes here was to unwind some code in MetaKeyKeyListener that assumed that only the low 8 bits of the meta key state were actually used. The new code abandons bitshifts in favor of simple conditionals that are probably easier to read anyways. The special meta key state constants used by MetaKeyKeyListener are now (@hide) defined in KeyEvent now so as to make it clearer that they share the same code space even if those codes are not valid for KeyEvents. The EventHub now takes care of detecting the appropriate key layout map and key character map when the device is added and sets system properties accordingly. This avoids having duplicate code in KeyCharacterMap to probe for the appropriate key character map although the current probing mechanism has been preserved for legacy reasons just in case. Added support for tracking caps lock, num lock and scroll lock and turning their corresponding LEDs on and off as needed. The key character map format will need to be updated to correctly support PC style external keyboard semantics related to modifier keys. That will come in a later change so caps lock doesn't actually do anything right now except turn the shiny LEDs on and off... Added a list of symbolic key names to KeyEvent and improved the toString() output for debug diagnosis. Having this list in a central place in the framework also allows us to remove it from Monkey so there is one less thing to maintain when we add new keycodes. Bug: 2912307 Change-Id: If8c25e8d50a7c29bbf5d663c94284f5f86de5da4
Diffstat (limited to 'core/java/android/view/MotionEvent.java')
-rw-r--r--core/java/android/view/MotionEvent.java50
1 files changed, 48 insertions, 2 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 941147482c4f..195d6893e1cb 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1550,8 +1550,54 @@ public final class MotionEvent extends InputEvent implements Parcelable {
@Override
public String toString() {
return "MotionEvent{" + Integer.toHexString(System.identityHashCode(this))
- + " action=" + mAction + " x=" + getX()
- + " y=" + getY() + " pressure=" + getPressure() + " size=" + getSize() + "}";
+ + " action=" + actionToString(mAction)
+ + " x=" + getX()
+ + " y=" + getY()
+ + " pressure=" + getPressure()
+ + " size=" + getSize()
+ + " touchMajor=" + getTouchMajor()
+ + " touchMinor=" + getTouchMinor()
+ + " toolMajor=" + getToolMajor()
+ + " toolMinor=" + getToolMinor()
+ + " orientation=" + getOrientation()
+ + " meta=" + KeyEvent.metaStateToString(mMetaState)
+ + " pointerCount=" + getPointerCount()
+ + " historySize=" + getHistorySize()
+ + " flags=0x" + Integer.toHexString(mFlags)
+ + " edgeFlags=0x" + Integer.toHexString(mEdgeFlags)
+ + " device=" + mDeviceId
+ + " source=0x" + Integer.toHexString(mSource)
+ + "}";
+ }
+
+ /**
+ * Returns a string that represents the symbolic name of the specified action
+ * such as "ACTION_DOWN", "ACTION_POINTER_DOWN(3)" or "35" (if unknown).
+ *
+ * @param action The action.
+ * @return The symbolic name of the specified action.
+ * @hide
+ */
+ public static String actionToString(int action) {
+ switch (action) {
+ case ACTION_DOWN:
+ return "ACTION_DOWN";
+ case ACTION_UP:
+ return "ACTION_UP";
+ case ACTION_CANCEL:
+ return "ACTION_CANCEL";
+ case ACTION_MOVE:
+ return "ACTION_MOVE";
+ }
+ int index = (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT;
+ switch (action & ACTION_MASK) {
+ case ACTION_POINTER_DOWN:
+ return "ACTION_POINTER_DOWN(" + index + ")";
+ case ACTION_POINTER_UP:
+ return "ACTION_POINTER_UP(" + index + ")";
+ default:
+ return Integer.toString(action);
+ }
}
public static final Parcelable.Creator<MotionEvent> CREATOR