diff options
author | Sven Gothel <[email protected]> | 2012-12-23 23:33:19 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-12-23 23:33:19 +0100 |
commit | 7ec58d773535e86e413e3c581a5e5bd734cb1269 (patch) | |
tree | ae203b875be32f58de6e2e02f690219e3d122104 /src | |
parent | 13168c99ff9e8bf71c83f1be7afee270a3db4074 (diff) |
Fix 13168c99ff9e8bf71c83f1be7afee270a3db4074 / 811e3791b98fea0dfa3b7d301cb532c54df8dc82: AWT-NEWT Modifier mapping - part-2
AWTNewtEventFactory:
- getAWTButtonMask() -> getAWTButtonDownMask()
- using proper _DOWN_MASK values (regression of commit 13168c99ff9e8bf71c83f1be7afee270a3db4074)
- com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER buttons
- adding 'ModifierMappings.txt' to API doc header
- remove obsolete 'int awtModifiers2Newt(int awtMods, boolean mouseHint)'
- 'int awtButton2Newt(int awtButton)' 1:1 button name mapping
Tests:
- rename TestNewtEventModifiers -> BaseNewtEventModifiers
to avoid being picked up by our junit testing framework.
The latter tests all classes starting w/ 'Test*'
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/event/InputEvent.java | 2 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java | 205 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java (renamed from src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java) | 75 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt | 37 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java | 6 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java | 6 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java | 6 |
7 files changed, 164 insertions, 173 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 0122bda9a..ad77ec79f 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -70,7 +70,7 @@ public abstract class InputEvent extends NEWTEvent * Returns the corresponding button mask for the given button. * <p> * In case the given button lies outside - * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}], + * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON_NUMBER}], * null is returned. * </p> */ diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 28174f139..665b7b5ee 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -29,29 +29,58 @@ package jogamp.newt.awt.event; import com.jogamp.common.util.IntIntHashMap; -import com.jogamp.newt.event.InputEvent; +/** + * + * <a name="AWTEventModifierMapping"><h5>AWT Event Modifier Mapping</h5></a> + * <pre> + Modifier AWT Constant AWT Bit AWT Ex NEWT Constant NEWT Bit + ------------- ------------------------------- ------- ------ ------------------------- -------- + Shift Event.SHIFT_MASK 0 + Ctrl Event.CTRL_MASK 1 + Meta Event.META_MASK 2 + Alt Event.ALT_MASK 3 + Button1 InputEvent.BUTTON1_MASK 4 + Button2 InputEvent.BUTTON2_MASK 3 + Button3 InputEvent.BUTTON3_MASK 2 + Shift Down InputEvent.SHIFT_DOWN_MASK 6 * InputEvent.SHIFT_MASK 0 + Ctrl Down InputEvent.CTRL_DOWN_MASK 7 * InputEvent.CTRL_MASK 1 + Meta Down InputEvent.META_DOWN_MASK 8 * InputEvent.META_MASK 2 + Alt Down InputEvent.ALT_DOWN_MASK 9 * InputEvent.ALT_MASK 3 + Button1 Down InputEvent.BUTTON1_DOWN_MASK 10 * InputEvent.BUTTON1_MASK 5 + Button2 Down InputEvent.BUTTON2_DOWN_MASK 11 * InputEvent.BUTTON2_MASK 6 + Button3 Down InputEvent.BUTTON3_DOWN_MASK 12 * InputEvent.BUTTON3_MASK 7 + AltGraph Down InputEvent.ALT_GRAPH_DOWN_MASK 13 * InputEvent.ALT_GRAPH_MASK 4 + Button4 Down -- 14 * InputEvent.BUTTON4_MASK 8 + Button5 Down -- 15 * InputEvent.BUTTON5_MASK 9 + Button6 Down -- 16 * InputEvent.BUTTON6_MASK 10 + Button7 Down -- 17 * InputEvent.BUTTON7_MASK 11 + Button8 Down -- 18 * InputEvent.BUTTON8_MASK 12 + Button9 Down -- 19 * InputEvent.BUTTON9_MASK 13 + Button10 Down -- 20 * 14 + Button11 Down -- 21 * 15 + Button12 Down -- 22 * 16 + Button13 Down -- 23 * 17 + Button14 Down -- 24 * 18 + Button15 Down -- 25 * 19 + Button16 Down -- 26 * InputEvent.BUTTONLAST_MASK 20 + Button17 Down -- 27 * + Button18 Down -- 28 * + Button19 Down -- 29 * + Button20 Down -- 30 * + Autorepeat -- - InputEvent.AUTOREPEAT_MASK 29 + Confined -- - InputEvent.CONFINED_MASK 30 + Invisible -- - InputEvent.INVISIBLE_MASK 31 + * </pre> + * + */ 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; - } - + /** zero-based AWT button mask array filled by {@link #getAWTButtonDownMask(int)}, allowing fast lookup. */ + private static int awtButtonDownMasks[] ; + static { IntIntHashMap map = new IntIntHashMap(); map.setKeyNotFoundValue(0xFFFFFFFF); @@ -88,66 +117,77 @@ public class AWTNewtEventFactory { eventTypeAWT2NEWT = map; - final int numButtonMasks ; - - // 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. // a given index refers to the same button in each array. - awtButtonMasks = new int[numButtonMasks] ; - for (int n = 0 ; n < awtButtonMasks.length ; ++n) { - awtButtonMasks[n] = getAWTButtonMask(n+1); + /* { + Method _getMaskForButtonMethod = null; + try { + _getMaskForButtonMethod = ReflectionUtil.getMethod(java.awt.event.InputEvent.class, "getMaskForButton", int.class); + } catch(Throwable t) {} + getMaskForButtonMethod = _getMaskForButtonMethod; + } */ + + awtButtonDownMasks = new int[com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER] ; // java.awt.MouseInfo.getNumberOfButtons() ; + for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) { + awtButtonDownMasks[n] = getAWTButtonDownMaskImpl(n+1); } - - newtButtonMasks = new int[numButtonMasks] ; - for (int n = 0 ; n < newtButtonMasks.length ; ++n) { - newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; - } } - + private static int getAWTButtonDownMaskImpl(int button) { + /** + * java.awt.event.InputEvent.getMaskForButton(button); + * + if(null != getMaskForButtonMethod) { + Object r=null; + try { + r = getMaskForButtonMethod.invoke(null, new Integer(button)); + } catch (Throwable t) { } + if(null != r) { + return ((Integer)r).intValue(); + } + } */ + final int m; + switch(button) { + case 0 : m = 0; break; + case 1 : m = java.awt.event.InputEvent.BUTTON1_DOWN_MASK; break; // 1<<10 + case 2 : m = java.awt.event.InputEvent.BUTTON2_DOWN_MASK; break; // 1<<11 + case 3 : m = java.awt.event.InputEvent.BUTTON3_DOWN_MASK; break; // 1<<12 + default: + if( button <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + m = 1 << ( 10 + button ) ; // b4 = 1<<14, b5 = 1<<15, etc + } else { + m = 0; + } + } + return m; + } + /** - * Converts the specified set of AWT event modifiers to the equivalent - * NEWT event modifiers. This method doesn't pay attention to the AWT - * button modifier bits explicitly even though there is a direct - * association in the AWT InputEvent class between BUTTON2_MASK and - * ALT_MASK, and BUTTON3_MASK and META_MASK. Instead the current - * button state is picked up from the bits in the extended modifiers. - * If you need the button bits too, then call - * {@link #awtModifiers2Newt(int,int,boolean)} instead. + * <p> + * See <a href="#AWTEventModifierMapping"> AWT event modifier mapping details</a>. + * </p> * - * @param awtMods - * The AWT event modifiers. - * - * @param mouseHint - * Not used currently. + * @param button + * @return */ - 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; - if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; - if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; - if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; - if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; - - // The BUTTON1_MASK, BUTTON2_MASK, and BUTTON3_MASK bits are - // being ignored intentionally. The AWT docs say that the - // BUTTON1_DOWN_MASK etc bits in the extended modifiers are - // the preferred place to check current button state. - - return newtMods; + public static int getAWTButtonDownMask(int button) { + if( 0 < button && button <= awtButtonDownMasks.length ) { + return awtButtonDownMasks[button-1]; + } else { + return 0; + } } /** * Converts the specified set of AWT event modifiers and extended event * modifiers to the equivalent NEWT event modifiers. * + * <p> + * See <a href="#AWTEventModifierMapping"> AWT event modifier mapping details</a>. + * </p> + * * @param awtMods * The AWT event modifiers. * @@ -160,33 +200,42 @@ public class AWTNewtEventFactory { */ public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) { int newtMods = 0; + + /** Redundant old modifiers .. + if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; + if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; + if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; + if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; */ + 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] ; + // The BUTTON1_MASK, BUTTON2_MASK, and BUTTON3_MASK bits are + // being ignored intentionally. The AWT docs say that the + // BUTTON1_DOWN_MASK etc bits in the extended modifiers are + // the preferred place to check current button state. + + if( 0 != awtModsEx ) { + for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) { + if ( (awtModsEx & awtButtonDownMasks[n]) != 0 ) { + newtMods |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1); + } } - } */ + } return newtMods; } public static final int awtButton2Newt(int awtButton) { - switch (awtButton) { - case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1; - case java.awt.event.MouseEvent.BUTTON2: return com.jogamp.newt.event.MouseEvent.BUTTON2; - case java.awt.event.MouseEvent.BUTTON3: return com.jogamp.newt.event.MouseEvent.BUTTON3; + if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + return awtButton; + } else { + return 0; } - return 0; } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { @@ -225,10 +274,10 @@ public class AWTNewtEventFactory { int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), true); if(null!=newtSource) { if(newtSource.isPointerConfined()) { - mods |= InputEvent.CONFINED_MASK; + mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK; } if(!newtSource.isPointerVisible()) { - mods |= InputEvent.INVISIBLE_MASK; + mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 81e1939b9..1dfdc4021 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -44,6 +44,8 @@ import org.junit.Before ; import org.junit.BeforeClass ; import org.junit.Test ; +import com.jogamp.common.os.Platform; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.test.junit.util.UITestCase ; /** @@ -52,7 +54,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase ; * and canvas up to subclasses. */ -public abstract class TestNewtEventModifiers extends UITestCase { +public abstract class BaseNewtEventModifiers extends UITestCase { static { @@ -162,9 +164,12 @@ public abstract class TestNewtEventModifiers extends UITestCase { if( _debug ) { _debugPrintStream.println( ", checking modifiers..." ) ; _debugPrintStream.println( " expected NEWT Modifiers:" ) ; - _printModifiers( _expectedModifiers ) ; + { + final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); + _debugPrintStream.println(" "+exp.getModifiersString(null).toString()); + } _debugPrintStream.println( " current NEWT Modifiers:" ) ; - _printModifiers( event.getModifiers() ) ; + _debugPrintStream.println(" "+event.getModifiersString(null).toString()); } _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; @@ -195,44 +200,17 @@ public abstract class TestNewtEventModifiers extends UITestCase { } if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { - _failures.add( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + StringBuilder sb = new StringBuilder(); + sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ).append(": "); + final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); + sb.append("Expected:").append(Platform.NEWLINE); + exp.getModifiersString(sb).append(Platform.NEWLINE); + sb.append(", Have: ").append(Platform.NEWLINE); + event.getModifiersString(sb).append(Platform.NEWLINE); + _failures.add( sb.toString() ) ; } } - private void _printModifiers( int modifiers ) { - if( ( modifiers & com.jogamp.newt.event.InputEvent.SHIFT_MASK ) != 0 ) { _debugPrintStream.println( " SHIFT" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.CTRL_MASK ) != 0 ) { _debugPrintStream.println( " CTRL" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.META_MASK ) != 0 ) { _debugPrintStream.println( " META" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_MASK ) != 0 ) { _debugPrintStream.println( " ALT" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { _debugPrintStream.println( " ALT_GRAPH" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON1_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON1" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON2_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON2" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON3_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON3" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON4_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON4" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON5_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON5" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON6_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON6" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON7_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON7" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON8_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON8" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON9_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON9" ) ; } - } - - 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 ArrayList<String> getFailures() { return _failures ; } @@ -291,7 +269,6 @@ public abstract class TestNewtEventModifiers extends UITestCase { private static int _numButtonsToTest ; private static int _awtButtonMasks[] ; - private static int _newtButtonMasks[] ; private static java.awt.Robot _robot ; @@ -300,6 +277,8 @@ public abstract class TestNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// public static int getAWTButtonMask(int button) { + // Java7: java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; -> using InputEvent.BUTTON1_DOWN_MASK .. etc + // Java6: Only use BUTTON1_MASK, .. int m; switch(button) { case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; @@ -316,7 +295,13 @@ public abstract class TestNewtEventModifiers extends UITestCase { // Who know how many buttons the AWT will say exist on given platform. // We'll test the smaller of what NEWT supports and what the // AWT says is available. - // _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; + /** Java7: + if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { + _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; + } else { + _numButtonsToTest = 3 ; + } */ + _numButtonsToTest = 3 ; // Then again, maybe not: @@ -327,7 +312,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { // up weren't even delivered to the listeners. // // So... for now we're only going to test 3 buttons since - // that's the common case. + // that's the common case _and_ Java6 safe. _numButtonsToTest = 3 ; @@ -344,13 +329,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); - } - - _newtButtonMasks = new int[_numButtonsToTest] ; - - for( int n = 0 ; n < _newtButtonMasks.length ; ++n ) { - _newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ; - } + } } _robot = new java.awt.Robot() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt b/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt deleted file mode 100644 index 1bd9102b5..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt +++ /dev/null @@ -1,37 +0,0 @@ -Modifier AWT Constant AWT Bit AWT Ex NEWT Constant NEWT Bit -------------- ------------------------------- ------- ------ ------------------------- -------- -Shift Event.SHIFT_MASK 0 -Ctrl Event.CTRL_MASK 1 -Meta Event.META_MASK 2 -Alt Event.ALT_MASK 3 -Button1 InputEvent.BUTTON1_MASK 4 -Button2 InputEvent.BUTTON2_MASK 3 -Button3 InputEvent.BUTTON3_MASK 2 -Shift Down InputEvent.SHIFT_DOWN_MASK 6 * InputEvent.SHIFT_MASK 0 -Ctrl Down InputEvent.CTRL_DOWN_MASK 7 * InputEvent.CTRL_MASK 1 -Meta Down InputEvent.META_DOWN_MASK 8 * InputEvent.META_MASK 2 -Alt Down InputEvent.ALT_DOWN_MASK 9 * InputEvent.ALT_MASK 3 -Button1 Down InputEvent.BUTTON1_DOWN_MASK 10 * InputEvent.BUTTON1_MASK 5 -Button2 Down InputEvent.BUTTON2_DOWN_MASK 11 * InputEvent.BUTTON2_MASK 6 -Button3 Down InputEvent.BUTTON3_DOWN_MASK 12 * InputEvent.BUTTON3_MASK 7 -AltGraph Down InputEvent.ALT_GRAPH_DOWN_MASK 13 * InputEvent.ALT_GRAPH_MASK 4 -Button4 Down -- 14 * InputEvent.BUTTON4_MASK 8 -Button5 Down -- 15 * InputEvent.BUTTON5_MASK 9 -Button6 Down -- 16 * InputEvent.BUTTON6_MASK 10 -Button7 Down -- 17 * InputEvent.BUTTON7_MASK 11 -Button8 Down -- 18 * InputEvent.BUTTON8_MASK 12 -Button9 Down -- 19 * InputEvent.BUTTON9_MASK 13 -Button10 Down -- 20 * -Button11 Down -- 21 * -Button12 Down -- 22 * -Button13 Down -- 23 * -Button14 Down -- 24 * -Button15 Down -- 25 * -Button16 Down -- 26 * InputEvent.BUTTONLAST_MASK 20 -Button17 Down -- 27 * -Button18 Down -- 28 * -Button19 Down -- 29 * -Button20 Down -- 30 * -Autorepeat -- - InputEvent.AUTOREPEAT_MASK 29 -Confined -- - InputEvent.CONFINED_MASK 30 -Invisible -- - InputEvent.INVISIBLE_MASK 31 diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index 3aa016d56..fd68ace73 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -44,7 +44,7 @@ import com.jogamp.newt.event.awt.AWTMouseAdapter ; * the source is an AWT canvas. */ -public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { +public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { private static JFrame _testFrame ; @@ -53,7 +53,7 @@ public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; final GLCanvas canvas = new GLCanvas() ; canvas.addGLEventListener( new BigGreenXGLEventListener() ) ; @@ -76,7 +76,7 @@ public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java index a2c1d3364..44f116ea1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -48,7 +48,7 @@ import com.jogamp.newt.opengl.GLWindow ; * the canvas is a NewtCanvasAWT. */ -public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers { +public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers { private static JFrame _testFrame ; private static GLWindow _glWindow ; @@ -58,7 +58,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; SwingUtilities.invokeAndWait( new Runnable() { public void run() { @@ -89,7 +89,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; SwingUtilities.invokeAndWait( new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index e6139bb37..501e0d1bd 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -47,7 +47,7 @@ import com.jogamp.newt.swt.NewtCanvasSWT ; * the canvas is a NewtCanvasSWT. */ -public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers { +public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers { private static Shell _testShell ; private static GLWindow _glWindow ; @@ -87,7 +87,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; _displayThread = new DisplayThread() ; _displayThread.start() ; @@ -127,7 +127,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; _glWindow.destroy() ; |