/** * @deprecated use {@link MotionEvent#obtain} or {@link * androidx.test.core.view.MotionEventBuilder} to create a MotionEvent with desired data. */ @Deprecated public MotionEvent setPointer2(float pointer1X, float pointer1Y) { NativeInput.MotionEvent event = getNativeMotionEvent(); List<NativeInput.PointerCoords> pointerCoords = event.getSamplePointerCoords(); List<PointerProperties> pointerProperties = event.getPointerProperties(); ensureTwoPointers(pointerCoords, pointerProperties); pointerCoords.get(1).setAxisValue(AMOTION_EVENT_AXIS_X, pointer1X); pointerCoords.get(1).setAxisValue(AMOTION_EVENT_AXIS_Y, pointer1Y); return realMotionEvent; }
final Ref<Float> y = new Ref<>(c.getAxisValue(AMOTION_EVENT_AXIS_Y) + oldYOffset); transformPoint(matrix, x.get(), y.get(), x, y); c.setAxisValue(AMOTION_EVENT_AXIS_X, x.get() - mXOffset); c.setAxisValue(AMOTION_EVENT_AXIS_Y, y.get() - mYOffset); float orientation = c.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION); c.setAxisValue( AMOTION_EVENT_AXIS_ORIENTATION, transformAngle(matrix, orientation, originX.get(), originY.get()));
/** * @deprecated use {@link MotionEvent#obtain} or {@link * androidx.test.core.view.MotionEventBuilder} to create a MotionEvent with desired data. */ @Deprecated public MotionEvent setPointer2(float pointer1X, float pointer1Y) { NativeInput.MotionEvent event = getNativeMotionEvent(); List<NativeInput.PointerCoords> pointerCoords = event.getSamplePointerCoords(); List<PointerProperties> pointerProperties = event.getPointerProperties(); ensureTwoPointers(pointerCoords, pointerProperties); pointerCoords.get(1).setAxisValue(AMOTION_EVENT_AXIS_X, pointer1X); pointerCoords.get(1).setAxisValue(AMOTION_EVENT_AXIS_Y, pointer1Y); return realMotionEvent; }
final Ref<Float> y = new Ref<>(c.getAxisValue(AMOTION_EVENT_AXIS_Y) + oldYOffset); transformPoint(matrix, x.get(), y.get(), x, y); c.setAxisValue(AMOTION_EVENT_AXIS_X, x.get() - mXOffset); c.setAxisValue(AMOTION_EVENT_AXIS_Y, y.get() - mYOffset); float orientation = c.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION); c.setAxisValue( AMOTION_EVENT_AXIS_ORIENTATION, transformAngle(matrix, orientation, originX.get(), originY.get()));
private static NativeInput.PointerCoords pointerCoordsToNative( PointerCoords pointerCoordsObj, float xOffset, float yOffset) { NativeInput.PointerCoords outRawPointerCoords = new NativeInput.PointerCoords(); outRawPointerCoords.clear(); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, pointerCoordsObj.x - xOffset); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, pointerCoordsObj.y - yOffset); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerCoordsObj.pressure); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerCoordsObj.size); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerCoordsObj.touchMajor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerCoordsObj.touchMinor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerCoordsObj.toolMajor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerCoordsObj.toolMinor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerCoordsObj.orientation); long packedAxisBits = ReflectionHelpers.getField(pointerCoordsObj, "mPackedAxisBits"); NativeBitSet64 bits = new NativeBitSet64(packedAxisBits); if (!bits.isEmpty()) { float[] valuesArray = ReflectionHelpers.getField(pointerCoordsObj, "mPackedAxisValues"); if (valuesArray != null) { int index = 0; do { int axis = bits.clearFirstMarkedBit(); outRawPointerCoords.setAxisValue(axis, valuesArray[index++]); } while (!bits.isEmpty()); } } return outRawPointerCoords; }
static void scaleAxisValue(PointerCoords c, int axis, float scaleFactor) { float value = c.getAxisValue(axis); if (value != 0) { c.setAxisValue(axis, value * scaleFactor); } }
public void applyOffset(float xOffset, float yOffset) { setAxisValue(AMOTION_EVENT_AXIS_X, getX() + xOffset); setAxisValue(AMOTION_EVENT_AXIS_Y, getY() + yOffset); }
private static NativeInput.PointerCoords pointerCoordsToNative( PointerCoords pointerCoordsObj, float xOffset, float yOffset) { NativeInput.PointerCoords outRawPointerCoords = new NativeInput.PointerCoords(); outRawPointerCoords.clear(); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, pointerCoordsObj.x - xOffset); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, pointerCoordsObj.y - yOffset); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerCoordsObj.pressure); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerCoordsObj.size); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerCoordsObj.touchMajor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerCoordsObj.touchMinor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerCoordsObj.toolMajor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerCoordsObj.toolMinor); outRawPointerCoords.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerCoordsObj.orientation); long packedAxisBits = ReflectionHelpers.getField(pointerCoordsObj, "mPackedAxisBits"); NativeBitSet64 bits = new NativeBitSet64(packedAxisBits); if (!bits.isEmpty()) { float[] valuesArray = ReflectionHelpers.getField(pointerCoordsObj, "mPackedAxisValues"); if (valuesArray != null) { int index = 0; do { int axis = bits.clearFirstMarkedBit(); outRawPointerCoords.setAxisValue(axis, valuesArray[index++]); } while (!bits.isEmpty()); } } return outRawPointerCoords; }
public void applyOffset(float xOffset, float yOffset) { setAxisValue(AMOTION_EVENT_AXIS_X, getX() + xOffset); setAxisValue(AMOTION_EVENT_AXIS_Y, getY() + yOffset); }
static void scaleAxisValue(PointerCoords c, int axis, float scaleFactor) { float value = c.getAxisValue(axis); if (value != 0) { c.setAxisValue(axis, value * scaleFactor); } }