summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2013-04-08 22:45:22 +0200
committerSven Gothel <sgothel@jausoft.com>2013-04-08 22:45:22 +0200
commit6755fc707672a77025bcde81a47a5e4d93b37fb1 (patch)
tree3e006015a8652454786d426b4cc374666da8f103
parent9b28aea53c9b7aa6fb8c9ae5521d935fa92d1026 (diff)
NEWT KeyEvent: More tight definition of isPrintable(), i.e. must have defined keyCode [and keyChar]; VK_KEYBOARD_INVISIBLE -> isActionKey
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyEvent.java36
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java2
3 files changed, 26 insertions, 16 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index 777c9b471..a3613fe2e 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -94,6 +94,9 @@ public class KeyEvent extends InputEvent
if( isActionKey(keySym) ) {
_flags |= F_ACTION_MASK;
}
+ if( 0 == _flags && VK_UNDEFINED != keySym && NULL_CHAR != keyChar ) {
+ _flags |= F_PRINTABLE_MASK;
+ }
flags = _flags;
}
}
@@ -261,7 +264,7 @@ public class KeyEvent extends InputEvent
case VK_COMPOSE:
case VK_BEGIN:
-
+ case VK_KEYBOARD_INVISIBLE:
return true;
}
return false;
@@ -279,23 +282,26 @@ public class KeyEvent extends InputEvent
}
/**
- * Returns <code>true</code> if given <code>virtualKey</code> represents a printable character,
- * i.e. neither a {@link #isModifierKey(short) modifier key}
+ * Returns <code>true</code> if given <code>virtualKey</code> represents a printable character,
+ * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key}
* nor an {@link #isActionKey(short) action key}.
* Otherwise returns <code>false</code>.
*/
public static boolean isPrintableKey(short vKey) {
- return !isModifierKey(vKey) && !isActionKey(vKey);
+ return VK_UNDEFINED != vKey && !isModifierKey(vKey) && !isActionKey(vKey);
}
/**
- * 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}.
+ * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a printable character,
+ * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key}
+ * nor an {@link #isActionKey(short) action key}. The {@link #getKeyChar() key char} value must also be
+ * different than {@link #NULL_CHAR}.
+ * <p>
* Otherwise returns <code>false</code>.
+ * </p>
*/
public final boolean isPrintableKey() {
- return 0 == ( F_NON_PRINT_MASK & flags ) ;
+ return 0 != ( F_PRINTABLE_MASK & flags ) ;
}
private final short keyCode;
@@ -304,7 +310,7 @@ public class KeyEvent extends InputEvent
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 ;
+ private static final byte F_PRINTABLE_MASK = 1 << 2;
/** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */
public static final short EVENT_KEY_PRESSED = 300;
@@ -880,10 +886,14 @@ public class KeyEvent extends InputEvent
public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD;
/**
- * 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.
+ * This value, {@value}, is used to indicate that the keyCode is unknown.
*/
- public static final short VK_UNDEFINED = (short) 0x0;
+ public static final short VK_UNDEFINED = (short) 0x0;
+
+ /**
+ * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable.
+ */
+ public static final char NULL_CHAR = '\0';
+
}
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 4c2ed06e8..9638e6a7c 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -155,7 +155,7 @@ public class AndroidNewtEventFactory {
}
break;
}
- return (short)0;
+ return com.jogamp.newt.event.KeyEvent.VK_UNDEFINED;
}
private static final int aKeyModifiers2Newt(int androidMods) {
@@ -211,7 +211,7 @@ public class AndroidNewtEventFactory {
}
private static com.jogamp.newt.event.KeyEvent createKeyEventImpl(android.view.KeyEvent aEvent, short newtType, short newtKeyCode, com.jogamp.newt.Window newtSource) {
- if( (short)0 != newtType && (short)0 != newtKeyCode ) {
+ if( (short)0 != newtType && com.jogamp.newt.event.KeyEvent.VK_UNDEFINED != newtKeyCode ) {
final Object src = null==newtSource ? null : newtSource;
final long unixTime = System.currentTimeMillis() + ( aEvent.getEventTime() - android.os.SystemClock.uptimeMillis() );
final int newtMods = aKeyModifiers2Newt(aEvent.getMetaState());
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java
index bc69c2204..80b1b6687 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java
@@ -859,7 +859,7 @@ public class LinuxEventDeviceTracker implements WindowListener {
case 239: // UWB
break; // FIXME
case 240: // unknown
- return KeyEvent.VK_UNDEFINED; // FIXME ?
+ return KeyEvent.VK_UNDEFINED;
case 241: // video next
break; // FIXME
case 242: // video prev