diff --git a/src/org/ab/x48/HPView.java b/src/org/ab/x48/HPView.java index 203bf4f..d75a78e 100644 --- a/src/org/ab/x48/HPView.java +++ b/src/org/ab/x48/HPView.java @@ -52,7 +52,6 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna private short buf []; private short audiobuf []; int currentOrientation; - private boolean multiTouch; private AudioTrack track; private TimerTask audioTask; private Timer audioTimer; @@ -103,7 +102,6 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna setFocusable(true); setFocusableInTouchMode(true); x48 = ((X48) context); - multiTouch = Wrapper.supportsMultitouch(x48); mSurfaceHolder = getHolder(); mSurfaceHolder.addCallback(this); mainScreen = Bitmap.createBitmap(262, 14+128, Bitmap.Config.RGB_565); @@ -947,67 +945,44 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna int code = -1; int pointerID = 0; systemOptionDisplayed = false; - if (multiTouch) { - if( actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_UP || - actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP ) { - pointerID = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; - x = Wrapper.MotionEvent_getX(event, pointerID); - y = Wrapper.MotionEvent_getY(event, pointerID); - pointerID = Wrapper.MotionEvent_getPointerId(event, pointerID) + 1; - } else { - return false; - } - - // *_DOWN : lookup by coordinates - // *_UP : lookup by pointer pressed - if( actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN ) { - for(int i=0;i= buttons_coords[i][0] && x < buttons_coords[i][2] && y >= buttons_coords[i][1] && y < buttons_coords[i][3]) - { - code = i; - break; - } - } - } else { - for(int i=0;i -1) { - key(code, actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN, pointerID); - return true; - } - } else { - // old code used before the 1.29 version: - x = event.getX(); - y = event.getY(); - - if (action != MotionEvent.ACTION_DOWN && action != MotionEvent.ACTION_UP) - return false; - - for(int i=0;i= buttons_coords[i][0] && x < buttons_coords[i][2] && y >= buttons_coords[i][1] && y < buttons_coords[i][3]) - { - code = i; - break; - } - } - if (code == -1 && action == MotionEvent.ACTION_DOWN && currentOrientation != Configuration.ORIENTATION_LANDSCAPE ) { - x48.openOptionsMenu(); - return true; - } - - if (code > -1) { - key(code, action == MotionEvent.ACTION_DOWN); - return action == MotionEvent.ACTION_DOWN; - } - } + if( actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_UP || + actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP ) { + pointerID = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; + x = event.getX(pointerID); + y = event.getY(pointerID); + pointerID = event.getPointerId(pointerID) + 1; + } else { + return false; + } + + // *_DOWN : lookup by coordinates + // *_UP : lookup by pointer pressed + if( actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN ) { + for(int i=0;i= buttons_coords[i][0] && x < buttons_coords[i][2] && y >= buttons_coords[i][1] && y < buttons_coords[i][3]) + { + code = i; + break; + } + } + } else { + for(int i=0;i -1) { + key(code, actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN, pointerID); + return true; + } + } return false; @@ -1041,16 +1016,6 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna //Log.i("x48", "code: " + code + " / " + down); if (code < MAX_TOUCHES) { if (down) { - if (!multiTouch) { - for(int i=0;i= 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(); - } -} diff --git a/src/org/ab/x48/Wrapper5.java b/src/org/ab/x48/Wrapper5.java deleted file mode 100755 index 411d644..0000000 --- a/src/org/ab/x48/Wrapper5.java +++ /dev/null @@ -1,44 +0,0 @@ -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); - } -}