0

For get MotionEvent.getRaw of other pointers...

I'm tried all

event.offsetLocation(event.getRawX()-event.getX(),event.getRawY()-event.getY());

and

void getRowPoint(MotionEvent ev, int index, PointF point){
    final int location[] = { 0, 0 };
    getLocationOnScreen(location);

    float x=ev.getX(index);
    float y=ev.getY(index);

    double angle=Math.toDegrees(Math.atan2(y, x));
    angle+=getRotation();

    final float length=PointF.length(x,y);

    x=(float)(length*Math.cos(Math.toRadians(angle)))+location[0];
    y=(float)(length*Math.sin(Math.toRadians(angle)))+location[1];

    point.set(x,y);
}

and

 Method getRawAxisValueMethod = MotionEvent.class.getDeclaredMethod(
            "nativeGetRawAxisValue", long.class, int.class, int.class, int.class);
    Field nativePtrField = MotionEvent.class.getDeclaredField("mNativePtr");
    Field historyCurrentField = MotionEvent.class.getDeclaredField("HISTORY_CURRENT");
    getRawAxisValueMethod.setAccessible(true);
    nativePtrField.setAccessible(true);
    historyCurrentField.setAccessible(true);

    float x = (float) getRawAxisValueMethod.invoke(null, nativePtrField.get(event),
            MotionEvent.AXIS_X, pointerIndex, historyCurrentField.get(null));
    float y = (float) getRawAxisValueMethod.invoke(null, nativePtrField.get(event),
            MotionEvent.AXIS_Y, pointerIndex, historyCurrentField.get(null));
// ........................... //

But everything will not work if the view is rotated to rotationY or rotationX

오재웅
  • 1
  • 4

0 Answers0