aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java48
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java27
2 files changed, 40 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..62a8941d7 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -56,33 +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;
}
+ /**
+ * @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;
}
+
public int getClickCount() {
return clickCount;
}
@@ -94,20 +108,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 +154,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 +169,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/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
index 5439c5c9e..75b9f8642 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -48,8 +48,8 @@ public 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_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);
@@ -127,21 +127,6 @@ public 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);
- }
public 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 @@ public 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 ..
}