summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java90
1 files changed, 35 insertions, 55 deletions
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index b8ab3176a..28174f139 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -34,7 +34,24 @@ import com.jogamp.newt.event.InputEvent;
public class AWTNewtEventFactory {
protected static final IntIntHashMap eventTypeAWT2NEWT;
+
+ // Define the button state masks we'll check based on what
+ // the AWT says is available.
+ private static int awtButtonMasks[] ;
+ private static int newtButtonMasks[] ;
+ public static int getAWTButtonMask(int button) {
+ // return java.awt.event.InputEvent.getMaskForButton(button); // n/a
+ int m;
+ switch(button) {
+ case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break;
+ case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break;
+ case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break;
+ default: m = 0;
+ }
+ return m;
+ }
+
static {
IntIntHashMap map = new IntIntHashMap();
map.setKeyNotFoundValue(0xFFFFFFFF);
@@ -70,27 +87,14 @@ public class AWTNewtEventFactory {
map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED);
eventTypeAWT2NEWT = map;
- }
-
- // Define the button state masks we'll check based on what
- // the AWT says is available.
-
- private static int awtButtonMasks[] ;
- private static int newtButtonMasks[] ;
-
- static {
+
+ final int numButtonMasks ;
- int numButtonMasks ;
-
- if (java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()) {
- numButtonMasks = java.awt.MouseInfo.getNumberOfButtons() ;
- } else {
- numButtonMasks = 3 ;
- }
-
- if (numButtonMasks > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER) {
- numButtonMasks = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ;
- }
+ // numButtonMasks = java.awt.MouseInfo.getNumberOfButtons() ;
+ // if (numButtonMasks > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER) {
+ // numButtonMasks = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ;
+ // }
+ numButtonMasks = 3 ;
// There is an assumption in awtModifiers2Newt(int,int,boolean)
// that the awtButtonMasks and newtButtonMasks are peers, i.e.
@@ -98,15 +102,16 @@ public class AWTNewtEventFactory {
awtButtonMasks = new int[numButtonMasks] ;
for (int n = 0 ; n < awtButtonMasks.length ; ++n) {
- awtButtonMasks[n] = java.awt.event.InputEvent.getMaskForButton(n+1) ;
+ awtButtonMasks[n] = getAWTButtonMask(n+1);
}
newtButtonMasks = new int[numButtonMasks] ;
for (int n = 0 ; n < newtButtonMasks.length ; ++n) {
newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ;
- }
+ }
}
+
/**
* Converts the specified set of AWT event modifiers to the equivalent
* NEWT event modifiers. This method doesn't pay attention to the AWT
@@ -123,7 +128,6 @@ public class AWTNewtEventFactory {
* @param mouseHint
* Not used currently.
*/
-
public static final int awtModifiers2Newt(int awtMods, boolean mouseHint) {
int newtMods = 0;
if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK;
@@ -149,57 +153,33 @@ public class AWTNewtEventFactory {
*
* @param awtModsEx
* The AWT extended event modifiers.
+ * AWT passes mouse button specific bits here and are the preferred way check the mouse button state.
*
* @param mouseHint
* Not used currently.
*/
-
public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) {
int newtMods = 0;
-
- //System.err.println( ">>>> AWT modifiers:") ;
- //_printAwtModifiers( awtMods, awtModsEx ) ;
- //System.err.println( ">>>> END AWT modifiers") ;
-
- // Bug 629:
- //
- // AWT defines the notion of "extended modifiers". They put other bits there
- // specific to the mouse buttons and say that these are the preferred bits to
- // check for mouse button state. This seems to hint that at some point they
- // may be the only way to get this info.
-
if ((awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK;
if ((awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK;
if ((awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK;
if ((awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK;
if ((awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK;
+ if ((awtModsEx & awtButtonMasks[0]) != 0) newtMods |= newtButtonMasks[0] ;
+ if ((awtModsEx & awtButtonMasks[1]) != 0) newtMods |= newtButtonMasks[1] ;
+ if ((awtModsEx & awtButtonMasks[2]) != 0) newtMods |= newtButtonMasks[2] ;
+
+ /**
for (int n = 0 ; n < awtButtonMasks.length ; ++n) {
if ((awtModsEx & awtButtonMasks[n]) != 0) {
newtMods |= newtButtonMasks[n] ;
}
- }
+ } */
return newtMods;
}
-/*
- private static void _printAwtModifiers( int awtMods, int awtModsEx ) {
- if( ( awtMods & java.awt.event.InputEvent.SHIFT_MASK ) != 0 ) { System.err.println( "SHIFT" ) ; }
- if( ( awtMods & java.awt.event.InputEvent.CTRL_MASK ) != 0 ) { System.err.println( "CTRL" ) ; }
- if( ( awtMods & java.awt.event.InputEvent.META_MASK ) != 0 ) { System.err.println( "META" ) ; }
- if( ( awtMods & java.awt.event.InputEvent.ALT_MASK ) != 0 ) { System.err.println( "ALT" ) ; }
- if( ( awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { System.err.println( "ALT_GRAPH" ) ; }
-
- if( ( awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { System.err.println( "SHIFT Ex" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { System.err.println( "CTRL Ex" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { System.err.println( "META Ex" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { System.err.println( "ALT Ex" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { System.err.println( "ALT_GRAPH Ex" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON1" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.BUTTON2_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON2" ) ; }
- if( ( awtModsEx & java.awt.event.InputEvent.BUTTON3_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON3" ) ; }
- }
-*/
+
public static final int awtButton2Newt(int awtButton) {
switch (awtButton) {
case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1;