aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/jogamp
diff options
context:
space:
mode:
authorRami Santina <[email protected]>2011-08-02 15:36:43 +0300
committerRami Santina <[email protected]>2011-08-02 15:36:43 +0300
commit6508b1bd4bdc1bb7ef71bfeb96052fae67a2f425 (patch)
tree0c72674bfd0413938c0a1ada32ed34b9b51a6d3c /src/newt/classes/com/jogamp
parentbbbf51acf183b6fe696afd009d0ae49f6745bc40 (diff)
parentae51b15c98af2ce462cb8ff1a237dd0c51e78e80 (diff)
merge with sgothel multitouch
Diffstat (limited to 'src/newt/classes/com/jogamp')
-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()+"]";
}