summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-05-06 18:20:01 -0700
committerJeff Brown <jeffbrown@google.com>2011-05-13 12:11:17 -0700
commitfe9f8ab03a63b1037f07dd85799fbea80ec6adaa (patch)
treec0cfa91d0537321eeee0ede693fb414d8778a1a2 /native
parent1abf1c59f8b15d5b4b198063b884e268bd79fb32 (diff)
downloadframeworks_base-fe9f8ab03a63b1037f07dd85799fbea80ec6adaa.zip
frameworks_base-fe9f8ab03a63b1037f07dd85799fbea80ec6adaa.tar.gz
frameworks_base-fe9f8ab03a63b1037f07dd85799fbea80ec6adaa.tar.bz2
Add initial API for stylus and mouse buttons.
Added the concept of pointer properties in a MotionEvent. This is currently used to track the pointer tool type to enable applications to distinguish finger touches from a stylus. Button states are also reported to application as part of touch events. There are no new actions for detecting changes in button states. The application should instead query the button state from the MotionEvent and take appropriate action as needed. A good time to check the button state is on ACTION_DOWN. As a side-effect, applications that do not support multiple buttons will treat primary, secondary and tertiary buttons identically for all touch events. The back button on the mouse is mapped to KEYCODE_BACK and the forward button is mapped to KEYCODE_FORWARD. Added basic plumbing for the secondary mouse button to invoke the context menu, particularly in lists. Added clamp and split methods on MotionEvent to take care of common filtering operations so we don't have them scattered in multiple places across the framework. Bug: 4260011 Change-Id: Ie992b4d4e00c8f2e76b961da0a902145b27f6d83
Diffstat (limited to 'native')
-rw-r--r--native/android/input.cpp8
-rw-r--r--native/include/android/input.h38
2 files changed, 45 insertions, 1 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp
index ed26667..91671c3 100644
--- a/native/android/input.cpp
+++ b/native/android/input.cpp
@@ -92,6 +92,10 @@ int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event) {
return static_cast<const MotionEvent*>(motion_event)->getMetaState();
}
+int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event) {
+ return static_cast<const MotionEvent*>(motion_event)->getButtonState();
+}
+
int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event) {
return reinterpret_cast<const MotionEvent*>(motion_event)->getEdgeFlags();
}
@@ -128,6 +132,10 @@ int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointe
return static_cast<const MotionEvent*>(motion_event)->getPointerId(pointer_index);
}
+int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index) {
+ return static_cast<const MotionEvent*>(motion_event)->getToolType(pointer_index);
+}
+
float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index) {
return static_cast<const MotionEvent*>(motion_event)->getRawX(pointer_index);
}
diff --git a/native/include/android/input.h b/native/include/android/input.h
index f1738c6..26cac50 100644
--- a/native/include/android/input.h
+++ b/native/include/android/input.h
@@ -372,6 +372,7 @@ enum {
AMOTION_EVENT_AXIS_WHEEL = 21,
AMOTION_EVENT_AXIS_GAS = 22,
AMOTION_EVENT_AXIS_BRAKE = 23,
+ AMOTION_EVENT_AXIS_DISTANCE = 24,
AMOTION_EVENT_AXIS_GENERIC_1 = 32,
AMOTION_EVENT_AXIS_GENERIC_2 = 33,
AMOTION_EVENT_AXIS_GENERIC_3 = 34,
@@ -394,6 +395,32 @@ enum {
};
/*
+ * Constants that identify buttons that are associated with motion events.
+ * Refer to the documentation on the MotionEvent class for descriptions of each button.
+ */
+enum {
+ AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
+ AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
+ AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
+ AMOTION_EVENT_BUTTON_BACK = 1 << 3,
+ AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
+ AMOTION_EVENT_BUTTON_ERASER = 1 << 5,
+};
+
+/*
+ * Constants that identify tool types.
+ * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
+ */
+enum {
+ AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
+ AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
+ AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
+ AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
+ AMOTION_EVENT_TOOL_TYPE_INDIRECT_FINGER = 4,
+ AMOTION_EVENT_TOOL_TYPE_INDIRECT_STYLUS = 5,
+};
+
+/*
* Input sources.
*
* Refer to the documentation on android.view.InputDevice for more details about input sources
@@ -417,6 +444,7 @@ enum {
AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
+ AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
@@ -532,6 +560,9 @@ int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
* event was generated. */
int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
+/* Get the button state of all buttons that are pressed. */
+int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
+
/* Get a bitfield indicating which edges, if any, were touched by this motion event.
* For touch events, clients can use this to determine if the user's finger was
* touching the edge of the display. */
@@ -572,11 +603,16 @@ float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
/* Get the pointer identifier associated with a particular pointer
- * data index is this event. The identifier tells you the actual pointer
+ * data index in this event. The identifier tells you the actual pointer
* number associated with the data, accounting for individual pointers
* going up and down since the start of the current gesture. */
int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
+/* Get the tool type of a pointer for the given pointer index.
+ * The tool type indicates the type of tool used to make contact such as a
+ * finger or stylus, if known. */
+int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
+
/* Get the original raw X coordinate of this event.
* For touch events on the screen, this is the original location of the event
* on the screen, before it had been adjusted for the containing window