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/InputEvent.java57
1 files changed, 54 insertions, 3 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
index b0df7b4d1..1d13ee505 100644
--- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
@@ -44,6 +44,9 @@ public abstract class InputEvent extends NEWTEvent
public static final int BUTTON1_MASK = 1 << 6;
public static final int BUTTON2_MASK = 1 << 7;
public static final int BUTTON3_MASK = 1 << 8;
+ public static final int POINTER1_MASK = 1 << 16;
+ public static final int POINTER2_MASK = 1 << 17;
+ public static final int POINTER3_MASK = 1 << 18;
protected InputEvent(int eventType, Object source, long when, int modifiers) {
super(eventType, source, when);
@@ -69,18 +72,66 @@ public abstract class InputEvent extends NEWTEvent
return (modifiers&SHIFT_MASK)!=0;
}
- public boolean isButton1Down() {
+ /**
+ * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} ..].
+ * If none is down, the resulting array is of length 0.
+ */
+ public final int[] getButtonsDown() {
+ int len = 0;
+ if(isButton1Down()) { len++; }
+ if(isButton2Down()) { len++; }
+ if(isButton3Down()) { len++; }
+
+ int[] res = new int[len];
+ int i=0;
+ if(isButton1Down()) { res[i++] = MouseEvent.BUTTON1; }
+ if(isButton2Down()) { res[i++] = MouseEvent.BUTTON2; }
+ if(isButton3Down()) { res[i++] = MouseEvent.BUTTON3; }
+ return res;
+ }
+
+ public final boolean isButton1Down() {
return (modifiers&BUTTON1_MASK)!=0;
}
- public boolean isButton2Down() {
+ public final boolean isButton2Down() {
return (modifiers&BUTTON2_MASK)!=0;
}
- public boolean isButton3Down() {
+ public final boolean isButton3Down() {
return (modifiers&BUTTON3_MASK)!=0;
}
+ /**
+ * @return Array of involved pointer [{@link MouseEvent#POINTER1} ..].
+ * If none is down, the resulting array is of length 0.
+ */
+ public final int[] getPointers() {
+ int len = 0;
+ if(isPointer1()) { len++; }
+ if(isPointer2()) { len++; }
+ if(isPointer3()) { len++; }
+
+ int[] res = new int[len];
+ int i=0;
+ if(isPointer1()) { res[i++] = MouseEvent.POINTER1; }
+ if(isPointer2()) { res[i++] = MouseEvent.POINTER2; }
+ if(isPointer3()) { res[i++] = MouseEvent.POINTER3; }
+ return res;
+ }
+
+ public final boolean isPointer1() {
+ return (modifiers&POINTER1_MASK)!=0;
+ }
+
+ public final boolean isPointer2() {
+ return (modifiers&POINTER2_MASK)!=0;
+ }
+
+ public final boolean isPointer3() {
+ return (modifiers&POINTER3_MASK)!=0;
+ }
+
public String toString() {
return "InputEvent[modifiers:"+modifiers+", "+super.toString()+"]";
}