diff options
author | Rami Santina <[email protected]> | 2011-08-04 17:08:55 +0300 |
---|---|---|
committer | Rami Santina <[email protected]> | 2011-08-04 17:08:55 +0300 |
commit | 618140a07899d96cc76a1fca6ce9f26f44895ca8 (patch) | |
tree | 3038bd17bdc3725e7bb708764789d388e6e300dc /src/newt/classes | |
parent | 444482f4b9a1168e0dfd29c7e2da4010cca2ca91 (diff) |
add multitouch getPointerId data
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/event/MouseEvent.java | 51 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/egl/android/event/AndroidNewtEventFactory.java | 27 |
2 files changed, 43 insertions, 35 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 7ad7d6e2d..be763b48d 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -56,30 +56,47 @@ public class MouseEvent extends InputEvent this.x = new int[]{x}; this.y = new int[]{y}; this.pressure = new float[]{0}; - + this.pointerids = new int[]{-1}; this.clickCount=clickCount; this.button=button; this.wheelRotation = rotation; } public MouseEvent(int eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, int clickCount, int button, + int modifiers, int[] x, int[] y, float[] pressure, int[] pointerids, int clickCount, int button, int rotation) { super(eventType, source, when, modifiers); this.x = x; this.y = y; this.pressure = pressure; - + this.pointerids = pointerids; this.clickCount=clickCount; this.button=button; this.wheelRotation = rotation; } + /** + * @return the count of pointers involved in this event + */ public int getPointerCount() { return x.length; } + public int getPointerId() { + return pointerids[0]; + } + + /** + * @return the pointer id for the data at index. + * return -1 if index not available. + */ + public int getPointerId(int index) { + if(index >= pointerids.length) + return -1; + return pointerids[index]; + } + public int getButton() { return button; } @@ -94,20 +111,29 @@ public class MouseEvent extends InputEvent return y[0]; } - public int getX(int pointer) { - return x[pointer]; + /** + * @return x-coord at index where index refers to the + * data coming from a pointer. + * @see getPointerId(index) + */ + public int getX(int index) { + return x[index]; } - public int getY(int pointer) { - return y[pointer]; + public int getY(int index) { + return y[index]; } public float getPressure(){ return pressure[0]; } - public float getPressure(int pointer){ - return pressure[pointer]; + /** + * @return the pressure associated with the pointer at index. + * the value of zero is return if not available. + */ + public float getPressure(int index){ + return pressure[index]; } public int getWheelRotation() { @@ -131,14 +157,13 @@ public class MouseEvent extends InputEvent case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED"; case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED"; case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED"; - case EVENT_MOUSE_PRESSED_MINOR: return "EVENT_MOUSE_PRESSED_MINOR"; - case EVENT_MOUSE_RELEASED_MINOR: return "EVENT_MOUSE_RELEASED_MINOR"; default: return "unknown (" + type + ")"; } } private final int x[], y[], clickCount, button, wheelRotation; private final float pressure[]; - + private final int pointerids[]; + public static final int EVENT_MOUSE_CLICKED = 200; public static final int EVENT_MOUSE_ENTERED = 201; public static final int EVENT_MOUSE_EXITED = 202; @@ -147,6 +172,4 @@ public class MouseEvent extends InputEvent public static final int EVENT_MOUSE_MOVED = 205; public static final int EVENT_MOUSE_DRAGGED = 206; public static final int EVENT_MOUSE_WHEEL_MOVED = 207; - public static final int EVENT_MOUSE_PRESSED_MINOR = 208; - public static final int EVENT_MOUSE_RELEASED_MINOR = 209; } diff --git a/src/newt/classes/jogamp/newt/egl/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/egl/android/event/AndroidNewtEventFactory.java index c8e3f204f..52e63a215 100644 --- a/src/newt/classes/jogamp/newt/egl/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/egl/android/event/AndroidNewtEventFactory.java @@ -48,8 +48,8 @@ class AndroidNewtEventFactory { map.put(android.view.MotionEvent.ACTION_MOVE, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); map.put(android.view.MotionEvent.ACTION_OUTSIDE, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - map.put(android.view.MotionEvent.ACTION_POINTER_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED_MINOR); - map.put(android.view.MotionEvent.ACTION_POINTER_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED_MINOR); + map.put(android.view.MotionEvent.ACTION_POINTER_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); + map.put(android.view.MotionEvent.ACTION_POINTER_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); map.put(android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); @@ -127,21 +127,6 @@ class AndroidNewtEventFactory { } return null; } - - public static final int androidActionPointer2Newt(android.view.MotionEvent event) { - int action = event.getAction(); - int androidMods = event.getMetaState(); - - if ((android.view.MotionEvent.ACTION_POINTER_UP != action) - || (android.view.MotionEvent.ACTION_POINTER_DOWN != action)) { - return 0; - } - - int pointerIndex = (androidMods & android.view.MotionEvent.ACTION_POINTER_INDEX_MASK); - pointerIndex = pointerIndex >> android.view.MotionEvent.ACTION_POINTER_INDEX_SHIFT; - - return event.getPointerId(pointerIndex); - } static final com.jogamp.newt.event.MouseEvent createMouseEvent(android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { int type = eventTypeANDROID2NEWT.get(event.getAction()); @@ -153,21 +138,21 @@ class AndroidNewtEventFactory { int[] x = new int[event.getPointerCount()]; int[] y = new int[event.getPointerCount()]; float[] pressure = new float[event.getPointerCount()]; - + int[] pointers = new int[event.getPointerCount()]; int index = 0; while(index < event.getPointerCount()) { x[index] = (int)event.getX(index); y[index] = (int)event.getY(index); pressure[index] = event.getPressure(index); + pointers[index] = event.getPointerId(index); index++; } - int pointer = androidActionPointer2Newt(event); return new com.jogamp.newt.event.MouseEvent( type, (null==newtSource)?null:(Object)newtSource, event.getEventTime(), modifiers , - x, y, pressure, clickCount, - pointer+1, rotation); + x, y, pressure, pointers, clickCount, + 0, rotation); } return null; // no mapping .. } |