summaryrefslogtreecommitdiffstats
path: root/services/input/InputDispatcher.cpp
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-02-14 17:03:18 -0800
committerJeff Brown <jeffbrown@google.com>2011-02-15 19:14:37 -0800
commit91c69ab01539f7ba28708f41ec1835cc2920d0a0 (patch)
tree04f5dc37a0fa3f18a18ba08916efe0c33a1de300 /services/input/InputDispatcher.cpp
parentc3451d4a4479b6244bd6d1dadf289a8d44bdcca2 (diff)
downloadframeworks_base-91c69ab01539f7ba28708f41ec1835cc2920d0a0.zip
frameworks_base-91c69ab01539f7ba28708f41ec1835cc2920d0a0.tar.gz
frameworks_base-91c69ab01539f7ba28708f41ec1835cc2920d0a0.tar.bz2
Add support for arbitrary axes in MotionEvents.
This change makes it possible to extend the set of axes that are reported in MotionEvents by defining new axis constants. The MotionEvent object is now backed by its C++ counterpart to avoid having to maintain multiple representations of the same data. Change-Id: Ibe93c90d4b390d43c176cce48d558d20869ee608
Diffstat (limited to 'services/input/InputDispatcher.cpp')
-rw-r--r--services/input/InputDispatcher.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index cbfdd75..466a9b3 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -482,8 +482,10 @@ bool InputDispatcher::enqueueInboundEventLocked(EventEntry* entry) {
&& (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER)
&& mInputTargetWaitCause == INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY
&& mInputTargetWaitApplication != NULL) {
- int32_t x = int32_t(motionEntry->firstSample.pointerCoords[0].x);
- int32_t y = int32_t(motionEntry->firstSample.pointerCoords[0].y);
+ int32_t x = int32_t(motionEntry->firstSample.pointerCoords[0].
+ getAxisValue(AINPUT_MOTION_AXIS_X));
+ int32_t y = int32_t(motionEntry->firstSample.pointerCoords[0].
+ getAxisValue(AINPUT_MOTION_AXIS_Y));
const InputWindow* touchedWindow = findTouchedWindowAtLocked(x, y);
if (touchedWindow
&& touchedWindow->inputWindowHandle != NULL
@@ -888,11 +890,15 @@ void InputDispatcher::logOutboundMotionDetailsLocked(const char* prefix, const M
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
i, entry->pointerIds[i],
- sample->pointerCoords[i].x, sample->pointerCoords[i].y,
- sample->pointerCoords[i].pressure, sample->pointerCoords[i].size,
- sample->pointerCoords[i].touchMajor, sample->pointerCoords[i].touchMinor,
- sample->pointerCoords[i].toolMajor, sample->pointerCoords[i].toolMinor,
- sample->pointerCoords[i].orientation);
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_X),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_Y),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
+ sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
}
// Keep in mind that due to batching, it is possible for the number of samples actually
@@ -1188,8 +1194,10 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
/* Case 1: New splittable pointer going down. */
int32_t pointerIndex = getMotionEventActionPointerIndex(action);
- int32_t x = int32_t(entry->firstSample.pointerCoords[pointerIndex].x);
- int32_t y = int32_t(entry->firstSample.pointerCoords[pointerIndex].y);
+ int32_t x = int32_t(entry->firstSample.pointerCoords[pointerIndex].
+ getAxisValue(AINPUT_MOTION_AXIS_X));
+ int32_t y = int32_t(entry->firstSample.pointerCoords[pointerIndex].
+ getAxisValue(AINPUT_MOTION_AXIS_Y));
const InputWindow* newTouchedWindow = NULL;
const InputWindow* topErrorWindow = NULL;
@@ -2275,11 +2283,16 @@ void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, uint32_t
LOGD(" Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f, "
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
- i, pointerIds[i], pointerCoords[i].x, pointerCoords[i].y,
- pointerCoords[i].pressure, pointerCoords[i].size,
- pointerCoords[i].touchMajor, pointerCoords[i].touchMinor,
- pointerCoords[i].toolMajor, pointerCoords[i].toolMinor,
- pointerCoords[i].orientation);
+ i, pointerIds[i],
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_X),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_Y),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
+ pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
}
#endif
if (! validateMotionEvent(action, pointerCount, pointerIds)) {