summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-16 21:09:16 +0200
committerSven Gothel <[email protected]>2012-04-16 21:09:16 +0200
commit2f0583aad39f93a934629c21beac66a758373249 (patch)
treeb23dab93bd3a01ebf298d94624de3247a8b114f5 /src/test/com
parentc4597b3a80f9fcbf89640bb007bc9004c361b6c7 (diff)
NEWT/Android: Add (soft) keyboard input. Complete the Android -> NEWT key translation. Minor fixes for mouse as well.
- AndroidNewtEventFactory - Android -> NEWT KeyCodes, leave out control keys like HOME, BACK, .. TBD .. - We don't consume the key event, in case we cannot map it, so the Android OS has a chance to handle the control keys. - Key-Release generates a Key Typed event. - Key/Mouse translate Android time-base (upTime) to Unix. - AndroidWindow - set our onKeyListener, using above tranlator - setFocusable(true) and setFocusableInTouchMode(true) on our SurfaceView, otherwise no key event will be delivered. Note: 'requestFocus()' must also be called on the view for key input! - Test: NEWTGearsES2Activity, which launches the soft key via: InputMethodManager mgr = (InputMethodManager) win.getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); // shows keyboard .. and requests the focus of the view for input.
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java16
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java8
2 files changed, 20 insertions, 4 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index c0eaec842..592ecf5d6 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -30,17 +30,22 @@ package com.jogamp.opengl.test.android;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
+import jogamp.newt.driver.android.AndroidWindow;
import jogamp.newt.driver.android.NewtBaseActivity;
import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.ScreenModeListener;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.util.Animator;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
+import android.view.inputmethod.InputMethodManager;
public class NEWTGearsES2Activity extends NewtBaseActivity {
static String TAG = "NEWTGearsES2Activity";
@@ -56,6 +61,17 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
GLWindow glWindow = GLWindow.create(caps);
glWindow.setFullscreen(true);
setContentView(getWindow(), glWindow);
+ glWindow.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if(e.getPressure()>2f) { // show Keyboard
+ final AndroidWindow win = (AndroidWindow)e.getSource();
+ InputMethodManager mgr = (InputMethodManager) win.getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); // shows keyboard ..
+ win.getAndroidView().requestFocus();
+ }
+ }
+ });
GearsES2 demo = new GearsES2(-1);
// demo.enableAndroidTrace(true);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
index 1a636a1aa..1dfdde515 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
@@ -52,14 +52,14 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc
props.setProperty("jogl.debug.GLDrawable", "true");
props.setProperty("jogl.debug.GLContext", "true");
props.setProperty("jogl.debug.GLSLCode", "true");
- props.setProperty("jogl.debug.CapabilitiesChooser", "true");
+ // props.setProperty("jogl.debug.CapabilitiesChooser", "true");
// properties.setProperty("jogl.debug.GLSLState", "true");
// properties.setProperty("jogl.debug.DebugGL", "true");
// properties.setProperty("jogl.debug.TraceGL", "true");
// properties.setProperty("newt.debug", "all");
- props.setProperty("newt.debug.Window", "true");
- // properties.setProperty("newt.debug.Window.MouseEvent", "true");
- // properties.setProperty("newt.debug.Window.KeyEvent", "true");
+ // props.setProperty("newt.debug.Window", "true");
+ // props.setProperty("newt.debug.Window.MouseEvent", "true");
+ // props.setProperty("newt.debug.Window.KeyEvent", "true");
props.setProperty("jogamp.debug.IOUtil", "true");
}