summaryrefslogtreecommitdiff
path: root/native/android/input.cpp
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/android/input.cpp
parent1abf1c59f8b15d5b4b198063b884e268bd79fb32 (diff)
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/android/input.cpp')
-rw-r--r--native/android/input.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp
index ed2666764472..91671c3e9d54 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);
}