diff options
author | 2015-12-03 01:14:46 -0800 | |
---|---|---|
committer | 2015-12-18 10:00:05 -0800 | |
commit | fa1706afaf12b48fe0ab6d4b061b614bf901b173 (patch) | |
tree | d469b20f7b3e57b79f74b90c951891a019c2bf2d | |
parent | 79a27adb5a5993a72d2c77f9ca692bfc57baf22c (diff) |
Add relative-x/y axis for mouse devices.
Used by Ie21e521f3e5c581f976dc0feb5d84bfa48b046cd.
Bug: 5452473
Change-Id: I4189eb4d93f50c2865b7a325727be5ceebcc71f8
-rw-r--r-- | include/android/input.h | 15 | ||||
-rw-r--r-- | services/inputflinger/InputDispatcher.cpp | 6 | ||||
-rw-r--r-- | services/inputflinger/InputReader.cpp | 35 |
3 files changed, 46 insertions, 10 deletions
diff --git a/include/android/input.h b/include/android/input.h index 5eeb7fc89c..fd9fa98e70 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -651,6 +651,21 @@ enum { */ AMOTION_EVENT_AXIS_SCROLL = 26, /** + * Axis constant: The movement of x position of a motion event. + * + * - For a mouse, reports a difference of x position between the previous position. + * This is useful when pointer is captured, in that case the mouse pointer doesn't + * change the location but this axis reports the difference which allows the app + * to see how the mouse is moved. + */ + AMOTION_EVENT_AXIS_RELATIVE_X = 27, + /** + * Axis constant: The movement of y position of a motion event. + * + * Same as {@link RELATIVE_X}, but for y position. + */ + AMOTION_EVENT_AXIS_RELATIVE_Y = 28, + /** * Axis constant: Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. */ diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp index 0fba1bf3e4..04919f723f 100644 --- a/services/inputflinger/InputDispatcher.cpp +++ b/services/inputflinger/InputDispatcher.cpp @@ -902,7 +902,7 @@ void InputDispatcher::logOutboundMotionDetailsLocked(const char* prefix, const M ALOGD(" Pointer %d: id=%d, toolType=%d, " "x=%f, y=%f, pressure=%f, size=%f, " "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, " - "orientation=%f", + "orientation=%f, relativeX=%f, relativeY=%f", i, entry->pointerProperties[i].id, entry->pointerProperties[i].toolType, entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X), @@ -913,7 +913,9 @@ void InputDispatcher::logOutboundMotionDetailsLocked(const char* prefix, const M entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR), entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR), entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR), - entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION)); + entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION), + entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), + entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)); } #endif } diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 2aee8ad863..e9914ec21f 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -2614,6 +2614,8 @@ void CursorInputMapper::sync(nsecs_t when) { mPointerController->getPosition(&x, &y); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY); displayId = ADISPLAY_ID_DEFAULT; } else { pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, deltaX); @@ -5333,13 +5335,14 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, } } + float deltaX = 0, deltaY = 0; if (activeTouchId >= 0 && mLastCookedState.fingerIdBits.hasBit(activeTouchId)) { const RawPointerData::Pointer& currentPointer = mCurrentRawState.rawPointerData.pointerForId(activeTouchId); const RawPointerData::Pointer& lastPointer = mLastRawState.rawPointerData.pointerForId(activeTouchId); - float deltaX = (currentPointer.x - lastPointer.x) * mPointerXMovementScale; - float deltaY = (currentPointer.y - lastPointer.y) * mPointerYMovementScale; + deltaX = (currentPointer.x - lastPointer.x) * mPointerXMovementScale; + deltaY = (currentPointer.y - lastPointer.y) * mPointerYMovementScale; rotateDelta(mSurfaceOrientation, &deltaX, &deltaY); mPointerVelocityControl.move(when, &deltaX, &deltaY); @@ -5366,6 +5369,8 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x); mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y); mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f); + mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX); + mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY); } else if (currentFingerCount == 0) { // Case 3. No fingers down and button is not pressed. (NEUTRAL) if (mPointerGesture.lastGestureMode != PointerGesture::NEUTRAL) { @@ -5473,15 +5478,14 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, mPointerGesture.currentGestureMode = PointerGesture::TAP_DRAG; } + float deltaX = 0, deltaY = 0; if (mLastCookedState.fingerIdBits.hasBit(activeTouchId)) { const RawPointerData::Pointer& currentPointer = mCurrentRawState.rawPointerData.pointerForId(activeTouchId); const RawPointerData::Pointer& lastPointer = mLastRawState.rawPointerData.pointerForId(activeTouchId); - float deltaX = (currentPointer.x - lastPointer.x) - * mPointerXMovementScale; - float deltaY = (currentPointer.y - lastPointer.y) - * mPointerYMovementScale; + deltaX = (currentPointer.x - lastPointer.x) * mPointerXMovementScale; + deltaY = (currentPointer.y - lastPointer.y) * mPointerYMovementScale; rotateDelta(mSurfaceOrientation, &deltaX, &deltaY); mPointerVelocityControl.move(when, &deltaX, &deltaY); @@ -5525,6 +5529,10 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y); mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, down ? 1.0f : 0.0f); + mPointerGesture.currentGestureCoords[0].setAxisValue( + AMOTION_EVENT_AXIS_RELATIVE_X, deltaX); + mPointerGesture.currentGestureCoords[0].setAxisValue( + AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY); if (lastFingerCount == 0 && currentFingerCount != 0) { mPointerGesture.resetTap(); @@ -5771,6 +5779,10 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, mPointerGesture.referenceGestureX); mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, mPointerGesture.referenceGestureY); + mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, + commonDeltaX); + mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, + commonDeltaY); mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f); } else if (mPointerGesture.currentGestureMode == PointerGesture::FREEFORM) { // FREEFORM mode. @@ -5867,6 +5879,10 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, AMOTION_EVENT_AXIS_Y, mPointerGesture.referenceGestureY + deltaY); mPointerGesture.currentGestureCoords[i].setAxisValue( AMOTION_EVENT_AXIS_PRESSURE, 1.0f); + mPointerGesture.currentGestureCoords[i].setAxisValue( + AMOTION_EVENT_AXIS_RELATIVE_X, deltaX); + mPointerGesture.currentGestureCoords[i].setAxisValue( + AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY); } if (mPointerGesture.activeGestureId < 0) { @@ -5960,12 +5976,13 @@ void TouchInputMapper::dispatchPointerMouse(nsecs_t when, uint32_t policyFlags) if (!mCurrentCookedState.mouseIdBits.isEmpty()) { uint32_t id = mCurrentCookedState.mouseIdBits.firstMarkedBit(); uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id]; + float deltaX = 0, deltaY = 0; if (mLastCookedState.mouseIdBits.hasBit(id)) { uint32_t lastIndex = mCurrentRawState.rawPointerData.idToIndex[id]; - float deltaX = (mCurrentRawState.rawPointerData.pointers[currentIndex].x + deltaX = (mCurrentRawState.rawPointerData.pointers[currentIndex].x - mLastRawState.rawPointerData.pointers[lastIndex].x) * mPointerXMovementScale; - float deltaY = (mCurrentRawState.rawPointerData.pointers[currentIndex].y + deltaY = (mCurrentRawState.rawPointerData.pointers[currentIndex].y - mLastRawState.rawPointerData.pointers[lastIndex].y) * mPointerYMovementScale; @@ -5988,6 +6005,8 @@ void TouchInputMapper::dispatchPointerMouse(nsecs_t when, uint32_t policyFlags) mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, hovering ? 0.0f : 1.0f); + mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, x); + mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, y); mPointerSimple.currentProperties.id = 0; mPointerSimple.currentProperties.toolType = mCurrentCookedState.cookedPointerData.pointerProperties[currentIndex].toolType; |