diff --git a/src/org/ab/x48/HPView.java b/src/org/ab/x48/HPView.java index b37cd56..2777a10 100644 --- a/src/org/ab/x48/HPView.java +++ b/src/org/ab/x48/HPView.java @@ -38,7 +38,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna boolean ann []; int ann_pos [] = { 62, 105, 152, 197, 244, 287 }; private List queuedCodes; - private boolean touches [] = new boolean [MAX_TOUCHES]; + private int touches [] = new int [MAX_TOUCHES]; protected boolean needFlip; private short buf []; private int currentOrientation; @@ -449,7 +449,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna mainScreen.copyPixelsFromBuffer(ShortBuffer.wrap(data)); c.drawBitmap(mainScreen, matrixScreen, screenPaint); for(int i=0;i> MotionEvent.ACTION_POINTER_INDEX_SHIFT; + x = event.getX(pointerID); + y = event.getY(pointerID); + pointerID = event.getPointerId(pointerID) + 1; + } else { + 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 ) { + // *_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, action == MotionEvent.ACTION_DOWN); - return action == MotionEvent.ACTION_DOWN; + key(code, actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN, pointerID); + return true; } } @@ -517,51 +534,35 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna this.keybLite = keybLite; } - public synchronized void key(int code, boolean down) { + public void key(int code, boolean down) { + key(code, down, 255); // Use pointerID 255 for keyboard + } + + public synchronized void key(int code, boolean down, int pointerID) { //Log.i("x48", "code: " + code + " / " + down); if (code < MAX_TOUCHES) { if (down) { - for(int i=0;i