diff options
Diffstat (limited to 'src')
17 files changed, 1446 insertions, 916 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index bda60004e..45bccf964 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -34,7 +34,11 @@ package com.jogamp.newt.event; +import com.jogamp.common.util.IntBitfield; + /** + * <a name="eventDelivery"><h5>KeyEvent Delivery</h5></a> + * * Key events are delivered in the following order: * <p> * <table border="0"> @@ -77,32 +81,84 @@ package com.jogamp.newt.event; * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}. * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. * </p> + * + * <a name="unicodeMapping"><h5>Unicode Mapping</h5></a> + * <p> + * {@link #getKeyChar() Key-chars}, as well as + * {@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols} + * use the UTF-16 unicode space w/o collision. + * + * </p> + * <p> + * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, + * i.e. {@link #isModifierKey() modifier-} and {@link #isActionKey() action-}keys, + * are mapped to unicode's control and private range and do not collide w/ {@link #isPrintableKey() printable} unicode values + * with the following exception. + * </p> + * + * <a name="unicodeCollision"><h5>Unicode Collision</h5></a> + * <p> + * The following {@link #getKeyCode() Key-code}s and {@link #getKeySymbol() key-symbol}s collide w/ unicode space:<br/> + * <table border="1"> + * <tr><th>unicode range</th> <th>virtual key code</th> <th>unicode character</th></tr> + * <tr><td>[0x61 .. 0x78]</td> <td>[{@link #VK_F1}..{@link #VK_F24}]</td> <td>['a'..'x']</td></tr> + * </table> + * </p> + * <p> + * Collision was chosen for {@link #getKeyCode() Key-code} and {@link #getKeySymbol() key-symbol} mapping + * to allow a minimal code range, i.e. <code>[0..255]</code>. + * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, + * e.g. to implement a key-press state tracker. + * </p> + * <pre> + * http://www.utf8-chartable.de/unicode-utf8-table.pl + * http://www.unicode.org/Public/5.1.0/ucd/PropList.txt + * https://en.wikipedia.org/wiki/Mapping_of_Unicode_characters + * https://en.wikipedia.org/wiki/Unicode_control_characters + * https://en.wikipedia.org/wiki/Private_Use_%28Unicode%29#Private_Use_Areas + * </pre> + * </p> */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { - public KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { - super(eventType, source, when, modifiers); + private KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, int keySymModMask, char keyChar) { + super(eventType, source, when, modifiers | keySymModMask); this.keyCode=keyCode; this.keySym=keySym; this.keyChar=keyChar; { // cache modifier and action flags byte _flags = 0; - if( isModifierKey(keySym) ) { - _flags |= F_MODIFIER_MASK; - } - if( isActionKey(keySym) ) { - _flags |= F_ACTION_MASK; - } - if( 0 == _flags && VK_UNDEFINED != keySym && NULL_CHAR != keyChar ) { + if( isPrintableKey(keySym, false) && isPrintableKey((short)keyChar, true) ) { _flags |= F_PRINTABLE_MASK; + } else { + if( 0 != keySymModMask ) { + _flags |= F_MODIFIER_MASK; + } else { + // A = U - ( P + M ) + _flags |= F_ACTION_MASK; + } } flags = _flags; + + // + // Validate flags + // + final int pma_bits = flags & ( F_PRINTABLE_MASK | F_MODIFIER_MASK | F_ACTION_MASK ) ; + final int pma_count = IntBitfield.getBitCount(pma_bits); + if ( 1 != pma_count ) { + throw new InternalError("Key must be either of type printable, modifier or action - but it is of "+pma_count+" types: "+this); + } } } + + public static KeyEvent create(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { + return new KeyEvent(eventType, source, when, modifiers, keyCode, keySym, getModifierMask(keySym), keyChar); + } /** - * Returns the <i>UTF-16</i> character reflecting the {@link #getKeySymbol() key symbol}. + * Returns the <i>UTF-16</i> character reflecting the {@link #getKeySymbol() key symbol} + * incl. active {@link #isModifierKey() modifiers}. * @see #getKeySymbol() * @see #getKeyCode() */ @@ -113,8 +169,9 @@ public class KeyEvent extends InputEvent /** * Returns the virtual <i>key symbol</i> reflecting the current <i>keyboard layout</i>. * <p> - * For {@link #isPrintableKey() printable keys}, the <i>key symbol</i> is the unshifted - * representation of the {@link #getKeyChar() UTF-16 key char}. + * For {@link #isPrintableKey() printable keys}, the <i>key symbol</i> is the {@link #isModifierKey() unmodified} + * representation of the UTF-16 {@link #getKeyChar() key char}.<br/> + * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. * </p> * @see #isPrintableKey() * @see #getKeyChar() @@ -136,10 +193,6 @@ public class KeyEvent extends InputEvent * <code>QWERTZ</code> is active. The {@link #getKeySymbol() key symbol} of the former is * {@link #VK_Y}, where the latter produces {@link #VK_Y}. * </p> - * <p> - * <b>Disclaimer</b>: In case <i>key code</i> is not implemented on your platform (OSX, ..) - * the {@link #getKeySymbol() key symbol} is returned. - * </p> * @see #getKeyChar() * @see #getKeySymbol() */ @@ -169,6 +222,18 @@ public class KeyEvent extends InputEvent } } + /** + * @param keyChar UTF16 value to map. It is expected that the incoming keyChar value is unshifted and unmodified, + * however, lower case a-z is mapped to {@link KeyEvent#VK_A} - {@link KeyEvent#VK_Z}. + * @return {@link KeyEvent} virtual key (VK) value. + */ + public static short utf16ToVKey(char keyChar) { + if( 'a' <= keyChar && keyChar <= 'z' ) { + return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); + } + return (short) keyChar; + } + /** * Returns <code>true</code> if the given <code>virtualKey</code> represents a modifier key, otherwise <code>false</code>. * <p> @@ -188,6 +253,25 @@ public class KeyEvent extends InputEvent } } + /** + * If <code>vKey</code> is a {@link #isModifierKey() modifier key}, method returns the corresponding modifier mask, + * otherwise 0. + */ + public static int getModifierMask(short vKey) { + switch (vKey) { + case VK_SHIFT: + return InputEvent.SHIFT_MASK; + case VK_CONTROL: + return InputEvent.CTRL_MASK; + case VK_ALT: + case VK_ALT_GRAPH: + return InputEvent.ALT_MASK; + case VK_META: + return InputEvent.META_MASK; + } + return 0; + } + /** * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a modifier key, * otherwise <code>false</code>. @@ -201,106 +285,67 @@ public class KeyEvent extends InputEvent public final boolean isModifierKey() { return 0 != ( F_MODIFIER_MASK & flags ) ; } - - /** - * Returns <code>true</code> if the given <code>virtualKey</code> represents a non-printable and - * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. - * <p> - * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, - * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, - * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... - * </p> - */ - public static boolean isActionKey(short vKey) { - if( ( VK_F1 <= vKey && vKey <= VK_F24 ) || - ( VK_ALL_CANDIDATES <= vKey && vKey <= VK_INPUT_METHOD_ON_OFF ) || - ( VK_CUT <= vKey && vKey <= VK_STOP ) ) { - return true; - } - - switch (vKey) { - case VK_CANCEL: - case VK_CLEAR: - case VK_PAUSE: - case VK_CAPS_LOCK: - case VK_ESCAPE: - case VK_PAGE_UP: - case VK_PAGE_DOWN: - case VK_END: - case VK_HOME: - case VK_LEFT: - case VK_UP: - case VK_RIGHT: - case VK_DOWN: - case VK_DELETE: - case VK_NUM_LOCK: - case VK_SCROLL_LOCK: - - case VK_PRINTSCREEN: - case VK_INSERT: - case VK_HELP: - case VK_META: - case VK_KP_UP: - case VK_KP_DOWN: - case VK_KP_LEFT: - case VK_KP_RIGHT: - - case VK_DEAD_VOICED_SOUND: - case VK_DEAD_SEMIVOICED_SOUND: - - case VK_WINDOWS: - case VK_CONTEXT_MENU: - case VK_FINAL: - - case VK_CONVERT: - case VK_NONCONVERT: - case VK_ACCEPT: - case VK_MODECHANGE: - - case VK_KANA: - case VK_KANJI: - - case VK_ALPHANUMERIC: - case VK_KATAKANA: - case VK_HIRAGANA: - case VK_FULL_WIDTH: - case VK_HALF_WIDTH: - case VK_ROMAN_CHARACTERS: - - case VK_COMPOSE: - case VK_BEGIN: - case VK_KEYBOARD_INVISIBLE: - return true; - } - return false; - } /** - * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a non-printable and - * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. + * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. * <p> - * See {@link #isActionKey(short)} for details. + * Hence it is the set A of all keys U w/o printable P and w/o modifiers M: + * <code> A = U - ( P + M ) </code> * </p> + * @see #isPrintableKey() + * @see #isModifierKey() */ public final boolean isActionKey() { return 0 != ( F_ACTION_MASK & flags ) ; } - /** - * Returns <code>true</code> if given <code>virtualKey</code> represents a printable character, - * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. + /** + * Returns <code>true</code> if given <code>uniChar</code> represents a printable character, + * i.e. a value other than {@link #VK_UNDEFINED} and not a control or non-printable private code. + * <p> + * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. + * </p> + * <p> * Otherwise returns <code>false</code>. + * </p> + * <p> + * Distinction of key character and virtual key code is made due to <a href="#unicodeCollision">unicode collision</a>. + * </p> + * + * @param uniChar the UTF-16 unicode value, which maybe a virtual key code or key character. + * @param isKeyChar true if <code>uniChar</code> is a key character, otherwise a virtual key code */ - public static boolean isPrintableKey(short vKey) { - return VK_UNDEFINED != vKey && !isModifierKey(vKey) && !isActionKey(vKey); + public static boolean isPrintableKey(final short uniChar, final boolean isKeyChar) { + if( VK_UNDEFINED == uniChar ) { + return false; + } + if( !isKeyChar ) { + if( ( nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || + ( nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || + ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + return false; + } + + } else { + if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || + ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || + ( nonPrintableKeys[2].inclKeyChar && nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + return false; + } + } + return true; } /** - * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a printable character, - * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. The {@link #getKeyChar() key char} value must also be - * different than {@link #NULL_CHAR}. + * Returns <code>true</code> if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} + * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} + * and not a control or non-printable private code. + * <p> + * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. + * </p> * <p> * Otherwise returns <code>false</code>. * </p> @@ -327,578 +372,599 @@ public class KeyEvent extends InputEvent */ public static final short EVENT_KEY_TYPED = 302; + /** + * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. + */ + public static final char NULL_CHAR = '\0'; + /* Virtual key codes. */ - public static final short VK_CANCEL = (short) 0x03; - public static final short VK_BACK_SPACE = (short) 0x08; // '\b' - public static final short VK_TAB = (short) 0x09; // '\t' - public static final short VK_ENTER = (short) 0x0A; // '\n' - public static final short VK_CLEAR = (short) 0x0C; - public static final short VK_SHIFT = (short) 0x10; - public static final short VK_CONTROL = (short) 0x11; + public static class NonPrintableRange { + /** min. unicode value, inclusive */ + public short min; + /** max. unicode value, inclusive */ + public short max; + /** true if valid for keyChar values as well, otherwise only valid for keyCode and keySym due to collision. */ + public final boolean inclKeyChar; + private NonPrintableRange(short min, short max, boolean inclKeyChar) { + this.min = min; + this.max = max; + this.inclKeyChar = inclKeyChar; + } + }; + /** Non printable key ranges, currently fixed to an aray of size 4. */ + public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), + new NonPrintableRange( (short)0x0061, (short)0x0078, false), + new NonPrintableRange( (short)0x007F, (short)0x009F, true ), + new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) }; + + // + // Unicode: Non printable controls: [0x00 - 0x1F] + // + /** - * Constant for the ALT function key, i.e. left ALT key. + * This value, {@value}, is used to indicate that the keyCode is unknown. */ + public static final short VK_UNDEFINED = (short) 0x0; + + static final short VK_FREE01 = (short) 0x01; + + /** Constant for the HOME function key. ASCII: Start Of Text. */ + public static final short VK_HOME = (short) 0x02; + + /** Constant for the END function key. ASCII: End Of Text. */ + public static final short VK_END = (short) 0x03; + + /** Constant for the END function key. ASCII: End Of Transmission. */ + public static final short VK_FINAL = (short) 0x04; + + /** Constant for the PRINT function key. ASCII: Enquiry. */ + public static final short VK_PRINTSCREEN = (short) 0x05; + + static final short VK_FREE06 = (short) 0x06; + static final short VK_FREE07 = (short) 0x07; + + /** Constant for the BACK SPACE key "\b", matching ASCII. */ + public static final short VK_BACK_SPACE = (short) 0x08; + + /** Constant for the HORIZ TAB key "\t", matching ASCII. */ + public static final short VK_TAB = (short) 0x09; + + /** Constant for the ENTER key, i.e. LINE FEED "\n", matching ASCII. */ + public static final short VK_ENTER = (short) 0x0A; + + /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ + public static final short VK_PAGE_DOWN = (short) 0x0B; + + /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ + public static final short VK_CLEAR = (short) 0x0C; + + static final short VK_FREE0D = (short) 0x0D; + static final short VK_FREE0E = (short) 0x0E; + + /** Constant for the CTRL function key. ASCII: shift-in. */ + public static final short VK_SHIFT = (short) 0x0F; + + /** Constant for the PAGE UP function key. ASCII: Data Link Escape. */ + public static final short VK_PAGE_UP = (short) 0x10; + + /** Constant for the CTRL function key. ASCII: device-ctrl-one. */ + public static final short VK_CONTROL = (short) 0x11; + + /** Constant for the left ALT function key. ASCII: device-ctrl-two. */ public static final short VK_ALT = (short) 0x12; - public static final short VK_PAUSE = (short) 0x13; + + /** Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII: device-ctrl-three. */ + public static final short VK_ALT_GRAPH = (short) 0x13; + + /** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */ public static final short VK_CAPS_LOCK = (short) 0x14; + + static final short VK_FREE15 = (short) 0x15; + + /** Constant for the PAUSE function key. ASCII: sync-idle. */ + public static final short VK_PAUSE = (short) 0x16; + + /** <b>scroll lock</b> key. ASCII: End Of Transmission Block. */ + public static final short VK_SCROLL_LOCK = (short) 0x17; + + /** Constant for the CANCEL function key. ASCII: Cancel. */ + public static final short VK_CANCEL = (short) 0x18; + + static final short VK_FREE19 = (short) 0x19; + + /** Constant for the INSERT function key. ASCII: Substitute. */ + public static final short VK_INSERT = (short) 0x1A; + + /** Constant for the ESCAPE function key. ASCII: Escape. */ public static final short VK_ESCAPE = (short) 0x1B; - public static final short VK_SPACE = (short) 0x20; - public static final short VK_PAGE_UP = (short) 0x21; - public static final short VK_PAGE_DOWN = (short) 0x22; - public static final short VK_END = (short) 0x23; - public static final short VK_HOME = (short) 0x24; + + /** Constant for the Convert function key, Japanese "henkan". ASCII: File Separator. */ + public static final short VK_CONVERT = (short) 0x1C; - /** - * Constant for the non-numpad <b>left</b> arrow key. - * @see #VK_KP_LEFT - */ - public static final short VK_LEFT = (short) 0x25; + /** Constant for the Don't Convert function key, Japanese "muhenkan". ASCII: Group Separator.*/ + public static final short VK_NONCONVERT = (short) 0x1D; - /** - * Constant for the non-numpad <b>up</b> arrow key. - * @see #VK_KP_UP - */ - public static final short VK_UP = (short) 0x26; + /** Constant for the Accept or Commit function key, Japanese "kakutei". ASCII: Record Separator.*/ + public static final short VK_ACCEPT = (short) 0x1E; - /** - * Constant for the non-numpad <b>right</b> arrow key. - * @see #VK_KP_RIGHT - */ - public static final short VK_RIGHT = (short) 0x27; + /** Constant for the Mode Change (?). ASCII: Unit Separator.*/ + public static final short VK_MODECHANGE = (short) 0x1F; - /** - * Constant for the non-numpad <b>down</b> arrow key. - * @see #VK_KP_DOWN - */ - public static final short VK_DOWN = (short) 0x28; + // + // Unicode: Printable [0x20 - 0x7E] + // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys + // + + /** Constant for the SPACE function key. ASCII: SPACE. */ + public static final short VK_SPACE = (short) 0x20; + + /** Constant for the "!" key. */ + public static final short VK_EXCLAMATION_MARK = (short) 0x21; - /** - * Constant for the comma key, "," - */ - public static final short VK_COMMA = (short) 0x2C; + /** Constant for the """ key. */ + public static final short VK_QUOTEDBL = (short) 0x22; + + /** Constant for the "#" key. */ + public static final short VK_NUMBER_SIGN = (short) 0x23; - /** - * Constant for the minus key, "-" - * @since 1.2 - */ + /** Constant for the "$" key. */ + public static final short VK_DOLLAR = (short) 0x24; + + /** Constant for the "%" key. */ + public static final short VK_PERCENT = (short) 0x25; + + /** Constant for the "&" key. */ + public static final short VK_AMPERSAND = (short) 0x26; + + /** Constant for the "'" key. */ + public static final short VK_QUOTE = (short) 0x27; + + /** Constant for the "(" key. */ + public static final short VK_LEFT_PARENTHESIS = (short) 0x28; + + /** Constant for the ")" key. */ + public static final short VK_RIGHT_PARENTHESIS = (short) 0x29; + + /** Constant for the "*" key */ + public static final short VK_ASTERISK = (short) 0x2A; + + /** Constant for the "+" key. */ + public static final short VK_PLUS = (short) 0x2B; + + /** Constant for the comma key, "," */ + public static final short VK_COMMA = (short) 0x2C; + + /** Constant for the minus key, "-" */ public static final short VK_MINUS = (short) 0x2D; - /** - * Constant for the period key, "." - */ + /** Constant for the period key, "." */ public static final short VK_PERIOD = (short) 0x2E; - /** - * Constant for the forward slash key, "/" - */ + /** Constant for the forward slash key, "/" */ public static final short VK_SLASH = (short) 0x2F; - /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ + /** VK_0 thru VK_9 are the same as UTF16/ASCII '0' thru '9' [0x30 - 0x39] */ public static final short VK_0 = (short) 0x30; + /** See {@link #VK_0}. */ public static final short VK_1 = (short) 0x31; + /** See {@link #VK_0}. */ public static final short VK_2 = (short) 0x32; + /** See {@link #VK_0}. */ public static final short VK_3 = (short) 0x33; + /** See {@link #VK_0}. */ public static final short VK_4 = (short) 0x34; + /** See {@link #VK_0}. */ public static final short VK_5 = (short) 0x35; + /** See {@link #VK_0}. */ public static final short VK_6 = (short) 0x36; + /** See {@link #VK_0}. */ public static final short VK_7 = (short) 0x37; + /** See {@link #VK_0}. */ public static final short VK_8 = (short) 0x38; + /** See {@link #VK_0}. */ public static final short VK_9 = (short) 0x39; - /** - * Constant for the semicolon key, ";" - */ + /** Constant for the ":" key. */ + public static final short VK_COLON = (short) 0x3A; + + /** Constant for the semicolon key, ";" */ public static final short VK_SEMICOLON = (short) 0x3B; - /** - * Constant for the equals key, "=" - */ + /** Constant for the equals key, "<" */ + public static final short VK_LESS = (short) 0x3C; + + /** Constant for the equals key, "=" */ public static final short VK_EQUALS = (short) 0x3D; - /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ + /** Constant for the equals key, ">" */ + public static final short VK_GREATER = (short) 0x3E; + + /** Constant for the equals key, "?" */ + public static final short VK_QUESTIONMARK = (short) 0x3F; + + /** Constant for the equals key, "@" */ + public static final short VK_AT = (short) 0x40; + + /** VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A) */ public static final short VK_A = (short) 0x41; + /** See {@link #VK_A}. */ public static final short VK_B = (short) 0x42; + /** See {@link #VK_A}. */ public static final short VK_C = (short) 0x43; + /** See {@link #VK_A}. */ public static final short VK_D = (short) 0x44; + /** See {@link #VK_A}. */ public static final short VK_E = (short) 0x45; + /** See {@link #VK_A}. */ public static final short VK_F = (short) 0x46; + /** See {@link #VK_A}. */ public static final short VK_G = (short) 0x47; + /** See {@link #VK_A}. */ public static final short VK_H = (short) 0x48; + /** See {@link #VK_A}. */ public static final short VK_I = (short) 0x49; + /** See {@link #VK_A}. */ public static final short VK_J = (short) 0x4A; + /** See {@link #VK_A}. */ public static final short VK_K = (short) 0x4B; + /** See {@link #VK_A}. */ public static final short VK_L = (short) 0x4C; + /** See {@link #VK_A}. */ public static final short VK_M = (short) 0x4D; + /** See {@link #VK_A}. */ public static final short VK_N = (short) 0x4E; + /** See {@link #VK_A}. */ public static final short VK_O = (short) 0x4F; + /** See {@link #VK_A}. */ public static final short VK_P = (short) 0x50; + /** See {@link #VK_A}. */ public static final short VK_Q = (short) 0x51; + /** See {@link #VK_A}. */ public static final short VK_R = (short) 0x52; + /** See {@link #VK_A}. */ public static final short VK_S = (short) 0x53; + /** See {@link #VK_A}. */ public static final short VK_T = (short) 0x54; + /** See {@link #VK_A}. */ public static final short VK_U = (short) 0x55; + /** See {@link #VK_A}. */ public static final short VK_V = (short) 0x56; + /** See {@link #VK_A}. */ public static final short VK_W = (short) 0x57; + /** See {@link #VK_A}. */ public static final short VK_X = (short) 0x58; + /** See {@link #VK_A}. */ public static final short VK_Y = (short) 0x59; + /** See {@link #VK_A}. */ public static final short VK_Z = (short) 0x5A; - /** - * Constant for the open bracket key, "[" - */ + /** Constant for the open bracket key, "[" */ public static final short VK_OPEN_BRACKET = (short) 0x5B; - /** - * Constant for the back slash key, "\" - */ + /**Constant for the back slash key, "\" */ public static final short VK_BACK_SLASH = (short) 0x5C; - /** - * Constant for the close bracket key, "]" - */ + /** Constant for the close bracket key, "]" */ public static final short VK_CLOSE_BRACKET = (short) 0x5D; - public static final short VK_NUMPAD0 = (short) 0x60; - public static final short VK_NUMPAD1 = (short) 0x61; - public static final short VK_NUMPAD2 = (short) 0x62; - public static final short VK_NUMPAD3 = (short) 0x63; - public static final short VK_NUMPAD4 = (short) 0x64; - public static final short VK_NUMPAD5 = (short) 0x65; - public static final short VK_NUMPAD6 = (short) 0x66; - public static final short VK_NUMPAD7 = (short) 0x67; - public static final short VK_NUMPAD8 = (short) 0x68; - public static final short VK_NUMPAD9 = (short) 0x69; - public static final short VK_MULTIPLY = (short) 0x6A; - public static final short VK_ADD = (short) 0x6B; + /** Constant for the "^" key. */ + public static final short VK_CIRCUMFLEX = (short) 0x5E; + /** Constant for the "_" key */ + public static final short VK_UNDERSCORE = (short) 0x5F; + + /** Constant for the "`" key */ + public static final short VK_BACK_QUOTE = (short) 0x60; + + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ + /** - * Constant for the Numpad Separator key. + * Constant for the F<i>n</i> function keys. + * <p> + * F1..F24, i.e. F<i>n</i>, are mapped from on <code>0x60+n</code> -> <code>[0x61 .. 0x78]</code>. + * </p> + * <p> + * <b>Warning:</b> The F<i>n</i> function keys <b>do collide</b> with unicode characters small 'a' thru 'x'!<br/> + * See <a href="#unicodeCollision">Unicode Collision</a> for details. + * </p> */ - public static final short VK_SEPARATOR = (short) 0x6C; + public static final short VK_F1 = (short) ( 0x60+ 1 ); - public static final short VK_SUBTRACT = (short) 0x6D; - public static final short VK_DECIMAL = (short) 0x6E; - public static final short VK_DIVIDE = (short) 0x6F; - public static final short VK_DELETE = (short) 0x7F; /* ASCII DEL */ - public static final short VK_NUM_LOCK = (short) 0x90; - public static final short VK_SCROLL_LOCK = (short) 0x91; + /** Constant for the F2 function key. See {@link #VK_F1}. */ + public static final short VK_F2 = (short) ( 0x60+ 2 ); - /** Constant for the F1 function key. */ - public static final short VK_F1 = (short) 0x70; + /** Constant for the F3 function key. See {@link #VK_F1}. */ + public static final short VK_F3 = (short) ( 0x60+ 3 ); - /** Constant for the F2 function key. */ - public static final short VK_F2 = (short) 0x71; + /** Constant for the F4 function key. See {@link #VK_F1}. */ + public static final short VK_F4 = (short) ( 0x60+ 4 ); - /** Constant for the F3 function key. */ - public static final short VK_F3 = (short) 0x72; + /** Constant for the F5 function key. See {@link #VK_F1}. */ + public static final short VK_F5 = (short) ( 0x60+ 5 ); - /** Constant for the F4 function key. */ - public static final short VK_F4 = (short) 0x73; + /** Constant for the F6 function key. See {@link #VK_F1}. */ + public static final short VK_F6 = (short) ( 0x60+ 6 ); - /** Constant for the F5 function key. */ - public static final short VK_F5 = (short) 0x74; + /** Constant for the F7 function key. See {@link #VK_F1}. */ + public static final short VK_F7 = (short) ( 0x60+ 7 ); - /** Constant for the F6 function key. */ - public static final short VK_F6 = (short) 0x75; + /** Constant for the F8 function key. See {@link #VK_F1}. */ + public static final short VK_F8 = (short) ( 0x60+ 8 ); - /** Constant for the F7 function key. */ - public static final short VK_F7 = (short) 0x76; + /** Constant for the F9 function key. See {@link #VK_F1}. */ + public static final short VK_F9 = (short) ( 0x60+ 9 ); - /** Constant for the F8 function key. */ - public static final short VK_F8 = (short) 0x77; + /** Constant for the F11 function key. See {@link #VK_F1}. */ + public static final short VK_F10 = (short) ( 0x60+10 ); - /** Constant for the F9 function key. */ - public static final short VK_F9 = (short) 0x78; + /** Constant for the F11 function key. See {@link #VK_F1}. */ + public static final short VK_F11 = (short) ( 0x60+11 ); - /** Constant for the F10 function key. */ - public static final short VK_F10 = (short) 0x79; + /** Constant for the F12 function key. See {@link #VK_F1}.*/ + public static final short VK_F12 = (short) ( 0x60+12 ); - /** Constant for the F11 function key. */ - public static final short VK_F11 = (short) 0x7A; + /** Constant for the F13 function key. See {@link #VK_F1}. */ + public static final short VK_F13 = (short) ( 0x60+13 ); - /** Constant for the F12 function key. */ - public static final short VK_F12 = (short) 0x7B; + /** Constant for the F14 function key. See {@link #VK_F1}. */ + public static final short VK_F14 = (short) ( 0x60+14 ); - /** - * Constant for the F13 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F13 = (short) 0xF000; + /** Constant for the F15 function key. See {@link #VK_F1}. */ + public static final short VK_F15 = (short) ( 0x60+15 ); - /** - * Constant for the F14 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F14 = (short) 0xF001; - - /** - * Constant for the F15 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F15 = (short) 0xF002; - - /** - * Constant for the F16 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F16 = (short) 0xF003; - - /** - * Constant for the F17 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F17 = (short) 0xF004; + /** Constant for the F16 function key. See {@link #VK_F1}. */ + public static final short VK_F16 = (short) ( 0x60+16 ); - /** - * Constant for the F18 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F18 = (short) 0xF005; + /** Constant for the F17 function key. See {@link #VK_F1}. */ + public static final short VK_F17 = (short) ( 0x60+17 ); - /** - * Constant for the F19 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F19 = (short) 0xF006; + /** Constant for the F18 function key. See {@link #VK_F1}. */ + public static final short VK_F18 = (short) ( 0x60+18 ); - /** - * Constant for the F20 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F20 = (short) 0xF007; + /** Constant for the F19 function key. See {@link #VK_F1}. */ + public static final short VK_F19 = (short) ( 0x60+19 ); - /** - * Constant for the F21 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F21 = (short) 0xF008; + /** Constant for the F20 function key. See {@link #VK_F1}. */ + public static final short VK_F20 = (short) ( 0x60+20 ); - /** - * Constant for the F22 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F22 = (short) 0xF009; + /** Constant for the F21 function key. See {@link #VK_F1}. */ + public static final short VK_F21 = (short) ( 0x60+21 ); - /** - * Constant for the F23 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F23 = (short) 0xF00A; + /** Constant for the F22 function key. See {@link #VK_F1}. */ + public static final short VK_F22 = (short) ( 0x60+22 ); - /** - * Constant for the F24 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F24 = (short) 0xF00B; + /** Constant for the F23 function key. See {@link #VK_F1}. */ + public static final short VK_F23 = (short) ( 0x60+23 ); - public static final short VK_PRINTSCREEN = (short) 0x9A; - public static final short VK_INSERT = (short) 0x9B; - public static final short VK_HELP = (short) 0x9C; - public static final short VK_META = (short) 0x9D; + /** Constant for the F24 function key. See {@link #VK_F1}. */ + public static final short VK_F24 = (short) ( 0x60+24 ); - public static final short VK_BACK_QUOTE = (short) 0xC0; - public static final short VK_QUOTE = (short) 0xDE; + + /** Constant for the "{" key */ + public static final short VK_LEFT_BRACE = (short) 0x7B; + /** Constant for the "|" key */ + public static final short VK_PIPE = (short) 0x7C; + /** Constant for the "}" key */ + public static final short VK_RIGHT_BRACE = (short) 0x7D; + + /** Constant for the "~" key, matching ASCII */ + public static final short VK_TILDE = (short) 0x7E; + + // + // Unicode: Non printable controls: [0x7F - 0x9F] + // + + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ + public static final short VK_DELETE = (short) 0x7F; + + /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ + public static final short VK_NUMPAD0 = (short) 0x80; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD1 = (short) 0x81; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD2 = (short) 0x82; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD3 = (short) 0x83; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD4 = (short) 0x84; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD5 = (short) 0x85; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD6 = (short) 0x86; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD7 = (short) 0x87; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD8 = (short) 0x88; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD9 = (short) 0x89; + + /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */ + public static final short VK_DECIMAL = (short) 0x8A; + + /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */ + public static final short VK_SEPARATOR = (short) 0x8B; + + /** Numeric keypad <b>add</b> key. Non printable UTF control. */ + public static final short VK_ADD = (short) 0x8C; - /** - * Constant for the numeric keypad <b>up</b> arrow key. - * @see #VK_UP - */ - public static final short VK_KP_UP = (short) 0xE0; + /** Numeric keypad <b>subtract</b> key. Non printable UTF control. */ + public static final short VK_SUBTRACT = (short) 0x8D; + + /** Numeric keypad <b>multiply</b> key. Non printable UTF control. */ + public static final short VK_MULTIPLY = (short) 0x8E; + + /** Numeric keypad <b>divide</b> key. Non printable UTF control. */ + public static final short VK_DIVIDE = (short) 0x8F; + + /** Numeric keypad <b>num lock</b> key. Non printable UTF control. */ + public static final short VK_NUM_LOCK = (short) 0x90; + + /** Numeric keypad <b>left</b> arrow key, for cursor pad see {@link #VK_LEFT}. Non printable UTF control. */ + public static final short VK_KP_LEFT = (short) 0x91; - /** - * Constant for the numeric keypad <b>down</b> arrow key. - * @see #VK_DOWN - */ - public static final short VK_KP_DOWN = (short) 0xE1; + /** Numeric keypad <b>up</b> arrow key, for cursor pad see {@link #VK_UP}. Non printable UTF control. */ + public static final short VK_KP_UP = (short) 0x92; - /** - * Constant for the numeric keypad <b>left</b> arrow key. - * @see #VK_LEFT - */ - public static final short VK_KP_LEFT = (short) 0xE2; + /** Constant for the numeric keypad <b>right</b> arrow key, for cursor pad see {@link #VK_RIGHT}. Non printable UTF control. */ + public static final short VK_KP_RIGHT = (short) 0x93; + + /** Numeric keypad <b>down</b> arrow key, for cursor pad see {@link #VK_DOWN}. Non printable UTF control. */ + public static final short VK_KP_DOWN = (short) 0x94; - /** - * Constant for the numeric keypad <b>right</b> arrow key. - * @see #VK_RIGHT - */ - public static final short VK_KP_RIGHT = (short) 0xE3; - - /** For European keyboards */ - public static final short VK_DEAD_GRAVE = (short) 0x80; - /** For European keyboards */ - public static final short VK_DEAD_ACUTE = (short) 0x81; - /** For European keyboards */ - public static final short VK_DEAD_CIRCUMFLEX = (short) 0x82; - /** For European keyboards */ - public static final short VK_DEAD_TILDE = (short) 0x83; - /** For European keyboards */ - public static final short VK_DEAD_MACRON = (short) 0x84; - /** For European keyboards */ - public static final short VK_DEAD_BREVE = (short) 0x85; - /** For European keyboards */ - public static final short VK_DEAD_ABOVEDOT = (short) 0x86; - /** For European keyboards */ - public static final short VK_DEAD_DIAERESIS = (short) 0x87; - /** For European keyboards */ - public static final short VK_DEAD_ABOVERING = (short) 0x88; - /** For European keyboards */ - public static final short VK_DEAD_DOUBLEACUTE = (short) 0x89; - /** For European keyboards */ - public static final short VK_DEAD_CARON = (short) 0x8a; - /** For European keyboards */ - public static final short VK_DEAD_CEDILLA = (short) 0x8b; - /** For European keyboards */ - public static final short VK_DEAD_OGONEK = (short) 0x8c; - /** For European keyboards */ - public static final short VK_DEAD_IOTA = (short) 0x8d; - /** For European keyboards */ - public static final short VK_DEAD_VOICED_SOUND = (short) 0x8e; - /** For European keyboards */ - public static final short VK_DEAD_SEMIVOICED_SOUND = (short) 0x8f; - - /** For European keyboards */ - public static final short VK_AMPERSAND = (short) 0x96; - /** For European keyboards */ - public static final short VK_ASTERISK = (short) 0x97; - /** For European keyboards */ - public static final short VK_QUOTEDBL = (short) 0x98; - /** For European keyboards */ - public static final short VK_LESS = (short) 0x99; - - /** For European keyboards */ - public static final short VK_GREATER = (short) 0xa0; - /** For European keyboards */ - public static final short VK_BRACELEFT = (short) 0xa1; - /** For European keyboards */ - public static final short VK_BRACERIGHT = (short) 0xa2; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_LEFT}*/ + public static final short VK_LEFT = (short) 0x95; - /** - * Constant for the "@" key. - */ - public static final short VK_AT = (short) 0x0200; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_UP}.*/ + public static final short VK_UP = (short) 0x96; - /** - * Constant for the ":" key. - */ - public static final short VK_COLON = (short) 0x0201; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_RIGHT}.*/ + public static final short VK_RIGHT = (short) 0x97; - /** - * Constant for the "^" key. - */ - public static final short VK_CIRCUMFLEX = (short) 0x0202; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_DOWN}.*/ + public static final short VK_DOWN = (short) 0x98; + + /** Constant for the Context Menu key. */ + public static final short VK_CONTEXT_MENU = (short) 0x99; /** - * Constant for the "$" key. + * Constant for the MS "Windows" function key. + * It is used for both the left and right version of the key. */ - public static final short VK_DOLLAR = (short) 0x0203; + public static final short VK_WINDOWS = (short) 0x9A; - /** - * Constant for the Euro currency sign key. - */ - public static final short VK_EURO_SIGN = (short) 0x0204; + /** Constant for the Meta function key. */ + public static final short VK_META = (short) 0x9B; + + /** Constant for the Help function key. */ + public static final short VK_HELP = (short) 0x9C; + + /** Constant for the Compose function key. */ + public static final short VK_COMPOSE = (short) 0x9D; - /** - * Constant for the "!" key. - */ - public static final short VK_EXCLAMATION_MARK = (short) 0x0205; + /** Constant for the Begin function key. */ + public static final short VK_BEGIN = (short) 0x9E; - /** - * Constant for the inverted exclamation mark key. - */ - public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0x0206; + /** Constant for the Stop function key. */ + public static final short VK_STOP = (short) 0x9F; + + // + // Unicode: Printable [0x00A0 - 0xDFFF] + // + + /** Constant for the inverted exclamation mark key. */ + public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1; + + /** Constant for the Euro currency sign key. */ + public static final short VK_EURO_SIGN = (short) 0x20AC; - /** - * Constant for the "(" key. - */ - public static final short VK_LEFT_PARENTHESIS = (short) 0x0207; + // + // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) + // + + /* for Sun keyboards */ + public static final short VK_CUT = (short) 0xF879; + public static final short VK_COPY = (short) 0xF87A; + public static final short VK_PASTE = (short) 0xF87B; + public static final short VK_UNDO = (short) 0xF87C; + public static final short VK_AGAIN = (short) 0xF87D; + public static final short VK_FIND = (short) 0xF87E; + public static final short VK_PROPS = (short) 0xF87F; - /** - * Constant for the "#" key. - */ - public static final short VK_NUMBER_SIGN = (short) 0x0208; + /* for input method support on Asian Keyboards */ /** - * Constant for the "+" key. + * Constant for the input method on/off key. */ - public static final short VK_PLUS = (short) 0x0209; - + /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ + public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890; + /** - * Constant for the ")" key. + * Constant for the Code Input function key. */ - public static final short VK_RIGHT_PARENTHESIS = (short) 0x020A; + /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ + public static final short VK_CODE_INPUT = (short) 0xF891; /** - * Constant for the "_" key. + * Constant for the Roman Characters function key. */ - public static final short VK_UNDERSCORE = (short) 0x020B; + /* Japanese PC 106 keyboard: roumaji */ + public static final short VK_ROMAN_CHARACTERS = (short) 0xF892; /** - * Constant for the Microsoft Windows "Windows" key. - * It is used for both the left and right version of the key. + * Constant for the All Candidates function key. */ - public static final short VK_WINDOWS = (short) 0x020C; + /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ + public static final short VK_ALL_CANDIDATES = (short) 0xF893; /** - * Constant for the Microsoft Windows Context Menu key. + * Constant for the Previous Candidate function key. */ - public static final short VK_CONTEXT_MENU = (short) 0x020D; - - /* for input method support on Asian Keyboards */ - - /* not clear what this means - listed in Microsoft Windows API */ - public static final short VK_FINAL = (short) 0x0018; - - /** Constant for the Convert function key. */ - /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */ - public static final short VK_CONVERT = (short) 0x001C; - - /** Constant for the Don't Convert function key. */ - /* Japanese PC 106 keyboard: muhenkan */ - public static final short VK_NONCONVERT = (short) 0x001D; - - /** Constant for the Accept or Commit function key. */ - /* Japanese Solaris keyboard: kakutei */ - public static final short VK_ACCEPT = (short) 0x001E; - - /* not clear what this means - listed in Microsoft Windows API */ - public static final short VK_MODECHANGE = (short) 0x001F; - - /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris; - might still be used on other platforms */ - public static final short VK_KANA = (short) 0x0015; - - /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris; - might still be used for other platforms */ - public static final short VK_KANJI = (short) 0x0019; + /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ + public static final short VK_PREVIOUS_CANDIDATE = (short) 0xF894; /** * Constant for the Alphanumeric function key. */ /* Japanese PC 106 keyboard: eisuu */ - public static final short VK_ALPHANUMERIC = (short) 0x00F0; + public static final short VK_ALPHANUMERIC = (short) 0xF895; /** * Constant for the Katakana function key. */ /* Japanese PC 106 keyboard: katakana */ - public static final short VK_KATAKANA = (short) 0x00F1; + public static final short VK_KATAKANA = (short) 0xF896; /** * Constant for the Hiragana function key. */ /* Japanese PC 106 keyboard: hiragana */ - public static final short VK_HIRAGANA = (short) 0x00F2; + public static final short VK_HIRAGANA = (short) 0xF897; /** * Constant for the Full-Width Characters function key. */ /* Japanese PC 106 keyboard: zenkaku */ - public static final short VK_FULL_WIDTH = (short) 0x00F3; + public static final short VK_FULL_WIDTH = (short) 0xF898; /** * Constant for the Half-Width Characters function key. */ /* Japanese PC 106 keyboard: hankaku */ - public static final short VK_HALF_WIDTH = (short) 0x00F4; - - /** - * Constant for the Roman Characters function key. - */ - /* Japanese PC 106 keyboard: roumaji */ - public static final short VK_ROMAN_CHARACTERS = (short) 0x00F5; - - /** - * Constant for the All Candidates function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ - public static final short VK_ALL_CANDIDATES = (short) 0x0100; - - /** - * Constant for the Previous Candidate function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ - public static final short VK_PREVIOUS_CANDIDATE = (short) 0x0101; - - /** - * Constant for the Code Input function key. - */ - /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ - public static final short VK_CODE_INPUT = (short) 0x0102; + public static final short VK_HALF_WIDTH = (short) 0xF89A; /** * Constant for the Japanese-Katakana function key. * This key switches to a Japanese input method and selects its Katakana input mode. */ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ - public static final short VK_JAPANESE_KATAKANA = (short) 0x0103; + public static final short VK_JAPANESE_KATAKANA = (short) 0xF89B; /** * Constant for the Japanese-Hiragana function key. * This key switches to a Japanese input method and selects its Hiragana input mode. */ /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_HIRAGANA = (short) 0x0104; + public static final short VK_JAPANESE_HIRAGANA = (short) 0xF89C; /** * Constant for the Japanese-Roman function key. * This key switches to a Japanese input method and selects its Roman-Direct input mode. */ /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_ROMAN = (short) 0x0105; + public static final short VK_JAPANESE_ROMAN = (short) 0xF89D; /** * Constant for the locking Kana function key. * This key locks the keyboard into a Kana layout. */ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ - public static final short VK_KANA_LOCK = (short) 0x0106; - - /** - * Constant for the input method on/off key. - */ - /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ - public static final short VK_INPUT_METHOD_ON_OFF = (short) 0x0107; - - /* for Sun keyboards */ - public static final short VK_CUT = (short) 0xFFD1; - public static final short VK_COPY = (short) 0xFFCD; - public static final short VK_PASTE = (short) 0xFFCF; - public static final short VK_UNDO = (short) 0xFFCB; - public static final short VK_AGAIN = (short) 0xFFC9; - public static final short VK_FIND = (short) 0xFFD0; - public static final short VK_PROPS = (short) 0xFFCA; - public static final short VK_STOP = (short) 0xFFC8; - - /** - * Constant for the Compose function key. - */ - public static final short VK_COMPOSE = (short) 0xFF20; - - /** - * Constant for the ALT_GRAPH function key, i.e. right ALT key. - */ - public static final short VK_ALT_GRAPH = (short) 0xFF7E; - - /** - * Constant for the Begin key. - */ - public static final short VK_BEGIN = (short) 0xFF58; + public static final short VK_KANA_LOCK = (short) 0xF89F; /** * Constant for Keyboard became invisible, e.g. Android's soft keyboard Back button hit while keyboard is visible. */ - public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD; - - /** - * This value, {@value}, is used to indicate that the keyCode is unknown. - */ - public static final short VK_UNDEFINED = (short) 0x0; - - /** - * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. - */ - public static final char NULL_CHAR = '\0'; + public static final short VK_KEYBOARD_INVISIBLE = (short) 0xF8FF; } diff --git a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java b/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java deleted file mode 100644 index 73afa0993..000000000 --- a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.newt.event; - -import com.jogamp.newt.event.KeyEvent; - -public class UTFKeyUtil { - - // - // UTF Key Constants - // - private static final char UTF_Equal = '='; - private static final char UTF_Minus = '-'; - private static final char UTF_RightBracket = ']'; - private static final char UTF_LeftBracket = '['; - private static final char UTF_Quote = '\''; - private static final char UTF_Semicolon = ';'; - private static final char UTF_Backslash = '\\'; - private static final char UTF_Comma = ','; - private static final char UTF_Slash = '/'; - private static final char UTF_Period = '.'; - private static final char UTF_Grave = '`'; // back quote - - /** - * @param keyChar UTF16 value to map. Note: Lower case values are preferred. - * @return {@link KeyEvent} virtual key (VK) value if possible, - * otherwise simply the UTF16 value of type short as a last resort. - */ - public static short utf16ToVKey(char keyChar) { - if( 'a' <= keyChar && keyChar <= 'z' ) { - return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); - } - if( '0' <= keyChar && keyChar <= '9' ) { - return (short) ( ( keyChar - '0' ) + KeyEvent.VK_0 ); - } - switch(keyChar) { - // - // KeyCodes (Layout Dependent) - // - case UTF_Equal: return KeyEvent.VK_EQUALS; - case UTF_Minus: return KeyEvent.VK_MINUS; - case UTF_RightBracket: return KeyEvent.VK_CLOSE_BRACKET; - case UTF_LeftBracket: return KeyEvent.VK_OPEN_BRACKET; - case UTF_Quote: return KeyEvent.VK_QUOTE; - case UTF_Semicolon: return KeyEvent.VK_SEMICOLON; - case UTF_Backslash: return KeyEvent.VK_BACK_SLASH; - case UTF_Comma: return KeyEvent.VK_COMMA; - case UTF_Slash: return KeyEvent.VK_SLASH; - case UTF_Period: return KeyEvent.VK_PERIOD; - case UTF_Grave: return KeyEvent.VK_BACK_QUOTE; // KeyEvent.VK_DEAD_GRAVE - } - if( 'A' <= keyChar && keyChar <= 'Z' ) { - return (short) ( ( keyChar - 'A' ) + KeyEvent.VK_A ); - } - return (short) keyChar; - } -} diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e5dd783ca..01a58a305 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2251,41 +2251,45 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // KeyListener/Event Support // - protected IntBitfield keyPressedState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); - protected IntBitfield keyRepeatState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); + private static final int keyTrackingRange = 255; + private final IntBitfield keyPressedState = new IntBitfield( keyTrackingRange + 1 ); + + protected final boolean isKeyCodeTracked(final short keyCode) { + return ( 0xFFFF & (int)keyCode ) <= keyTrackingRange; + } /** - * @param keyCode - * @return 1 if pressed, 0 if not pressed, -1 if not handled. + * @param keyCode the keyCode to set pressed state + * @param pressed true if pressed, otherwise false + * @return the previus pressed value */ - protected final int isKeyPressed(int keyCode) { - if( 0 <= keyCode && keyCode < keyPressedState.capacity() ) { - return keyPressedState.get(keyCode) ? 1 : 0; + protected final boolean setKeyPressed(short keyCode, boolean pressed) { + final int v = 0xFFFF & (int)keyCode; + if( v <= keyTrackingRange ) { + return keyPressedState.put(v, pressed); } - return -1; + return false; } /** - * @param keyCode - * @return 1 if pressed, 0 if not pressed, -1 if not handled. + * @param keyCode the keyCode to test pressed state + * @return true if pressed, otherwise false */ - protected final int isKeyInAutoRepeat(int keyCode) { - if( 0 <= keyCode && keyCode < keyRepeatState.capacity() ) { - return keyRepeatState.get(keyCode) ? 1 : 0; + protected final boolean isKeyPressed(short keyCode) { + final int v = 0xFFFF & (int)keyCode; + if( v <= keyTrackingRange ) { + return keyPressedState.get(v); } - return -1; - } - protected final boolean isKeyCodeTracked(int keyCode) { - return 0 <= keyCode && keyCode < keyRepeatState.capacity(); + return false; } public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } @Override @@ -2400,7 +2404,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED final KeyEvent eTyped; if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) { - eTyped = new KeyEvent(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); + eTyped = KeyEvent.create(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); } else { eTyped = null; } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index b90c2106e..ccbdc07bf 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -176,6 +176,14 @@ public class AWTNewtEventFactory { } } + public static final short awtButton2Newt(int awtButton) { + if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + return (short)awtButton; + } else { + return (short)0; + } + } + /** * Converts the specified set of AWT event modifiers and extended event * modifiers to the equivalent NEWT event modifiers. @@ -223,12 +231,365 @@ public class AWTNewtEventFactory { return newtMods; } - public static final short awtButton2Newt(int awtButton) { - if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - return (short)awtButton; - } else { - return (short)0; + public static short awtKeyCode2NewtKeyCode(final int awtKeyCode) { + final short defNEWTKeyCode = (short)awtKeyCode; + switch (awtKeyCode) { + case java.awt.event.KeyEvent.VK_HOME : return com.jogamp.newt.event.KeyEvent.VK_HOME; + case java.awt.event.KeyEvent.VK_END : return com.jogamp.newt.event.KeyEvent.VK_END; + case java.awt.event.KeyEvent.VK_FINAL : return com.jogamp.newt.event.KeyEvent.VK_FINAL; + case java.awt.event.KeyEvent.VK_PRINTSCREEN : return com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN; + case java.awt.event.KeyEvent.VK_BACK_SPACE : return com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE; + case java.awt.event.KeyEvent.VK_TAB : return com.jogamp.newt.event.KeyEvent.VK_TAB; + case java.awt.event.KeyEvent.VK_ENTER : return com.jogamp.newt.event.KeyEvent.VK_ENTER; + case java.awt.event.KeyEvent.VK_PAGE_DOWN : return com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN; + case java.awt.event.KeyEvent.VK_CLEAR : return com.jogamp.newt.event.KeyEvent.VK_CLEAR; + case java.awt.event.KeyEvent.VK_SHIFT : return com.jogamp.newt.event.KeyEvent.VK_SHIFT; + case java.awt.event.KeyEvent.VK_PAGE_UP : return com.jogamp.newt.event.KeyEvent.VK_PAGE_UP; + case java.awt.event.KeyEvent.VK_CONTROL : return com.jogamp.newt.event.KeyEvent.VK_CONTROL; + case java.awt.event.KeyEvent.VK_ALT : return com.jogamp.newt.event.KeyEvent.VK_ALT; + case java.awt.event.KeyEvent.VK_ALT_GRAPH : return com.jogamp.newt.event.KeyEvent.VK_ALT_GRAPH; + case java.awt.event.KeyEvent.VK_CAPS_LOCK : return com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK; + case java.awt.event.KeyEvent.VK_PAUSE : return com.jogamp.newt.event.KeyEvent.VK_PAUSE; + case java.awt.event.KeyEvent.VK_SCROLL_LOCK : return com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK; + case java.awt.event.KeyEvent.VK_CANCEL : return com.jogamp.newt.event.KeyEvent.VK_CANCEL; + case java.awt.event.KeyEvent.VK_INSERT : return com.jogamp.newt.event.KeyEvent.VK_INSERT; + case java.awt.event.KeyEvent.VK_ESCAPE : return com.jogamp.newt.event.KeyEvent.VK_ESCAPE; + case java.awt.event.KeyEvent.VK_CONVERT : return com.jogamp.newt.event.KeyEvent.VK_CONVERT; + case java.awt.event.KeyEvent.VK_NONCONVERT : return com.jogamp.newt.event.KeyEvent.VK_NONCONVERT; + case java.awt.event.KeyEvent.VK_ACCEPT : return com.jogamp.newt.event.KeyEvent.VK_ACCEPT; + case java.awt.event.KeyEvent.VK_MODECHANGE : return com.jogamp.newt.event.KeyEvent.VK_MODECHANGE; + case java.awt.event.KeyEvent.VK_SPACE : return com.jogamp.newt.event.KeyEvent.VK_SPACE; + case java.awt.event.KeyEvent.VK_EXCLAMATION_MARK: return com.jogamp.newt.event.KeyEvent.VK_EXCLAMATION_MARK; + case java.awt.event.KeyEvent.VK_QUOTEDBL : return com.jogamp.newt.event.KeyEvent.VK_QUOTEDBL; + case java.awt.event.KeyEvent.VK_NUMBER_SIGN : return com.jogamp.newt.event.KeyEvent.VK_NUMBER_SIGN; + case java.awt.event.KeyEvent.VK_DOLLAR : return com.jogamp.newt.event.KeyEvent.VK_DOLLAR; + // case 0x25 : return com.jogamp.newt.event.KeyEvent.VK_PERCENT; + case java.awt.event.KeyEvent.VK_AMPERSAND : return com.jogamp.newt.event.KeyEvent.VK_AMPERSAND; + case java.awt.event.KeyEvent.VK_QUOTE : return com.jogamp.newt.event.KeyEvent.VK_QUOTE; + case java.awt.event.KeyEvent.VK_LEFT_PARENTHESIS : return com.jogamp.newt.event.KeyEvent.VK_LEFT_PARENTHESIS; + case java.awt.event.KeyEvent.VK_RIGHT_PARENTHESIS: return com.jogamp.newt.event.KeyEvent.VK_RIGHT_PARENTHESIS; + case java.awt.event.KeyEvent.VK_ASTERISK : return com.jogamp.newt.event.KeyEvent.VK_ASTERISK; + case java.awt.event.KeyEvent.VK_PLUS : return com.jogamp.newt.event.KeyEvent.VK_PLUS; + case java.awt.event.KeyEvent.VK_COMMA : return com.jogamp.newt.event.KeyEvent.VK_COMMA; + case java.awt.event.KeyEvent.VK_MINUS : return com.jogamp.newt.event.KeyEvent.VK_MINUS; + case java.awt.event.KeyEvent.VK_PERIOD : return com.jogamp.newt.event.KeyEvent.VK_PERIOD; + case java.awt.event.KeyEvent.VK_SLASH : return com.jogamp.newt.event.KeyEvent.VK_SLASH; + case java.awt.event.KeyEvent.VK_0 : return com.jogamp.newt.event.KeyEvent.VK_0; + case java.awt.event.KeyEvent.VK_1 : return com.jogamp.newt.event.KeyEvent.VK_1; + case java.awt.event.KeyEvent.VK_2 : return com.jogamp.newt.event.KeyEvent.VK_2; + case java.awt.event.KeyEvent.VK_3 : return com.jogamp.newt.event.KeyEvent.VK_3; + case java.awt.event.KeyEvent.VK_4 : return com.jogamp.newt.event.KeyEvent.VK_4; + case java.awt.event.KeyEvent.VK_5 : return com.jogamp.newt.event.KeyEvent.VK_5; + case java.awt.event.KeyEvent.VK_6 : return com.jogamp.newt.event.KeyEvent.VK_6; + case java.awt.event.KeyEvent.VK_7 : return com.jogamp.newt.event.KeyEvent.VK_7; + case java.awt.event.KeyEvent.VK_8 : return com.jogamp.newt.event.KeyEvent.VK_8; + case java.awt.event.KeyEvent.VK_9 : return com.jogamp.newt.event.KeyEvent.VK_9; + case java.awt.event.KeyEvent.VK_COLON : return com.jogamp.newt.event.KeyEvent.VK_COLON; + case java.awt.event.KeyEvent.VK_SEMICOLON : return com.jogamp.newt.event.KeyEvent.VK_SEMICOLON; + case java.awt.event.KeyEvent.VK_LESS : return com.jogamp.newt.event.KeyEvent.VK_LESS; + case java.awt.event.KeyEvent.VK_EQUALS : return com.jogamp.newt.event.KeyEvent.VK_EQUALS; + case java.awt.event.KeyEvent.VK_GREATER : return com.jogamp.newt.event.KeyEvent.VK_GREATER; + case 0x3f : return com.jogamp.newt.event.KeyEvent.VK_QUESTIONMARK; + case java.awt.event.KeyEvent.VK_AT : return com.jogamp.newt.event.KeyEvent.VK_AT; + case java.awt.event.KeyEvent.VK_A : return com.jogamp.newt.event.KeyEvent.VK_A; + case java.awt.event.KeyEvent.VK_B : return com.jogamp.newt.event.KeyEvent.VK_B; + case java.awt.event.KeyEvent.VK_C : return com.jogamp.newt.event.KeyEvent.VK_C; + case java.awt.event.KeyEvent.VK_D : return com.jogamp.newt.event.KeyEvent.VK_D; + case java.awt.event.KeyEvent.VK_E : return com.jogamp.newt.event.KeyEvent.VK_E; + case java.awt.event.KeyEvent.VK_F : return com.jogamp.newt.event.KeyEvent.VK_F; + case java.awt.event.KeyEvent.VK_G : return com.jogamp.newt.event.KeyEvent.VK_G; + case java.awt.event.KeyEvent.VK_H : return com.jogamp.newt.event.KeyEvent.VK_H; + case java.awt.event.KeyEvent.VK_I : return com.jogamp.newt.event.KeyEvent.VK_I; + case java.awt.event.KeyEvent.VK_J : return com.jogamp.newt.event.KeyEvent.VK_J; + case java.awt.event.KeyEvent.VK_K : return com.jogamp.newt.event.KeyEvent.VK_K; + case java.awt.event.KeyEvent.VK_L : return com.jogamp.newt.event.KeyEvent.VK_L; + case java.awt.event.KeyEvent.VK_M : return com.jogamp.newt.event.KeyEvent.VK_M; + case java.awt.event.KeyEvent.VK_N : return com.jogamp.newt.event.KeyEvent.VK_N; + case java.awt.event.KeyEvent.VK_O : return com.jogamp.newt.event.KeyEvent.VK_O; + case java.awt.event.KeyEvent.VK_P : return com.jogamp.newt.event.KeyEvent.VK_P; + case java.awt.event.KeyEvent.VK_Q : return com.jogamp.newt.event.KeyEvent.VK_Q; + case java.awt.event.KeyEvent.VK_R : return com.jogamp.newt.event.KeyEvent.VK_R; + case java.awt.event.KeyEvent.VK_S : return com.jogamp.newt.event.KeyEvent.VK_S; + case java.awt.event.KeyEvent.VK_T : return com.jogamp.newt.event.KeyEvent.VK_T; + case java.awt.event.KeyEvent.VK_U : return com.jogamp.newt.event.KeyEvent.VK_U; + case java.awt.event.KeyEvent.VK_V : return com.jogamp.newt.event.KeyEvent.VK_V; + case java.awt.event.KeyEvent.VK_W : return com.jogamp.newt.event.KeyEvent.VK_W; + case java.awt.event.KeyEvent.VK_X : return com.jogamp.newt.event.KeyEvent.VK_X; + case java.awt.event.KeyEvent.VK_Y : return com.jogamp.newt.event.KeyEvent.VK_Y; + case java.awt.event.KeyEvent.VK_Z : return com.jogamp.newt.event.KeyEvent.VK_Z; + case java.awt.event.KeyEvent.VK_OPEN_BRACKET : return com.jogamp.newt.event.KeyEvent.VK_OPEN_BRACKET; + case java.awt.event.KeyEvent.VK_BACK_SLASH : return com.jogamp.newt.event.KeyEvent.VK_BACK_SLASH; + case java.awt.event.KeyEvent.VK_CLOSE_BRACKET : return com.jogamp.newt.event.KeyEvent.VK_CLOSE_BRACKET; + case java.awt.event.KeyEvent.VK_CIRCUMFLEX : return com.jogamp.newt.event.KeyEvent.VK_CIRCUMFLEX; + case java.awt.event.KeyEvent.VK_UNDERSCORE : return com.jogamp.newt.event.KeyEvent.VK_UNDERSCORE; + case java.awt.event.KeyEvent.VK_BACK_QUOTE : return com.jogamp.newt.event.KeyEvent.VK_BACK_QUOTE; + case java.awt.event.KeyEvent.VK_F1 : return com.jogamp.newt.event.KeyEvent.VK_F1; + case java.awt.event.KeyEvent.VK_F2 : return com.jogamp.newt.event.KeyEvent.VK_F2; + case java.awt.event.KeyEvent.VK_F3 : return com.jogamp.newt.event.KeyEvent.VK_F3; + case java.awt.event.KeyEvent.VK_F4 : return com.jogamp.newt.event.KeyEvent.VK_F4; + case java.awt.event.KeyEvent.VK_F5 : return com.jogamp.newt.event.KeyEvent.VK_F5; + case java.awt.event.KeyEvent.VK_F6 : return com.jogamp.newt.event.KeyEvent.VK_F6; + case java.awt.event.KeyEvent.VK_F7 : return com.jogamp.newt.event.KeyEvent.VK_F7; + case java.awt.event.KeyEvent.VK_F8 : return com.jogamp.newt.event.KeyEvent.VK_F8; + case java.awt.event.KeyEvent.VK_F9 : return com.jogamp.newt.event.KeyEvent.VK_F9; + case java.awt.event.KeyEvent.VK_F10 : return com.jogamp.newt.event.KeyEvent.VK_F10; + case java.awt.event.KeyEvent.VK_F11 : return com.jogamp.newt.event.KeyEvent.VK_F11; + case java.awt.event.KeyEvent.VK_F12 : return com.jogamp.newt.event.KeyEvent.VK_F12; + case java.awt.event.KeyEvent.VK_F13 : return com.jogamp.newt.event.KeyEvent.VK_F13; + case java.awt.event.KeyEvent.VK_F14 : return com.jogamp.newt.event.KeyEvent.VK_F14; + case java.awt.event.KeyEvent.VK_F15 : return com.jogamp.newt.event.KeyEvent.VK_F15; + case java.awt.event.KeyEvent.VK_F16 : return com.jogamp.newt.event.KeyEvent.VK_F16; + case java.awt.event.KeyEvent.VK_F17 : return com.jogamp.newt.event.KeyEvent.VK_F17; + case java.awt.event.KeyEvent.VK_F18 : return com.jogamp.newt.event.KeyEvent.VK_F18; + case java.awt.event.KeyEvent.VK_F19 : return com.jogamp.newt.event.KeyEvent.VK_F19; + case java.awt.event.KeyEvent.VK_F20 : return com.jogamp.newt.event.KeyEvent.VK_F20; + case java.awt.event.KeyEvent.VK_F21 : return com.jogamp.newt.event.KeyEvent.VK_F21; + case java.awt.event.KeyEvent.VK_F22 : return com.jogamp.newt.event.KeyEvent.VK_F22; + case java.awt.event.KeyEvent.VK_F23 : return com.jogamp.newt.event.KeyEvent.VK_F23; + case java.awt.event.KeyEvent.VK_F24 : return com.jogamp.newt.event.KeyEvent.VK_F24; + case java.awt.event.KeyEvent.VK_BRACELEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT_BRACE; + case 0x7c : return com.jogamp.newt.event.KeyEvent.VK_PIPE; + case java.awt.event.KeyEvent.VK_BRACERIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT_BRACE; + case java.awt.event.KeyEvent.VK_DEAD_TILDE : return com.jogamp.newt.event.KeyEvent.VK_TILDE; + case java.awt.event.KeyEvent.VK_DELETE : return com.jogamp.newt.event.KeyEvent.VK_DELETE; + case java.awt.event.KeyEvent.VK_NUMPAD0 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0; + case java.awt.event.KeyEvent.VK_NUMPAD1 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD1; + case java.awt.event.KeyEvent.VK_NUMPAD2 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD2; + case java.awt.event.KeyEvent.VK_NUMPAD3 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD3; + case java.awt.event.KeyEvent.VK_NUMPAD4 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD4; + case java.awt.event.KeyEvent.VK_NUMPAD5 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD5; + case java.awt.event.KeyEvent.VK_NUMPAD6 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD6; + case java.awt.event.KeyEvent.VK_NUMPAD7 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD7; + case java.awt.event.KeyEvent.VK_NUMPAD8 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD8; + case java.awt.event.KeyEvent.VK_NUMPAD9 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD9; + case java.awt.event.KeyEvent.VK_DECIMAL : return com.jogamp.newt.event.KeyEvent.VK_DECIMAL; + case java.awt.event.KeyEvent.VK_SEPARATOR : return com.jogamp.newt.event.KeyEvent.VK_SEPARATOR; + case java.awt.event.KeyEvent.VK_ADD : return com.jogamp.newt.event.KeyEvent.VK_ADD; + case java.awt.event.KeyEvent.VK_SUBTRACT : return com.jogamp.newt.event.KeyEvent.VK_SUBTRACT; + case java.awt.event.KeyEvent.VK_MULTIPLY : return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; + case java.awt.event.KeyEvent.VK_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; + case java.awt.event.KeyEvent.VK_NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; + case java.awt.event.KeyEvent.VK_KP_LEFT : return com.jogamp.newt.event.KeyEvent.VK_KP_LEFT; + case java.awt.event.KeyEvent.VK_KP_UP : return com.jogamp.newt.event.KeyEvent.VK_KP_UP; + case java.awt.event.KeyEvent.VK_KP_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT; + case java.awt.event.KeyEvent.VK_KP_DOWN : return com.jogamp.newt.event.KeyEvent.VK_KP_DOWN; + case java.awt.event.KeyEvent.VK_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; + case java.awt.event.KeyEvent.VK_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; + case java.awt.event.KeyEvent.VK_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT; + case java.awt.event.KeyEvent.VK_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; + case java.awt.event.KeyEvent.VK_CONTEXT_MENU : return com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU; + case java.awt.event.KeyEvent.VK_WINDOWS : return com.jogamp.newt.event.KeyEvent.VK_WINDOWS; + case java.awt.event.KeyEvent.VK_META : return com.jogamp.newt.event.KeyEvent.VK_META; + case java.awt.event.KeyEvent.VK_HELP : return com.jogamp.newt.event.KeyEvent.VK_HELP; + case java.awt.event.KeyEvent.VK_COMPOSE : return com.jogamp.newt.event.KeyEvent.VK_COMPOSE; + case java.awt.event.KeyEvent.VK_BEGIN : return com.jogamp.newt.event.KeyEvent.VK_BEGIN; + case java.awt.event.KeyEvent.VK_STOP : return com.jogamp.newt.event.KeyEvent.VK_STOP; + case java.awt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return com.jogamp.newt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK; + case java.awt.event.KeyEvent.VK_EURO_SIGN : return com.jogamp.newt.event.KeyEvent.VK_EURO_SIGN; + case java.awt.event.KeyEvent.VK_CUT : return com.jogamp.newt.event.KeyEvent.VK_CUT; + case java.awt.event.KeyEvent.VK_COPY : return com.jogamp.newt.event.KeyEvent.VK_COPY; + case java.awt.event.KeyEvent.VK_PASTE : return com.jogamp.newt.event.KeyEvent.VK_PASTE; + case java.awt.event.KeyEvent.VK_UNDO : return com.jogamp.newt.event.KeyEvent.VK_UNDO; + case java.awt.event.KeyEvent.VK_AGAIN : return com.jogamp.newt.event.KeyEvent.VK_AGAIN; + case java.awt.event.KeyEvent.VK_FIND : return com.jogamp.newt.event.KeyEvent.VK_FIND; + case java.awt.event.KeyEvent.VK_PROPS : return com.jogamp.newt.event.KeyEvent.VK_PROPS; + case java.awt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF: return com.jogamp.newt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF; + case java.awt.event.KeyEvent.VK_CODE_INPUT : return com.jogamp.newt.event.KeyEvent.VK_CODE_INPUT; + case java.awt.event.KeyEvent.VK_ROMAN_CHARACTERS: return com.jogamp.newt.event.KeyEvent.VK_ROMAN_CHARACTERS; + case java.awt.event.KeyEvent.VK_ALL_CANDIDATES: return com.jogamp.newt.event.KeyEvent.VK_ALL_CANDIDATES; + case java.awt.event.KeyEvent.VK_PREVIOUS_CANDIDATE: return com.jogamp.newt.event.KeyEvent.VK_PREVIOUS_CANDIDATE; + case java.awt.event.KeyEvent.VK_ALPHANUMERIC : return com.jogamp.newt.event.KeyEvent.VK_ALPHANUMERIC; + case java.awt.event.KeyEvent.VK_KATAKANA : return com.jogamp.newt.event.KeyEvent.VK_KATAKANA; + case java.awt.event.KeyEvent.VK_HIRAGANA : return com.jogamp.newt.event.KeyEvent.VK_HIRAGANA; + case java.awt.event.KeyEvent.VK_FULL_WIDTH : return com.jogamp.newt.event.KeyEvent.VK_FULL_WIDTH; + case java.awt.event.KeyEvent.VK_HALF_WIDTH : return com.jogamp.newt.event.KeyEvent.VK_HALF_WIDTH; + case java.awt.event.KeyEvent.VK_JAPANESE_KATAKANA: return com.jogamp.newt.event.KeyEvent.VK_JAPANESE_KATAKANA; + case java.awt.event.KeyEvent.VK_JAPANESE_HIRAGANA: return com.jogamp.newt.event.KeyEvent.VK_JAPANESE_HIRAGANA; + case java.awt.event.KeyEvent.VK_JAPANESE_ROMAN: return com.jogamp.newt.event.KeyEvent.VK_JAPANESE_ROMAN; + case java.awt.event.KeyEvent.VK_KANA_LOCK : return com.jogamp.newt.event.KeyEvent.VK_KANA_LOCK; + } + return defNEWTKeyCode; + } + + public static int newtKeyCode2AWTKeyCode(final short newtKeyCode) { + final int defAwtKeyCode = 0xFFFF & (int)newtKeyCode; + switch (newtKeyCode) { + case com.jogamp.newt.event.KeyEvent.VK_HOME : return java.awt.event.KeyEvent.VK_HOME; + case com.jogamp.newt.event.KeyEvent.VK_END : return java.awt.event.KeyEvent.VK_END; + case com.jogamp.newt.event.KeyEvent.VK_FINAL : return java.awt.event.KeyEvent.VK_FINAL; + case com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN : return java.awt.event.KeyEvent.VK_PRINTSCREEN; + case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE : return java.awt.event.KeyEvent.VK_BACK_SPACE; + case com.jogamp.newt.event.KeyEvent.VK_TAB : return java.awt.event.KeyEvent.VK_TAB; + case com.jogamp.newt.event.KeyEvent.VK_ENTER : return java.awt.event.KeyEvent.VK_ENTER; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN : return java.awt.event.KeyEvent.VK_PAGE_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_CLEAR : return java.awt.event.KeyEvent.VK_CLEAR; + case com.jogamp.newt.event.KeyEvent.VK_SHIFT : return java.awt.event.KeyEvent.VK_SHIFT; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_UP : return java.awt.event.KeyEvent.VK_PAGE_UP; + case com.jogamp.newt.event.KeyEvent.VK_CONTROL : return java.awt.event.KeyEvent.VK_CONTROL; + case com.jogamp.newt.event.KeyEvent.VK_ALT : return java.awt.event.KeyEvent.VK_ALT; + // FIXME: On X11 it results to 0xff7e w/ AWTRobot, which is wrong. 0xffea Alt_R is expected AFAIK. + case com.jogamp.newt.event.KeyEvent.VK_ALT_GRAPH : return java.awt.event.KeyEvent.VK_ALT_GRAPH; + case com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK : return java.awt.event.KeyEvent.VK_CAPS_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_PAUSE : return java.awt.event.KeyEvent.VK_PAUSE; + case com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK : return java.awt.event.KeyEvent.VK_SCROLL_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_CANCEL : return java.awt.event.KeyEvent.VK_CANCEL; + case com.jogamp.newt.event.KeyEvent.VK_INSERT : return java.awt.event.KeyEvent.VK_INSERT; + case com.jogamp.newt.event.KeyEvent.VK_ESCAPE : return java.awt.event.KeyEvent.VK_ESCAPE; + case com.jogamp.newt.event.KeyEvent.VK_CONVERT : return java.awt.event.KeyEvent.VK_CONVERT; + case com.jogamp.newt.event.KeyEvent.VK_NONCONVERT : return java.awt.event.KeyEvent.VK_NONCONVERT; + case com.jogamp.newt.event.KeyEvent.VK_ACCEPT : return java.awt.event.KeyEvent.VK_ACCEPT; + case com.jogamp.newt.event.KeyEvent.VK_MODECHANGE : return java.awt.event.KeyEvent.VK_MODECHANGE; + case com.jogamp.newt.event.KeyEvent.VK_SPACE : return java.awt.event.KeyEvent.VK_SPACE; + case com.jogamp.newt.event.KeyEvent.VK_EXCLAMATION_MARK: return java.awt.event.KeyEvent.VK_EXCLAMATION_MARK; + case com.jogamp.newt.event.KeyEvent.VK_QUOTEDBL : return java.awt.event.KeyEvent.VK_QUOTEDBL; + case com.jogamp.newt.event.KeyEvent.VK_NUMBER_SIGN : return java.awt.event.KeyEvent.VK_NUMBER_SIGN; + case com.jogamp.newt.event.KeyEvent.VK_DOLLAR : return java.awt.event.KeyEvent.VK_DOLLAR; + case com.jogamp.newt.event.KeyEvent.VK_PERCENT : return defAwtKeyCode; + case com.jogamp.newt.event.KeyEvent.VK_AMPERSAND : return java.awt.event.KeyEvent.VK_AMPERSAND; + case com.jogamp.newt.event.KeyEvent.VK_QUOTE : return java.awt.event.KeyEvent.VK_QUOTE; + case com.jogamp.newt.event.KeyEvent.VK_LEFT_PARENTHESIS : return java.awt.event.KeyEvent.VK_LEFT_PARENTHESIS; + case com.jogamp.newt.event.KeyEvent.VK_RIGHT_PARENTHESIS: return java.awt.event.KeyEvent.VK_RIGHT_PARENTHESIS; + case com.jogamp.newt.event.KeyEvent.VK_ASTERISK : return java.awt.event.KeyEvent.VK_ASTERISK; + case com.jogamp.newt.event.KeyEvent.VK_PLUS : return java.awt.event.KeyEvent.VK_PLUS; + case com.jogamp.newt.event.KeyEvent.VK_COMMA : return java.awt.event.KeyEvent.VK_COMMA; + case com.jogamp.newt.event.KeyEvent.VK_MINUS : return java.awt.event.KeyEvent.VK_MINUS; + case com.jogamp.newt.event.KeyEvent.VK_PERIOD : return java.awt.event.KeyEvent.VK_PERIOD; + case com.jogamp.newt.event.KeyEvent.VK_SLASH : return java.awt.event.KeyEvent.VK_SLASH; + case com.jogamp.newt.event.KeyEvent.VK_0 : return java.awt.event.KeyEvent.VK_0; + case com.jogamp.newt.event.KeyEvent.VK_1 : return java.awt.event.KeyEvent.VK_1; + case com.jogamp.newt.event.KeyEvent.VK_2 : return java.awt.event.KeyEvent.VK_2; + case com.jogamp.newt.event.KeyEvent.VK_3 : return java.awt.event.KeyEvent.VK_3; + case com.jogamp.newt.event.KeyEvent.VK_4 : return java.awt.event.KeyEvent.VK_4; + case com.jogamp.newt.event.KeyEvent.VK_5 : return java.awt.event.KeyEvent.VK_5; + case com.jogamp.newt.event.KeyEvent.VK_6 : return java.awt.event.KeyEvent.VK_6; + case com.jogamp.newt.event.KeyEvent.VK_7 : return java.awt.event.KeyEvent.VK_7; + case com.jogamp.newt.event.KeyEvent.VK_8 : return java.awt.event.KeyEvent.VK_8; + case com.jogamp.newt.event.KeyEvent.VK_9 : return java.awt.event.KeyEvent.VK_9; + case com.jogamp.newt.event.KeyEvent.VK_COLON : return java.awt.event.KeyEvent.VK_COLON; + case com.jogamp.newt.event.KeyEvent.VK_SEMICOLON : return java.awt.event.KeyEvent.VK_SEMICOLON; + case com.jogamp.newt.event.KeyEvent.VK_LESS : return java.awt.event.KeyEvent.VK_LESS; + case com.jogamp.newt.event.KeyEvent.VK_EQUALS : return java.awt.event.KeyEvent.VK_EQUALS; + case com.jogamp.newt.event.KeyEvent.VK_GREATER : return java.awt.event.KeyEvent.VK_GREATER; + case com.jogamp.newt.event.KeyEvent.VK_QUESTIONMARK : return defAwtKeyCode; + case com.jogamp.newt.event.KeyEvent.VK_AT : return java.awt.event.KeyEvent.VK_AT; + case com.jogamp.newt.event.KeyEvent.VK_A : return java.awt.event.KeyEvent.VK_A; + case com.jogamp.newt.event.KeyEvent.VK_B : return java.awt.event.KeyEvent.VK_B; + case com.jogamp.newt.event.KeyEvent.VK_C : return java.awt.event.KeyEvent.VK_C; + case com.jogamp.newt.event.KeyEvent.VK_D : return java.awt.event.KeyEvent.VK_D; + case com.jogamp.newt.event.KeyEvent.VK_E : return java.awt.event.KeyEvent.VK_E; + case com.jogamp.newt.event.KeyEvent.VK_F : return java.awt.event.KeyEvent.VK_F; + case com.jogamp.newt.event.KeyEvent.VK_G : return java.awt.event.KeyEvent.VK_G; + case com.jogamp.newt.event.KeyEvent.VK_H : return java.awt.event.KeyEvent.VK_H; + case com.jogamp.newt.event.KeyEvent.VK_I : return java.awt.event.KeyEvent.VK_I; + case com.jogamp.newt.event.KeyEvent.VK_J : return java.awt.event.KeyEvent.VK_J; + case com.jogamp.newt.event.KeyEvent.VK_K : return java.awt.event.KeyEvent.VK_K; + case com.jogamp.newt.event.KeyEvent.VK_L : return java.awt.event.KeyEvent.VK_L; + case com.jogamp.newt.event.KeyEvent.VK_M : return java.awt.event.KeyEvent.VK_M; + case com.jogamp.newt.event.KeyEvent.VK_N : return java.awt.event.KeyEvent.VK_N; + case com.jogamp.newt.event.KeyEvent.VK_O : return java.awt.event.KeyEvent.VK_O; + case com.jogamp.newt.event.KeyEvent.VK_P : return java.awt.event.KeyEvent.VK_P; + case com.jogamp.newt.event.KeyEvent.VK_Q : return java.awt.event.KeyEvent.VK_Q; + case com.jogamp.newt.event.KeyEvent.VK_R : return java.awt.event.KeyEvent.VK_R; + case com.jogamp.newt.event.KeyEvent.VK_S : return java.awt.event.KeyEvent.VK_S; + case com.jogamp.newt.event.KeyEvent.VK_T : return java.awt.event.KeyEvent.VK_T; + case com.jogamp.newt.event.KeyEvent.VK_U : return java.awt.event.KeyEvent.VK_U; + case com.jogamp.newt.event.KeyEvent.VK_V : return java.awt.event.KeyEvent.VK_V; + case com.jogamp.newt.event.KeyEvent.VK_W : return java.awt.event.KeyEvent.VK_W; + case com.jogamp.newt.event.KeyEvent.VK_X : return java.awt.event.KeyEvent.VK_X; + case com.jogamp.newt.event.KeyEvent.VK_Y : return java.awt.event.KeyEvent.VK_Y; + case com.jogamp.newt.event.KeyEvent.VK_Z : return java.awt.event.KeyEvent.VK_Z; + case com.jogamp.newt.event.KeyEvent.VK_OPEN_BRACKET : return java.awt.event.KeyEvent.VK_OPEN_BRACKET; + case com.jogamp.newt.event.KeyEvent.VK_BACK_SLASH : return java.awt.event.KeyEvent.VK_BACK_SLASH; + case com.jogamp.newt.event.KeyEvent.VK_CLOSE_BRACKET : return java.awt.event.KeyEvent.VK_CLOSE_BRACKET; + case com.jogamp.newt.event.KeyEvent.VK_CIRCUMFLEX : return java.awt.event.KeyEvent.VK_CIRCUMFLEX; + case com.jogamp.newt.event.KeyEvent.VK_UNDERSCORE : return java.awt.event.KeyEvent.VK_UNDERSCORE; + case com.jogamp.newt.event.KeyEvent.VK_BACK_QUOTE : return java.awt.event.KeyEvent.VK_BACK_QUOTE; + case com.jogamp.newt.event.KeyEvent.VK_F1 : return java.awt.event.KeyEvent.VK_F1; + case com.jogamp.newt.event.KeyEvent.VK_F2 : return java.awt.event.KeyEvent.VK_F2; + case com.jogamp.newt.event.KeyEvent.VK_F3 : return java.awt.event.KeyEvent.VK_F3; + case com.jogamp.newt.event.KeyEvent.VK_F4 : return java.awt.event.KeyEvent.VK_F4; + case com.jogamp.newt.event.KeyEvent.VK_F5 : return java.awt.event.KeyEvent.VK_F5; + case com.jogamp.newt.event.KeyEvent.VK_F6 : return java.awt.event.KeyEvent.VK_F6; + case com.jogamp.newt.event.KeyEvent.VK_F7 : return java.awt.event.KeyEvent.VK_F7; + case com.jogamp.newt.event.KeyEvent.VK_F8 : return java.awt.event.KeyEvent.VK_F8; + case com.jogamp.newt.event.KeyEvent.VK_F9 : return java.awt.event.KeyEvent.VK_F9; + case com.jogamp.newt.event.KeyEvent.VK_F10 : return java.awt.event.KeyEvent.VK_F10; + case com.jogamp.newt.event.KeyEvent.VK_F11 : return java.awt.event.KeyEvent.VK_F11; + case com.jogamp.newt.event.KeyEvent.VK_F12 : return java.awt.event.KeyEvent.VK_F12; + case com.jogamp.newt.event.KeyEvent.VK_F13 : return java.awt.event.KeyEvent.VK_F13; + case com.jogamp.newt.event.KeyEvent.VK_F14 : return java.awt.event.KeyEvent.VK_F14; + case com.jogamp.newt.event.KeyEvent.VK_F15 : return java.awt.event.KeyEvent.VK_F15; + case com.jogamp.newt.event.KeyEvent.VK_F16 : return java.awt.event.KeyEvent.VK_F16; + case com.jogamp.newt.event.KeyEvent.VK_F17 : return java.awt.event.KeyEvent.VK_F17; + case com.jogamp.newt.event.KeyEvent.VK_F18 : return java.awt.event.KeyEvent.VK_F18; + case com.jogamp.newt.event.KeyEvent.VK_F19 : return java.awt.event.KeyEvent.VK_F19; + case com.jogamp.newt.event.KeyEvent.VK_F20 : return java.awt.event.KeyEvent.VK_F20; + case com.jogamp.newt.event.KeyEvent.VK_F21 : return java.awt.event.KeyEvent.VK_F21; + case com.jogamp.newt.event.KeyEvent.VK_F22 : return java.awt.event.KeyEvent.VK_F22; + case com.jogamp.newt.event.KeyEvent.VK_F23 : return java.awt.event.KeyEvent.VK_F23; + case com.jogamp.newt.event.KeyEvent.VK_F24 : return java.awt.event.KeyEvent.VK_F24; + case com.jogamp.newt.event.KeyEvent.VK_LEFT_BRACE : return java.awt.event.KeyEvent.VK_BRACELEFT; + case com.jogamp.newt.event.KeyEvent.VK_PIPE : return defAwtKeyCode; + case com.jogamp.newt.event.KeyEvent.VK_RIGHT_BRACE : return java.awt.event.KeyEvent.VK_BRACERIGHT; + case com.jogamp.newt.event.KeyEvent.VK_TILDE : return java.awt.event.KeyEvent.VK_DEAD_TILDE; + case com.jogamp.newt.event.KeyEvent.VK_DELETE : return java.awt.event.KeyEvent.VK_DELETE; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 : return java.awt.event.KeyEvent.VK_NUMPAD0; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD1 : return java.awt.event.KeyEvent.VK_NUMPAD1; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD2 : return java.awt.event.KeyEvent.VK_NUMPAD2; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD3 : return java.awt.event.KeyEvent.VK_NUMPAD3; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD4 : return java.awt.event.KeyEvent.VK_NUMPAD4; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD5 : return java.awt.event.KeyEvent.VK_NUMPAD5; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD6 : return java.awt.event.KeyEvent.VK_NUMPAD6; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD7 : return java.awt.event.KeyEvent.VK_NUMPAD7; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD8 : return java.awt.event.KeyEvent.VK_NUMPAD8; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD9 : return java.awt.event.KeyEvent.VK_NUMPAD9; + case com.jogamp.newt.event.KeyEvent.VK_DECIMAL : return java.awt.event.KeyEvent.VK_DECIMAL; + case com.jogamp.newt.event.KeyEvent.VK_SEPARATOR : return java.awt.event.KeyEvent.VK_SEPARATOR; + case com.jogamp.newt.event.KeyEvent.VK_ADD : return java.awt.event.KeyEvent.VK_ADD; + case com.jogamp.newt.event.KeyEvent.VK_SUBTRACT : return java.awt.event.KeyEvent.VK_SUBTRACT; + case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return java.awt.event.KeyEvent.VK_MULTIPLY; + case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return java.awt.event.KeyEvent.VK_DIVIDE; + case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return java.awt.event.KeyEvent.VK_NUM_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : return java.awt.event.KeyEvent.VK_KP_LEFT; + case com.jogamp.newt.event.KeyEvent.VK_KP_UP : return java.awt.event.KeyEvent.VK_KP_UP; + case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : return java.awt.event.KeyEvent.VK_KP_RIGHT; + case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : return java.awt.event.KeyEvent.VK_KP_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_LEFT : return java.awt.event.KeyEvent.VK_LEFT; + case com.jogamp.newt.event.KeyEvent.VK_UP : return java.awt.event.KeyEvent.VK_UP; + case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return java.awt.event.KeyEvent.VK_RIGHT; + case com.jogamp.newt.event.KeyEvent.VK_DOWN : return java.awt.event.KeyEvent.VK_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU : return java.awt.event.KeyEvent.VK_CONTEXT_MENU; + case com.jogamp.newt.event.KeyEvent.VK_WINDOWS : return java.awt.event.KeyEvent.VK_WINDOWS; + case com.jogamp.newt.event.KeyEvent.VK_META : return java.awt.event.KeyEvent.VK_META; + case com.jogamp.newt.event.KeyEvent.VK_HELP : return java.awt.event.KeyEvent.VK_HELP; + case com.jogamp.newt.event.KeyEvent.VK_COMPOSE : return java.awt.event.KeyEvent.VK_COMPOSE; + case com.jogamp.newt.event.KeyEvent.VK_BEGIN : return java.awt.event.KeyEvent.VK_BEGIN; + case com.jogamp.newt.event.KeyEvent.VK_STOP : return java.awt.event.KeyEvent.VK_STOP; + case com.jogamp.newt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return java.awt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK; + case com.jogamp.newt.event.KeyEvent.VK_EURO_SIGN : return java.awt.event.KeyEvent.VK_EURO_SIGN; + case com.jogamp.newt.event.KeyEvent.VK_CUT : return java.awt.event.KeyEvent.VK_CUT; + case com.jogamp.newt.event.KeyEvent.VK_COPY : return java.awt.event.KeyEvent.VK_COPY; + case com.jogamp.newt.event.KeyEvent.VK_PASTE : return java.awt.event.KeyEvent.VK_PASTE; + case com.jogamp.newt.event.KeyEvent.VK_UNDO : return java.awt.event.KeyEvent.VK_UNDO; + case com.jogamp.newt.event.KeyEvent.VK_AGAIN : return java.awt.event.KeyEvent.VK_AGAIN; + case com.jogamp.newt.event.KeyEvent.VK_FIND : return java.awt.event.KeyEvent.VK_FIND; + case com.jogamp.newt.event.KeyEvent.VK_PROPS : return java.awt.event.KeyEvent.VK_PROPS; + case com.jogamp.newt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF: return java.awt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF; + case com.jogamp.newt.event.KeyEvent.VK_CODE_INPUT : return java.awt.event.KeyEvent.VK_CODE_INPUT; + case com.jogamp.newt.event.KeyEvent.VK_ROMAN_CHARACTERS: return java.awt.event.KeyEvent.VK_ROMAN_CHARACTERS; + case com.jogamp.newt.event.KeyEvent.VK_ALL_CANDIDATES: return java.awt.event.KeyEvent.VK_ALL_CANDIDATES; + case com.jogamp.newt.event.KeyEvent.VK_PREVIOUS_CANDIDATE: return java.awt.event.KeyEvent.VK_PREVIOUS_CANDIDATE; + case com.jogamp.newt.event.KeyEvent.VK_ALPHANUMERIC : return java.awt.event.KeyEvent.VK_ALPHANUMERIC; + case com.jogamp.newt.event.KeyEvent.VK_KATAKANA : return java.awt.event.KeyEvent.VK_KATAKANA; + case com.jogamp.newt.event.KeyEvent.VK_HIRAGANA : return java.awt.event.KeyEvent.VK_HIRAGANA; + case com.jogamp.newt.event.KeyEvent.VK_FULL_WIDTH : return java.awt.event.KeyEvent.VK_FULL_WIDTH; + case com.jogamp.newt.event.KeyEvent.VK_HALF_WIDTH : return java.awt.event.KeyEvent.VK_HALF_WIDTH; + case com.jogamp.newt.event.KeyEvent.VK_JAPANESE_KATAKANA: return java.awt.event.KeyEvent.VK_JAPANESE_KATAKANA; + case com.jogamp.newt.event.KeyEvent.VK_JAPANESE_HIRAGANA: return java.awt.event.KeyEvent.VK_JAPANESE_HIRAGANA; + case com.jogamp.newt.event.KeyEvent.VK_JAPANESE_ROMAN: return java.awt.event.KeyEvent.VK_JAPANESE_ROMAN; + case com.jogamp.newt.event.KeyEvent.VK_KANA_LOCK : return java.awt.event.KeyEvent.VK_KANA_LOCK; } + return defAwtKeyCode; } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { @@ -289,11 +650,11 @@ public class AWTNewtEventFactory { public static final com.jogamp.newt.event.KeyEvent createKeyEvent(short newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { if( (short)0 != newtType ) { - final short keyCode = (short)event.getKeyCode(); - return new com.jogamp.newt.event.KeyEvent( + final short newtKeyCode = awtKeyCode2NewtKeyCode( event.getKeyCode() ); + return com.jogamp.newt.event.KeyEvent.create( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), - keyCode, keyCode, event.getKeyChar()); + newtKeyCode, newtKeyCode, event.getKeyChar()); } return null; // no mapping .. } 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 9638e6a7c..364a348ee 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -216,7 +216,7 @@ public class AndroidNewtEventFactory { final long unixTime = System.currentTimeMillis() + ( aEvent.getEventTime() - android.os.SystemClock.uptimeMillis() ); final int newtMods = aKeyModifiers2Newt(aEvent.getMetaState()); - return new com.jogamp.newt.event.KeyEvent( + return com.jogamp.newt.event.KeyEvent.create( newtType, src, unixTime, newtMods, newtKeyCode, newtKeyCode, (char) aEvent.getUnicodeChar()); } return null; diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index ead567d82..4139951aa 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -38,7 +38,6 @@ import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.util.EDTUtil; -import jogamp.newt.DefaultEDTUtil; import jogamp.newt.DisplayImpl; public class DisplayDriver extends DisplayImpl { diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 80b1b6687..fc8c5adc6 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -311,7 +311,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } private char NewtVKey2Unicode(short VK){ - if( KeyEvent.isPrintableKey(VK) ){ + if( KeyEvent.isPrintableKey(VK, false) ){ return (char)VK; } return 0; @@ -479,9 +479,9 @@ public class LinuxEventDeviceTracker implements WindowListener { case 39: return KeyEvent.VK_SEMICOLON; case 40: // apostrophe - return KeyEvent.VK_DEAD_ACUTE; + return KeyEvent.VK_QUOTE; case 41: // grave - return KeyEvent.VK_DEAD_GRAVE; + return KeyEvent.VK_BACK_QUOTE; case 42: // left shift return KeyEvent.VK_SHIFT; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index b1d18e487..bb72350e3 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -51,7 +51,6 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.UTFKeyUtil; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { @@ -412,7 +411,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); final short keySym; { - short _keySym = KeyEvent.NULL_CHAR != keySymChar ? UTFKeyUtil.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; + short _keySym = KeyEvent.NULL_CHAR != keySymChar ? KeyEvent.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; keySym = KeyEvent.VK_UNDEFINED != _keySym ? _keySym : keyCode; } /* { @@ -421,7 +420,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", keyCode 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+ ", keySymChar '"+keySymChar+"', 0x"+Integer.toHexString(keySymChar)+" -> 0x"+Integer.toHexString(keySym)+ ", mods "+toHexString(modifiers)+ - ", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode); } */ // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED @@ -429,15 +428,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { - keyRepeatState.put(keyCode, false); // prev == true -> AR out - keyPressedState.put(keyCode, false); + setKeyPressed(keyCode, false); } break; case KeyEvent.EVENT_KEY_PRESSED: if( isKeyCodeTracked(keyCode) ) { - if( keyPressedState.put(keyCode, true) ) { + if( setKeyPressed(keyCode, true) ) { // key was already pressed - keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); // RELEASED } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index e7a8d5a33..ad7e1e8f3 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -261,13 +261,17 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } + private short repeatedKey = KeyEvent.VK_UNDEFINED; + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { - if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { - final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); + if( setKeyPressed(keyCode, true) ) { + // AR: Key was already pressed: Either [enter | within] AR mode + final boolean withinAR = repeatedKey == keyCode; + repeatedKey = keyCode; if( !isModifierKey ) { // AR: Key was already pressed: Either [enter | within] AR mode modifiers |= InputEvent.AUTOREPEAT_MASK; - if( preKeyRepeatState ) { + if( withinAR ) { // AR: Within AR mode super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } @@ -289,11 +293,12 @@ public class WindowDriver extends WindowImpl { switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { - if( keyRepeatState.put(keyCode, false) && !isModifierKey ) { + if( repeatedKey == keyCode && !isModifierKey ) { // AR out - send out missing PRESSED super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar); } - keyPressedState.put(keyCode, false); + setKeyPressed(keyCode, false); + repeatedKey = KeyEvent.VK_UNDEFINED; } super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); break; diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 1ebb714fa..5e240636d 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -68,6 +68,141 @@ public class SWTNewtEventFactory { return newtMods; } + public static short swtKeyCode2NewtKeyCode(final int swtKeyCode) { + final short defNEWTKeyCode = (short)swtKeyCode; + switch (swtKeyCode) { + case SWT.HOME : return com.jogamp.newt.event.KeyEvent.VK_HOME; + case SWT.END : return com.jogamp.newt.event.KeyEvent.VK_END; + case SWT.PRINT_SCREEN : return com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN; + case SWT.BS : return com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE; + case SWT.TAB : return com.jogamp.newt.event.KeyEvent.VK_TAB; + case SWT.LF : return com.jogamp.newt.event.KeyEvent.VK_ENTER; + case SWT.PAGE_DOWN : return com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN; + case SWT.PAGE_UP : return com.jogamp.newt.event.KeyEvent.VK_PAGE_UP; + case SWT.CONTROL : return com.jogamp.newt.event.KeyEvent.VK_CONTROL; + case SWT.CAPS_LOCK : return com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK; + case SWT.PAUSE : return com.jogamp.newt.event.KeyEvent.VK_PAUSE; + case SWT.SCROLL_LOCK : return com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK; + case SWT.CANCEL : return com.jogamp.newt.event.KeyEvent.VK_CANCEL; + case SWT.INSERT : return com.jogamp.newt.event.KeyEvent.VK_INSERT; + case SWT.ESC : return com.jogamp.newt.event.KeyEvent.VK_ESCAPE; + case SWT.SPACE : return com.jogamp.newt.event.KeyEvent.VK_SPACE; + case SWT.F1 : return com.jogamp.newt.event.KeyEvent.VK_F1; + case SWT.F2 : return com.jogamp.newt.event.KeyEvent.VK_F2; + case SWT.F3 : return com.jogamp.newt.event.KeyEvent.VK_F3; + case SWT.F4 : return com.jogamp.newt.event.KeyEvent.VK_F4; + case SWT.F5 : return com.jogamp.newt.event.KeyEvent.VK_F5; + case SWT.F6 : return com.jogamp.newt.event.KeyEvent.VK_F6; + case SWT.F7 : return com.jogamp.newt.event.KeyEvent.VK_F7; + case SWT.F8 : return com.jogamp.newt.event.KeyEvent.VK_F8; + case SWT.F9 : return com.jogamp.newt.event.KeyEvent.VK_F9; + case SWT.F10 : return com.jogamp.newt.event.KeyEvent.VK_F10; + case SWT.F11 : return com.jogamp.newt.event.KeyEvent.VK_F11; + case SWT.F12 : return com.jogamp.newt.event.KeyEvent.VK_F12; + case SWT.F13 : return com.jogamp.newt.event.KeyEvent.VK_F13; + case SWT.F14 : return com.jogamp.newt.event.KeyEvent.VK_F14; + case SWT.F15 : return com.jogamp.newt.event.KeyEvent.VK_F15; + case SWT.F16 : return com.jogamp.newt.event.KeyEvent.VK_F16; + case SWT.F17 : return com.jogamp.newt.event.KeyEvent.VK_F17; + case SWT.F18 : return com.jogamp.newt.event.KeyEvent.VK_F18; + case SWT.F19 : return com.jogamp.newt.event.KeyEvent.VK_F19; + case SWT.F20 : return com.jogamp.newt.event.KeyEvent.VK_F20; + case SWT.DEL : return com.jogamp.newt.event.KeyEvent.VK_DELETE; + case SWT.KEYPAD_0 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0; + case SWT.KEYPAD_1 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD1; + case SWT.KEYPAD_2 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD2; + case SWT.KEYPAD_3 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD3; + case SWT.KEYPAD_4 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD4; + case SWT.KEYPAD_5 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD5; + case SWT.KEYPAD_6 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD6; + case SWT.KEYPAD_7 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD7; + case SWT.KEYPAD_8 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD8; + case SWT.KEYPAD_9 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD9; + case SWT.KEYPAD_DECIMAL: return com.jogamp.newt.event.KeyEvent.VK_DECIMAL; + case SWT.KEYPAD_ADD : return com.jogamp.newt.event.KeyEvent.VK_ADD; + case SWT.KEYPAD_SUBTRACT: return com.jogamp.newt.event.KeyEvent.VK_SUBTRACT; + case SWT.KEYPAD_MULTIPLY: return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; + case SWT.KEYPAD_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; + case SWT.NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; + case SWT.ARROW_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; + case SWT.ARROW_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; + case SWT.ARROW_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT; + case SWT.ARROW_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; + case SWT.HELP : return com.jogamp.newt.event.KeyEvent.VK_HELP; + } + return defNEWTKeyCode; + } + + public static int newtKeyCode2SWTKeyCode(final short newtKeyCode) { + final int defSWTKeyCode = 0xFFFF & (int)newtKeyCode; + switch (newtKeyCode) { + case com.jogamp.newt.event.KeyEvent.VK_HOME : return SWT.HOME; + case com.jogamp.newt.event.KeyEvent.VK_END : return SWT.END; + case com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN : return SWT.PRINT_SCREEN; + case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE : return SWT.BS; + case com.jogamp.newt.event.KeyEvent.VK_TAB : return SWT.TAB; + case com.jogamp.newt.event.KeyEvent.VK_ENTER : return SWT.LF; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN : return SWT.PAGE_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_UP : return SWT.PAGE_UP; + case com.jogamp.newt.event.KeyEvent.VK_CONTROL : return SWT.CONTROL; + case com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK : return SWT.CAPS_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_PAUSE : return SWT.PAUSE; + case com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK : return SWT.SCROLL_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_CANCEL : return SWT.CANCEL; + case com.jogamp.newt.event.KeyEvent.VK_INSERT : return SWT.INSERT; + case com.jogamp.newt.event.KeyEvent.VK_ESCAPE : return SWT.ESC; + case com.jogamp.newt.event.KeyEvent.VK_SPACE : return SWT.SPACE; + case com.jogamp.newt.event.KeyEvent.VK_F1 : return SWT.F1; + case com.jogamp.newt.event.KeyEvent.VK_F2 : return SWT.F2; + case com.jogamp.newt.event.KeyEvent.VK_F3 : return SWT.F3; + case com.jogamp.newt.event.KeyEvent.VK_F4 : return SWT.F4; + case com.jogamp.newt.event.KeyEvent.VK_F5 : return SWT.F5; + case com.jogamp.newt.event.KeyEvent.VK_F6 : return SWT.F6; + case com.jogamp.newt.event.KeyEvent.VK_F7 : return SWT.F7; + case com.jogamp.newt.event.KeyEvent.VK_F8 : return SWT.F8; + case com.jogamp.newt.event.KeyEvent.VK_F9 : return SWT.F9; + case com.jogamp.newt.event.KeyEvent.VK_F10 : return SWT.F10; + case com.jogamp.newt.event.KeyEvent.VK_F11 : return SWT.F11; + case com.jogamp.newt.event.KeyEvent.VK_F12 : return SWT.F12; + case com.jogamp.newt.event.KeyEvent.VK_F13 : return SWT.F13; + case com.jogamp.newt.event.KeyEvent.VK_F14 : return SWT.F14; + case com.jogamp.newt.event.KeyEvent.VK_F15 : return SWT.F15; + case com.jogamp.newt.event.KeyEvent.VK_F16 : return SWT.F16; + case com.jogamp.newt.event.KeyEvent.VK_F17 : return SWT.F17; + case com.jogamp.newt.event.KeyEvent.VK_F18 : return SWT.F18; + case com.jogamp.newt.event.KeyEvent.VK_F19 : return SWT.F19; + case com.jogamp.newt.event.KeyEvent.VK_F20 : return SWT.F20; + case com.jogamp.newt.event.KeyEvent.VK_DELETE : return SWT.DEL; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 : return SWT.KEYPAD_0; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD1 : return SWT.KEYPAD_1; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD2 : return SWT.KEYPAD_2; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD3 : return SWT.KEYPAD_3; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD4 : return SWT.KEYPAD_4; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD5 : return SWT.KEYPAD_5; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD6 : return SWT.KEYPAD_6; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD7 : return SWT.KEYPAD_7; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD8 : return SWT.KEYPAD_8; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD9 : return SWT.KEYPAD_9; + case com.jogamp.newt.event.KeyEvent.VK_DECIMAL : return SWT.KEYPAD_DECIMAL; + case com.jogamp.newt.event.KeyEvent.VK_ADD : return SWT.KEYPAD_ADD; + case com.jogamp.newt.event.KeyEvent.VK_SUBTRACT : return SWT.KEYPAD_SUBTRACT; + case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return SWT.KEYPAD_MULTIPLY; + case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return SWT.KEYPAD_DIVIDE; + case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return SWT.NUM_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : + case com.jogamp.newt.event.KeyEvent.VK_LEFT : return SWT.ARROW_LEFT; + case com.jogamp.newt.event.KeyEvent.VK_KP_UP : + case com.jogamp.newt.event.KeyEvent.VK_UP : return SWT.ARROW_UP; + case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : + case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return SWT.ARROW_RIGHT; + case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : + case com.jogamp.newt.event.KeyEvent.VK_DOWN : return SWT.ARROW_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_HELP : return SWT.HELP; + } + return defSWTKeyCode; + } + + public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, Object source) { com.jogamp.newt.event.InputEvent res = createMouseEvent(event, source); if(null == res) { @@ -126,10 +261,11 @@ public class SWTNewtEventFactory { } final short type = eventTypeSWT2NEWT(event.type); if( (short)0 != type ) { - return new com.jogamp.newt.event.KeyEvent( + final short newtKeyCode = swtKeyCode2NewtKeyCode( event.keyCode ); + return com.jogamp.newt.event.KeyEvent.create( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), swtModifiers2Newt(event.stateMask, false), - (short)event.keyCode, (short)event.keyCode, event.character); + newtKeyCode, newtKeyCode, event.character); } return null; // no mapping .. } diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 946b3c904..7a63b19ce 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -33,194 +33,206 @@ #define EVENT_KEY_RELEASED 301 #define EVENT_KEY_TYPED 302 -#define J_VK_ENTER '\n' -#define J_VK_BACK_SPACE '\b' -#define J_VK_TAB '\t' -#define J_VK_CANCEL 0x03 -#define J_VK_CLEAR 0x0C -#define J_VK_SHIFT 0x10 -#define J_VK_CONTROL 0x11 -#define J_VK_ALT 0x12 -#define J_VK_PAUSE 0x13 -#define J_VK_CAPS_LOCK 0x14 -#define J_VK_ESCAPE 0x1B -#define J_VK_SPACE 0x20 -#define J_VK_PAGE_UP 0x21 -#define J_VK_PAGE_DOWN 0x22 -#define J_VK_END 0x23 -#define J_VK_HOME 0x24 -#define J_VK_LEFT 0x25 -#define J_VK_UP 0x26 -#define J_VK_RIGHT 0x27 -#define J_VK_DOWN 0x28 -#define J_VK_COMMA 0x2C -#define J_VK_MINUS 0x2D -#define J_VK_PERIOD 0x2E -#define J_VK_SLASH 0x2F -#define J_VK_0 0x30 -#define J_VK_1 0x31 -#define J_VK_2 0x32 -#define J_VK_3 0x33 -#define J_VK_4 0x34 -#define J_VK_5 0x35 -#define J_VK_6 0x36 -#define J_VK_7 0x37 -#define J_VK_8 0x38 -#define J_VK_9 0x39 -#define J_VK_SEMICOLON 0x3B -#define J_VK_EQUALS 0x3D -#define J_VK_A 0x41 -#define J_VK_B 0x42 -#define J_VK_C 0x43 -#define J_VK_D 0x44 -#define J_VK_E 0x45 -#define J_VK_F 0x46 -#define J_VK_G 0x47 -#define J_VK_H 0x48 -#define J_VK_I 0x49 -#define J_VK_J 0x4A -#define J_VK_K 0x4B -#define J_VK_L 0x4C -#define J_VK_M 0x4D -#define J_VK_N 0x4E -#define J_VK_O 0x4F -#define J_VK_P 0x50 -#define J_VK_Q 0x51 -#define J_VK_R 0x52 -#define J_VK_S 0x53 -#define J_VK_T 0x54 -#define J_VK_U 0x55 -#define J_VK_V 0x56 -#define J_VK_W 0x57 -#define J_VK_X 0x58 -#define J_VK_Y 0x59 -#define J_VK_Z 0x5A -#define J_VK_OPEN_BRACKET 0x5B -#define J_VK_BACK_SLASH 0x5C -#define J_VK_CLOSE_BRACKET 0x5D -#define J_VK_NUMPAD0 0x60 -#define J_VK_NUMPAD1 0x61 -#define J_VK_NUMPAD2 0x62 -#define J_VK_NUMPAD3 0x63 -#define J_VK_NUMPAD4 0x64 -#define J_VK_NUMPAD5 0x65 -#define J_VK_NUMPAD6 0x66 -#define J_VK_NUMPAD7 0x67 -#define J_VK_NUMPAD8 0x68 -#define J_VK_NUMPAD9 0x69 -#define J_VK_MULTIPLY 0x6A -#define J_VK_ADD 0x6B -#define J_VK_SEPARATOR 0x6C -#define J_VK_SUBTRACT 0x6D -#define J_VK_DECIMAL 0x6E -#define J_VK_DIVIDE 0x6F -#define J_VK_DELETE 0x7F /* ASCII DEL */ -#define J_VK_NUM_LOCK 0x90 -#define J_VK_SCROLL_LOCK 0x91 -#define J_VK_F1 0x70 -#define J_VK_F2 0x71 -#define J_VK_F3 0x72 -#define J_VK_F4 0x73 -#define J_VK_F5 0x74 -#define J_VK_F6 0x75 -#define J_VK_F7 0x76 -#define J_VK_F8 0x77 -#define J_VK_F9 0x78 -#define J_VK_F10 0x79 -#define J_VK_F11 0x7A -#define J_VK_F12 0x7B -#define J_VK_F13 0xF000 -#define J_VK_F14 0xF001 -#define J_VK_F15 0xF002 -#define J_VK_F16 0xF003 -#define J_VK_F17 0xF004 -#define J_VK_F18 0xF005 -#define J_VK_F19 0xF006 -#define J_VK_F20 0xF007 -#define J_VK_F21 0xF008 -#define J_VK_F22 0xF009 -#define J_VK_F23 0xF00A -#define J_VK_F24 0xF00B -#define J_VK_PRINTSCREEN 0x9A -#define J_VK_INSERT 0x9B -#define J_VK_HELP 0x9C -#define J_VK_META 0x9D -#define J_VK_BACK_QUOTE 0xC0 -#define J_VK_QUOTE 0xDE -#define J_VK_KP_UP 0xE0 -#define J_VK_KP_DOWN 0xE1 -#define J_VK_KP_LEFT 0xE2 -#define J_VK_KP_RIGHT 0xE3 -#define J_VK_DEAD_GRAVE 0x80 -#define J_VK_DEAD_ACUTE 0x81 -#define J_VK_DEAD_CIRCUMFLEX 0x82 -#define J_VK_DEAD_TILDE 0x83 -#define J_VK_DEAD_MACRON 0x84 -#define J_VK_DEAD_BREVE 0x85 -#define J_VK_DEAD_ABOVEDOT 0x86 -#define J_VK_DEAD_DIAERESIS 0x87 -#define J_VK_DEAD_ABOVERING 0x88 -#define J_VK_DEAD_DOUBLEACUTE 0x89 -#define J_VK_DEAD_CARON 0x8a -#define J_VK_DEAD_CEDILLA 0x8b -#define J_VK_DEAD_OGONEK 0x8c -#define J_VK_DEAD_IOTA 0x8d -#define J_VK_DEAD_VOICED_SOUND 0x8e -#define J_VK_DEAD_SEMIVOICED_SOUND 0x8f -#define J_VK_AMPERSAND 0x96 -#define J_VK_ASTERISK 0x97 -#define J_VK_QUOTEDBL 0x98 -#define J_VK_LESS 0x99 -#define J_VK_GREATER 0xa0 -#define J_VK_BRACELEFT 0xa1 -#define J_VK_BRACERIGHT 0xa2 -#define J_VK_AT 0x0200 -#define J_VK_COLON 0x0201 -#define J_VK_CIRCUMFLEX 0x0202 -#define J_VK_DOLLAR 0x0203 -#define J_VK_EURO_SIGN 0x0204 -#define J_VK_EXCLAMATION_MARK 0x0205 -#define J_VK_INVERTED_EXCLAMATION_MARK 0x0206 -#define J_VK_LEFT_PARENTHESIS 0x0207 -#define J_VK_NUMBER_SIGN 0x0208 -#define J_VK_PLUS 0x0209 -#define J_VK_RIGHT_PARENTHESIS 0x020A -#define J_VK_UNDERSCORE 0x020B -#define J_VK_WINDOWS 0x020C -#define J_VK_CONTEXT_MENU 0x020D -#define J_VK_FINAL 0x0018 -#define J_VK_CONVERT 0x001C -#define J_VK_NONCONVERT 0x001D -#define J_VK_ACCEPT 0x001E -#define J_VK_MODECHANGE 0x001F -#define J_VK_KANA 0x0015 -#define J_VK_KANJI 0x0019 -#define J_VK_ALPHANUMERIC 0x00F0 -#define J_VK_KATAKANA 0x00F1 -#define J_VK_HIRAGANA 0x00F2 -#define J_VK_FULL_WIDTH 0x00F3 -#define J_VK_HALF_WIDTH 0x00F4 -#define J_VK_ROMAN_CHARACTERS 0x00F5 -#define J_VK_ALL_CANDIDATES 0x0100 -#define J_VK_PREVIOUS_CANDIDATE 0x0101 -#define J_VK_CODE_INPUT 0x0102 -#define J_VK_JAPANESE_KATAKANA 0x0103 -#define J_VK_JAPANESE_HIRAGANA 0x0104 -#define J_VK_JAPANESE_ROMAN 0x0105 -#define J_VK_KANA_LOCK 0x0106 -#define J_VK_INPUT_METHOD_ON_OFF 0x0107 -#define J_VK_CUT 0xFFD1 -#define J_VK_COPY 0xFFCD -#define J_VK_PASTE 0xFFCF -#define J_VK_UNDO 0xFFCB -#define J_VK_AGAIN 0xFFC9 -#define J_VK_FIND 0xFFD0 -#define J_VK_PROPS 0xFFCA -#define J_VK_STOP 0xFFC8 -#define J_VK_COMPOSE 0xFF20 -#define J_VK_ALT_GRAPH 0xFF7E -#define J_VK_BEGIN 0xFF58 -#define J_VK_UNDEFINED 0x0 +#define J_VK_UNDEFINED ( 0x0U ) +#define J_VK_HOME ( 0x02U ) +#define J_VK_END ( 0x03U ) +#define J_VK_FINAL ( 0x04U ) +#define J_VK_PRINTSCREEN ( 0x05U ) +#define J_VK_BACK_SPACE ( 0x08U ) +#define J_VK_TAB ( 0x09U ) +#define J_VK_ENTER ( 0x0AU ) +#define J_VK_PAGE_DOWN ( 0x0BU ) +#define J_VK_CLEAR ( 0x0CU ) +#define J_VK_SHIFT ( 0x0FU ) +#define J_VK_PAGE_UP ( 0x10U ) +#define J_VK_CONTROL ( 0x11U ) +#define J_VK_ALT ( 0x12U ) +#define J_VK_ALT_GRAPH ( 0x13U ) +#define J_VK_CAPS_LOCK ( 0x14U ) +#define J_VK_PAUSE ( 0x16U ) +#define J_VK_SCROLL_LOCK ( 0x17U ) +#define J_VK_CANCEL ( 0x18U ) +#define J_VK_INSERT ( 0x1AU ) +#define J_VK_ESCAPE ( 0x1BU ) +#define J_VK_CONVERT ( 0x1CU ) +#define J_VK_NONCONVERT ( 0x1DU ) +#define J_VK_ACCEPT ( 0x1EU ) +#define J_VK_MODECHANGE ( 0x1FU ) + +// +// Unicode: Printable [0x20 - 0x7E] +// + +#define J_VK_SPACE ( 0x20U ) +#define J_VK_EXCLAMATION_MARK ( 0x21U ) +#define J_VK_QUOTEDBL ( 0x22U ) +#define J_VK_NUMBER_SIGN ( 0x23U ) +#define J_VK_DOLLAR ( 0x24U ) +#define J_VK_PERCENT ( 0x25U ) +#define J_VK_AMPERSAND ( 0x26U ) +#define J_VK_QUOTE ( 0x27U ) +#define J_VK_LEFT_PARENTHESIS ( 0x28U ) +#define J_VK_RIGHT_PARENTHESIS ( 0x29U ) +#define J_VK_ASTERISK ( 0x2AU ) +#define J_VK_PLUS ( 0x2BU ) +#define J_VK_COMMA ( 0x2CU ) +#define J_VK_MINUS ( 0x2DU ) +#define J_VK_PERIOD ( 0x2EU ) +#define J_VK_SLASH ( 0x2FU ) +#define J_VK_0 ( 0x30U ) +#define J_VK_1 ( 0x31U ) +#define J_VK_2 ( 0x32U ) +#define J_VK_3 ( 0x33U ) +#define J_VK_4 ( 0x34U ) +#define J_VK_5 ( 0x35U ) +#define J_VK_6 ( 0x36U ) +#define J_VK_7 ( 0x37U ) +#define J_VK_8 ( 0x38U ) +#define J_VK_9 ( 0x39U ) +#define J_VK_COLON ( 0x3AU ) +#define J_VK_SEMICOLON ( 0x3BU ) +#define J_VK_LESS ( 0x3CU ) +#define J_VK_EQUALS ( 0x3DU ) +#define J_VK_GREATER ( 0x3EU ) +#define J_VK_QUESTIONMARK ( 0x3FU ) +#define J_VK_AT ( 0x40U ) +#define J_VK_A ( 0x41U ) +#define J_VK_B ( 0x42U ) +#define J_VK_C ( 0x43U ) +#define J_VK_D ( 0x44U ) +#define J_VK_E ( 0x45U ) +#define J_VK_F ( 0x46U ) +#define J_VK_G ( 0x47U ) +#define J_VK_H ( 0x48U ) +#define J_VK_I ( 0x49U ) +#define J_VK_J ( 0x4AU ) +#define J_VK_K ( 0x4BU ) +#define J_VK_L ( 0x4CU ) +#define J_VK_M ( 0x4DU ) +#define J_VK_N ( 0x4EU ) +#define J_VK_O ( 0x4FU ) +#define J_VK_P ( 0x50U ) +#define J_VK_Q ( 0x51U ) +#define J_VK_R ( 0x52U ) +#define J_VK_S ( 0x53U ) +#define J_VK_T ( 0x54U ) +#define J_VK_U ( 0x55U ) +#define J_VK_V ( 0x56U ) +#define J_VK_W ( 0x57U ) +#define J_VK_X ( 0x58U ) +#define J_VK_Y ( 0x59U ) +#define J_VK_Z ( 0x5AU ) +#define J_VK_OPEN_BRACKET ( 0x5BU ) +#define J_VK_BACK_SLASH ( 0x5CU ) +#define J_VK_CLOSE_BRACKET ( 0x5DU ) +#define J_VK_CIRCUMFLEX ( 0x5EU ) +#define J_VK_UNDERSCORE ( 0x5FU ) +#define J_VK_BACK_QUOTE ( 0x60U ) +#define J_VK_F1 ( 0x60U+ 1U ) +#define J_VK_F2 ( 0x60U+ 2U ) +#define J_VK_F3 ( 0x60U+ 3U ) +#define J_VK_F4 ( 0x60U+ 4U ) +#define J_VK_F5 ( 0x60U+ 5U ) +#define J_VK_F6 ( 0x60U+ 6U ) +#define J_VK_F7 ( 0x60U+ 7U ) +#define J_VK_F8 ( 0x60U+ 8U ) +#define J_VK_F9 ( 0x60U+ 9U ) +#define J_VK_F10 ( 0x60U+10U ) +#define J_VK_F11 ( 0x60U+11U ) +#define J_VK_F12 ( 0x60U+12U ) +#define J_VK_F13 ( 0x60U+13U ) +#define J_VK_F14 ( 0x60U+14U ) +#define J_VK_F15 ( 0x60U+15U ) +#define J_VK_F16 ( 0x60U+16U ) +#define J_VK_F17 ( 0x60U+17U ) +#define J_VK_F18 ( 0x60U+18U ) +#define J_VK_F19 ( 0x60U+19U ) +#define J_VK_F20 ( 0x60U+20U ) +#define J_VK_F21 ( 0x60U+21U ) +#define J_VK_F22 ( 0x60U+22U ) +#define J_VK_F23 ( 0x60U+23U ) +#define J_VK_F24 ( 0x60U+24U ) +#define J_VK_LEFT_BRACE ( 0x7BU ) +#define J_VK_PIPE ( 0x7CU ) +#define J_VK_RIGHT_BRACE ( 0x7DU ) +#define J_VK_TILDE ( 0x7EU ) + +// +// Unicode: Non printable controls: [0x7F - 0x9F] +// + +#define J_VK_DELETE ( 0x7FU ) +#define J_VK_NUMPAD0 ( 0x80U ) +#define J_VK_NUMPAD1 ( 0x81U ) +#define J_VK_NUMPAD2 ( 0x82U ) +#define J_VK_NUMPAD3 ( 0x83U ) +#define J_VK_NUMPAD4 ( 0x84U ) +#define J_VK_NUMPAD5 ( 0x85U ) +#define J_VK_NUMPAD6 ( 0x86U ) +#define J_VK_NUMPAD7 ( 0x87U ) +#define J_VK_NUMPAD8 ( 0x88U ) +#define J_VK_NUMPAD9 ( 0x89U ) +#define J_VK_DECIMAL ( 0x8AU ) +#define J_VK_SEPARATOR ( 0x8BU ) +#define J_VK_ADD ( 0x8CU ) +#define J_VK_SUBTRACT ( 0x8DU ) +#define J_VK_MULTIPLY ( 0x8EU ) +#define J_VK_DIVIDE ( 0x8FU ) +#define J_VK_NUM_LOCK ( 0x90U ) +#define J_VK_KP_LEFT ( 0x91U ) +#define J_VK_KP_UP ( 0x92U ) +#define J_VK_KP_RIGHT ( 0x93U ) +#define J_VK_KP_DOWN ( 0x94U ) +#define J_VK_LEFT ( 0x95U ) +#define J_VK_UP ( 0x96U ) +#define J_VK_RIGHT ( 0x97U ) +#define J_VK_DOWN ( 0x98U ) +#define J_VK_CONTEXT_MENU ( 0x99U ) +#define J_VK_WINDOWS ( 0x9AU ) +#define J_VK_META ( 0x9BU ) +#define J_VK_HELP ( 0x9CU ) +#define J_VK_COMPOSE ( 0x9DU ) +#define J_VK_BEGIN ( 0x9EU ) +#define J_VK_STOP ( 0x9FU ) + + +// +// Unicode: Printable [0x00A0 - 0xDFFF] +// + +#define J_VK_INVERTED_EXCLAMATION_MARK ( 0xA1U ) +#define J_VK_EURO_SIGN ( 0x20ACU ) + +// +// Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) +// + +/* for Sun keyboards */ +#define J_VK_CUT ( 0xF879U ) +#define J_VK_COPY ( 0xF87AU ) +#define J_VK_PASTE ( 0xF87BU ) +#define J_VK_UNDO ( 0xF87CU ) +#define J_VK_AGAIN ( 0xF87DU ) +#define J_VK_FIND ( 0xF87EU ) +#define J_VK_PROPS ( 0xF87FU ) + +/* for input method support on Asian Keyboards */ +#define J_VK_INPUT_METHOD_ON_OFF ( 0xF890U ) +#define J_VK_CODE_INPUT ( 0xF891U ) +#define J_VK_ROMAN_CHARACTERS ( 0xF892U ) +#define J_VK_ALL_CANDIDATES ( 0xF893U ) +#define J_VK_PREVIOUS_CANDIDATE ( 0xF894U ) +#define J_VK_ALPHANUMERIC ( 0xF895U ) +#define J_VK_KATAKANA ( 0xF896U ) +#define J_VK_HIRAGANA ( 0xF897U ) +#define J_VK_FULL_WIDTH ( 0xF898U ) +#define J_VK_HALF_WIDTH ( 0xF89AU ) +#define J_VK_JAPANESE_KATAKANA ( 0xF89BU ) +#define J_VK_JAPANESE_HIRAGANA ( 0xF89CU ) +#define J_VK_JAPANESE_ROMAN ( 0xF89DU ) +#define J_VK_KANA_LOCK ( 0xF89FU ) + +#define J_VK_KEYBOARD_INVISIBLE ( 0xF8FFU ) #endif diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 903188467..56b7251d2 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -99,6 +99,8 @@ static short X11KeySym2NewtVKey(KeySym keySym) { case XK_Super_L: case XK_Super_R: return J_VK_WINDOWS; + case XK_Menu: + return J_VK_CONTEXT_MENU; case XK_Pause: return J_VK_PAUSE; case XK_Caps_Lock: diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java index 7106ed7ce..d1b276105 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java @@ -226,8 +226,8 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { { try { System.err.println("[K-"+_n+"]"); - AWTRobotUtil.keyPress(_n, _robot, true, KeyEvent.VK_0, 10); - AWTRobotUtil.keyPress(_n, _robot, false, KeyEvent.VK_0, 0); + AWTRobotUtil.newtKeyPress(_n, _robot, true, KeyEvent.VK_0, 10); + AWTRobotUtil.newtKeyPress(_n, _robot, false, KeyEvent.VK_0, 0); Thread.sleep( 40L ) ; _n++; if(!_display.isDisposed()) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index 08a181e10..b075af977 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -160,81 +160,90 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { } @SuppressWarnings("deprecation") - static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask, int keyCode, char keyCharOnly, char keyCharMod) { + static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, short modifierKey, int modifierMask, short keyCode, + char keyCharOnly, char keyCharMod) { keyAdapter.reset(); - AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.keyPress(0, robot, false, keyCode, 100); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release+typed keyCode robot.waitForIdle(); - for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected robot.delay(100); } - AWTRobotUtil.keyPress(0, robot, true, modifierKey, 10); // press MOD - AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.keyPress(0, robot, false, keyCode, 10); // release+typed keyCode - AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, true, modifierKey, 10); // press MOD + AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD robot.waitForIdle(); - for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected robot.delay(100); } - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 3 /* press-SI */, 3 /* release-SI */, 2 /* typed-SI */, + final int modTypedCount = KeyEvent.NULL_CHAR != keyCharMod ? 2 : -1 ; // ignore due to mods 'isPrintable' impact. + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + 3 /* press-SI */, 3 /* release-SI */, modTypedCount /* typed-SI */, 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); - final List<EventObject> queue = keyAdapter.getQueued(); + final List<EventObject> queue = keyAdapter.getQueued(); int i=0; NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, (char)0); + KeyEvent e = (KeyEvent) queue.get(i++); + if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); + e = (KeyEvent) queue.get(i++); + } + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); } @SuppressWarnings("deprecation") static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { - final int m1k = KeyEvent.VK_ALT; - final int m1m = InputEvent.ALT_MASK; - final int m2k = KeyEvent.VK_CONTROL; - final int m2m = InputEvent.CTRL_MASK; - final int m3k = KeyEvent.VK_SHIFT; - final int m3m = InputEvent.SHIFT_MASK; + final short m1k = KeyEvent.VK_ALT; + final int m1m = InputEvent.ALT_MASK; + final short m2k = KeyEvent.VK_CONTROL; + final int m2m = InputEvent.CTRL_MASK; + final short m3k = KeyEvent.VK_SHIFT; + final int m3m = InputEvent.SHIFT_MASK; keyAdapter.reset(); - AWTRobotUtil.keyPress(0, robot, true, m1k, 10); // press MOD1 - AWTRobotUtil.keyPress(0, robot, true, m2k, 10); // press MOD2 - AWTRobotUtil.keyPress(0, robot, true, m3k, 10); // press MOD3 - AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P + AWTRobotUtil.newtKeyPress(0, robot, true, m1k, 10); // press MOD1 + AWTRobotUtil.newtKeyPress(0, robot, true, m2k, 10); // press MOD2 + AWTRobotUtil.newtKeyPress(0, robot, true, m3k, 10); // press MOD3 + AWTRobotUtil.newtKeyPress(0, robot, true, KeyEvent.VK_1, 10); // press P - AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P - AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release MOD - AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release MOD - AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release+typed P + AWTRobotUtil.newtKeyPress(0, robot, false, m3k, 10); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, false, m2k, 10); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD robot.waitForIdle(); - for(int j=0; j < 40 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 4 /* press-SI */, 4 /* release-SI */, 1 /* typed-SI */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + 4 /* press-SI */, 4 /* release-SI */, -1 /* typed-SI - ignored, since unknow whether printable w/ all mods */, + 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); final List<EventObject> queue = keyAdapter.getQueued(); int i=0; - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, (char)0); - - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); + KeyEvent e = (KeyEvent) queue.get(i++); + if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); + e = (KeyEvent) queue.get(i++); + } + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, KeyEvent.NULL_CHAR); } void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { @@ -265,8 +274,8 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_1, '1', '!'); testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_Y, 'y', 'Y'); // US: Y, DE: Z testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_P, 'p', 'P'); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_P, 'p', (char)0); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_P, 'p', (char)0); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_1, '1', KeyEvent.NULL_CHAR); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_1, '1', KeyEvent.NULL_CHAR); testKeyCodeAllModifierV1(robot, glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index 277924477..fb42141ea 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -155,32 +155,35 @@ public class TestNewtKeyCodesAWT extends UITestCase { testNewtCanvasAWT_Impl(false); } + /** Almost all keyCodes reachable w/o modifiers [shift, alt, ..] on US keyboard! */ static CodeSeg[] codeSegments = new CodeSeg[] { - new CodeSeg(0x008, 0x008, "bs"), - // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key - new CodeSeg(0x00a, 0x00a, "cr"), - new CodeSeg(0x010, 0x012, "shift, ctrl, alt"), - new CodeSeg(0x01B, 0x01B, "esc"), - new CodeSeg(0x020, 0x024, "space, up, down, end, home"), - new CodeSeg(0x025, 0x028, "cursor"), - new CodeSeg(0x02C, 0x02F, ", - . /"), - new CodeSeg(0x030, 0x039, "0 - 9"), - new CodeSeg(0x03B, 0x03B, ";"), - new CodeSeg(0x03D, 0x03D, "="), - new CodeSeg(0x041, 0x05A, "a - z"), - new CodeSeg(0x05B, 0x05D, "[ \\ ]"), - // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes - // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes - new CodeSeg(0x07F, 0x07F, "del"), - // new CodeSeg(0x090, 0x091, "num lock, scroll lock"), - // new CodeSeg(0x070, 0x07B, "F1 - F12"), - // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"), - new CodeSeg(0x0C0, 0x0C0, "back quote"), - new CodeSeg(0x0DE, 0x0DE, "quote"), - // new CodeSeg(0x0E0, 0x0E3, "cursor kp"), - // new CodeSeg(0x080, 0x08F, "dead-1"), - // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"), - // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. + // new CodeSeg(KeyEvent.VK_HOME, KeyEvent.VK_PRINTSCREEN, "home, end, final, prnt"), + new CodeSeg(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE, "bs"), + // new CodeSeg(KeyEvent.VK_TAB, KeyEvent.VK_TAB, "tab"), // TAB functions as focus traversal key + new CodeSeg(KeyEvent.VK_ENTER, KeyEvent.VK_ENTER, "cr"), + new CodeSeg(KeyEvent.VK_PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, "pg_down"), + new CodeSeg(KeyEvent.VK_SHIFT, KeyEvent.VK_ALT, "shift, pg_up, ctrl, alt"), + // new CodeSeg(KeyEvent.VK_ALT_GRAPH, KeyEvent.VK_ALT_GRAPH, "alt_gr"), // AWT Robot produces 0xff7e on X11 + // new CodeSeg(KeyEvent.VK_SCROLL_LOCK, KeyEvent.VK_SCROLL_LOCK, "scroll lock"), + new CodeSeg(KeyEvent.VK_ESCAPE, KeyEvent.VK_ESCAPE, "esc"), + new CodeSeg(KeyEvent.VK_SPACE, KeyEvent.VK_SPACE, "space"), + new CodeSeg(KeyEvent.VK_QUOTE, KeyEvent.VK_QUOTE, "quote"), + new CodeSeg(KeyEvent.VK_COMMA, KeyEvent.VK_SLASH, ", - . /"), + new CodeSeg(KeyEvent.VK_0, KeyEvent.VK_9, "0 - 9"), + new CodeSeg(KeyEvent.VK_SEMICOLON, KeyEvent.VK_SEMICOLON, ";"), + new CodeSeg(KeyEvent.VK_EQUALS, KeyEvent.VK_EQUALS, "="), + new CodeSeg(KeyEvent.VK_A, KeyEvent.VK_Z, "a - z"), + new CodeSeg(KeyEvent.VK_OPEN_BRACKET, KeyEvent.VK_CLOSE_BRACKET, "[ \\ ]"), + new CodeSeg(KeyEvent.VK_BACK_QUOTE, KeyEvent.VK_BACK_QUOTE, "`"), + new CodeSeg(KeyEvent.VK_F1, KeyEvent.VK_F8, "f1..f8"), + // new CodeSeg(KeyEvent.VK_F1, KeyEvent.VK_F12, "f1..f12"), // f9-f12 may cause some odd desktop functions! + new CodeSeg(KeyEvent.VK_DELETE, KeyEvent.VK_DELETE, "del"), + // new CodeSeg(KeyEvent.VK_NUMPAD0, KeyEvent.VK_NUMPAD9, "numpad0-9"), // can be mapped to normal keycodes + // new CodeSeg(KeyEvent.VK_DECIMAL, KeyEvent.VK_DIVIDE, "numpad ops"), // can be mapped to normal keycodes + // new CodeSeg(KeyEvent.VK_NUM_LOCK, KeyEvent.VK_NUM_LOCK, "num lock"), + // new CodeSeg(KeyEvent.VK_KP_LEFT, KeyEvent.VK_KP_DOWN, "numpad cursor arrows"), + new CodeSeg(KeyEvent.VK_LEFT, KeyEvent.VK_DOWN, "cursor arrows"), + // new CodeSeg(KeyEvent.VK_WINDOWS, KeyEvent.VK_HELP, "windows, meta, hlp"), }; static void testKeyCodes(Robot robot, NEWTKeyAdapter keyAdapter) { @@ -191,23 +194,23 @@ public class TestNewtKeyCodesAWT extends UITestCase { final CodeSeg codeSeg = codeSegments[i]; // System.err.println("*** Segment "+codeSeg.description); int eventCount = 0; - for(short c=codeSeg.min; c<=codeSeg.max; c++) { + for(short c=codeSeg.min; c<=codeSeg.max; c++) { // System.err.println("*** KeyCode 0x"+Integer.toHexString(c)); try { - AWTRobotUtil.keyPress(0, robot, true, c, 10); + AWTRobotUtil.newtKeyPress(0, robot, true, c, 10); } catch (Exception e) { System.err.println("Exception @ AWT Robot.PRESS "+MiscUtils.toHexString(c)+" - "+e.getMessage()); break; } eventCount++; try { - AWTRobotUtil.keyPress(0, robot, false, c, 100); + AWTRobotUtil.newtKeyPress(0, robot, false, c, 100); } catch (Exception e) { System.err.println("Exception @ AWT Robot.RELEASE "+MiscUtils.toHexString(c)+" - "+e.getMessage()); break; } eventCount++; - if( KeyEvent.isPrintableKey(c) ) { + if( KeyEvent.isPrintableKey(c, false) ) { eventCount++; } robot.waitForIdle(); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 4195711d6..e128123ed 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.util; import jogamp.newt.WindowImplAccess; +import jogamp.newt.awt.event.AWTNewtEventFactory; import java.lang.reflect.InvocationTargetException; import java.awt.AWTException; @@ -449,6 +450,19 @@ public class AWTRobotUtil { return (int) ( System.currentTimeMillis() - t0 ) ; } + /** No validation is performed .. */ + public static int newtKeyPress(int i, Robot robot, boolean press, short newtKeyCode, int msDelay) { + final int keyCode = AWTNewtEventFactory.newtKeyCode2AWTKeyCode(newtKeyCode); + final long t0 = System.currentTimeMillis(); + if(press) { + awtRobotKeyPress(robot, keyCode, msDelay); + } else { + awtRobotKeyRelease(robot, keyCode, msDelay); + } + + return (int) ( System.currentTimeMillis() - t0 ) ; + } + /** * @param keyCode TODO * @param counter shall return the number of keys typed (press + release) diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index d007d2424..1def57edf 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -104,7 +104,7 @@ public class NEWTKeyUtil { missCodes.add(new CodeEvent(c, codeSeg.description, e)); misses++; } - if( KeyEvent.isPrintableKey(c) ) { + if( KeyEvent.isPrintableKey(c, false) ) { evtIdx += 3; // w/ TYPED } else { evtIdx += 2; @@ -118,17 +118,17 @@ public class NEWTKeyUtil { return res; } - public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode, char keyChar) { + public static void validateKeyEvent(KeyEvent e, short eventType, int modifiers, short keyCode, char keyChar) { if(0 <= eventType) { Assert.assertTrue("KeyEvent type mismatch, expected 0x"+Integer.toHexString(eventType)+", has "+e, eventType == e.getEventType()); } - if(0 <= modifier) { - Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifier)+", has "+e, modifier == e.getModifiers()); + if(0 <= modifiers) { + Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifiers)+", has "+e, modifiers == e.getModifiers()); } - if(0 < keyCode) { + if(KeyEvent.VK_UNDEFINED != keyCode) { Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode()); } - if(0 < keyChar) { + if(KeyEvent.NULL_CHAR != keyChar) { Assert.assertTrue("KeyEvent char mismatch, expected 0x"+Integer.toHexString(keyChar)+", has "+e, keyChar == e.getKeyChar()); } } @@ -168,17 +168,17 @@ public class NEWTKeyUtil { * @param keyAdapter * @param expPressedCountSI number of single key press events * @param expReleasedCountSI number of single key release events - * @param expTypedCountSI number of single key types events + * @param expTypedCountSI number of single key types events, set to -1 to ignore * @param expPressedCountAR number of auto-repeat key press events * @param expReleasedCountAR number of auto-repeat key release events - * @param expTypedCountAR number of auto-repeat key types events + * @param expTypedCountAR number of auto-repeat key types events, set to -1 to ignore */ public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI, int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) { - final int expTotalCountSI = expPressedCountSI + expReleasedCountSI + expTypedCountSI; - final int expTotalCountAR = expPressedCountAR + expReleasedCountAR + expTypedCountAR; - final int expTotalCountALL = expTotalCountSI + expTotalCountAR; + final int expPressReleaseCountSI = expPressedCountSI + expReleasedCountSI; + final int expPressReleaseCountAR = expPressedCountAR + expReleasedCountAR; + final int expPressReleaseCountALL = expPressReleaseCountSI + expPressReleaseCountAR; final int keyPressedALL = keyAdapter.getKeyPressedCount(false); final int keyPressedAR = keyAdapter.getKeyPressedCount(true); @@ -191,35 +191,39 @@ public class NEWTKeyUtil { final int keyReleasedSI = keyReleasedALL-keyReleasedAR; final int keyTypedSI = keyTypedALL-keyTypedAR; - final int totalCountALL = keyPressedALL + keyReleasedALL + keyTypedALL; - final int totalCountSI = keyPressedSI + keyReleasedSI + keyTypedSI; - final int totalCountAR = keyPressedAR + keyReleasedAR + keyTypedAR; + final int pressReleaseCountALL = keyPressedALL + keyReleasedALL; + final int pressReleaseCountSI = keyPressedSI + keyReleasedSI; + final int pressReleaseCountAR = keyPressedAR + keyReleasedAR; - System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI +", Events "+expTotalCountSI); - System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR +", Events "+expTotalCountAR); + System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI); + System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR); - System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+totalCountSI); - System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+totalCountAR); - System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+totalCountALL); + System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+pressReleaseCountSI); + System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+pressReleaseCountAR); + System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+pressReleaseCountALL); - Assert.assertEquals("Internal Error: totalSI != totalALL - totalAR", totalCountSI, totalCountALL - totalCountAR); + Assert.assertEquals("Internal Error: pressReleaseSI != pressReleaseALL - pressReleaseAR", pressReleaseCountSI, pressReleaseCountALL - pressReleaseCountAR); Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR); - Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); + if( 0 <= expTypedCountAR ) { + Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); + } Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI); Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI); - Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); + if( 0 <= expTypedCountSI ) { + Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); + } Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR); Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR); - Assert.assertEquals("Key total count failure (SI)", expTotalCountSI, totalCountSI); - Assert.assertEquals("Key total count failure (AR)", expTotalCountAR, totalCountAR); + Assert.assertEquals("Key pressRelease count failure (SI)", expPressReleaseCountSI, pressReleaseCountSI); + Assert.assertEquals("Key pressRelease count failure (AR)", expPressReleaseCountAR, pressReleaseCountAR); final List<EventObject> keyEvents = keyAdapter.getQueued(); - Assert.assertEquals("Key total count failure (ALL) w/ list sum ", expTotalCountALL, totalCountALL); - Assert.assertEquals("Key total count failure (ALL) w/ list size ", expTotalCountALL, keyEvents.size()); + Assert.assertEquals("Key pressRelease count failure (ALL) w/ list sum ", expPressReleaseCountALL, pressReleaseCountALL); + Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL + keyTypedALL, keyEvents.size()); } } |