Forgot the event wrapper classes
This commit is contained in:
parent
b3db7fb931
commit
14cbe8ebda
2 changed files with 103 additions and 0 deletions
59
src/org/ab/x48/Wrapper.java
Executable file
59
src/org/ab/x48/Wrapper.java
Executable file
|
@ -0,0 +1,59 @@
|
|||
package org.ab.x48;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public class Wrapper {
|
||||
|
||||
static final int SDK_INT = Integer.parseInt(Build.VERSION.SDK);
|
||||
|
||||
public static boolean supportsMultitouch(Context context) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.supportsMultitouch(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final int MotionEvent_getPointerCount(MotionEvent event) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.MotionEvent_getPointerCount(event);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static final int MotionEvent_getPointerId(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.MotionEvent_getPointerId(event, pointerIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final int MotionEvent_findPointerIndex(MotionEvent event,
|
||||
int pointerId) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.MotionEvent_findPointerIndex(event, pointerId);
|
||||
if (pointerId == 0)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static final float MotionEvent_getX(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.MotionEvent_getX(event, pointerIndex);
|
||||
return event.getX();
|
||||
}
|
||||
|
||||
public static final float MotionEvent_getY(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.MotionEvent_getY(event, pointerIndex);
|
||||
return event.getY();
|
||||
}
|
||||
|
||||
public static final float MotionEvent_getSize(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
if (SDK_INT >= 5)
|
||||
return Wrapper5.MotionEvent_getSize(event, pointerIndex);
|
||||
return event.getSize();
|
||||
}
|
||||
}
|
44
src/org/ab/x48/Wrapper5.java
Executable file
44
src/org/ab/x48/Wrapper5.java
Executable file
|
@ -0,0 +1,44 @@
|
|||
package org.ab.x48;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
class Wrapper5 {
|
||||
|
||||
public static final boolean supportsMultitouch(Context context) {
|
||||
if (Wrapper.SDK_INT < 7)
|
||||
return true;
|
||||
|
||||
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH);
|
||||
}
|
||||
|
||||
public static final int MotionEvent_getPointerCount(MotionEvent event) {
|
||||
return event.getPointerCount();
|
||||
}
|
||||
|
||||
public static final int MotionEvent_getPointerId(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
return event.getPointerId(pointerIndex);
|
||||
}
|
||||
|
||||
public static final int MotionEvent_findPointerIndex(MotionEvent event,
|
||||
int pointerId) {
|
||||
return event.findPointerIndex(pointerId);
|
||||
}
|
||||
|
||||
public static final float MotionEvent_getX(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
return event.getX(pointerIndex);
|
||||
}
|
||||
|
||||
public static final float MotionEvent_getY(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
return event.getY(pointerIndex);
|
||||
}
|
||||
|
||||
public static final float MotionEvent_getSize(MotionEvent event,
|
||||
int pointerIndex) {
|
||||
return event.getSize(pointerIndex);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue