summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-02-19 08:00:38 +0100
committerSven Gothel <[email protected]>2013-02-19 08:00:38 +0100
commit85338858f5c58694fa88e77df1386d0556887944 (patch)
tree3fc6ff607520b6781c22fd50dd63aa62e79cfb10 /src/newt
parenta40ee817a3bd537b0de7018772b0835f995a1bed (diff)
Bug 678 (fix), Bug 641 (API + Windows Impl.), Bug 688 (prep): Update NEWT's KeyEvent handling while distinguish keyCode (kbd layout independent) and keySym (kbd layout dependent)
API Changes: - Virtual key codes and symbols are of type short. - KeyEvent.keySymbol() shall return a layout dependent value (Bug 641) - Method returns former keyCode() value, which was layout dependent. - Returns 'short' value - KeyEvent.keyCode() returns a short value, instead of int - KeyEvent.keyCode() shall return a layout independent value (Bug 641) - To ease implementation, we only 'require' the scan code to be mapped to a 'US Keyboard layout', which allows reusing layout dependent code while preserving the goal to have a fixed physical key association - Implementation status: - Windows OK - X11 TODO - OSX: 50/50 TODO - Using layout independent 'action keys' - Using layout dependent 'printable keys' - returning above semantics for both, keyCode and keySym - Android 50/50 TODO - Returning the layout independent keyCode - Mapping probably incomplete - KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent) (Bug 688) - Marked DEPRECATED - No more called for auto-repeat events - Synthesized in WindowImpl.consumeKeyEvent(..): No more injection by native- or java driver code - NEWTEvent.eventType: int -> short - field, as well as all method involving eventType changed to short. - NEWTEvent.isSystemEvent: REMOVED - Never used as well as never being implemented properly Internal Changes: - Simplified keyEvent driver code - Especially the Windows native driver's mapping code could be simplified using scanCode and MapVirtualKeyEx - NEWT Event Factories: hashMap -> switch/case Unit Tests: - - Added NewtCanvasAWT Offscreen Layer Tests important to test the AWT -> NEWT translation on OSX/CALayer: - TestNewtKeyCodeModifiersAWT - TestNewtKeyCodesAWT - TestNewtKeyEventAutoRepeatAWT - TestNewtKeyEventOrderAWT - TestNewtKeyPressReleaseUnmaskRepeatAWT
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/event/InputEvent.java10
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyEvent.java552
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyListener.java18
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java61
-rw-r--r--src/newt/classes/com/jogamp/newt/event/NEWTEvent.java72
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowEvent.java18
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java3
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java116
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java110
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java100
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java8
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java33
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java14
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java262
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java40
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java89
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java33
-rw-r--r--src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java52
-rw-r--r--src/newt/native/KDWindow.c12
-rw-r--r--src/newt/native/NewtMacWindow.h6
-rw-r--r--src/newt/native/NewtMacWindow.m36
-rw-r--r--src/newt/native/WindowsWindow.c743
-rw-r--r--src/newt/native/X11Display.c142
-rw-r--r--src/newt/native/bcm_vc_iv.c8
25 files changed, 1237 insertions, 1303 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
index ad77ec79f..9ef4de2b6 100644
--- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
@@ -86,7 +86,7 @@ public abstract class InputEvent extends NEWTEvent
*/
public static final Object consumedTag = new Object();
- protected InputEvent(int eventType, Object source, long when, int modifiers) {
+ protected InputEvent(short eventType, Object source, long when, int modifiers) {
super(eventType, source, when);
this.modifiers=modifiers;
}
@@ -154,16 +154,16 @@ public abstract class InputEvent extends NEWTEvent
* @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}].
* If none is down, the resulting array is of length 0.
*/
- public final int[] getButtonsDown() {
+ public final short[] getButtonsDown() {
int len = 0;
for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) {
- if(isButtonDown(i)) { len++; }
+ if( isButtonDown(i) ) { len++; }
}
- int[] res = new int[len];
+ short[] res = new short[len];
int j = 0;
for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) {
- if(isButtonDown(i)) { res[j++] = ( MouseEvent.BUTTON1 - 1 ) + i; }
+ if( isButtonDown(i) ) { res[j++] = (short) ( ( MouseEvent.BUTTON1 - 1 ) + i ); }
}
return res;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index ff67b7f57..f626fec38 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -36,68 +36,123 @@ package com.jogamp.newt.event;
/**
* Key events are delivered in the following order:
- * <ol>
- * <li>{@link #EVENT_KEY_PRESSED}</li>
- * <li>{@link #EVENT_KEY_RELEASED}</li>
- * <li>{@link #EVENT_KEY_TYPED}</li>
- * </ol>
+ * <p>
+ * <table border="0">
+ * <tr><th>#</th><th>Event Type</th> <th>Constraints</th> <th>Notes</th></tr>
+ * <tr><td>1</td><td>{@link #EVENT_KEY_PRESSED} </td><td> <i> excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys</i></td><td></td></tr>
+ * <tr><td>2</td><td>{@link #EVENT_KEY_RELEASED} </td><td> <i> excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys</i></td><td></td></tr>
+ * <tr><td>3</td><td>{@link #EVENT_KEY_TYPED} </td><td> <i>only for {@link #isPrintableKey() printable} and non {@link #isAutoRepeat() auto-repeat} keys</i></td><td><b>Deprecated</b>: Use {@link #EVENT_KEY_RELEASED} and apply constraints.</td></tr>
+ * </table>
+ * </p>
* In case the native platform does not
* deliver keyboard events in the above order or skip events,
* the NEWT driver will reorder and inject synthetic events if required.
* <p>
* Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc.,
- * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected.
+ * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected, following above constraints.
* </p>
* <p>
* Auto-Repeat shall behave as follow:
* <pre>
- D = pressed, U = released, T = typed
+ P = pressed, R = released, T = typed
0 = normal, 1 = auto-repeat
- D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
+ P(0), [ R(1), P(1), R(1), ..], R(0) T(0)
* </pre>
* The idea is if you mask out auto-repeat in your event listener
- * you just get one long pressed key D/U/T triple.
+ * or catch {@link #EVENT_KEY_TYPED typed} events only,
+ * you just get one long pressed P/R/T triple for {@link #isPrintableKey() printable} keys.
+ * {@link #isActionKey() Action} keys would produce one long pressed P/R tuple in case you mask out auto-repeat .
+ * </p>
+ * <p>
+ * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed}
+ * and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}.
+ * </p>
+ * <p>
+ * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed},
+ * {@link #EVENT_KEY_RELEASED released} and {@link #EVENT_KEY_TYPED typed} events, the latter is excluded for {@link #isAutoRepeat() auto-repeat} events.
* </p>
* <p>
- * {@link #isModifierKey() Modifiers keys} will produce regular events (pressed, released and typed),
- * however they will not produce Auto-Repeat events itself.
+ * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed}
+ * 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>
*/
@SuppressWarnings("serial")
public class KeyEvent extends InputEvent
{
- public KeyEvent(int eventType, Object source, long when, int modifiers, int keyCode, char keyChar) {
+ public KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) {
super(eventType, source, when, modifiers);
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;
+ }
+ flags = _flags;
+ }
}
/**
- * Returns the character matching the {@link #getKeyCode() virtual key code}.
+ * Returns the <i>UTF-16</i> character reflecting the {@link #getKeySymbol() key symbol}.
+ * @see #getKeySymbol()
+ * @see #getKeyCode()
*/
- public char getKeyChar() {
+ public final char getKeyChar() {
return keyChar;
}
- /** Returns the virtual key code. */
- public int getKeyCode() {
+ /**
+ * Returns the virtual <i>key symbol</i> reflecting the current <i>keyboard layout</i>.
+ * @see #getKeyChar()
+ * @see #getKeyCode()
+ */
+ public final short getKeySymbol() {
+ return keySym;
+ }
+
+ /**
+ * Returns the virtual <i>key code</i> using a fixed mapping to the <i>US keyboard layout</i>.
+ * <p>
+ * In contrast to {@link #getKeySymbol() key symbol}, <i>key code</i>
+ * uses a fixed <i>US keyboard layout</i> and therefore is keyboard layout independent.
+ * </p>
+ * <p>
+ * E.g. <i>virtual key code</i> {@link #VK_Y} denotes the same physical key
+ * regardless whether <i>keyboard layout</i> <code>QWERTY</code> or
+ * <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()
+ */
+ public final short getKeyCode() {
return keyCode;
}
- public String toString() {
+ public final String toString() {
return toString(null).toString();
}
- public StringBuilder toString(StringBuilder sb) {
+ public final StringBuilder toString(StringBuilder sb) {
if(null == sb) {
sb = new StringBuilder();
}
- sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", ");
+ sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(toHexString(keyCode)).append(", sym ").append(toHexString(keySym)).append(", char '").append(keyChar).append("' (").append(toHexString((short)keyChar))
+ .append("), isModifierKey ").append(isModifierKey()).append(", isActionKey ").append(isActionKey()).append(", ");
return super.toString(sb).append("]");
}
- public static String getEventTypeString(int type) {
+ public static String getEventTypeString(short type) {
switch(type) {
case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
@@ -107,13 +162,13 @@ public class KeyEvent extends InputEvent
}
/**
- * Returns true if the given <code>keyCode</code> represents a non-printable modifier key.
+ * Returns <code>true</code> if the given <code>virtualKey</code> represents a modifier key, otherwise <code>false</code>.
* <p>
* A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}.
* </p>
*/
- public static boolean isModifierKey(int keyCode) {
- switch (keyCode) {
+ public static boolean isModifierKey(short vKey) {
+ switch (vKey) {
case VK_SHIFT:
case VK_CONTROL:
case VK_ALT:
@@ -126,31 +181,36 @@ public class KeyEvent extends InputEvent
}
/**
- * Returns true if {@link #getKeyCode()} represents a non-printable modifier key.
+ * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a modifier key,
+ * otherwise <code>false</code>.
+ * <p>
+ * See {@link #isModifierKey(short)} for details.
+ * </p>
* <p>
- * See {@link #isModifierKey(int)} for details.
+ * Note: Implementation uses a cached value.
* </p>
*/
- public boolean isModifierKey() {
- return isModifierKey(keyCode);
+ public final boolean isModifierKey() {
+ return 0 != ( F_MODIFIER_MASK & flags ) ;
}
/**
- * Returns true if the given <code>keyCode</code> represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}.
+ * 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(int keyCode) {
- if( ( VK_F1 <= keyCode && keyCode <= VK_F24 ) ||
- ( VK_ALL_CANDIDATES <= keyCode && keyCode <= VK_INPUT_METHOD_ON_OFF ) ||
- ( VK_CUT <= keyCode && keyCode <= VK_STOP ) ) {
+ 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 (keyCode) {
+ switch (vKey) {
case VK_CANCEL:
case VK_CLEAR:
case VK_PAUSE:
@@ -208,600 +268,614 @@ public class KeyEvent extends InputEvent
}
/**
- * Returns true if {@link #getKeyCode() keyCode} represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}.
+ * 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(int)} for details.
+ * See {@link #isActionKey(short)} for details.
* </p>
*/
- public boolean isActionKey() {
- return isActionKey(keyCode);
+ public final boolean isActionKey() {
+ return 0 != ( F_ACTION_MASK & flags ) ;
}
/**
- * Returns true if given <code>keyKode</code> represents a printable character, which is neither a {@link #isModifierKey(int) modifier key}
- * nor an {@link #isActionKey(int) action key}.
+ * Returns <code>true</code> if given <code>virtualKey</code> represents a printable character,
+ * i.e. neither a {@link #isModifierKey(short) modifier key}
+ * nor an {@link #isActionKey(short) action key}.
* Otherwise returns <code>false</code>.
*/
- public static boolean isPrintableKey(int keyCode) {
- return !isModifierKey(keyCode) && !isActionKey(keyCode);
+ public static boolean isPrintableKey(short vKey) {
+ return !isModifierKey(vKey) && !isActionKey(vKey);
}
/**
- * Returns true if {@link #getKeyCode() keyCode} represents a printable character, which is neither a {@link #isModifierKey(int) modifier key}
- * nor an {@link #isActionKey(int) action key}.
+ * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a printable character,
+ * i.e. neither a {@link #isModifierKey(short) modifier key}
+ * nor an {@link #isActionKey(short) action key}.
* Otherwise returns <code>false</code>.
*/
- public boolean isPrintableKey() {
- return isPrintableKey(keyCode);
+ public final boolean isPrintableKey() {
+ return 0 == ( F_NON_PRINT_MASK & flags ) ;
}
- private final int keyCode;
+ private final short keyCode;
+ private final short keySym;
private final char keyChar;
-
- public static final int EVENT_KEY_PRESSED = 300;
- public static final int EVENT_KEY_RELEASED= 301;
- public static final int EVENT_KEY_TYPED = 302;
+ private final byte flags;
+ private static final byte F_MODIFIER_MASK = 1 << 0;
+ private static final byte F_ACTION_MASK = 1 << 1;
+ private static final byte F_NON_PRINT_MASK = F_MODIFIER_MASK | F_ACTION_MASK ;
+
+ /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */
+ public static final short EVENT_KEY_PRESSED = 300;
+ /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */
+ public static final short EVENT_KEY_RELEASED= 301;
+ /**
+ * A {@link #isPrintableKey() printable} key has been typed (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}.
+ * @deprecated Redundant, will be removed soon. Use {@link #EVENT_KEY_RELEASED} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}.
+ */
+ public static final short EVENT_KEY_TYPED = 302;
/* Virtual key codes. */
- public static final int VK_CANCEL = 0x03;
- public static final int VK_BACK_SPACE = 0x08; // '\b'
- public static final int VK_TAB = 0x09; // '\t'
- public static final int VK_ENTER = 0x0A; // '\n'
- public static final int VK_CLEAR = 0x0C;
- public static final int VK_SHIFT = 0x10;
- public static final int VK_CONTROL = 0x11;
- public static final int VK_ALT = 0x12;
- public static final int VK_PAUSE = 0x13;
- public static final int VK_CAPS_LOCK = 0x14;
- public static final int VK_ESCAPE = 0x1B;
- public static final int VK_SPACE = 0x20;
- public static final int VK_PAGE_UP = 0x21;
- public static final int VK_PAGE_DOWN = 0x22;
- public static final int VK_END = 0x23;
- public static final int VK_HOME = 0x24;
+ 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 final short VK_ALT = (short) 0x12;
+ public static final short VK_PAUSE = (short) 0x13;
+ public static final short VK_CAPS_LOCK = (short) 0x14;
+ 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 non-numpad <b>left</b> arrow key.
* @see #VK_KP_LEFT
*/
- public static final int VK_LEFT = 0x25;
+ public static final short VK_LEFT = (short) 0x25;
/**
* Constant for the non-numpad <b>up</b> arrow key.
* @see #VK_KP_UP
*/
- public static final int VK_UP = 0x26;
+ public static final short VK_UP = (short) 0x26;
/**
* Constant for the non-numpad <b>right</b> arrow key.
* @see #VK_KP_RIGHT
*/
- public static final int VK_RIGHT = 0x27;
+ public static final short VK_RIGHT = (short) 0x27;
/**
* Constant for the non-numpad <b>down</b> arrow key.
* @see #VK_KP_DOWN
*/
- public static final int VK_DOWN = 0x28;
+ public static final short VK_DOWN = (short) 0x28;
/**
* Constant for the comma key, ","
*/
- public static final int VK_COMMA = 0x2C;
+ public static final short VK_COMMA = (short) 0x2C;
/**
* Constant for the minus key, "-"
* @since 1.2
*/
- public static final int VK_MINUS = 0x2D;
+ public static final short VK_MINUS = (short) 0x2D;
/**
* Constant for the period key, "."
*/
- public static final int VK_PERIOD = 0x2E;
+ public static final short VK_PERIOD = (short) 0x2E;
/**
* Constant for the forward slash key, "/"
*/
- public static final int VK_SLASH = 0x2F;
+ public static final short VK_SLASH = (short) 0x2F;
/** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
- public static final int VK_0 = 0x30;
- public static final int VK_1 = 0x31;
- public static final int VK_2 = 0x32;
- public static final int VK_3 = 0x33;
- public static final int VK_4 = 0x34;
- public static final int VK_5 = 0x35;
- public static final int VK_6 = 0x36;
- public static final int VK_7 = 0x37;
- public static final int VK_8 = 0x38;
- public static final int VK_9 = 0x39;
+ public static final short VK_0 = (short) 0x30;
+ public static final short VK_1 = (short) 0x31;
+ public static final short VK_2 = (short) 0x32;
+ public static final short VK_3 = (short) 0x33;
+ public static final short VK_4 = (short) 0x34;
+ public static final short VK_5 = (short) 0x35;
+ public static final short VK_6 = (short) 0x36;
+ public static final short VK_7 = (short) 0x37;
+ public static final short VK_8 = (short) 0x38;
+ public static final short VK_9 = (short) 0x39;
/**
* Constant for the semicolon key, ";"
*/
- public static final int VK_SEMICOLON = 0x3B;
+ public static final short VK_SEMICOLON = (short) 0x3B;
/**
* Constant for the equals key, "="
*/
- public static final int VK_EQUALS = 0x3D;
+ public static final short VK_EQUALS = (short) 0x3D;
/** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
- public static final int VK_A = 0x41;
- public static final int VK_B = 0x42;
- public static final int VK_C = 0x43;
- public static final int VK_D = 0x44;
- public static final int VK_E = 0x45;
- public static final int VK_F = 0x46;
- public static final int VK_G = 0x47;
- public static final int VK_H = 0x48;
- public static final int VK_I = 0x49;
- public static final int VK_J = 0x4A;
- public static final int VK_K = 0x4B;
- public static final int VK_L = 0x4C;
- public static final int VK_M = 0x4D;
- public static final int VK_N = 0x4E;
- public static final int VK_O = 0x4F;
- public static final int VK_P = 0x50;
- public static final int VK_Q = 0x51;
- public static final int VK_R = 0x52;
- public static final int VK_S = 0x53;
- public static final int VK_T = 0x54;
- public static final int VK_U = 0x55;
- public static final int VK_V = 0x56;
- public static final int VK_W = 0x57;
- public static final int VK_X = 0x58;
- public static final int VK_Y = 0x59;
- public static final int VK_Z = 0x5A;
+ public static final short VK_A = (short) 0x41;
+ public static final short VK_B = (short) 0x42;
+ public static final short VK_C = (short) 0x43;
+ public static final short VK_D = (short) 0x44;
+ public static final short VK_E = (short) 0x45;
+ public static final short VK_F = (short) 0x46;
+ public static final short VK_G = (short) 0x47;
+ public static final short VK_H = (short) 0x48;
+ public static final short VK_I = (short) 0x49;
+ public static final short VK_J = (short) 0x4A;
+ public static final short VK_K = (short) 0x4B;
+ public static final short VK_L = (short) 0x4C;
+ public static final short VK_M = (short) 0x4D;
+ public static final short VK_N = (short) 0x4E;
+ public static final short VK_O = (short) 0x4F;
+ public static final short VK_P = (short) 0x50;
+ public static final short VK_Q = (short) 0x51;
+ public static final short VK_R = (short) 0x52;
+ public static final short VK_S = (short) 0x53;
+ public static final short VK_T = (short) 0x54;
+ public static final short VK_U = (short) 0x55;
+ public static final short VK_V = (short) 0x56;
+ public static final short VK_W = (short) 0x57;
+ public static final short VK_X = (short) 0x58;
+ public static final short VK_Y = (short) 0x59;
+ public static final short VK_Z = (short) 0x5A;
/**
* Constant for the open bracket key, "["
*/
- public static final int VK_OPEN_BRACKET = 0x5B;
+ public static final short VK_OPEN_BRACKET = (short) 0x5B;
/**
* Constant for the back slash key, "\"
*/
- public static final int VK_BACK_SLASH = 0x5C;
+ public static final short VK_BACK_SLASH = (short) 0x5C;
/**
* Constant for the close bracket key, "]"
*/
- public static final int VK_CLOSE_BRACKET = 0x5D;
-
- public static final int VK_NUMPAD0 = 0x60;
- public static final int VK_NUMPAD1 = 0x61;
- public static final int VK_NUMPAD2 = 0x62;
- public static final int VK_NUMPAD3 = 0x63;
- public static final int VK_NUMPAD4 = 0x64;
- public static final int VK_NUMPAD5 = 0x65;
- public static final int VK_NUMPAD6 = 0x66;
- public static final int VK_NUMPAD7 = 0x67;
- public static final int VK_NUMPAD8 = 0x68;
- public static final int VK_NUMPAD9 = 0x69;
- public static final int VK_MULTIPLY = 0x6A;
- public static final int VK_ADD = 0x6B;
+ 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 Numpad Separator key.
*/
- public static final int VK_SEPARATOR = 0x6C;
+ public static final short VK_SEPARATOR = (short) 0x6C;
- public static final int VK_SUBTRACT = 0x6D;
- public static final int VK_DECIMAL = 0x6E;
- public static final int VK_DIVIDE = 0x6F;
- public static final int VK_DELETE = 0x7F; /* ASCII DEL */
- public static final int VK_NUM_LOCK = 0x90;
- public static final int VK_SCROLL_LOCK = 0x91;
+ 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 F1 function key. */
- public static final int VK_F1 = 0x70;
+ public static final short VK_F1 = (short) 0x70;
/** Constant for the F2 function key. */
- public static final int VK_F2 = 0x71;
+ public static final short VK_F2 = (short) 0x71;
/** Constant for the F3 function key. */
- public static final int VK_F3 = 0x72;
+ public static final short VK_F3 = (short) 0x72;
/** Constant for the F4 function key. */
- public static final int VK_F4 = 0x73;
+ public static final short VK_F4 = (short) 0x73;
/** Constant for the F5 function key. */
- public static final int VK_F5 = 0x74;
+ public static final short VK_F5 = (short) 0x74;
/** Constant for the F6 function key. */
- public static final int VK_F6 = 0x75;
+ public static final short VK_F6 = (short) 0x75;
/** Constant for the F7 function key. */
- public static final int VK_F7 = 0x76;
+ public static final short VK_F7 = (short) 0x76;
/** Constant for the F8 function key. */
- public static final int VK_F8 = 0x77;
+ public static final short VK_F8 = (short) 0x77;
/** Constant for the F9 function key. */
- public static final int VK_F9 = 0x78;
+ public static final short VK_F9 = (short) 0x78;
/** Constant for the F10 function key. */
- public static final int VK_F10 = 0x79;
+ public static final short VK_F10 = (short) 0x79;
/** Constant for the F11 function key. */
- public static final int VK_F11 = 0x7A;
+ public static final short VK_F11 = (short) 0x7A;
/** Constant for the F12 function key. */
- public static final int VK_F12 = 0x7B;
+ public static final short VK_F12 = (short) 0x7B;
/**
* Constant for the F13 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F13 = 0xF000;
+ public static final short VK_F13 = (short) 0xF000;
/**
* Constant for the F14 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F14 = 0xF001;
+ 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 int VK_F15 = 0xF002;
+ 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 int VK_F16 = 0xF003;
+ 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 int VK_F17 = 0xF004;
+ public static final short VK_F17 = (short) 0xF004;
/**
* Constant for the F18 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F18 = 0xF005;
+ public static final short VK_F18 = (short) 0xF005;
/**
* Constant for the F19 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F19 = 0xF006;
+ public static final short VK_F19 = (short) 0xF006;
/**
* Constant for the F20 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F20 = 0xF007;
+ public static final short VK_F20 = (short) 0xF007;
/**
* Constant for the F21 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F21 = 0xF008;
+ public static final short VK_F21 = (short) 0xF008;
/**
* Constant for the F22 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F22 = 0xF009;
+ public static final short VK_F22 = (short) 0xF009;
/**
* Constant for the F23 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F23 = 0xF00A;
+ public static final short VK_F23 = (short) 0xF00A;
/**
* Constant for the F24 function key.
* <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p>
*/
- public static final int VK_F24 = 0xF00B;
+ public static final short VK_F24 = (short) 0xF00B;
- public static final int VK_PRINTSCREEN = 0x9A;
- public static final int VK_INSERT = 0x9B;
- public static final int VK_HELP = 0x9C;
- public static final int VK_META = 0x9D;
+ 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;
- public static final int VK_BACK_QUOTE = 0xC0;
- public static final int VK_QUOTE = 0xDE;
+ public static final short VK_BACK_QUOTE = (short) 0xC0;
+ public static final short VK_QUOTE = (short) 0xDE;
/**
* Constant for the numeric keypad <b>up</b> arrow key.
* @see #VK_UP
*/
- public static final int VK_KP_UP = 0xE0;
+ public static final short VK_KP_UP = (short) 0xE0;
/**
* Constant for the numeric keypad <b>down</b> arrow key.
* @see #VK_DOWN
*/
- public static final int VK_KP_DOWN = 0xE1;
+ public static final short VK_KP_DOWN = (short) 0xE1;
/**
* Constant for the numeric keypad <b>left</b> arrow key.
* @see #VK_LEFT
*/
- public static final int VK_KP_LEFT = 0xE2;
+ public static final short VK_KP_LEFT = (short) 0xE2;
/**
* Constant for the numeric keypad <b>right</b> arrow key.
* @see #VK_RIGHT
*/
- public static final int VK_KP_RIGHT = 0xE3;
+ public static final short VK_KP_RIGHT = (short) 0xE3;
/** For European keyboards */
- public static final int VK_DEAD_GRAVE = 0x80;
+ public static final short VK_DEAD_GRAVE = (short) 0x80;
/** For European keyboards */
- public static final int VK_DEAD_ACUTE = 0x81;
+ public static final short VK_DEAD_ACUTE = (short) 0x81;
/** For European keyboards */
- public static final int VK_DEAD_CIRCUMFLEX = 0x82;
+ public static final short VK_DEAD_CIRCUMFLEX = (short) 0x82;
/** For European keyboards */
- public static final int VK_DEAD_TILDE = 0x83;
+ public static final short VK_DEAD_TILDE = (short) 0x83;
/** For European keyboards */
- public static final int VK_DEAD_MACRON = 0x84;
+ public static final short VK_DEAD_MACRON = (short) 0x84;
/** For European keyboards */
- public static final int VK_DEAD_BREVE = 0x85;
+ public static final short VK_DEAD_BREVE = (short) 0x85;
/** For European keyboards */
- public static final int VK_DEAD_ABOVEDOT = 0x86;
+ public static final short VK_DEAD_ABOVEDOT = (short) 0x86;
/** For European keyboards */
- public static final int VK_DEAD_DIAERESIS = 0x87;
+ public static final short VK_DEAD_DIAERESIS = (short) 0x87;
/** For European keyboards */
- public static final int VK_DEAD_ABOVERING = 0x88;
+ public static final short VK_DEAD_ABOVERING = (short) 0x88;
/** For European keyboards */
- public static final int VK_DEAD_DOUBLEACUTE = 0x89;
+ public static final short VK_DEAD_DOUBLEACUTE = (short) 0x89;
/** For European keyboards */
- public static final int VK_DEAD_CARON = 0x8a;
+ public static final short VK_DEAD_CARON = (short) 0x8a;
/** For European keyboards */
- public static final int VK_DEAD_CEDILLA = 0x8b;
+ public static final short VK_DEAD_CEDILLA = (short) 0x8b;
/** For European keyboards */
- public static final int VK_DEAD_OGONEK = 0x8c;
+ public static final short VK_DEAD_OGONEK = (short) 0x8c;
/** For European keyboards */
- public static final int VK_DEAD_IOTA = 0x8d;
+ public static final short VK_DEAD_IOTA = (short) 0x8d;
/** For European keyboards */
- public static final int VK_DEAD_VOICED_SOUND = 0x8e;
+ public static final short VK_DEAD_VOICED_SOUND = (short) 0x8e;
/** For European keyboards */
- public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
+ public static final short VK_DEAD_SEMIVOICED_SOUND = (short) 0x8f;
/** For European keyboards */
- public static final int VK_AMPERSAND = 0x96;
+ public static final short VK_AMPERSAND = (short) 0x96;
/** For European keyboards */
- public static final int VK_ASTERISK = 0x97;
+ public static final short VK_ASTERISK = (short) 0x97;
/** For European keyboards */
- public static final int VK_QUOTEDBL = 0x98;
+ public static final short VK_QUOTEDBL = (short) 0x98;
/** For European keyboards */
- public static final int VK_LESS = 0x99;
+ public static final short VK_LESS = (short) 0x99;
/** For European keyboards */
- public static final int VK_GREATER = 0xa0;
+ public static final short VK_GREATER = (short) 0xa0;
/** For European keyboards */
- public static final int VK_BRACELEFT = 0xa1;
+ public static final short VK_BRACELEFT = (short) 0xa1;
/** For European keyboards */
- public static final int VK_BRACERIGHT = 0xa2;
+ public static final short VK_BRACERIGHT = (short) 0xa2;
/**
* Constant for the "@" key.
*/
- public static final int VK_AT = 0x0200;
+ public static final short VK_AT = (short) 0x0200;
/**
* Constant for the ":" key.
*/
- public static final int VK_COLON = 0x0201;
+ public static final short VK_COLON = (short) 0x0201;
/**
* Constant for the "^" key.
*/
- public static final int VK_CIRCUMFLEX = 0x0202;
+ public static final short VK_CIRCUMFLEX = (short) 0x0202;
/**
* Constant for the "$" key.
*/
- public static final int VK_DOLLAR = 0x0203;
+ public static final short VK_DOLLAR = (short) 0x0203;
/**
* Constant for the Euro currency sign key.
*/
- public static final int VK_EURO_SIGN = 0x0204;
+ public static final short VK_EURO_SIGN = (short) 0x0204;
/**
* Constant for the "!" key.
*/
- public static final int VK_EXCLAMATION_MARK = 0x0205;
+ public static final short VK_EXCLAMATION_MARK = (short) 0x0205;
/**
* Constant for the inverted exclamation mark key.
*/
- public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
+ public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0x0206;
/**
* Constant for the "(" key.
*/
- public static final int VK_LEFT_PARENTHESIS = 0x0207;
+ public static final short VK_LEFT_PARENTHESIS = (short) 0x0207;
/**
* Constant for the "#" key.
*/
- public static final int VK_NUMBER_SIGN = 0x0208;
+ public static final short VK_NUMBER_SIGN = (short) 0x0208;
/**
* Constant for the "+" key.
*/
- public static final int VK_PLUS = 0x0209;
+ public static final short VK_PLUS = (short) 0x0209;
/**
* Constant for the ")" key.
*/
- public static final int VK_RIGHT_PARENTHESIS = 0x020A;
+ public static final short VK_RIGHT_PARENTHESIS = (short) 0x020A;
/**
* Constant for the "_" key.
*/
- public static final int VK_UNDERSCORE = 0x020B;
+ public static final short VK_UNDERSCORE = (short) 0x020B;
/**
* Constant for the Microsoft Windows "Windows" key.
* It is used for both the left and right version of the key.
*/
- public static final int VK_WINDOWS = 0x020C;
+ public static final short VK_WINDOWS = (short) 0x020C;
/**
* Constant for the Microsoft Windows Context Menu key.
*/
- public static final int VK_CONTEXT_MENU = 0x020D;
+ 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 int VK_FINAL = 0x0018;
+ 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 int VK_CONVERT = 0x001C;
+ public static final short VK_CONVERT = (short) 0x001C;
/** Constant for the Don't Convert function key. */
/* Japanese PC 106 keyboard: muhenkan */
- public static final int VK_NONCONVERT = 0x001D;
+ public static final short VK_NONCONVERT = (short) 0x001D;
/** Constant for the Accept or Commit function key. */
/* Japanese Solaris keyboard: kakutei */
- public static final int VK_ACCEPT = 0x001E;
+ public static final short VK_ACCEPT = (short) 0x001E;
/* not clear what this means - listed in Microsoft Windows API */
- public static final int VK_MODECHANGE = 0x001F;
+ 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 int VK_KANA = 0x0015;
+ 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 int VK_KANJI = 0x0019;
+ public static final short VK_KANJI = (short) 0x0019;
/**
* Constant for the Alphanumeric function key.
*/
/* Japanese PC 106 keyboard: eisuu */
- public static final int VK_ALPHANUMERIC = 0x00F0;
+ public static final short VK_ALPHANUMERIC = (short) 0x00F0;
/**
* Constant for the Katakana function key.
*/
/* Japanese PC 106 keyboard: katakana */
- public static final int VK_KATAKANA = 0x00F1;
+ public static final short VK_KATAKANA = (short) 0x00F1;
/**
* Constant for the Hiragana function key.
*/
/* Japanese PC 106 keyboard: hiragana */
- public static final int VK_HIRAGANA = 0x00F2;
+ public static final short VK_HIRAGANA = (short) 0x00F2;
/**
* Constant for the Full-Width Characters function key.
*/
/* Japanese PC 106 keyboard: zenkaku */
- public static final int VK_FULL_WIDTH = 0x00F3;
+ public static final short VK_FULL_WIDTH = (short) 0x00F3;
/**
* Constant for the Half-Width Characters function key.
*/
/* Japanese PC 106 keyboard: hankaku */
- public static final int VK_HALF_WIDTH = 0x00F4;
+ public static final short VK_HALF_WIDTH = (short) 0x00F4;
/**
* Constant for the Roman Characters function key.
*/
/* Japanese PC 106 keyboard: roumaji */
- public static final int VK_ROMAN_CHARACTERS = 0x00F5;
+ 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 int VK_ALL_CANDIDATES = 0x0100;
+ 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 int VK_PREVIOUS_CANDIDATE = 0x0101;
+ 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 int VK_CODE_INPUT = 0x0102;
+ public static final short VK_CODE_INPUT = (short) 0x0102;
/**
* 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 int VK_JAPANESE_KATAKANA = 0x0103;
+ public static final short VK_JAPANESE_KATAKANA = (short) 0x0103;
/**
* 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 int VK_JAPANESE_HIRAGANA = 0x0104;
+ public static final short VK_JAPANESE_HIRAGANA = (short) 0x0104;
/**
* 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 int VK_JAPANESE_ROMAN = 0x0105;
+ public static final short VK_JAPANESE_ROMAN = (short) 0x0105;
/**
* 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 int VK_KANA_LOCK = 0x0106;
+ 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 int VK_INPUT_METHOD_ON_OFF = 0x0107;
+ public static final short VK_INPUT_METHOD_ON_OFF = (short) 0x0107;
/* for Sun keyboards */
- public static final int VK_CUT = 0xFFD1;
- public static final int VK_COPY = 0xFFCD;
- public static final int VK_PASTE = 0xFFCF;
- public static final int VK_UNDO = 0xFFCB;
- public static final int VK_AGAIN = 0xFFC9;
- public static final int VK_FIND = 0xFFD0;
- public static final int VK_PROPS = 0xFFCA;
- public static final int VK_STOP = 0xFFC8;
+ 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 int VK_COMPOSE = 0xFF20;
+ public static final short VK_COMPOSE = (short) 0xFF20;
/**
* Constant for the AltGraph function key.
*/
- public static final int VK_ALT_GRAPH = 0xFF7E;
+ public static final short VK_ALT_GRAPH = (short) 0xFF7E;
/**
* Constant for the Begin key.
*/
- public static final int VK_BEGIN = 0xFF58;
+ public static final short VK_BEGIN = (short) 0xFF58;
/**
* This value is used to indicate that the keyCode is unknown.
* KEY_TYPED events do not have a keyCode value; this value
* is used instead.
*/
- public static final int VK_UNDEFINED = 0x0;
+ public static final short VK_UNDEFINED = (short) 0x0;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java
index dae343d80..5bca733d3 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java
@@ -34,10 +34,22 @@
package com.jogamp.newt.event;
+/**
+ * Listener for {@link KeyEvent}s.
+ *
+ * @see KeyEvent
+ */
public interface KeyListener extends NEWTEventListener
{
- public void keyPressed(KeyEvent e);
- public void keyReleased(KeyEvent e);
- public void keyTyped(KeyEvent e) ;
+ /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */
+ public void keyPressed(KeyEvent e);
+ /** A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */
+ public void keyReleased(KeyEvent e);
+
+ /**
+ * A {@link #isPrintableKey() printable} key has been {@link KeyEvent#EVENT_KEY_TYPED typed} (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. See {@link KeyEvent}.
+ * @deprecated Redundant, will be removed soon. Use {@link #keyReleased(KeyEvent)} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}.
+ */
+ public void keyTyped(KeyEvent e) ;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index e6b3d8a24..23549533e 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -38,47 +38,47 @@ package com.jogamp.newt.event;
public class MouseEvent extends InputEvent
{
/** ID for button 1, value <code>1</code> */
- public static final int BUTTON1 = 1;
+ public static final short BUTTON1 = 1;
/** ID for button 2, value <code>2</code> */
- public static final int BUTTON2 = 2;
+ public static final short BUTTON2 = 2;
/** ID for button 3, value <code>3</code> */
- public static final int BUTTON3 = 3;
+ public static final short BUTTON3 = 3;
/** ID for button 4, value <code>4</code> */
- public static final int BUTTON4 = 4;
+ public static final short BUTTON4 = 4;
/** ID for button 5, value <code>5</code> */
- public static final int BUTTON5 = 5;
+ public static final short BUTTON5 = 5;
/** ID for button 6, value <code>6</code> */
- public static final int BUTTON6 = 6;
+ public static final short BUTTON6 = 6;
/** ID for button 6, value <code>7</code> */
- public static final int BUTTON7 = 7;
+ public static final short BUTTON7 = 7;
/** ID for button 6, value <code>8</code> */
- public static final int BUTTON8 = 8;
+ public static final short BUTTON8 = 8;
/** ID for button 6, value <code>9</code> */
- public static final int BUTTON9 = 9;
+ public static final short BUTTON9 = 9;
/** Maximum number of buttons, value <code>16</code> */
- public static final int BUTTON_NUMBER = 16;
+ public static final short BUTTON_NUMBER = 16;
- public static final int getClickTimeout() {
+ public static final short getClickTimeout() {
return 300;
}
- public MouseEvent(int eventType, Object source, long when,
- int modifiers, int x, int y, int clickCount, int button,
+ public MouseEvent(short eventType, Object source, long when,
+ int modifiers, int x, int y, short clickCount, short button,
float rotation)
{
super(eventType, source, when, modifiers);
this.x = new int[]{x};
this.y = new int[]{y};
this.pressure = new float[]{0};
- this.pointerids = new int[]{-1};
+ this.pointerids = new short[]{-1};
this.clickCount=clickCount;
this.button=button;
this.wheelRotation = rotation;
}
- public MouseEvent(int eventType, Object source, long when,
- int modifiers, int[] x, int[] y, float[] pressure, int[] pointerids, int clickCount, int button,
+ public MouseEvent(short eventType, Object source, long when,
+ int modifiers, int[] x, int[] y, float[] pressure, short[] pointerids, short clickCount, short button,
float rotation)
{
super(eventType, source, when, modifiers);
@@ -107,17 +107,17 @@ public class MouseEvent extends InputEvent
* @return the pointer id for the data at index.
* return -1 if index not available.
*/
- public int getPointerId(int index) {
+ public short getPointerId(int index) {
if(index >= pointerids.length)
return -1;
return pointerids[index];
}
- public int getButton() {
+ public short getButton() {
return button;
}
- public int getClickCount() {
+ public short getClickCount() {
return clickCount;
}
public int getX() {
@@ -208,7 +208,7 @@ public class MouseEvent extends InputEvent
return super.toString(sb).append("]");
}
- public static String getEventTypeString(int type) {
+ public static String getEventTypeString(short type) {
switch(type) {
case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED";
case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED";
@@ -221,17 +221,18 @@ public class MouseEvent extends InputEvent
default: return "unknown (" + type + ")";
}
}
- private final int x[], y[], clickCount, button;
+ private final int x[], y[];;
+ private final short clickCount, button;
private final float wheelRotation;
private final float pressure[];
- private final int pointerids[];
+ private final short pointerids[];
- public static final int EVENT_MOUSE_CLICKED = 200;
- public static final int EVENT_MOUSE_ENTERED = 201;
- public static final int EVENT_MOUSE_EXITED = 202;
- public static final int EVENT_MOUSE_PRESSED = 203;
- public static final int EVENT_MOUSE_RELEASED = 204;
- public static final int EVENT_MOUSE_MOVED = 205;
- public static final int EVENT_MOUSE_DRAGGED = 206;
- public static final int EVENT_MOUSE_WHEEL_MOVED = 207;
+ public static final short EVENT_MOUSE_CLICKED = 200;
+ public static final short EVENT_MOUSE_ENTERED = 201;
+ public static final short EVENT_MOUSE_EXITED = 202;
+ public static final short EVENT_MOUSE_PRESSED = 203;
+ public static final short EVENT_MOUSE_RELEASED = 204;
+ public static final short EVENT_MOUSE_MOVED = 205;
+ public static final short EVENT_MOUSE_DRAGGED = 206;
+ public static final short EVENT_MOUSE_WHEEL_MOVED = 207;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
index 9d8d92ff6..b8de6eb18 100644
--- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
@@ -48,81 +48,21 @@ package com.jogamp.newt.event;
*/
@SuppressWarnings("serial")
public class NEWTEvent extends java.util.EventObject {
- private final boolean isSystemEvent;
- private final int eventType;
+ private final short eventType;
private final long when;
private Object attachment;
static final boolean DEBUG = false;
- // 0: NEWTEvent.java
- // 1: InputEvent.java
- // 2: KeyEvent.java
- // 3: com.jogamp.newt.Window
- // 3: com.jogamp.newt.event.awt.AWTNewtEventFactory
- // 2: MouseEvent.java
- // 3: com.jogamp.newt.Window
- // 3: com.jogamp.newt.event.awt.AWTNewtEventFactory
- // 1: WindowEvent.java
- // 2: com.jogamp.newt.Window
- // 2: com.jogamp.newt.event.awt.AWTNewtEventFactory
- //
- // FIXME: verify the isSystemEvent evaluation
- //
- static final String WindowClazzName = "com.jogamp.newt.Window" ;
- static final String AWTNewtEventFactoryClazzName = "com.jogamp.newt.event.awt.AWTNewtEventFactory" ;
-
- /**
- static final boolean evaluateIsSystemEvent(NEWTEvent event, Throwable t) {
- StackTraceElement[] stack = t.getStackTrace();
- if(stack.length==0 || null==stack[0]) {
- return false;
- }
- if(DEBUG) {
- for (int i = 0; i < stack.length && i<5; i++) {
- System.err.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName());
- }
- }
-
- String clazzName = null;
-
- if( event instanceof com.jogamp.newt.event.WindowEvent ) {
- if ( stack.length > 2 ) {
- clazzName = stack[2].getClassName();
- }
- } else if( (event instanceof com.jogamp.newt.event.MouseEvent) ||
- (event instanceof com.jogamp.newt.event.KeyEvent) ) {
- if ( stack.length > 3 ) {
- clazzName = stack[3].getClassName();
- }
- }
-
- boolean res = null!=clazzName && (
- clazzName.equals(WindowClazzName) ||
- clazzName.equals(AWTNewtEventFactoryClazzName) ) ;
- if(DEBUG) {
- System.err.println("system: "+res);
- }
- return res;
- } */
-
- protected NEWTEvent(int eventType, Object source, long when) {
+ protected NEWTEvent(short eventType, Object source, long when) {
super(source);
- // this.isSystemEvent = evaluateIsSystemEvent(this, new Throwable());
- this.isSystemEvent = false; // FIXME: Need a more efficient way to determine system events
this.eventType = eventType;
this.when = when;
this.attachment=null;
}
- /** Indicates whether this event was produced by the system or
- generated by user code. */
- public final boolean isSystemEvent() {
- return isSystemEvent;
- }
-
/** Returns the event type of this event. */
- public final int getEventType() {
+ public final short getEventType() {
return eventType;
}
@@ -158,10 +98,10 @@ public class NEWTEvent extends java.util.EventObject {
if(null == sb) {
sb = new StringBuilder();
}
- return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]");
+ return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]");
}
- static String toHexString(int hex) {
- return "0x" + Integer.toHexString(hex);
+ static String toHexString(short hex) {
+ return "0x" + Integer.toHexString( (int)hex & 0x0000FFFF );
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
index 163b51439..24b3b380a 100644
--- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
@@ -41,19 +41,19 @@ package com.jogamp.newt.event;
*/
@SuppressWarnings("serial")
public class WindowEvent extends NEWTEvent {
- public static final int EVENT_WINDOW_RESIZED = 100;
- public static final int EVENT_WINDOW_MOVED = 101;
- public static final int EVENT_WINDOW_DESTROY_NOTIFY = 102;
- public static final int EVENT_WINDOW_GAINED_FOCUS = 103;
- public static final int EVENT_WINDOW_LOST_FOCUS = 104;
- public static final int EVENT_WINDOW_REPAINT = 105;
- public static final int EVENT_WINDOW_DESTROYED = 106;
+ public static final short EVENT_WINDOW_RESIZED = 100;
+ public static final short EVENT_WINDOW_MOVED = 101;
+ public static final short EVENT_WINDOW_DESTROY_NOTIFY = 102;
+ public static final short EVENT_WINDOW_GAINED_FOCUS = 103;
+ public static final short EVENT_WINDOW_LOST_FOCUS = 104;
+ public static final short EVENT_WINDOW_REPAINT = 105;
+ public static final short EVENT_WINDOW_DESTROYED = 106;
- public WindowEvent(int eventType, Object source, long when) {
+ public WindowEvent(short eventType, Object source, long when) {
super(eventType, source, when);
}
- public static String getEventTypeString(int type) {
+ public static String getEventTypeString(short type) {
switch(type) {
case EVENT_WINDOW_RESIZED: return "WINDOW_RESIZED";
case EVENT_WINDOW_MOVED: return "WINDOW_MOVED";
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java
index e3f0373ec..a0f6e2cb4 100644
--- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java
@@ -34,7 +34,7 @@ import javax.media.nativewindow.util.Rectangle;
public class WindowUpdateEvent extends WindowEvent {
final Rectangle bounds;
- public WindowUpdateEvent(int eventType, Object source, long when, Rectangle bounds)
+ public WindowUpdateEvent(short eventType, Object source, long when, Rectangle bounds)
{
super(eventType, source, when);
this.bounds = bounds;
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
index 64071eed6..1edef347b 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -72,14 +72,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
@Override
public void keyReleased(java.awt.event.KeyEvent e) {
com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
- com.jogamp.newt.event.KeyEvent keyTypedEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, e, newtWindow);
if(null!=newtListener) {
final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener;
newtKeyListener.keyReleased(keyReleaseEvt);
- newtKeyListener.keyTyped(keyTypedEvt);
} else {
enqueueEvent(false, keyReleaseEvt);
- enqueueEvent(false, keyTypedEvt);
}
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index cb43fae32..73c0d2754 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -121,10 +121,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private ArrayList<NativeWindow> childWindows = new ArrayList<NativeWindow>();
private ArrayList<MouseListener> mouseListeners = new ArrayList<MouseListener>();
- private int mouseButtonPressed = 0; // current pressed mouse button number
- private int mouseButtonModMask = 0; // current pressed mouse button modifier mask
+ private short mouseButtonPressed = (short)0; // current pressed mouse button number
+ private int mouseButtonModMask = 0; // current pressed mouse button modifier mask
private long lastMousePressed = 0; // last time when a mouse button was pressed
- private int lastMouseClickCount = 0; // last mouse button click count
+ private short lastMouseClickCount = (short)0; // last mouse button click count
private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic)
private Point lastMousePosition = new Point();
@@ -1976,17 +1976,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
//
// MouseListener/Event Support
//
- public void sendMouseEvent(int eventType, int modifiers,
- int x, int y, int button, float rotation) {
+ public void sendMouseEvent(short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation);
}
- public void enqueueMouseEvent(boolean wait, int eventType, int modifiers,
- int x, int y, int button, float rotation) {
+ public void enqueueMouseEvent(boolean wait, short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation);
}
- protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers,
- int x, int y, int button, float rotation) {
+ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) {
if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) {
x = lastMousePosition.getX();
@@ -1996,9 +1996,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
x = Math.min(Math.max(x, 0), getWidth()-1);
y = Math.min(Math.max(y, 0), getHeight()-1);
mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED;
- lastMousePressed = 0; // clear state
- mouseButtonPressed = 0; // clear state
- mouseButtonModMask = 0; // clear state
+ // clear states
+ lastMousePressed = 0;
+ lastMouseClickCount = (short)0;
+ mouseButtonPressed = 0;
+ mouseButtonModMask = 0;
}
if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) {
return; // .. invalid ..
@@ -2013,10 +2015,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(!mouseInWindow) {
mouseInWindow = true;
eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when,
- modifiers, x, y, lastMouseClickCount, button, 0);
- lastMousePressed = 0; // clear state
- mouseButtonPressed = 0; // clear state
- mouseButtonModMask = 0; // clear state
+ modifiers, x, y, (short)0, (short)0, (short)0);
+ // clear states
+ lastMousePressed = 0;
+ lastMouseClickCount = (short)0;
+ mouseButtonPressed = 0;
+ mouseButtonModMask = 0;
} else if( lastMousePosition.getX() == x && lastMousePosition.getY()==y ) {
if(DEBUG_MOUSE_EVENT) {
System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition);
@@ -2046,7 +2050,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if( when - lastMousePressed < MouseEvent.getClickTimeout() ) {
lastMouseClickCount++;
} else {
- lastMouseClickCount=1;
+ lastMouseClickCount=(short)1;
}
lastMousePressed = when;
mouseButtonPressed = button;
@@ -2060,7 +2064,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when,
modifiers, x, y, lastMouseClickCount, button, 0);
} else {
- lastMouseClickCount = 0;
+ lastMouseClickCount = (short)0;
lastMousePressed = 0;
}
mouseButtonPressed = 0;
@@ -2068,15 +2072,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
} else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) {
if ( mouseButtonPressed > 0 ) {
e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
- modifiers, x, y, 1, mouseButtonPressed, 0);
+ modifiers, x, y, (short)1, mouseButtonPressed, 0);
} else {
e = new MouseEvent(eventType, this, when,
- modifiers, x, y, 0, button, 0);
+ modifiers, x, y, (short)0, button, (short)0);
}
} else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) {
- e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, rotation);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotation);
} else {
- e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, 0);
}
if( null != eEntered ) {
if(DEBUG_MOUSE_EVENT) {
@@ -2203,23 +2207,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return 0 <= keyCode && keyCode < keyRepeatState.capacity();
}
- public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
- doKeyEvent(false, false, eventType, modifiers, keyCode, keyChar);
+ 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) );
}
- public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- doKeyEvent(true, wait, eventType, modifiers, keyCode, 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) );
}
- protected void doKeyEvent(boolean enqueue, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask
- if( enqueue ) {
- enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) );
- } else {
- consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) );
- }
- }
-
public void addKeyListener(KeyListener l) {
addKeyListener(-1, l);
}
@@ -2290,6 +2287,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return keyListeners.toArray(new KeyListener[keyListeners.size()]);
}
+ @SuppressWarnings("deprecation")
private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) {
switch(e.getEventType()) {
case KeyEvent.EVENT_KEY_PRESSED:
@@ -2307,21 +2305,49 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return InputEvent.consumedTag == e.getAttachment();
}
+ @SuppressWarnings("deprecation")
protected void consumeKeyEvent(KeyEvent e) {
- boolean consumed;
+ boolean consumedE = false, consumedTyped = false;
+ if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) {
+ throw new InternalError("Deprecated KeyEvent.EVENT_KEY_TYPED is synthesized - don't send/enqueue it!");
+ }
+
+ // 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());
+ } else {
+ eTyped = null;
+ }
if(null != keyboardFocusHandler) {
- consumed = propagateKeyEvent(e, keyboardFocusHandler);
+ consumedE = propagateKeyEvent(e, keyboardFocusHandler);
if(DEBUG_KEY_EVENT) {
- System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumed);
+ System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE);
}
- } else {
- consumed = false;
- if(DEBUG_KEY_EVENT) {
+ if( null != eTyped ) {
+ consumedTyped = propagateKeyEvent(eTyped, keyboardFocusHandler);
+ if(DEBUG_KEY_EVENT) {
+ System.err.println("consumeKeyEvent: "+eTyped+", keyboardFocusHandler consumed: "+consumedTyped);
+ }
+ }
+ }
+ if(DEBUG_KEY_EVENT) {
+ if( !consumedE ) {
System.err.println("consumeKeyEvent: "+e);
}
}
- for(int i = 0; !consumed && i < keyListeners.size(); i++ ) {
- consumed = propagateKeyEvent(e, keyListeners.get(i));
+ for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) {
+ consumedE = propagateKeyEvent(e, keyListeners.get(i));
+ }
+ if( null != eTyped ) {
+ if(DEBUG_KEY_EVENT) {
+ if( !consumedTyped ) {
+ System.err.println("consumeKeyEvent: "+eTyped);
+ }
+ }
+ for(int i = 0; !consumedTyped && i < keyListeners.size(); i++ ) {
+ consumedTyped = propagateKeyEvent(eTyped, keyListeners.get(i));
+ }
}
}
@@ -2329,11 +2355,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// WindowListener/Event Support
//
public void sendWindowEvent(int eventType) {
- consumeWindowEvent( new WindowEvent(eventType, this, System.currentTimeMillis()) );
+ consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME
}
public void enqueueWindowEvent(boolean wait, int eventType) {
- enqueueEvent( wait, new WindowEvent(eventType, this, System.currentTimeMillis()) );
+ enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME
}
public void addWindowListener(WindowListener l) {
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index e11d79ddc..b90c2106e 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -28,8 +28,6 @@
package jogamp.newt.awt.event;
-import com.jogamp.common.util.IntIntHashMap;
-
/**
*
* <a name="AWTEventModifierMapping"><h5>AWT Event Modifier Mapping</h5></a>
@@ -76,47 +74,10 @@ import com.jogamp.common.util.IntIntHashMap;
*/
public class AWTNewtEventFactory {
- protected static final IntIntHashMap eventTypeAWT2NEWT;
-
/** zero-based AWT button mask array filled by {@link #getAWTButtonDownMask(int)}, allowing fast lookup. */
private static int awtButtonDownMasks[] ;
static {
- IntIntHashMap map = new IntIntHashMap();
- map.setKeyNotFoundValue(0xFFFFFFFF);
- // n/a map.put(java.awt.event.WindowEvent.WINDOW_OPENED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED);
- map.put(java.awt.event.WindowEvent.WINDOW_CLOSING, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
- map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED);
- // n/a map.put(java.awt.event.WindowEvent.WINDOW_ICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED);
- // n/a map.put(java.awt.event.WindowEvent.WINDOW_DEICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED);
- map.put(java.awt.event.WindowEvent.WINDOW_ACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
- map.put(java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
- map.put(java.awt.event.FocusEvent.FOCUS_GAINED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
- map.put(java.awt.event.WindowEvent.WINDOW_DEACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
- map.put(java.awt.event.WindowEvent.WINDOW_LOST_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
- map.put(java.awt.event.FocusEvent.FOCUS_LOST, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS);
- // n/a map.put(java.awt.event.WindowEvent.WINDOW_STATE_CHANGED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED);
-
- map.put(java.awt.event.ComponentEvent.COMPONENT_MOVED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED);
- map.put(java.awt.event.ComponentEvent.COMPONENT_RESIZED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED);
- // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_SHOWN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN);
- // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_HIDDEN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN);
-
- map.put(java.awt.event.MouseEvent.MOUSE_CLICKED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED);
- map.put(java.awt.event.MouseEvent.MOUSE_PRESSED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED);
- map.put(java.awt.event.MouseEvent.MOUSE_RELEASED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED);
- map.put(java.awt.event.MouseEvent.MOUSE_MOVED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED);
- map.put(java.awt.event.MouseEvent.MOUSE_ENTERED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED);
- map.put(java.awt.event.MouseEvent.MOUSE_EXITED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED);
- map.put(java.awt.event.MouseEvent.MOUSE_DRAGGED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED);
- map.put(java.awt.event.MouseEvent.MOUSE_WHEEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED);
-
- map.put(java.awt.event.KeyEvent.KEY_PRESSED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED);
- map.put(java.awt.event.KeyEvent.KEY_RELEASED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED);
- map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED);
-
- eventTypeAWT2NEWT = map;
-
// There is an assumption in awtModifiers2Newt(int,int,boolean)
// that the awtButtonMasks and newtButtonMasks are peers, i.e.
// a given index refers to the same button in each array.
@@ -135,6 +96,41 @@ public class AWTNewtEventFactory {
}
}
+ public static final short eventTypeAWT2NEWT(int awtType) {
+ switch( awtType ) {
+ // n/a case java.awt.event.WindowEvent.WINDOW_OPENED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED;
+ case java.awt.event.WindowEvent.WINDOW_CLOSING: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY;
+ case java.awt.event.WindowEvent.WINDOW_CLOSED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED;
+ // n/a case java.awt.event.WindowEvent.WINDOW_ICONIFIED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED;
+ // n/a case java.awt.event.WindowEvent.WINDOW_DEICONIFIED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED;
+ case java.awt.event.WindowEvent.WINDOW_ACTIVATED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS;
+ case java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS;
+ case java.awt.event.FocusEvent.FOCUS_GAINED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS;
+ case java.awt.event.WindowEvent.WINDOW_DEACTIVATED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS;
+ case java.awt.event.WindowEvent.WINDOW_LOST_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS;
+ case java.awt.event.FocusEvent.FOCUS_LOST: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS;
+ // n/a case java.awt.event.WindowEvent.WINDOW_STATE_CHANGED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED;
+
+ case java.awt.event.ComponentEvent.COMPONENT_MOVED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED;
+ case java.awt.event.ComponentEvent.COMPONENT_RESIZED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED;
+ // n/a case java.awt.event.ComponentEvent.COMPONENT_SHOWN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN;
+ // n/a case java.awt.event.ComponentEvent.COMPONENT_HIDDEN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN;
+
+ case java.awt.event.MouseEvent.MOUSE_CLICKED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED;
+ case java.awt.event.MouseEvent.MOUSE_PRESSED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
+ case java.awt.event.MouseEvent.MOUSE_RELEASED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
+ case java.awt.event.MouseEvent.MOUSE_MOVED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED;
+ case java.awt.event.MouseEvent.MOUSE_ENTERED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED;
+ case java.awt.event.MouseEvent.MOUSE_EXITED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED;
+ case java.awt.event.MouseEvent.MOUSE_DRAGGED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED;
+ case java.awt.event.MouseEvent.MOUSE_WHEEL: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
+
+ case java.awt.event.KeyEvent.KEY_PRESSED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED;
+ case java.awt.event.KeyEvent.KEY_RELEASED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED;
+ }
+ return (short)0;
+ }
+
private static int getAWTButtonDownMaskImpl(int button) {
/**
* java.awt.event.InputEvent.getMaskForButton(button);
@@ -227,48 +223,48 @@ public class AWTNewtEventFactory {
return newtMods;
}
- public static final int awtButton2Newt(int awtButton) {
+ public static final short awtButton2Newt(int awtButton) {
if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) {
- return awtButton;
+ return (short)awtButton;
} else {
- return 0;
+ return (short)0;
}
}
public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) {
- final int newtType = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != newtType) {
+ final short newtType = eventTypeAWT2NEWT(event.getID());
+ if( (short)0 != newtType ) {
return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis());
}
return null; // no mapping ..
}
public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) {
- final int newtType = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != newtType) {
+ final short newtType = eventTypeAWT2NEWT(event.getID());
+ if( (short)0 != newtType ) {
return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
}
return null; // no mapping ..
}
public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) {
- final int newtType = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != newtType) {
+ final short newtType = eventTypeAWT2NEWT(event.getID());
+ if( (short)0 != newtType ) {
return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
}
return null; // no mapping ..
}
public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) {
- final int newtType = eventTypeAWT2NEWT.get(event.getID());
- if(0xFFFFFFFF != newtType) {
+ final short newtType = eventTypeAWT2NEWT(event.getID());
+ if( (short)0 != newtType ) {
float rotation = 0;
if (event instanceof java.awt.event.MouseWheelEvent) {
// AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up.
rotation = -1f * ((java.awt.event.MouseWheelEvent)event).getWheelRotation();
}
- final int newtButton = awtButton2Newt(event.getButton());
+ final short newtButton = awtButton2Newt(event.getButton());
int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx());
mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK
if(null!=newtSource) {
@@ -281,25 +277,25 @@ public class AWTNewtEventFactory {
}
return new com.jogamp.newt.event.MouseEvent(
newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
- mods, event.getX(), event.getY(), event.getClickCount(),
+ mods, event.getX(), event.getY(), (short)event.getClickCount(),
newtButton, rotation);
}
return null; // no mapping ..
}
public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
- return createKeyEvent(eventTypeAWT2NEWT.get(event.getID()), event, newtSource);
+ return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, newtSource);
}
- public static final com.jogamp.newt.event.KeyEvent createKeyEvent(int newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
- if(0xFFFFFFFF != newtType) {
+ 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(
newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()),
- event.getKeyCode(), event.getKeyChar());
+ keyCode, keyCode, 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 dc1e8aeef..22e2cbc51 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -42,78 +42,62 @@ public class AndroidNewtEventFactory {
/** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */
private static final int ACTION_SCROLL = 8;
- private static final int aMotionEventType2Newt(int aType) {
- final int nType;
+ private static final short aMotionEventType2Newt(int aType) {
switch( aType ) {
case android.view.MotionEvent.ACTION_DOWN:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
case android.view.MotionEvent.ACTION_UP:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
case android.view.MotionEvent.ACTION_MOVE:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED;
case android.view.MotionEvent.ACTION_CANCEL:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
case android.view.MotionEvent.ACTION_OUTSIDE:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED;
- break;
- //
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED;
case android.view.MotionEvent.ACTION_POINTER_DOWN:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
case android.view.MotionEvent.ACTION_POINTER_UP:
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
// case ACTION_HOVER_MOVE
case ACTION_SCROLL: // API Level 12 !
- nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
- break;
+ return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
// case ACTION_HOVER_ENTER
// case ACTION_HOVER_EXIT
- default:
- nType = 0xFFFFFFFF;
}
- return nType;
+ return (short)0;
}
- private static final int aAccessibilityEventType2Newt(int aType) {
- final int nType;
+ private static final short aAccessibilityEventType2Newt(int aType) {
switch( aType ) {
case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED:
- nType = com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; break;
- default:
- nType = 0xFFFFFFFF;
+ return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS;
}
- return nType;
+ return (short)0;
}
- private static final int aKeyEventType2NewtEventType(int androidKeyAction) {
+ private static final short aKeyEventType2NewtEventType(int androidKeyAction) {
switch(androidKeyAction) {
case android.view.KeyEvent.ACTION_DOWN:
case android.view.KeyEvent.ACTION_MULTIPLE:
return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED;
case android.view.KeyEvent.ACTION_UP:
return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED;
- default:
- return 0;
}
+ return (short)0;
}
- private static final int aKeyCode2NewtKeyCode(int androidKeyCode) {
+ private static final short aKeyCode2NewtKeyCode(int androidKeyCode) {
if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) {
- return com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ;
+ return (short) ( com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) );
}
if(android.view.KeyEvent.KEYCODE_A <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_Z) {
- return com.jogamp.newt.event.KeyEvent.VK_A + ( androidKeyCode - android.view.KeyEvent.KEYCODE_A ) ;
+ return (short) ( com.jogamp.newt.event.KeyEvent.VK_A + ( androidKeyCode - android.view.KeyEvent.KEYCODE_A ) );
}
if(android.view.KeyEvent.KEYCODE_F1 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_F12) {
- return com.jogamp.newt.event.KeyEvent.VK_F1 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_F1 ) ;
+ return (short) ( com.jogamp.newt.event.KeyEvent.VK_F1 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_F1 ) );
}
if(android.view.KeyEvent.KEYCODE_NUMPAD_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_NUMPAD_9) {
- return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_NUMPAD_0 ) ;
+ return (short) ( com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_NUMPAD_0 ) );
}
switch(androidKeyCode) {
case android.view.KeyEvent.KEYCODE_COMMA: return com.jogamp.newt.event.KeyEvent.VK_COMMA;
@@ -144,7 +128,7 @@ public class AndroidNewtEventFactory {
case android.view.KeyEvent.KEYCODE_CTRL_LEFT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL;
case android.view.KeyEvent.KEYCODE_CTRL_RIGHT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; // ??
}
- return 0;
+ return (short)0;
}
private static final int aKeyModifiers2Newt(int androidMods) {
@@ -170,38 +154,29 @@ public class AndroidNewtEventFactory {
public com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) {
final int aType = event.getEventType();
- final int nType = aAccessibilityEventType2Newt(aType);
+ final short nType = aAccessibilityEventType2Newt(aType);
- if(0xFFFFFFFF != nType) {
+ if( (short)0 != nType) {
return new com.jogamp.newt.event.WindowEvent(nType, ((null==newtSource)?null:(Object)newtSource), event.getEventTime());
}
return null; // no mapping ..
}
- public com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) {
- final int type = aKeyEventType2NewtEventType(event.getAction());
+ public com.jogamp.newt.event.KeyEvent createKeyEvent(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) {
+ final short type = aKeyEventType2NewtEventType(event.getAction());
if(Window.DEBUG_MOUSE_EVENT) {
System.err.println("createKeyEvent: type 0x"+Integer.toHexString(type)+", keyCode 0x"+Integer.toHexString(keyCode)+", "+event);
}
- if(0xFFFFFFFF != type) {
- final int newtKeyCode = aKeyCode2NewtKeyCode(keyCode);
- if(0 != newtKeyCode) {
+ if( (short)0 != type) {
+ final short newtKeyCode = aKeyCode2NewtKeyCode(keyCode);
+ if( (short)0 != newtKeyCode ) {
final Object src = (null==newtSource)?null:(Object)newtSource;
final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() );
final int newtMods = aKeyModifiers2Newt(event.getMetaState());
- final com.jogamp.newt.event.KeyEvent ke1 = new com.jogamp.newt.event.KeyEvent(
- type, src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel());
-
- if( com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED == type ) {
- return new com.jogamp.newt.event.KeyEvent[] { ke1,
- new com.jogamp.newt.event.KeyEvent(
- com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED,
- src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()) };
- } else {
- return new com.jogamp.newt.event.KeyEvent[] { ke1 };
- }
+ return new com.jogamp.newt.event.KeyEvent(
+ type, src, unixTime, newtMods, newtKeyCode, newtKeyCode, event.getDisplayLabel());
}
}
return null;
@@ -218,7 +193,8 @@ public class AndroidNewtEventFactory {
//
// Prefilter Android Event (Gesture, ..) and determine final type
//
- final int aType, nType;
+ final int aType;
+ final short nType;
float[] rotationXY = null;
int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL
{
@@ -265,8 +241,8 @@ public class AndroidNewtEventFactory {
}
}
- if(0xFFFFFFFF != nType) {
- final int clickCount = 1;
+ if( (short)0 != nType ) {
+ final short clickCount = 1;
int modifiers = 0;
if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12
@@ -299,7 +275,7 @@ public class AndroidNewtEventFactory {
//
final int pCount;
final int pIndex;
- final int button;
+ final short button;
switch( aType ) {
case android.view.MotionEvent.ACTION_POINTER_DOWN:
case android.view.MotionEvent.ACTION_POINTER_UP: {
@@ -307,7 +283,7 @@ public class AndroidNewtEventFactory {
pCount = 1;
final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 !
if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) {
- button = b;
+ button = (short)b;
} else {
button = com.jogamp.newt.event.MouseEvent.BUTTON1;
}
@@ -326,7 +302,7 @@ public class AndroidNewtEventFactory {
final int[] x = new int[pCount];
final int[] y = new int[pCount];
final float[] pressure = new float[pCount];
- final int[] pointerIds = new int[pCount];
+ final short[] pointerIds = new short[pCount];
{
if(Window.DEBUG_MOUSE_EVENT) {
System.err.println("createMouseEvent: collect ptr-data ["+pIndex+".."+(pIndex+pCount-1)+", "+pCount+"], aType "+aType+", button "+button+", gestureScrollPointerDown "+gestureScrollPointerDown);
@@ -337,7 +313,7 @@ public class AndroidNewtEventFactory {
x[j] = (int)event.getX(i);
y[j] = (int)event.getY(i);
pressure[j] = event.getPressure(i);
- pointerIds[j] = event.getPointerId(i);
+ pointerIds[j] = (short)event.getPointerId(i);
if(Window.DEBUG_MOUSE_EVENT) {
System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]);
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java
index ee0c8f8b1..2d972f752 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java
@@ -38,11 +38,9 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo
@Override
public boolean onKey(View v, int keyCode, android.view.KeyEvent event) {
- final com.jogamp.newt.event.KeyEvent[] newtEvents = factory.createKeyEvents(keyCode, event, newtWindow);
- if(null != newtEvents) {
- for(int i=0; i<newtEvents.length; i++) {
- newtWindow.enqueueEvent(false, newtEvents[i]);
- }
+ final com.jogamp.newt.event.KeyEvent newtEvent = factory.createKeyEvent(keyCode, event, newtWindow);
+ if(null != newtEvent) {
+ newtWindow.enqueueEvent(false, newtEvent);
return true;
}
return false;
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java
index 5efce2524..2c0e6d3dd 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java
@@ -210,9 +210,9 @@ public class LinuxEventDeviceTracker implements WindowListener {
short code;
int value;
- int keyCode=KeyEvent.VK_UNDEFINED;
+ short keyCode=KeyEvent.VK_UNDEFINED;
char keyChar=' ';
- int eventType=0;
+ short eventType=0;
int modifiers=0;
loop:
@@ -263,24 +263,20 @@ public class LinuxEventDeviceTracker implements WindowListener {
case 0:
modifiers=0;
eventType=KeyEvent.EVENT_KEY_RELEASED;
- focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyChar);
- //Send syntetic typed
- focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, (char) keyChar);
+ focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar);
break;
case 1:
eventType=KeyEvent.EVENT_KEY_PRESSED;
- focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyChar);
+ focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar);
break;
case 2:
eventType=KeyEvent.EVENT_KEY_PRESSED;
modifiers=InputEvent.AUTOREPEAT_MASK;
//Send syntetic autorepeat release
- focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar);
- //Send syntetic typed
- focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar);
+ focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar);
- focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyChar);
+ focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar);
break;
}
break;
@@ -314,14 +310,15 @@ public class LinuxEventDeviceTracker implements WindowListener {
stop=true;
}
- private char NewtVKey2Unicode(int VK){
- if(KeyEvent.isPrintableKey(VK)){
+ private char NewtVKey2Unicode(short VK){
+ if( KeyEvent.isPrintableKey(VK) ){
return (char)VK;
}
return 0;
}
- private char LinuxEVKey2Unicode(short EVKey) {
+ @SuppressWarnings("unused")
+ private char LinuxEVKey2Unicode(short EVKey) {
// This is the stuff normally mapped by a system keymap
switch(EVKey){
@@ -377,9 +374,8 @@ public class LinuxEventDeviceTracker implements WindowListener {
return 0;
}
- private int LinuxEVKey2NewtVKey(short EVKey) {
- char vkCode = KeyEvent.VK_UNDEFINED;
-
+ private short LinuxEVKey2NewtVKey(short EVKey) {
+
switch(EVKey) {
case 1: // ESC
return KeyEvent.VK_ESCAPE;
@@ -886,8 +882,9 @@ public class LinuxEventDeviceTracker implements WindowListener {
if(Window.DEBUG_KEY_EVENT) {
System.out.println("LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey);
- }
- return vkCode;
+ }
+
+ return KeyEvent.VK_UNDEFINED;
}
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
index b8a326a6c..0d6278bfb 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
@@ -65,10 +65,10 @@ public class LinuxMouseTracker implements WindowListener {
private volatile boolean stop = false;
private int x = 0;
private int y = 0;
- private int buttonDown = 0;
+ private short buttonDown = 0;
private int old_x = 0;
private int old_y = 0;
- private int old_buttonDown = 0;
+ private short old_buttonDown = 0;
private WindowImpl focusedWindow = null;
private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller();
@@ -183,19 +183,15 @@ public class LinuxMouseTracker implements WindowListener {
if(old_x != x || old_y != y) {
// mouse moved
- focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, 0, 0 );
+ focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, (short)0, 0 );
}
if(old_buttonDown != buttonDown) {
// press/release
if( 0 != buttonDown ) {
- focusedWindow.sendMouseEvent(
- MouseEvent.EVENT_MOUSE_PRESSED,
- 0, wx, wy, buttonDown, 0 );
+ focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_PRESSED, 0, wx, wy, buttonDown, 0 );
} else {
- focusedWindow.sendMouseEvent(
- MouseEvent.EVENT_MOUSE_RELEASED,
- 0, wx, wy, old_buttonDown, 0 );
+ focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_RELEASED, 0, wx, wy, old_buttonDown, 0 );
}
}
} else {
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java
index 5966bd30f..c07576901 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java
@@ -31,56 +31,129 @@ import com.jogamp.newt.event.KeyEvent;
public class MacKeyUtil {
- // KeyCodes (independent)
- private static final int kVK_Return = 0x24;
- private static final int kVK_Tab = 0x30;
- private static final int kVK_Space = 0x31;
- private static final int kVK_Delete = 0x33;
- private static final int kVK_Escape = 0x35;
- private static final int kVK_Command = 0x37;
- private static final int kVK_Shift = 0x38;
- private static final int kVK_CapsLock = 0x39;
- private static final int kVK_Option = 0x3A;
- private static final int kVK_Control = 0x3B;
- private static final int kVK_RightShift = 0x3C;
- private static final int kVK_RightOption = 0x3D;
- private static final int kVK_RightControl = 0x3E;
- private static final int kVK_Function = 0x3F;
- private static final int kVK_F17 = 0x40;
- private static final int kVK_VolumeUp = 0x48;
- private static final int kVK_VolumeDown = 0x49;
- private static final int kVK_Mute = 0x4A;
- private static final int kVK_F18 = 0x4F;
- private static final int kVK_F19 = 0x50;
- private static final int kVK_F20 = 0x5A;
- private static final int kVK_F5 = 0x60;
- private static final int kVK_F6 = 0x61;
- private static final int kVK_F7 = 0x62;
- private static final int kVK_F3 = 0x63;
- private static final int kVK_F8 = 0x64;
- private static final int kVK_F9 = 0x65;
- private static final int kVK_F11 = 0x67;
- private static final int kVK_F13 = 0x69;
- private static final int kVK_F16 = 0x6A;
- private static final int kVK_F14 = 0x6B;
- private static final int kVK_F10 = 0x6D;
- private static final int kVK_F12 = 0x6F;
- private static final int kVK_F15 = 0x71;
- private static final int kVK_Help = 0x72;
- private static final int kVK_Home = 0x73;
- private static final int kVK_PageUp = 0x74;
- private static final int kVK_ForwardDelete = 0x75;
- private static final int kVK_F4 = 0x76;
- private static final int kVK_End = 0x77;
- private static final int kVK_F2 = 0x78;
- private static final int kVK_PageDown = 0x79;
- private static final int kVK_F1 = 0x7A;
- private static final int kVK_LeftArrow = 0x7B;
- private static final int kVK_RightArrow = 0x7C;
- private static final int kVK_DownArrow = 0x7D;
- private static final int kVK_UpArrow = 0x7E;
+ //
+ // KeyCodes (Layout Dependent)
+ //
+ private static final short kVK_ANSI_A = 0x00;
+ private static final short kVK_ANSI_S = 0x01;
+ private static final short kVK_ANSI_D = 0x02;
+ private static final short kVK_ANSI_F = 0x03;
+ private static final short kVK_ANSI_H = 0x04;
+ private static final short kVK_ANSI_G = 0x05;
+ private static final short kVK_ANSI_Z = 0x06;
+ private static final short kVK_ANSI_X = 0x07;
+ private static final short kVK_ANSI_C = 0x08;
+ private static final short kVK_ANSI_V = 0x09;
+ private static final short kVK_ANSI_B = 0x0B;
+ private static final short kVK_ANSI_Q = 0x0C;
+ private static final short kVK_ANSI_W = 0x0D;
+ private static final short kVK_ANSI_E = 0x0E;
+ private static final short kVK_ANSI_R = 0x0F;
+ private static final short kVK_ANSI_Y = 0x10;
+ private static final short kVK_ANSI_T = 0x11;
+ private static final short kVK_ANSI_1 = 0x12;
+ private static final short kVK_ANSI_2 = 0x13;
+ private static final short kVK_ANSI_3 = 0x14;
+ private static final short kVK_ANSI_4 = 0x15;
+ private static final short kVK_ANSI_6 = 0x16;
+ private static final short kVK_ANSI_5 = 0x17;
+ private static final short kVK_ANSI_Equal = 0x18;
+ private static final short kVK_ANSI_9 = 0x19;
+ private static final short kVK_ANSI_7 = 0x1A;
+ private static final short kVK_ANSI_Minus = 0x1B;
+ private static final short kVK_ANSI_8 = 0x1C;
+ private static final short kVK_ANSI_0 = 0x1D;
+ private static final short kVK_ANSI_RightBracket = 0x1E;
+ private static final short kVK_ANSI_O = 0x1F;
+ private static final short kVK_ANSI_U = 0x20;
+ private static final short kVK_ANSI_LeftBracket = 0x21;
+ private static final short kVK_ANSI_I = 0x22;
+ private static final short kVK_ANSI_P = 0x23;
+ private static final short kVK_ANSI_L = 0x25;
+ private static final short kVK_ANSI_J = 0x26;
+ private static final short kVK_ANSI_Quote = 0x27;
+ private static final short kVK_ANSI_K = 0x28;
+ private static final short kVK_ANSI_Semicolon = 0x29;
+ private static final short kVK_ANSI_Backslash = 0x2A;
+ private static final short kVK_ANSI_Comma = 0x2B;
+ private static final short kVK_ANSI_Slash = 0x2C;
+ private static final short kVK_ANSI_N = 0x2D;
+ private static final short kVK_ANSI_M = 0x2E;
+ private static final short kVK_ANSI_Period = 0x2F;
+ private static final short kVK_ANSI_Grave = 0x32;
+ private static final short kVK_ANSI_KeypadDecimal = 0x41;
+ private static final short kVK_ANSI_KeypadMultiply = 0x43;
+ private static final short kVK_ANSI_KeypadPlus = 0x45;
+ private static final short kVK_ANSI_KeypadClear = 0x47;
+ private static final short kVK_ANSI_KeypadDivide = 0x4B;
+ private static final short kVK_ANSI_KeypadEnter = 0x4C;
+ private static final short kVK_ANSI_KeypadMinus = 0x4E;
+ private static final short kVK_ANSI_KeypadEquals = 0x51;
+ private static final short kVK_ANSI_Keypad0 = 0x52;
+ private static final short kVK_ANSI_Keypad1 = 0x53;
+ private static final short kVK_ANSI_Keypad2 = 0x54;
+ private static final short kVK_ANSI_Keypad3 = 0x55;
+ private static final short kVK_ANSI_Keypad4 = 0x56;
+ private static final short kVK_ANSI_Keypad5 = 0x57;
+ private static final short kVK_ANSI_Keypad6 = 0x58;
+ private static final short kVK_ANSI_Keypad7 = 0x59;
+ private static final short kVK_ANSI_Keypad8 = 0x5B;
+ private static final short kVK_ANSI_Keypad9 = 0x5C;
+
+ //
+ // KeyCodes (Layout Independent)
+ //
+ private static final short kVK_Return = 0x24;
+ private static final short kVK_Tab = 0x30;
+ private static final short kVK_Space = 0x31;
+ private static final short kVK_Delete = 0x33;
+ private static final short kVK_Escape = 0x35;
+ private static final short kVK_Command = 0x37;
+ private static final short kVK_Shift = 0x38;
+ private static final short kVK_CapsLock = 0x39;
+ private static final short kVK_Option = 0x3A;
+ private static final short kVK_Control = 0x3B;
+ private static final short kVK_RightShift = 0x3C;
+ private static final short kVK_RightOption = 0x3D;
+ private static final short kVK_RightControl = 0x3E;
+ // private static final short kVK_Function = 0x3F;
+ private static final short kVK_F17 = 0x40;
+ // private static final short kVK_VolumeUp = 0x48;
+ // private static final short kVK_VolumeDown = 0x49;
+ // private static final short kVK_Mute = 0x4A;
+ private static final short kVK_F18 = 0x4F;
+ private static final short kVK_F19 = 0x50;
+ private static final short kVK_F20 = 0x5A;
+ private static final short kVK_F5 = 0x60;
+ private static final short kVK_F6 = 0x61;
+ private static final short kVK_F7 = 0x62;
+ private static final short kVK_F3 = 0x63;
+ private static final short kVK_F8 = 0x64;
+ private static final short kVK_F9 = 0x65;
+ private static final short kVK_F11 = 0x67;
+ private static final short kVK_F13 = 0x69;
+ private static final short kVK_F16 = 0x6A;
+ private static final short kVK_F14 = 0x6B;
+ private static final short kVK_F10 = 0x6D;
+ private static final short kVK_F12 = 0x6F;
+ private static final short kVK_F15 = 0x71;
+ private static final short kVK_Help = 0x72;
+ private static final short kVK_Home = 0x73;
+ private static final short kVK_PageUp = 0x74;
+ private static final short kVK_ForwardDelete = 0x75;
+ private static final short kVK_F4 = 0x76;
+ private static final short kVK_End = 0x77;
+ private static final short kVK_F2 = 0x78;
+ private static final short kVK_PageDown = 0x79;
+ private static final short kVK_F1 = 0x7A;
+ private static final short kVK_LeftArrow = 0x7B;
+ private static final short kVK_RightArrow = 0x7C;
+ private static final short kVK_DownArrow = 0x7D;
+ private static final short kVK_UpArrow = 0x7E;
+ //
// Key constants handled differently on Mac OS X than other platforms
+ //
private static final char NSUpArrowFunctionKey = 0xF700;
private static final char NSDownArrowFunctionKey = 0xF701;
private static final char NSLeftArrowFunctionKey = 0xF702;
@@ -109,6 +182,7 @@ public class MacKeyUtil {
private static final char NSF22FunctionKey = 0xF719;
private static final char NSF23FunctionKey = 0xF71A;
private static final char NSF24FunctionKey = 0xF71B;
+ /**
private static final char NSF25FunctionKey = 0xF71C;
private static final char NSF26FunctionKey = 0xF71D;
private static final char NSF27FunctionKey = 0xF71E;
@@ -120,6 +194,7 @@ public class MacKeyUtil {
private static final char NSF33FunctionKey = 0xF724;
private static final char NSF34FunctionKey = 0xF725;
private static final char NSF35FunctionKey = 0xF726;
+ */
private static final char NSInsertFunctionKey = 0xF727;
private static final char NSDeleteFunctionKey = 0xF728;
private static final char NSHomeFunctionKey = 0xF729;
@@ -130,10 +205,11 @@ public class MacKeyUtil {
private static final char NSPrintScreenFunctionKey = 0xF72E;
private static final char NSScrollLockFunctionKey = 0xF72F;
private static final char NSPauseFunctionKey = 0xF730;
- private static final char NSSysReqFunctionKey = 0xF731;
- private static final char NSBreakFunctionKey = 0xF732;
- private static final char NSResetFunctionKey = 0xF733;
+ // private static final char NSSysReqFunctionKey = 0xF731;
+ // private static final char NSBreakFunctionKey = 0xF732;
+ // private static final char NSResetFunctionKey = 0xF733;
private static final char NSStopFunctionKey = 0xF734;
+ /**
private static final char NSMenuFunctionKey = 0xF735;
private static final char NSUserFunctionKey = 0xF736;
private static final char NSSystemFunctionKey = 0xF737;
@@ -153,10 +229,83 @@ public class MacKeyUtil {
private static final char NSFindFunctionKey = 0xF745;
private static final char NSHelpFunctionKey = 0xF746;
private static final char NSModeSwitchFunctionKey = 0xF747;
+ */
- static int validateKeyCode(int keyCode, char keyChar) {
+ static short validateKeyCode(short keyCode, char keyChar) {
// OS X Virtual Keycodes
switch(keyCode) {
+ //
+ // KeyCodes (Layout Dependent)
+ //
+ case kVK_ANSI_A: return KeyEvent.VK_A;
+ case kVK_ANSI_S: return KeyEvent.VK_S;
+ case kVK_ANSI_D: return KeyEvent.VK_D;
+ case kVK_ANSI_F: return KeyEvent.VK_F;
+ case kVK_ANSI_H: return KeyEvent.VK_H;
+ case kVK_ANSI_G: return KeyEvent.VK_G;
+ case kVK_ANSI_Z: return KeyEvent.VK_Z;
+ case kVK_ANSI_X: return KeyEvent.VK_X;
+ case kVK_ANSI_C: return KeyEvent.VK_C;
+ case kVK_ANSI_V: return KeyEvent.VK_V;
+ case kVK_ANSI_B: return KeyEvent.VK_B;
+ case kVK_ANSI_Q: return KeyEvent.VK_Q;
+ case kVK_ANSI_W: return KeyEvent.VK_W;
+ case kVK_ANSI_E: return KeyEvent.VK_E;
+ case kVK_ANSI_R: return KeyEvent.VK_R;
+ case kVK_ANSI_Y: return KeyEvent.VK_Y;
+ case kVK_ANSI_T: return KeyEvent.VK_T;
+ case kVK_ANSI_1: return KeyEvent.VK_1;
+ case kVK_ANSI_2: return KeyEvent.VK_2;
+ case kVK_ANSI_3: return KeyEvent.VK_3;
+ case kVK_ANSI_4: return KeyEvent.VK_4;
+ case kVK_ANSI_6: return KeyEvent.VK_6;
+ case kVK_ANSI_5: return KeyEvent.VK_5;
+ case kVK_ANSI_Equal: return KeyEvent.VK_EQUALS;
+ case kVK_ANSI_9: return KeyEvent.VK_9;
+ case kVK_ANSI_7: return KeyEvent.VK_7;
+ case kVK_ANSI_Minus: return KeyEvent.VK_MINUS;
+ case kVK_ANSI_8: return KeyEvent.VK_8;
+ case kVK_ANSI_0: return KeyEvent.VK_0;
+ case kVK_ANSI_RightBracket: return KeyEvent.VK_CLOSE_BRACKET;
+ case kVK_ANSI_O: return KeyEvent.VK_O;
+ case kVK_ANSI_U: return KeyEvent.VK_U;
+ case kVK_ANSI_LeftBracket: return KeyEvent.VK_OPEN_BRACKET;
+ case kVK_ANSI_I: return KeyEvent.VK_I;
+ case kVK_ANSI_P: return KeyEvent.VK_P;
+ case kVK_ANSI_L: return KeyEvent.VK_L;
+ case kVK_ANSI_J: return KeyEvent.VK_J;
+ case kVK_ANSI_Quote: return KeyEvent.VK_QUOTE;
+ case kVK_ANSI_K: return KeyEvent.VK_K;
+ case kVK_ANSI_Semicolon: return KeyEvent.VK_SEMICOLON;
+ case kVK_ANSI_Backslash: return KeyEvent.VK_BACK_SLASH;
+ case kVK_ANSI_Comma: return KeyEvent.VK_COMMA;
+ case kVK_ANSI_Slash: return KeyEvent.VK_SLASH;
+ case kVK_ANSI_N: return KeyEvent.VK_N;
+ case kVK_ANSI_M: return KeyEvent.VK_M;
+ case kVK_ANSI_Period: return KeyEvent.VK_PERIOD;
+ case kVK_ANSI_Grave: return KeyEvent.VK_BACK_QUOTE; // KeyEvent.VK_DEAD_GRAVE
+ case kVK_ANSI_KeypadDecimal: return KeyEvent.VK_DECIMAL;
+ case kVK_ANSI_KeypadMultiply: return KeyEvent.VK_MULTIPLY;
+ case kVK_ANSI_KeypadPlus: return KeyEvent.VK_PLUS;
+ case kVK_ANSI_KeypadClear: return KeyEvent.VK_CLEAR;
+ case kVK_ANSI_KeypadDivide: return KeyEvent.VK_DIVIDE;
+ case kVK_ANSI_KeypadEnter: return KeyEvent.VK_ENTER;
+ case kVK_ANSI_KeypadMinus: return KeyEvent.VK_MINUS;
+ case kVK_ANSI_KeypadEquals: return KeyEvent.VK_EQUALS;
+ case kVK_ANSI_Keypad0: return KeyEvent.VK_0;
+ case kVK_ANSI_Keypad1: return KeyEvent.VK_1;
+ case kVK_ANSI_Keypad2: return KeyEvent.VK_2;
+ case kVK_ANSI_Keypad3: return KeyEvent.VK_3;
+ case kVK_ANSI_Keypad4: return KeyEvent.VK_4;
+ case kVK_ANSI_Keypad5: return KeyEvent.VK_5;
+ case kVK_ANSI_Keypad6: return KeyEvent.VK_6;
+ case kVK_ANSI_Keypad7: return KeyEvent.VK_7;
+ case kVK_ANSI_Keypad8: return KeyEvent.VK_8;
+ case kVK_ANSI_Keypad9: return KeyEvent.VK_9;
+
+ //
+ // KeyCodes (Layout Independent)
+ //
case kVK_Return: return KeyEvent.VK_ENTER;
case kVK_Tab: return KeyEvent.VK_TAB;
case kVK_Space: return KeyEvent.VK_SPACE;
@@ -270,15 +419,8 @@ public class MacKeyUtil {
// NSFindFunctionKey
// NSHelpFunctionKey
// NSModeSwitchFunctionKey
- case 0x60: return KeyEvent.VK_BACK_QUOTE; // `
- case 0x27: return KeyEvent.VK_QUOTE; // '
- case '\r': return KeyEvent.VK_ENTER;
- }
-
- if ('a' <= keyChar && keyChar <= 'z') {
- return KeyEvent.VK_A + ( keyChar - 'a' ) ;
}
- return (int) keyChar; // let's hope for the best (compatibility of keyChar/keyCode's)
+ return (short) keyChar; // let's hope for the best (compatibility of keyChar/keyCode's)
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 89d53fbeb..1bbbf8a7d 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -316,20 +316,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
} // else may need offscreen solution ? FIXME
}
- private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- if( send ) {
- super.sendKeyEvent(eventType, modifiers, keyCode, keyChar);
- } else {
- super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar);
- }
+ @Override
+ public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) {
+ throw new InternalError("XXX: Adapt Java Code to Native Code Changes");
}
-
- private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int _keyCode, char keyChar) {
+
+ @Override
+ public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, short keySym, char keyChar) {
// Note that we send the key char for the key code on this
// platform -- we do not get any useful key codes out of the system
- final int keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar);
- // final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode);
- // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode);
+ final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar);
+ /* {
+ final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode);
+ System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+
+ ", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode);
+ } */
// 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED
// Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED
@@ -346,25 +347,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
// key was already pressed
keyRepeatState.put(keyCode, true); // prev == false -> AR in
modifiers |= InputEvent.AUTOREPEAT_MASK;
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); // RELEASED
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED
+ super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); // RELEASED
}
}
break;
- case KeyEvent.EVENT_KEY_TYPED:
- break;
}
- emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar);
- }
-
- @Override
- public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
- handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar);
- }
-
- @Override
- public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar);
+ super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyCode, keyChar);
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index 650958f25..475687eb4 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -46,7 +46,6 @@ import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
-import com.jogamp.common.util.IntIntHashMap;
import com.jogamp.newt.event.InputEvent;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.MouseAdapter;
@@ -261,87 +260,55 @@ public class WindowDriver extends WindowImpl {
// nop - using event driven insetsChange(..)
}
- private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- if( send ) {
- super.sendKeyEvent(eventType, modifiers, keyCode, keyChar);
- } else {
- super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar);
- }
+ 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( !isModifierKey ) {
+ // AR: Key was already pressed: Either [enter | within] AR mode
+ modifiers |= InputEvent.AUTOREPEAT_MASK;
+ if( preKeyRepeatState ) {
+ // 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 }
+ super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
+ }
+ return true;
+ }
+ return false;
}
- /** FIXME: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..). */
- private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1);
-
- private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- final boolean isPrintableKey = KeyEvent.isPrintableKey(keyCode);
- final boolean isModifierKey = KeyEvent.isModifierKey(keyCode);
- // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+isPrintableKey+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
+ @Override
+ public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) {
+ final boolean isModifierKey = KeyEvent.isModifierKey(keySym);
+ // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+
+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
// Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1)
// Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0).
switch(eventType) {
case KeyEvent.EVENT_KEY_RELEASED:
- final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0);
- if( 0 != keyCharTyped ) {
- keyChar = (char)keyCharTyped;
- }
if( isKeyCodeTracked(keyCode) ) {
if( keyRepeatState.put(keyCode, false) && !isModifierKey ) {
// AR out - send out missing PRESSED
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar);
+ super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar);
}
keyPressedState.put(keyCode, false);
}
- emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar);
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar);
+ super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
break;
case KeyEvent.EVENT_KEY_PRESSED:
- // TYPED is delivered right after PRESSED for printable keys and contains the key-char information,
- // hence we only deliver non printable keys (action and modifier keys) here.
- // Modifier keys shall not AR.
- if( !isPrintableKey ) {
- if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) {
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar);
- }
- }
- break;
- case KeyEvent.EVENT_KEY_TYPED:
- if( isPrintableKey ) {
- typedKeyCode2KeyChar.put(keyCode, keyChar);
- if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) {
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar);
- }
+ if( !handlePressTypedAutoRepeat(isModifierKey, modifiers, keyCode, keySym, keyChar) ) {
+ super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
}
break;
+ // case KeyEvent.EVENT_KEY_TYPED:
+ // break;
}
}
- private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, boolean send, boolean wait, int modifiers, int keyCode, char keyChar) {
- if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) {
- final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true);
- if( !isModifierKey ) {
- // AR: Key was already pressed: Either [enter | within] AR mode
- modifiers |= InputEvent.AUTOREPEAT_MASK;
- if( preKeyRepeatState ) {
- // AR: Within AR mode
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar);
- } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT }
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar);
- emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar);
- }
- return true;
- }
- return false;
- }
-
- @Override
- public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
- handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar);
- }
-
@Override
- public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
- handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar);
+ public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) {
+ throw new InternalError("XXX: Adapt Java Code to Native Code Changes");
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index c55fddd07..8d33d4d73 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -48,6 +48,7 @@ import javax.media.nativewindow.util.Point;
import com.jogamp.nativewindow.x11.X11GraphicsDevice;
import com.jogamp.nativewindow.x11.X11GraphicsScreen;
import com.jogamp.newt.event.InputEvent;
+import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.MouseEvent;
public class WindowDriver extends WindowImpl {
@@ -227,8 +228,8 @@ public class WindowDriver extends WindowImpl {
}
@Override
- protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers,
- int x, int y, int button, float rotation) {
+ protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
switch(eventType) {
case MouseEvent.EVENT_MOUSE_PRESSED:
switch(button) {
@@ -270,6 +271,34 @@ public class WindowDriver extends WindowImpl {
super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation);
}
+ @Override
+ public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) {
+ // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar);
+ final boolean isModifierKey = KeyEvent.isModifierKey(keyCode);
+ final boolean isAutoRepeat = 0 != ( KeyEvent.AUTOREPEAT_MASK & modifiers );
+ // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+
+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
+
+ if( !isAutoRepeat || !isModifierKey ) { // ! ( isModifierKey && isAutoRepeat )
+ switch(eventType) {
+ case KeyEvent.EVENT_KEY_PRESSED:
+ super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
+ break;
+
+ case KeyEvent.EVENT_KEY_RELEASED:
+ super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
+ break;
+
+ // case KeyEvent.EVENT_KEY_TYPED:
+ // break;
+ }
+ }
+ }
+
+ @Override
+ public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) {
+ throw new InternalError("XXX: Adapt Java Code to Native Code Changes");
+ }
//----------------------------------------------------------------------
// Internals only
diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
index 0fc487e91..1ebb714fa 100644
--- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
@@ -32,7 +32,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
-import com.jogamp.common.util.IntIntHashMap;
import com.jogamp.newt.event.InputEvent;
/**
@@ -43,26 +42,22 @@ import com.jogamp.newt.event.InputEvent;
*/
public class SWTNewtEventFactory {
- protected static final IntIntHashMap eventTypeSWT2NEWT;
+ public static final short eventTypeSWT2NEWT(int swtType) {
+ switch( swtType ) {
+ // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED;
+ case SWT.MouseDown: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
+ case SWT.MouseUp: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
+ case SWT.MouseMove: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED;
+ case SWT.MouseEnter: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED;
+ case SWT.MouseExit: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED;
+ // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED;
+ case SWT.MouseVerticalWheel: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
- static {
- IntIntHashMap map = new IntIntHashMap();
- map.setKeyNotFoundValue(0xFFFFFFFF);
-
- // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED);
- map.put(SWT.MouseDown, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED);
- map.put(SWT.MouseUp, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED);
- map.put(SWT.MouseMove, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED);
- map.put(SWT.MouseEnter, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED);
- map.put(SWT.MouseExit, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED);
- // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED);
- map.put(SWT.MouseVerticalWheel, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED);
-
- map.put(SWT.KeyDown, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED);
- map.put(SWT.KeyUp, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED);
- // map.put(SWT.KeyXXX, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED);
-
- eventTypeSWT2NEWT = map;
+ case SWT.KeyDown: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED;
+ case SWT.KeyUp: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED;
+ // case SWT.KeyXXX: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED;
+ }
+ return (short)0;
}
public static final int swtModifiers2Newt(int awtMods, boolean mouseHint) {
@@ -93,8 +88,8 @@ public class SWTNewtEventFactory {
default:
return null;
}
- int type = eventTypeSWT2NEWT.get(event.type);
- if(0xFFFFFFFF != type) {
+ final short type = eventTypeSWT2NEWT(event.type);
+ if( (short)0 != type ) {
float rotation = 0;
if (SWT.MouseVerticalWheel == event.type) {
// SWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up.
@@ -116,7 +111,7 @@ public class SWTNewtEventFactory {
return new com.jogamp.newt.event.MouseEvent(
type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time),
- mods, event.x, event.y, event.count, event.button, rotation);
+ mods, event.x, event.y, (short)event.count, (short)event.button, rotation);
}
return null; // no mapping ..
}
@@ -129,12 +124,12 @@ public class SWTNewtEventFactory {
default:
return null;
}
- int type = eventTypeSWT2NEWT.get(event.type);
- if(0xFFFFFFFF != type) {
+ final short type = eventTypeSWT2NEWT(event.type);
+ if( (short)0 != type ) {
return new com.jogamp.newt.event.KeyEvent(
type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time),
swtModifiers2Newt(event.stateMask, false),
- event.keyCode, event.character);
+ (short)event.keyCode, (short)event.keyCode, event.character);
}
return null; // no mapping ..
}
@@ -143,7 +138,7 @@ public class SWTNewtEventFactory {
//
//
- int dragButtonDown = 0;
+ short dragButtonDown = 0;
public SWTNewtEventFactory() {
resetButtonsDown();
@@ -159,7 +154,7 @@ public class SWTNewtEventFactory {
if(null != l) {
switch(event.type) {
case SWT.MouseDown:
- dragButtonDown = event.button;
+ dragButtonDown = (short) event.button;
l.mousePressed(res); break;
case SWT.MouseUp:
dragButtonDown = 0;
@@ -214,7 +209,6 @@ public class SWTNewtEventFactory {
break;
case SWT.KeyUp:
l.keyReleased(res);
- l.keyTyped(res);
break;
}
}
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index 3d059c336..cfec60dc1 100644
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -161,14 +161,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_DisplayDriver_DispatchMessages
if(KD_INPUT_POINTER_SELECT==ptr->index) {
DBG_PRINT( "event mouse click: src: %p, s:%d, (%d,%d)\n", userData, ptr->select, ptr->x, ptr->y);
(*env)->CallVoidMethod(env, javaWindow, sendMouseEventID,
- (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED,
+ (ptr->select==0) ? (jshort) EVENT_MOUSE_RELEASED : (jshort) EVENT_MOUSE_PRESSED,
(jint) 0,
- (jint) ptr->x, (jint) ptr->y, 1, 0.0f);
+ (jint) ptr->x, (jint) ptr->y, (short)1, 0.0f);
} else {
DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y);
- (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED,
+ (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED,
0,
- (jint) ptr->x, (jint) ptr->y, 0, 0.0f);
+ (jint) ptr->x, (jint) ptr->y, (jshort)0, 0.0f);
}
}
break;
@@ -193,8 +193,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V");
+ sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V");
if (windowCreatedID == NULL ||
sizeChangedID == NULL ||
visibleChangedID == NULL ||
diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h
index 29b646fbf..1e4f0c3ba 100644
--- a/src/newt/native/NewtMacWindow.h
+++ b/src/newt/native/NewtMacWindow.h
@@ -145,9 +145,9 @@
- (void) setMouseConfined:(BOOL)v;
- (void) setMousePosition:(NSPoint)p;
-- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType;
-- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType;
-- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType;
+- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType;
+- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType;
+- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType;
- (void) focusChanged: (BOOL) gained;
- (BOOL) becomeFirstResponder;
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index e69f74dfb..66d68d9d2 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -349,10 +349,10 @@ static jmethodID windowRepaintID = NULL;
+ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz
{
- enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V");
- enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V");
+ enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISSC)V");
+ sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V");
@@ -626,15 +626,15 @@ static jint mods2JavaMods(NSUInteger mods)
return javaMods;
}
-- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType
+- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType
{
- jint keyCode = (jint) [event keyCode];
+ jshort keyCode = (jshort) [event keyCode];
NSString* chars = [event charactersIgnoringModifiers];
NSUInteger mods = [event modifierFlags];
[self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType];
}
-- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType
+- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType
{
NSView* nsview = [self contentView];
if( ! [nsview isMemberOfClass:[NewtView class]] ) {
@@ -668,10 +668,10 @@ static jint mods2JavaMods(NSUInteger mods)
#ifdef USE_SENDIO_DIRECT
(*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID,
- evType, javaMods, keyCode, keyChar);
+ evType, javaMods, keyCode, keyCode, keyChar);
#else
(*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE,
- evType, javaMods, keyCode, keyChar);
+ evType, javaMods, keyCode, keyCode, keyChar);
#endif
}
} else {
@@ -682,10 +682,10 @@ static jint mods2JavaMods(NSUInteger mods)
#ifdef USE_SENDIO_DIRECT
(*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID,
- evType, javaMods, keyCode, keyChar);
+ evType, javaMods, keyCode, keyCode, keyChar);
#else
(*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE,
- evType, javaMods, keyCode, keyChar);
+ evType, javaMods, keyCode, keyCode, keyChar);
#endif
}
@@ -694,7 +694,7 @@ static jint mods2JavaMods(NSUInteger mods)
}
}
-- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType
+- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType
{
NSView* nsview = [self contentView];
if( ! [nsview isMemberOfClass:[NewtView class]] ) {
@@ -718,7 +718,7 @@ static jint mods2JavaMods(NSUInteger mods)
// convert to 1-based button number (or use zero if no button is involved)
// TODO: detect mouse button when mouse wheel scrolled
- jint javaButtonNum = 0;
+ jshort javaButtonNum = 0;
jfloat scrollDeltaY = 0.0f;
switch ([event type]) {
case NSScrollWheel: {
@@ -850,13 +850,12 @@ static jint mods2JavaMods(NSUInteger mods)
- (void) keyDown: (NSEvent*) theEvent
{
- [self sendKeyEvent: theEvent eventType: EVENT_KEY_PRESSED];
+ [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED];
}
- (void) keyUp: (NSEvent*) theEvent
{
- [self sendKeyEvent: theEvent eventType: EVENT_KEY_RELEASED];
- [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED];
+ [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED];
}
#define kVK_Shift 0x38
@@ -868,11 +867,10 @@ static jint mods2JavaMods(NSUInteger mods)
{
if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) {
modsDown[keyIdx] = YES;
- [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_PRESSED];
+ [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED];
} else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) {
modsDown[keyIdx] = NO;
- [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_RELEASED];
- [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_TYPED];
+ [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED];
}
}
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 24d513c68..05953cb86 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -132,9 +132,7 @@ static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowRepaintID = NULL;
-static jmethodID enqueueMouseEventID = NULL;
static jmethodID sendMouseEventID = NULL;
-static jmethodID enqueueKeyEventID = NULL;
static jmethodID sendKeyEventID = NULL;
static jmethodID requestFocusID = NULL;
@@ -146,345 +144,294 @@ typedef struct {
} WindowUserData;
typedef struct {
- UINT javaKey;
- UINT windowsKey;
+ USHORT javaKey;
+ USHORT windowsKey;
+ USHORT windowsScanCodeUS;
} KeyMapEntry;
// Static table, arranged more or less spatially.
static KeyMapEntry keyMapTable[] = {
// Modifier keys
- {J_VK_CAPS_LOCK, VK_CAPITAL},
- {J_VK_SHIFT, VK_SHIFT},
- {J_VK_CONTROL, VK_CONTROL},
- {J_VK_ALT, VK_MENU},
- {J_VK_NUM_LOCK, VK_NUMLOCK},
+ {J_VK_CAPS_LOCK, VK_CAPITAL, 0},
+ {J_VK_SHIFT, VK_SHIFT, 0},
+ {J_VK_SHIFT, VK_LSHIFT, 0},
+ {J_VK_SHIFT, VK_RSHIFT, 0},
+ {J_VK_CONTROL, VK_CONTROL, 0},
+ {J_VK_CONTROL, VK_LCONTROL, 0},
+ {J_VK_CONTROL, VK_RCONTROL, 0},
+ {J_VK_ALT, VK_MENU, 0},
+ {J_VK_ALT, VK_LMENU, 0},
+ {J_VK_ALT, VK_RMENU, 0},
+ {J_VK_NUM_LOCK, VK_NUMLOCK, 0},
// Miscellaneous Windows keys
- {J_VK_WINDOWS, VK_LWIN},
- {J_VK_WINDOWS, VK_RWIN},
- {J_VK_CONTEXT_MENU, VK_APPS},
+ {J_VK_WINDOWS, VK_LWIN, 0},
+ {J_VK_WINDOWS, VK_RWIN, 0},
+ {J_VK_CONTEXT_MENU, VK_APPS, 0},
// Alphabet
- {J_VK_A, 'A'},
- {J_VK_B, 'B'},
- {J_VK_C, 'C'},
- {J_VK_D, 'D'},
- {J_VK_E, 'E'},
- {J_VK_F, 'F'},
- {J_VK_G, 'G'},
- {J_VK_H, 'H'},
- {J_VK_I, 'I'},
- {J_VK_J, 'J'},
- {J_VK_K, 'K'},
- {J_VK_L, 'L'},
- {J_VK_M, 'M'},
- {J_VK_N, 'N'},
- {J_VK_O, 'O'},
- {J_VK_P, 'P'},
- {J_VK_Q, 'Q'},
- {J_VK_R, 'R'},
- {J_VK_S, 'S'},
- {J_VK_T, 'T'},
- {J_VK_U, 'U'},
- {J_VK_V, 'V'},
- {J_VK_W, 'W'},
- {J_VK_X, 'X'},
- {J_VK_Y, 'Y'},
- {J_VK_Z, 'Z'},
- {J_VK_0, '0'},
- {J_VK_1, '1'},
- {J_VK_2, '2'},
- {J_VK_3, '3'},
- {J_VK_4, '4'},
- {J_VK_5, '5'},
- {J_VK_6, '6'},
- {J_VK_7, '7'},
- {J_VK_8, '8'},
- {J_VK_9, '9'},
- {J_VK_ENTER, VK_RETURN},
- {J_VK_SPACE, VK_SPACE},
- {J_VK_BACK_SPACE, VK_BACK},
- {J_VK_TAB, VK_TAB},
- {J_VK_ESCAPE, VK_ESCAPE},
- {J_VK_INSERT, VK_INSERT},
- {J_VK_DELETE, VK_DELETE},
- {J_VK_HOME, VK_HOME},
- {J_VK_END, VK_END},
- {J_VK_PAGE_UP, VK_PRIOR},
- {J_VK_PAGE_DOWN, VK_NEXT},
- {J_VK_CLEAR, VK_CLEAR}, // NumPad 5
+ {J_VK_A, 'A', 0},
+ {J_VK_B, 'B', 0},
+ {J_VK_C, 'C', 0},
+ {J_VK_D, 'D', 0},
+ {J_VK_E, 'E', 0},
+ {J_VK_F, 'F', 0},
+ {J_VK_G, 'G', 0},
+ {J_VK_H, 'H', 0},
+ {J_VK_I, 'I', 0},
+ {J_VK_J, 'J', 0},
+ {J_VK_K, 'K', 0},
+ {J_VK_L, 'L', 0},
+ {J_VK_M, 'M', 0},
+ {J_VK_N, 'N', 0},
+ {J_VK_O, 'O', 0},
+ {J_VK_P, 'P', 0},
+ {J_VK_Q, 'Q', 0},
+ {J_VK_R, 'R', 0},
+ {J_VK_S, 'S', 0},
+ {J_VK_T, 'T', 0},
+ {J_VK_U, 'U', 0},
+ {J_VK_V, 'V', 0},
+ {J_VK_W, 'W', 0},
+ {J_VK_X, 'X', 0},
+ {J_VK_Y, 'Y', 0},
+ {J_VK_Z, 'Z', 0},
+ {J_VK_0, '0', 0},
+ {J_VK_1, '1', 0},
+ {J_VK_2, '2', 0},
+ {J_VK_3, '3', 0},
+ {J_VK_4, '4', 0},
+ {J_VK_5, '5', 0},
+ {J_VK_6, '6', 0},
+ {J_VK_7, '7', 0},
+ {J_VK_8, '8', 0},
+ {J_VK_9, '9', 0},
+ {J_VK_ENTER, VK_RETURN, 0},
+ {J_VK_SPACE, VK_SPACE, 0},
+ {J_VK_BACK_SPACE, VK_BACK, 0},
+ {J_VK_TAB, VK_TAB, 0},
+ {J_VK_ESCAPE, VK_ESCAPE, 0},
+ {J_VK_INSERT, VK_INSERT, 0},
+ {J_VK_DELETE, VK_DELETE, 0},
+ {J_VK_HOME, VK_HOME, 0},
+ {J_VK_END, VK_END, 0},
+ {J_VK_PAGE_UP, VK_PRIOR, 0},
+ {J_VK_PAGE_DOWN, VK_NEXT, 0},
+ {J_VK_CLEAR, VK_CLEAR, 0}, // NumPad 5
// NumPad with NumLock off & extended arrows block (triangular)
- {J_VK_LEFT, VK_LEFT},
- {J_VK_RIGHT, VK_RIGHT},
- {J_VK_UP, VK_UP},
- {J_VK_DOWN, VK_DOWN},
+ {J_VK_LEFT, VK_LEFT, 0},
+ {J_VK_RIGHT, VK_RIGHT, 0},
+ {J_VK_UP, VK_UP, 0},
+ {J_VK_DOWN, VK_DOWN, 0},
// NumPad with NumLock on: numbers
- {J_VK_NUMPAD0, VK_NUMPAD0},
- {J_VK_NUMPAD1, VK_NUMPAD1},
- {J_VK_NUMPAD2, VK_NUMPAD2},
- {J_VK_NUMPAD3, VK_NUMPAD3},
- {J_VK_NUMPAD4, VK_NUMPAD4},
- {J_VK_NUMPAD5, VK_NUMPAD5},
- {J_VK_NUMPAD6, VK_NUMPAD6},
- {J_VK_NUMPAD7, VK_NUMPAD7},
- {J_VK_NUMPAD8, VK_NUMPAD8},
- {J_VK_NUMPAD9, VK_NUMPAD9},
+ {J_VK_NUMPAD0, VK_NUMPAD0, 0},
+ {J_VK_NUMPAD1, VK_NUMPAD1, 0},
+ {J_VK_NUMPAD2, VK_NUMPAD2, 0},
+ {J_VK_NUMPAD3, VK_NUMPAD3, 0},
+ {J_VK_NUMPAD4, VK_NUMPAD4, 0},
+ {J_VK_NUMPAD5, VK_NUMPAD5, 0},
+ {J_VK_NUMPAD6, VK_NUMPAD6, 0},
+ {J_VK_NUMPAD7, VK_NUMPAD7, 0},
+ {J_VK_NUMPAD8, VK_NUMPAD8, 0},
+ {J_VK_NUMPAD9, VK_NUMPAD9, 0},
// NumPad with NumLock on
- {J_VK_MULTIPLY, VK_MULTIPLY},
- {J_VK_ADD, VK_ADD},
- {J_VK_SEPARATOR, VK_SEPARATOR},
- {J_VK_SUBTRACT, VK_SUBTRACT},
- {J_VK_DECIMAL, VK_DECIMAL},
- {J_VK_DIVIDE, VK_DIVIDE},
+ {J_VK_MULTIPLY, VK_MULTIPLY, 0},
+ {J_VK_ADD, VK_ADD, 0},
+ {J_VK_SEPARATOR, VK_SEPARATOR, 0},
+ {J_VK_SUBTRACT, VK_SUBTRACT, 0},
+ {J_VK_DECIMAL, VK_DECIMAL, 0},
+ {J_VK_DIVIDE, VK_DIVIDE, 0},
// Functional keys
- {J_VK_F1, VK_F1},
- {J_VK_F2, VK_F2},
- {J_VK_F3, VK_F3},
- {J_VK_F4, VK_F4},
- {J_VK_F5, VK_F5},
- {J_VK_F6, VK_F6},
- {J_VK_F7, VK_F7},
- {J_VK_F8, VK_F8},
- {J_VK_F9, VK_F9},
- {J_VK_F10, VK_F10},
- {J_VK_F11, VK_F11},
- {J_VK_F12, VK_F12},
- {J_VK_F13, VK_F13},
- {J_VK_F14, VK_F14},
- {J_VK_F15, VK_F15},
- {J_VK_F16, VK_F16},
- {J_VK_F17, VK_F17},
- {J_VK_F18, VK_F18},
- {J_VK_F19, VK_F19},
- {J_VK_F20, VK_F20},
- {J_VK_F21, VK_F21},
- {J_VK_F22, VK_F22},
- {J_VK_F23, VK_F23},
- {J_VK_F24, VK_F24},
-
- {J_VK_PRINTSCREEN, VK_SNAPSHOT},
- {J_VK_SCROLL_LOCK, VK_SCROLL},
- {J_VK_PAUSE, VK_PAUSE},
- {J_VK_CANCEL, VK_CANCEL},
- {J_VK_HELP, VK_HELP},
+ {J_VK_F1, VK_F1, 0},
+ {J_VK_F2, VK_F2, 0},
+ {J_VK_F3, VK_F3, 0},
+ {J_VK_F4, VK_F4, 0},
+ {J_VK_F5, VK_F5, 0},
+ {J_VK_F6, VK_F6, 0},
+ {J_VK_F7, VK_F7, 0},
+ {J_VK_F8, VK_F8, 0},
+ {J_VK_F9, VK_F9, 0},
+ {J_VK_F10, VK_F10, 0},
+ {J_VK_F11, VK_F11, 0},
+ {J_VK_F12, VK_F12, 0},
+ {J_VK_F13, VK_F13, 0},
+ {J_VK_F14, VK_F14, 0},
+ {J_VK_F15, VK_F15, 0},
+ {J_VK_F16, VK_F16, 0},
+ {J_VK_F17, VK_F17, 0},
+ {J_VK_F18, VK_F18, 0},
+ {J_VK_F19, VK_F19, 0},
+ {J_VK_F20, VK_F20, 0},
+ {J_VK_F21, VK_F21, 0},
+ {J_VK_F22, VK_F22, 0},
+ {J_VK_F23, VK_F23, 0},
+ {J_VK_F24, VK_F24, 0},
+
+ {J_VK_PRINTSCREEN, VK_SNAPSHOT, 0},
+ {J_VK_SCROLL_LOCK, VK_SCROLL, 0},
+ {J_VK_PAUSE, VK_PAUSE, 0},
+ {J_VK_CANCEL, VK_CANCEL, 0},
+ {J_VK_HELP, VK_HELP, 0},
+
+ // Since we unify mappings via US kbd layout .. this is valid:
+ {J_VK_SEMICOLON, VK_OEM_1, 0}, // US only ';:'
+ {J_VK_EQUALS, VK_OEM_PLUS, 0}, // '=+'
+ {J_VK_COMMA, VK_OEM_COMMA, 0}, // ',<'
+ {J_VK_MINUS, VK_OEM_MINUS, 0}, // '-_'
+ {J_VK_PERIOD, VK_OEM_PERIOD, 0}, // '.>'
+ {J_VK_SLASH, VK_OEM_2, 0}, // US only '/?'
+ {J_VK_BACK_QUOTE, VK_OEM_3, 0}, // US only '`~'
+ {J_VK_OPEN_BRACKET, VK_OEM_4, 0}, // US only '[}'
+ {J_VK_BACK_SLASH, VK_OEM_5, 0}, // US only '\|'
+ {J_VK_CLOSE_BRACKET, VK_OEM_6, 0}, // US only ']}'
+ {J_VK_QUOTE, VK_OEM_7, 0}, // US only ''"'
+ // {J_VK_????, VK_OEM_8, 0}, // varies ..
+ // {J_VK_????, VK_OEM_102, 0}, // angle-bracket or backslash key on RT 102-key kbd
// Japanese
/*
- {J_VK_CONVERT, VK_CONVERT},
- {J_VK_NONCONVERT, VK_NONCONVERT},
- {J_VK_INPUT_METHOD_ON_OFF, VK_KANJI},
- {J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC},
- {J_VK_KATAKANA, VK_DBE_KATAKANA},
- {J_VK_HIRAGANA, VK_DBE_HIRAGANA},
- {J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR},
- {J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR},
- {J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN},
+ {J_VK_CONVERT, VK_CONVERT, 0},
+ {J_VK_NONCONVERT, VK_NONCONVERT, 0},
+ {J_VK_INPUT_METHOD_ON_OFF, VK_KANJI, 0},
+ {J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC, 0},
+ {J_VK_KATAKANA, VK_DBE_KATAKANA, 0},
+ {J_VK_HIRAGANA, VK_DBE_HIRAGANA, 0},
+ {J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR, 0},
+ {J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR, 0},
+ {J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN, 0},
*/
- {J_VK_UNDEFINED, 0}
+ {J_VK_UNDEFINED, 0, 0}
};
-/*
-Dynamic mapping table for OEM VK codes. This table is refilled
-by BuildDynamicKeyMapTable when keyboard layout is switched.
-(see NT4 DDK src/input/inc/vkoem.h for OEM VK_ values).
-*/
-typedef struct {
- // OEM VK codes known in advance
- UINT windowsKey;
- // depends on input langauge (kbd layout)
- UINT javaKey;
-} DynamicKeyMapEntry;
-
-static DynamicKeyMapEntry dynamicKeyMapTable[] = {
- {0x00BA, J_VK_UNDEFINED}, // VK_OEM_1
- {0x00BB, J_VK_UNDEFINED}, // VK_OEM_PLUS
- {0x00BC, J_VK_UNDEFINED}, // VK_OEM_COMMA
- {0x00BD, J_VK_UNDEFINED}, // VK_OEM_MINUS
- {0x00BE, J_VK_UNDEFINED}, // VK_OEM_PERIOD
- {0x00BF, J_VK_UNDEFINED}, // VK_OEM_2
- {0x00C0, J_VK_UNDEFINED}, // VK_OEM_3
- {0x00DB, J_VK_UNDEFINED}, // VK_OEM_4
- {0x00DC, J_VK_UNDEFINED}, // VK_OEM_5
- {0x00DD, J_VK_UNDEFINED}, // VK_OEM_6
- {0x00DE, J_VK_UNDEFINED}, // VK_OEM_7
- {0x00DF, J_VK_UNDEFINED}, // VK_OEM_8
- {0x00E2, J_VK_UNDEFINED}, // VK_OEM_102
- {0, 0}
-};
+#ifndef KLF_ACTIVATE
+ #define KLF_ACTIVATE 0x00000001
+#endif
+#ifndef MAPVK_VK_TO_VSC
+ #define MAPVK_VK_TO_VSC 0
+#endif
+#ifndef MAPVK_VSC_TO_VK
+ #define MAPVK_VSC_TO_VK 1
+#endif
+#ifndef MAPVK_VK_TO_CHAR
+ #define MAPVK_VK_TO_CHAR 2
+#endif
+#ifndef MAPVK_VSC_TO_VK_EX
+ #define MAPVK_VSC_TO_VK_EX 3
+#endif
+#ifndef MAPVK_VK_TO_VSC_EX
+ #define MAPVK_VK_TO_VSC_EX 4
+#endif
-// Auxiliary tables used to fill the above dynamic table. We first
-// find the character for the OEM VK code using ::MapVirtualKey and
-// then go through these auxiliary tables to map it to Java VK code.
+static HKL kbdLayoutUS = 0;
+static const LPCSTR US_LAYOUT_NAME = "00000409";
-typedef struct {
- WCHAR c;
- UINT javaKey;
-} CharToVKEntry;
-
-static const CharToVKEntry charToVKTable[] = {
- {L'!', J_VK_EXCLAMATION_MARK},
- {L'"', J_VK_QUOTEDBL},
- {L'#', J_VK_NUMBER_SIGN},
- {L'$', J_VK_DOLLAR},
- {L'&', J_VK_AMPERSAND},
- {L'\'', J_VK_QUOTE},
- {L'(', J_VK_LEFT_PARENTHESIS},
- {L')', J_VK_RIGHT_PARENTHESIS},
- {L'*', J_VK_ASTERISK},
- {L'+', J_VK_PLUS},
- {L',', J_VK_COMMA},
- {L'-', J_VK_MINUS},
- {L'.', J_VK_PERIOD},
- {L'/', J_VK_SLASH},
- {L':', J_VK_COLON},
- {L';', J_VK_SEMICOLON},
- {L'<', J_VK_LESS},
- {L'=', J_VK_EQUALS},
- {L'>', J_VK_GREATER},
- {L'@', J_VK_AT},
- {L'[', J_VK_OPEN_BRACKET},
- {L'\\', J_VK_BACK_SLASH},
- {L']', J_VK_CLOSE_BRACKET},
- {L'^', J_VK_CIRCUMFLEX},
- {L'_', J_VK_UNDERSCORE},
- {L'`', J_VK_BACK_QUOTE},
- {L'{', J_VK_BRACELEFT},
- {L'}', J_VK_BRACERIGHT},
- {0x00A1, J_VK_INVERTED_EXCLAMATION_MARK},
- {0x20A0, J_VK_EURO_SIGN}, // ????
- {0,0}
-};
+static BYTE kbdState[256];
+static USHORT spaceScanCode;
-// For dead accents some layouts return ASCII punctuation, while some
-// return spacing accent chars, so both should be listed. NB: MS docs
-// say that conversion routings return spacing accent character, not
-// combining.
-static const CharToVKEntry charToDeadVKTable[] = {
- {L'`', J_VK_DEAD_GRAVE},
- {L'\'', J_VK_DEAD_ACUTE},
- {0x00B4, J_VK_DEAD_ACUTE},
- {L'^', J_VK_DEAD_CIRCUMFLEX},
- {L'~', J_VK_DEAD_TILDE},
- {0x02DC, J_VK_DEAD_TILDE},
- {0x00AF, J_VK_DEAD_MACRON},
- {0x02D8, J_VK_DEAD_BREVE},
- {0x02D9, J_VK_DEAD_ABOVEDOT},
- {L'"', J_VK_DEAD_DIAERESIS},
- {0x00A8, J_VK_DEAD_DIAERESIS},
- {0x02DA, J_VK_DEAD_ABOVERING},
- {0x02DD, J_VK_DEAD_DOUBLEACUTE},
- {0x02C7, J_VK_DEAD_CARON}, // aka hacek
- {L',', J_VK_DEAD_CEDILLA},
- {0x00B8, J_VK_DEAD_CEDILLA},
- {0x02DB, J_VK_DEAD_OGONEK},
- {0x037A, J_VK_DEAD_IOTA}, // ASCII ???
- {0x309B, J_VK_DEAD_VOICED_SOUND},
- {0x309C, J_VK_DEAD_SEMIVOICED_SOUND},
- {0,0}
-};
+static void InitKeyMapTableScanCode(JNIEnv *env) {
+ HKL hkl = GetKeyboardLayout(0);
+ int i;
-// ANSI CP identifiers are no longer than this
-#define MAX_ACP_STR_LEN 7
+ kbdLayoutUS = LoadKeyboardLayout( US_LAYOUT_NAME, 0 /* ? KLF_ACTIVATE ? */ );
+ if( 0 == kbdLayoutUS ) {
+ int lastError = (int) GetLastError();
+ kbdLayoutUS = hkl; // use prev. layout .. well
+ STD_PRINT("Warning: NEWT Windows: LoadKeyboardLayout(US, ..) failed: winErr 0x%X %d\n", lastError, lastError);
+ }
+ ActivateKeyboardLayout(hkl, 0);
+
+ spaceScanCode = MapVirtualKeyEx(VK_SPACE, MAPVK_VK_TO_VSC, hkl);
+
+ // Setup keyMapTable's windowsScanCodeUS
+ for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
+ USHORT scancode = (USHORT) MapVirtualKeyEx(keyMapTable[i].windowsKey, MAPVK_VK_TO_VSC_EX, kbdLayoutUS);
+ #ifdef DEBUG_KEYS
+ if( 0 == scancode ) {
+ int lastError = (int) GetLastError();
+ STD_PRINT("*** WindowsWindow: InitKeyMapTableScanCode: No ScanCode for windows vkey 0x%X (item %d), winErr 0x%X %d\n",
+ keyMapTable[i].windowsKey, i, lastError, lastError);
+ }
+ STD_PRINT("*** WindowsWindow: InitKeyMapTableScanCode: %3.3d windows vkey 0x%X -> scancode 0x%X\n",
+ i, keyMapTable[i].windowsKey, scancode);
+ #endif
+ keyMapTable[i].windowsScanCodeUS = scancode;
+ }
+}
+
+static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, USHORT *outJavaVKeyUS, USHORT *outJavaVKeyXX, USHORT *outUTF16Char) {
+ wchar_t uniChars[2] = { L'\0', L'\0' }; // uint16_t
+ USHORT winVKeyUS = 0;
+ int nUniChars, i, j;
+ USHORT javaVKeyUS = J_VK_UNDEFINED;
+ USHORT javaVKeyXX = J_VK_UNDEFINED;
-static void BuildDynamicKeyMapTable()
-{
HKL hkl = GetKeyboardLayout(0);
- // Will need this to reset layout after dead keys.
- UINT spaceScanCode = MapVirtualKeyEx(VK_SPACE, 0, hkl);
- DynamicKeyMapEntry *dynamic;
-
- LANGID idLang = LOWORD(GetKeyboardLayout(0));
- UINT codePage;
- TCHAR strCodePage[MAX_ACP_STR_LEN];
- // use the LANGID to create a LCID
- LCID idLocale = MAKELCID(idLang, SORT_DEFAULT);
- // get the ANSI code page associated with this locale
- if (GetLocaleInfo(idLocale, LOCALE_IDEFAULTANSICODEPAGE,
- strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 )
- {
- codePage = _ttoi(strCodePage);
- } else {
- codePage = GetACP();
+
+ //
+ // winVKey, winScanCode -> UTF16 w/ current KeyboardLayout
+ //
+ GetKeyboardState(kbdState);
+ kbdState[winVKey] |= 0x80;
+ nUniChars = ToUnicodeEx(winVKey, winScanCode, kbdState, uniChars, 2, 0, hkl);
+ kbdState[winVKey] &= ~0x80;
+
+ *outUTF16Char = (USHORT)(uniChars[0]); // Note: Even dead key are written in uniChar's ..
+
+ if ( 0 > nUniChars ) { // Dead key
+ char junkbuf[2] = { '\0', '\0'};
+
+ // We need to reset layout so that next translation
+ // is unaffected by the dead status. We do this by
+ // translating <SPACE> key.
+ kbdState[VK_SPACE] |= 0x80;
+ ToAsciiEx(VK_SPACE, spaceScanCode, kbdState, (WORD*)junkbuf, 0, hkl);
+ kbdState[VK_SPACE] &= ~0x80;
}
- // Entries in dynamic table that maps between Java VK and Windows
- // VK are built in three steps:
- // 1. Map windows VK to ANSI character (cannot map to unicode
- // directly, since ::ToUnicode is not implemented on win9x)
- // 2. Convert ANSI char to Unicode char
- // 3. Map Unicode char to Java VK via two auxilary tables.
+ // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN)
+ USHORT winScanCodeExt = winScanCode;
+ if( 0 != ( 0x01 & flags ) ) {
+ winScanCodeExt |= 0xE000;
+ }
- for (dynamic = dynamicKeyMapTable; dynamic->windowsKey != 0; ++dynamic)
- {
- char cbuf[2] = { '\0', '\0'};
- WCHAR ucbuf[2] = { L'\0', L'\0' };
- int nchars;
- UINT scancode;
- const CharToVKEntry *charMap;
- int nconverted;
- WCHAR uc;
- BYTE kbdState[256];
-
- // Defaults to J_VK_UNDEFINED
- dynamic->javaKey = J_VK_UNDEFINED;
-
- GetKeyboardState(kbdState);
-
- kbdState[dynamic->windowsKey] |= 0x80; // Press the key.
-
- // Unpress modifiers, since they are most likely pressed as
- // part of the keyboard switching shortcut.
- kbdState[VK_CONTROL] &= ~0x80;
- kbdState[VK_SHIFT] &= ~0x80;
- kbdState[VK_MENU] &= ~0x80;
-
- scancode = MapVirtualKeyEx(dynamic->windowsKey, 0, hkl);
- nchars = ToAsciiEx(dynamic->windowsKey, scancode, kbdState,
- (WORD*)cbuf, 0, hkl);
-
- // Auxiliary table used to map Unicode character to Java VK.
- // Will assign a different table for dead keys (below).
- charMap = charToVKTable;
-
- if (nchars < 0) { // Dead key
- char junkbuf[2] = { '\0', '\0'};
- // Use a different table for dead chars since different layouts
- // return different characters for the same dead key.
- charMap = charToDeadVKTable;
-
- // We also need to reset layout so that next translation
- // is unaffected by the dead status. We do this by
- // translating <SPACE> key.
- kbdState[dynamic->windowsKey] &= ~0x80;
- kbdState[VK_SPACE] |= 0x80;
-
- ToAsciiEx(VK_SPACE, spaceScanCode, kbdState,
- (WORD*)junkbuf, 0, hkl);
+ //
+ // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout
+ //
+ for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
+ if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) {
+ javaVKeyUS = keyMapTable[i].javaKey;
+ winVKeyUS = keyMapTable[i].windowsKey;
+ break;
}
+ }
- nconverted = MultiByteToWideChar(codePage, 0,
- cbuf, 1, ucbuf, 2);
-
- uc = ucbuf[0];
- {
- const CharToVKEntry *map;
- for (map = charMap; map->c != 0; ++map) {
- if (uc == map->c) {
- dynamic->javaKey = map->javaKey;
- break;
- }
- }
+ //
+ // winVKey -> javaVKeyXX
+ //
+ for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
+ if ( keyMapTable[i].windowsKey == winVKey ) {
+ javaVKeyXX = keyMapTable[i].javaKey;
+ break;
}
+ }
+
+ *outJavaVKeyUS = javaVKeyUS;
+ *outJavaVKeyXX = javaVKeyXX;
- } // for each VK_OEM_*
+#ifdef DEBUG_KEYS
+ STD_PRINT("*** WindowsWindow: ParseWmVKeyAndScanCode winVKey 0x%X, winScanCode 0x%X, winScanCodeExt 0x%X, flags 0x%X -> UTF(0x%X, %c, res %d, sizeof %d), vKeys( US(win 0x%X, java 0x%X), XX(win 0x%X, java 0x%X))\n",
+ (int)winVKey, (int)winScanCode, winScanCodeExt, (int)flags,
+ *outUTF16Char, *outUTF16Char, nUniChars, sizeof(uniChars[0]),
+ winVKeyUS, javaVKeyUS, winVKey, javaVKeyXX);
+#endif
}
-static jint GetModifiers(BOOL altKeyFlagged, UINT jkey) {
+static jint GetModifiers(BOOL altKeyFlagged, USHORT jkey) {
jint modifiers = 0;
// have to do &0xFFFF to avoid runtime assert caused by compiling with
// /RTCcsu
@@ -516,121 +463,38 @@ static BOOL IsAltKeyDown(BYTE flags, BOOL system) {
return system && ( flags & (1<<5) ) != 0;
}
-UINT WindowsKeyToJavaKey(UINT windowsKey)
-{
- int i, j, javaKey = J_VK_UNDEFINED;
- // for the general case, use a bi-directional table
- for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
- if (keyMapTable[i].windowsKey == windowsKey) {
- javaKey = keyMapTable[i].javaKey;
- }
- }
- if( J_VK_UNDEFINED == javaKey ) {
- for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
- if (dynamicKeyMapTable[j].windowsKey == windowsKey) {
- if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) {
- javaKey = dynamicKeyMapTable[j].javaKey;
- } else {
- break;
- }
- }
- }
- }
-
-#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: WindowsKeyToJavaKey 0x%X -> 0x%X\n", windowsKey, javaKey);
-#endif
- return javaKey;
-}
-
-#ifndef MAPVK_VSC_TO_VK
- #define MAPVK_VSC_TO_VK 1
-#endif
-#ifndef MAPVK_VK_TO_CHAR
- #define MAPVK_VK_TO_CHAR 2
-#endif
-
-static UINT WmVKey2ShiftedChar(UINT wkey, UINT modifiers) {
- UINT c = MapVirtualKey(wkey, MAPVK_VK_TO_CHAR);
- if( 0 != ( modifiers & EVENT_SHIFT_MASK ) ) {
- return islower(c) ? toupper(c) : c;
- }
- return isupper(c) ? tolower(c) : c;
-}
-
-static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) {
- UINT modifiers = 0, jkey = 0, wkey = 0;
-
- wkey = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK);
- jkey = WindowsKeyToJavaKey(wkey);
- modifiers = GetModifiers( IsAltKeyDown(flags, system), 0 );
-
- if (character == VK_RETURN) {
- character = J_VK_ENTER;
- }
-
- (*env)->CallVoidMethod(env, window, sendKeyEventID,
- (jint) EVENT_KEY_TYPED,
- modifiers,
- (jint) jkey,
- (jchar) character);
- return 1;
-}
-
-static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) {
- UINT modifiers = 0, jkey = 0, character = 0;
+static int WmKeyDown(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) {
+ UINT modifiers = 0;
+ USHORT javaVKeyUS=0, javaVKeyXX=0, utf16Char=0;
if (wkey == VK_PROCESSKEY) {
return 1;
}
- jkey = WindowsKeyToJavaKey(wkey);
- modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey );
- character = WmVKey2ShiftedChar(wkey, modifiers);
+ ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char);
-/*
- character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
-*/
+ modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX );
(*env)->CallVoidMethod(env, window, sendKeyEventID,
- (jint) EVENT_KEY_PRESSED,
- modifiers,
- (jint) jkey,
- (jchar) character);
-
- /* windows does not create a WM_CHAR for the Del key
- for some reason, so we need to create the KEY_TYPED event on the
- WM_KEYDOWN.
- */
- if (jkey == J_VK_DELETE) {
- (*env)->CallVoidMethod(env, window, sendKeyEventID,
- (jint) EVENT_KEY_TYPED,
- modifiers,
- (jint) jkey,
- (jchar) '\177');
- }
+ (jshort) EVENT_KEY_PRESSED,
+ (jint) modifiers, (jshort) javaVKeyUS, (jshort) javaVKeyXX, (jchar) utf16Char);
return 0;
}
-static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) {
- UINT modifiers = 0, jkey = 0, character = 0;
+static int WmKeyUp(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) {
+ UINT modifiers = 0;
+ USHORT javaVKeyUS=0, javaVKeyXX=0, utf16Char=0;
if (wkey == VK_PROCESSKEY) {
return 1;
}
- jkey = WindowsKeyToJavaKey(wkey);
- modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey );
- character = WmVKey2ShiftedChar(wkey, modifiers);
+ ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char);
-/*
- character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
-*/
+ modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX );
(*env)->CallVoidMethod(env, window, sendKeyEventID,
- (jint) EVENT_KEY_RELEASED,
- modifiers,
- (jint) jkey,
- (jchar) character);
+ (jshort) EVENT_KEY_RELEASED,
+ (jint) modifiers, (jshort) javaVKeyUS, (jshort) javaVKeyXX, (jchar) utf16Char);
return 0;
}
@@ -933,46 +797,35 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
break;
case WM_SYSCHAR:
- repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt);
- repCnt = LOWORD(lParam);
-#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: windProc WM_SYSCHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
-#endif
- useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, TRUE);
+ useDefWindowProc = 1;
break;
case WM_SYSKEYDOWN:
repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt);
repCnt = LOWORD(lParam);
#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
+ DBG_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
#endif
- useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, TRUE);
+ useDefWindowProc = WmKeyDown(env, window, (USHORT)wParam, repCnt, scanCode, flags, TRUE);
break;
case WM_SYSKEYUP:
repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt);
repCnt = LOWORD(lParam);
#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
+ DBG_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
#endif
- useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, TRUE);
+ useDefWindowProc = WmKeyUp(env, window, (USHORT)wParam, repCnt, scanCode, flags, TRUE);
break;
case WM_CHAR:
- repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt);
- repCnt = LOWORD(lParam);
-#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: windProc WM_CHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
-#endif
- useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, FALSE);
+ useDefWindowProc = 1;
break;
case WM_KEYDOWN:
repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt);
- repCnt = LOWORD(lParam);
#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
+ DBG_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
#endif
useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, FALSE);
break;
@@ -981,7 +834,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt);
repCnt = LOWORD(lParam);
#ifdef DEBUG_KEYS
- STD_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
+ DBG_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags);
#endif
useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, FALSE);
break;
@@ -1005,19 +858,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n");
(*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_PRESSED,
+ (jshort) EVENT_MOUSE_PRESSED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 1, (jfloat) 0.0f);
+ (jshort) 1, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
case WM_LBUTTONUP:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_RELEASED,
+ (jshort) EVENT_MOUSE_RELEASED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 1, (jfloat) 0.0f);
+ (jshort) 1, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
@@ -1025,19 +878,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n");
(*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_PRESSED,
+ (jshort) EVENT_MOUSE_PRESSED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 2, (jfloat) 0.0f);
+ (jshort) 2, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
case WM_MBUTTONUP:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_RELEASED,
+ (jshort) EVENT_MOUSE_RELEASED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 2, (jfloat) 0.0f);
+ (jshort) 2, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
@@ -1045,36 +898,36 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n");
(*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_PRESSED,
+ (jshort) EVENT_MOUSE_PRESSED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 3, (jfloat) 0.0f);
+ (jshort) 3, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
case WM_RBUTTONUP:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_RELEASED,
+ (jshort) EVENT_MOUSE_RELEASED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 3, (jfloat) 0.0f);
+ (jshort) 3, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
case WM_MOUSEMOVE:
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_MOVED,
+ (jshort) EVENT_MOUSE_MOVED,
GetModifiers( FALSE, 0 ),
(jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam),
- (jint) 0, (jfloat) 0.0f);
+ (jshort) 0, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
case WM_MOUSELEAVE:
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID, JNI_FALSE,
- (jint) EVENT_MOUSE_EXITED,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID, JNI_FALSE,
+ (jshort) EVENT_MOUSE_EXITED,
0,
(jint) -1, (jint) -1, // fake
- (jint) 0, (jfloat) 0.0f);
+ (jshort) 0, (jfloat) 0.0f);
useDefWindowProc = 1;
break;
// Java synthesizes EVENT_MOUSE_ENTERED
@@ -1099,10 +952,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
}
DBG_PRINT("*** WindowsWindow: WM_HSCROLL 0x%X, rotation %f, mods 0x%X\n", sb, rotation, modifiers);
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_WHEEL_MOVED,
+ (jshort) EVENT_MOUSE_WHEEL_MOVED,
modifiers,
(jint) 0, (jint) 0,
- (jint) 1, (jfloat) rotation);
+ (jshort) 1, (jfloat) rotation);
useDefWindowProc = 1;
break;
}
@@ -1128,10 +981,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
(int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers);
}
(*env)->CallVoidMethod(env, window, sendMouseEventID,
- (jint) EVENT_MOUSE_WHEEL_MOVED,
+ (jshort) EVENT_MOUSE_WHEEL_MOVED,
modifiers,
(jint) eventPt.x, (jint) eventPt.y,
- (jint) 1, (jfloat) rotationOrTilt);
+ (jshort) 1, (jfloat) rotationOrTilt);
useDefWindowProc = 1;
break;
}
@@ -1208,7 +1061,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes
// DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne);
if (gotOne) {
++i;
- TranslateMessage(&msg);
+ // TranslateMessage(&msg); // No more needed: We translate V_KEY -> UTF Char manually in key up/down
DispatchMessage(&msg);
}
} while (gotOne && i < 100);
@@ -1474,10 +1327,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V");
- enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V");
- enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V");
+ sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V");
requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V");
if (insetsChangedID == NULL ||
@@ -1487,14 +1338,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
windowRepaintID == NULL ||
- enqueueMouseEventID == NULL ||
sendMouseEventID == NULL ||
- enqueueKeyEventID == NULL ||
sendKeyEventID == NULL ||
requestFocusID == NULL) {
return JNI_FALSE;
}
- BuildDynamicKeyMapTable();
+ InitKeyMapTableScanCode(env);
return JNI_TRUE;
}
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 85b3a14c7..9b11ff0dd 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -28,8 +28,6 @@
#include "X11Common.h"
-#define USE_SENDIO_DIRECT 1
-
jclass X11NewtWindowClazz = NULL;
jmethodID insetsChangedID = NULL;
jmethodID visibleChangedID = NULL;
@@ -46,9 +44,7 @@ static jmethodID focusChangedID = NULL;
static jmethodID reparentNotifyID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowRepaintID = NULL;
-static jmethodID enqueueMouseEventID = NULL;
static jmethodID sendMouseEventID = NULL;
-static jmethodID enqueueKeyEventID = NULL;
static jmethodID sendKeyEventID = NULL;
static jmethodID requestFocusID = NULL;
@@ -59,10 +55,18 @@ static jmethodID requestFocusID = NULL;
#define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b))
static jint X11KeySym2NewtVKey(KeySym keySym) {
- if(IS_WITHIN(keySym,XK_F1,XK_F12))
- return (keySym-XK_F1)+J_VK_F1;
- if(IS_WITHIN(keySym,XK_KP_0,XK_KP_9))
- return (keySym-XK_KP_0)+J_VK_NUMPAD0;
+ if( IS_WITHIN( keySym, XK_a, XK_z ) ) {
+ return ( keySym - XK_a ) + J_VK_A ;
+ }
+ if( IS_WITHIN( keySym, XK_0, XK_9 ) ) {
+ return ( keySym - XK_0 ) + J_VK_0 ;
+ }
+ if( IS_WITHIN( keySym, XK_KP_0, XK_KP_9 ) ) {
+ return ( keySym - XK_KP_0 ) + J_VK_NUMPAD0 ;
+ }
+ if( IS_WITHIN( keySym, XK_F1, XK_F12 ) ) {
+ return ( keySym - XK_F1 ) + J_VK_F1 ;
+ }
switch(keySym) {
case XK_Return:
@@ -154,15 +158,15 @@ static jint X11KeySym2NewtVKey(KeySym keySym) {
return keySym;
}
-static jint X11InputState2NewtModifiers(unsigned int xstate, KeySym keySym) {
+static jint X11InputState2NewtModifiers(unsigned int xstate, int javaVKey) {
jint modifiers = 0;
- if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == keySym ) {
+ if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == javaVKey ) {
modifiers |= EVENT_CTRL_MASK;
}
- if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == keySym ) {
+ if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == javaVKey ) {
modifiers |= EVENT_SHIFT_MASK;
}
- if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == keySym ) {
+ if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == javaVKey ) {
modifiers |= EVENT_ALT_MASK;
}
if ( (Button1Mask & xstate) != 0 ) {
@@ -218,10 +222,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0
reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z");
windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V");
- enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIIF)V");
- sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIIF)V");
- enqueueKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueKeyEvent", "(ZIIIC)V");
- sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(IIIC)V");
+ sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V");
+ sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSC)V");
requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V");
if (displayCompletedID == NULL ||
@@ -235,9 +237,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0
reparentNotifyID == NULL ||
windowDestroyNotifyID == NULL ||
windowRepaintID == NULL ||
- enqueueMouseEventID == NULL ||
sendMouseEventID == NULL ||
- enqueueKeyEventID == NULL ||
sendKeyEventID == NULL ||
requestFocusID == NULL) {
return JNI_FALSE;
@@ -328,6 +328,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
jobject jwindow = NULL;
XEvent evt;
KeySym keySym = 0;
+ KeyCode keyCode = 0;
+ jshort javaVKeyUS = 0;
+ jshort javaVKeyNN = 0;
jint modifiers = 0;
char keyChar = 0;
char text[255];
@@ -386,18 +389,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK;
}
// fall through intended
- case KeyPress:
- if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) {
- KeySym lower_return = 0, upper_return = 0;
- keyChar=text[0];
- XConvertCase(keySym, &lower_return, &upper_return);
- // always return upper case, set modifier masks (SHIFT, ..)
- keySym = X11KeySym2NewtVKey(upper_return);
- } else {
- keyChar=0;
- keySym = X11KeySym2NewtVKey(keySym);
+ case KeyPress: {
+ KeySym shiftedKeySym; // layout depending keySym w/ SHIFT
+
+ keyCode = evt.xkey.keycode;
+ keySym = XkbKeycodeToKeysym(dpy, keyCode, 0 /* group */, 0 /* shift level */); // layout depending keySym w/o SHIFT
+
+ if( XLookupString(&evt.xkey, text, 255, &shiftedKeySym, 0) == 1 ) {
+ keyChar=text[0];
+ }
+
+ javaVKeyNN = X11KeySym2NewtVKey(keySym);
+ javaVKeyUS = javaVKeyNN; // FIXME!
+ modifiers |= X11InputState2NewtModifiers(evt.xkey.state, javaVKeyNN) | autoRepeatModifiers;
+
+ fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X (shifted: 0x%X), keyChar '%c', javaVKey[US 0x%X, NN 0x%X]\n",
+ (int)keyCode, (int)keySym, (int)shiftedKeySym, (int)keyChar, (int)javaVKeyUS, (int)javaVKeyNN);
}
- modifiers |= X11InputState2NewtModifiers(evt.xkey.state, keySym) | autoRepeatModifiers;
break;
case ButtonPress:
@@ -413,87 +421,39 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
switch(evt.type) {
case ButtonPress:
(*env)->CallVoidMethod(env, jwindow, requestFocusID, JNI_FALSE);
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED,
- modifiers,
- (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED,
modifiers,
- (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/);
- #endif
+ (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/);
break;
case ButtonRelease:
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED,
- modifiers,
- (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED,
modifiers,
- (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/);
- #endif
+ (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/);
break;
case MotionNotify:
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED,
modifiers,
- (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED,
- modifiers,
- (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/);
- #endif
+ (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jshort) 0, 0.0f /*rotation*/);
break;
case EnterNotify:
DBG_PRINT( "X11: event . EnterNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y);
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED,
- modifiers,
- (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_ENTERED,
modifiers,
- (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/);
- #endif
+ (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/);
break;
case LeaveNotify:
DBG_PRINT( "X11: event . LeaveNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y);
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_EXITED,
modifiers,
- (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED,
- modifiers,
- (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/);
- #endif
+ (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/);
break;
case KeyPress:
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED,
- modifiers, keySym, (jchar) keyChar);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED,
- modifiers, keySym, (jchar) keyChar);
- #endif
-
+ (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_PRESSED,
+ modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar);
break;
case KeyRelease:
- #ifdef USE_SENDIO_DIRECT
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED,
- modifiers, keySym, (jchar) keyChar);
-
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED,
- modifiers, keySym, (jchar) keyChar);
- #else
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED,
- modifiers, keySym, (jchar) keyChar);
-
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED,
- modifiers, keySym, (jchar) keyChar);
- #endif
-
+ (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_RELEASED,
+ modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar);
break;
case DestroyNotify:
DBG_PRINT( "X11: event . DestroyNotify call %p, parent %p, child-event: %d\n",
diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c
index bbddf764b..f3474ee34 100644
--- a/src/newt/native/bcm_vc_iv.c
+++ b/src/newt/native/bcm_vc_iv.c
@@ -50,8 +50,6 @@ static jmethodID windowCreatedID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID sendMouseEventID = NULL;
-static jmethodID sendKeyEventID = NULL;
/**
* Display
@@ -117,14 +115,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
if (windowCreatedID == NULL ||
sizeChangedID == NULL ||
visibleChangedID == NULL ||
- windowDestroyNotifyID == NULL ||
- sendMouseEventID == NULL ||
- sendKeyEventID == NULL) {
+ windowDestroyNotifyID == NULL) {
DBG_PRINT( "initIDs failed\n" );
return JNI_FALSE;
}