From 618140a07899d96cc76a1fca6ce9f26f44895ca8 Mon Sep 17 00:00:00 2001 From: Rami Santina Date: Thu, 4 Aug 2011 17:08:55 +0300 Subject: add multitouch getPointerId data --- .../classes/com/jogamp/newt/event/MouseEvent.java | 51 ++++++++++++++++------ 1 file changed, 37 insertions(+), 14 deletions(-) (limited to 'src/newt/classes/com') 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; } -- cgit v1.2.3 From 94d9bcebaa382c87cb4baa6be4b85c8789a140dd Mon Sep 17 00:00:00 2001 From: Rami Santina Date: Fri, 5 Aug 2011 12:35:10 +0300 Subject: Fix: event mapping mismatch --- src/newt/classes/com/jogamp/newt/event/MouseEvent.java | 5 +---- .../jogamp/newt/egl/android/event/AndroidNewtEventFactory.java | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/newt/classes/com') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index be763b48d..62a8941d7 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -83,10 +83,6 @@ public class MouseEvent extends InputEvent return x.length; } - public int getPointerId() { - return pointerids[0]; - } - /** * @return the pointer id for the data at index. * return -1 if index not available. @@ -100,6 +96,7 @@ public class MouseEvent extends InputEvent public int getButton() { return button; } + public int getClickCount() { return clickCount; } 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 52e63a215..3619558f8 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); - map.put(android.view.MotionEvent.ACTION_POINTER_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); + map.put(android.view.MotionEvent.ACTION_POINTER_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); + map.put(android.view.MotionEvent.ACTION_POINTER_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); map.put(android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); -- cgit v1.2.3