aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-02-28 13:31:29 +0100
committerSven Gothel <[email protected]>2013-02-28 13:31:29 +0100
commit3a4892c43be4a9dabba73d42175c2cfa39bd6d8d (patch)
tree8780bb35234f6d16c89efc34c94409816f54464a /src/newt/classes/com
parent1f9bff1aab54c399438c735581508ac85c6a29b3 (diff)
Fix Bug 677: NEWT/Android: Add support for Android's KeyEvent.KEYCODE_BACK
Original author: Eric Brayet <[email protected]> Revised by: Sven Gothel <[email protected]> I took the freedom to cleanup the three original patches from https://github.com/Pooouf/jogl.git branch 'bug_677': - 7449d4726633d524a3bb79efffd04cfd0ca25e58 (removed by followup patch!) - 68c739a4f03e46deecdbb71c125b4586aec08d63 (removes previous patch!) - c2813dfc325a1482d18b6fc304e4e483f5633964 Further more I was able to reduce the 'extra' code while utilizing - Window's isKeyboardVisible() and using keyboardVisibilityChanged(false) to update the hidden keyboard state. - Moving the key-handling code to the containing WindowDriver class avoiding passing a reference to the inner view. - Using AndroidNewtEventFactory for NEWT KeyEvent creation +++ - Handle KeyEvent.KEYCODE_BACK w/ jogamp.newt.driver.android.WindowDriver.MSurfaceView.onKeyPreIme(..): if( soft keyboard is up ) [1] Update keyboard visibility state and return NEWT KeyEvent.VK_KEYBOARD_INVISIBLE; else [2] call WindowImpl.windowDestroyNotify(true) [3] then cont. processing, i.e. return false; - Turns out respecting WindowClosingMode might be - too complicated - interfere w/ Android UI behavior - AndroidNewtEventFactory - createKeyEvent - static - adding boolean param 'inclSysKeys', if true, KEYCODE_BACK and KEYCODE_HOME are mapped - Unit tests: GearsES2 + MovieCubeActivity0 shows keyboard if pressure > 0.6f - pressure on Android shall be between [0..1], however we have to figure out badly calibrated touchpads/Android device where we could experience pressure > 2.0f ! - TODO: API documentation of pressure [0..1]
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyEvent.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/event/NEWTEvent.java2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index f626fec38..5117ffe29 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -872,6 +872,11 @@ public class KeyEvent extends InputEvent
public static final short VK_BEGIN = (short) 0xFF58;
/**
+ * Constant for Keyboard became invisible, e.g. Android's soft keyboard Back button hit while keyboard is visible.
+ */
+ public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD;
+
+ /**
* This value is used to indicate that the keyCode is unknown.
* KEY_TYPED events do not have a keyCode value; this value
* is used instead.
diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
index 6f4561ce6..17210cef8 100644
--- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java
@@ -107,7 +107,7 @@ public class NEWTEvent extends java.util.EventObject {
return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]");
}
- static String toHexString(short hex) {
+ public static String toHexString(short hex) {
return "0x" + Integer.toHexString( (int)hex & 0x0000FFFF );
}
}