Still trying to get the overlay gamepad

This commit is contained in:
Gerhard Stein
2013-10-20 08:38:06 +02:00
parent 177661c77c
commit b66d746b81
3 changed files with 33 additions and 30 deletions

View File

@@ -329,9 +329,9 @@ public class MainActivity extends SDLActivity
setContentView(_videoLayout);*/ setContentView(_videoLayout);*/
/*mGLView = new DemoGLSurfaceView(this); mGLView = new DemoGLSurfaceView(this);
SetLayerType.get().setLayerType(mGLView); SetLayerType.get().setLayerType(mGLView);
mLayout.addView(mGLView);*/ mLayout.addView(mGLView);
//mGLView.setFocusableInTouchMode(true); //mGLView.setFocusableInTouchMode(true);
//mGLView.setFocusable(true); //mGLView.setFocusable(true);
//mGLView.requestFocus(); //mGLView.requestFocus();
@@ -474,7 +474,7 @@ public class MainActivity extends SDLActivity
if (sendBackspace && event.getAction() == KeyEvent.ACTION_UP) if (sendBackspace && event.getAction() == KeyEvent.ACTION_UP)
{ {
synchronized(textInput) { synchronized(textInput) {
DemoRenderer.nativeTextInput( 8, 0 ); // Send backspace to native code //DemoRenderer.nativeTextInput( 8, 0 ); // Send backspace to native code
} }
} }
// EditText deletes two characters at a time, here's a hacky fix // EditText deletes two characters at a time, here's a hacky fix
@@ -562,12 +562,12 @@ public class MainActivity extends SDLActivity
synchronized(textInput) synchronized(textInput)
{ {
String text = _screenKeyboard.getText().toString(); String text = _screenKeyboard.getText().toString();
for(int i = 0; i < text.length(); i++) /*for(int i = 0; i < text.length(); i++)
{ {
DemoRenderer.nativeTextInput( (int)text.charAt(i), (int)text.codePointAt(i) ); DemoRenderer.nativeTextInput( (int)text.charAt(i), (int)text.codePointAt(i) );
} }*/
} }
DemoRenderer.nativeTextInputFinished(); //DemoRenderer.nativeTextInputFinished();
_inputManager.hideSoftInputFromWindow(_screenKeyboard.getWindowToken(), 0); _inputManager.hideSoftInputFromWindow(_screenKeyboard.getWindowToken(), 0);
mLayout.removeView(_screenKeyboard); mLayout.removeView(_screenKeyboard);
_screenKeyboard = null; _screenKeyboard = null;
@@ -689,14 +689,14 @@ public class MainActivity extends SDLActivity
@Override @Override
public boolean onKeyDown(int keyCode, final KeyEvent event) public boolean onKeyDown(int keyCode, final KeyEvent event)
{ {
/*if(_screenKeyboard != null) if(_screenKeyboard != null)
_screenKeyboard.onKeyDown(keyCode, event); _screenKeyboard.onKeyDown(keyCode, event);
else else
if( mGLView != null ) if( mGLView != null )
{ {
if( mGLView.nativeKey( keyCode, 1 ) == 0 ) if( mGLView.nativeKey( keyCode, 1 ) == 0 )
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
}*/ }
/* /*
else else
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null ) if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
@@ -707,11 +707,11 @@ public class MainActivity extends SDLActivity
onStop(); onStop();
} }
*/ */
/*else else
if( keyListener != null ) if( keyListener != null )
{ {
keyListener.onKeyEvent(keyCode); keyListener.onKeyEvent(keyCode);
}*/ }
return true; return true;
} }

View File

@@ -454,8 +454,8 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceCreated(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); Log.i("SDL", "libSDL: DemoRenderer.onSurfaceCreated(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart );
mGlSurfaceCreated = true; mGlSurfaceCreated = true;
mGl = gl; mGl = gl;
if( ! mPaused && ! mFirstTimeStart ) /*if( ! mPaused && ! mFirstTimeStart )
nativeGlContextRecreated(); nativeGlContextRecreated();*/
mFirstTimeStart = false; mFirstTimeStart = false;
} }
@@ -471,14 +471,14 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
mWidth = w; mWidth = w;
mHeight = h; mHeight = h;
mGl = gl; mGl = gl;
nativeResize(w, h, Globals.KeepAspectRatio ? 1 : 0); //nativeResize(w, h, Globals.KeepAspectRatio ? 1 : 0);
} }
public void onSurfaceDestroyed() { public void onSurfaceDestroyed() {
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceDestroyed(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); Log.i("SDL", "libSDL: DemoRenderer.onSurfaceDestroyed(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart );
mGlSurfaceCreated = false; mGlSurfaceCreated = false;
mGlContextLost = true; mGlContextLost = true;
nativeGlContextLost(); //nativeGlContextLost();
}; };
public void onDrawFrame(GL10 gl) { public void onDrawFrame(GL10 gl) {
@@ -487,7 +487,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
DrawLogo(mGl); DrawLogo(mGl);
SwapBuffers(); SwapBuffers();
nativeInitJavaCallbacks(); //nativeInitJavaCallbacks();
// Make main thread priority lower so audio thread won't get underrun // Make main thread priority lower so audio thread won't get underrun
// Thread.currentThread().setPriority((Thread.currentThread().getPriority() + Thread.MIN_PRIORITY)/2); // Thread.currentThread().setPriority((Thread.currentThread().getPriority() + Thread.MIN_PRIORITY)/2);
@@ -503,10 +503,10 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
if(Globals.AudioBufferConfig >= 2) if(Globals.AudioBufferConfig >= 2)
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
nativeInit( Globals.DataDir, /*nativeInit( Globals.DataDir,
Globals.CommandLine, Globals.CommandLine,
( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0, ( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0,
android.os.Debug.isDebuggerConnected() ? 1 : 0 ); android.os.Debug.isDebuggerConnected() ? 1 : 0 );*/
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
} }
@@ -618,7 +618,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
public void exitApp() public void exitApp()
{ {
nativeDone(); //nativeDone();
} }
public void getAdvertisementParams(int params[]) public void getAdvertisementParams(int params[])
@@ -702,15 +702,15 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
} }
private native void nativeInitJavaCallbacks(); //private native void nativeInitJavaCallbacks();
private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo, int isDebuggerConnected); //private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo, int isDebuggerConnected);
private native void nativeResize(int w, int h, int keepAspectRatio); //private native void nativeResize(int w, int h, int keepAspectRatio);
private native void nativeDone(); //private native void nativeDone();
private native void nativeGlContextLost(); //private native void nativeGlContextLost();
public native void nativeGlContextRecreated(); //public native void nativeGlContextRecreated();
public native void nativeGlContextLostAsyncEvent(); //public native void nativeGlContextLostAsyncEvent();
public static native void nativeTextInput( int ascii, int unicode ); //public static native void nativeTextInput( int ascii, int unicode );
public static native void nativeTextInputFinished(); //public static native void nativeTextInputFinished();
private MainActivity context = null; private MainActivity context = null;
public AccelerometerReader accelerometer = null; public AccelerometerReader accelerometer = null;
@@ -788,7 +788,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
if(mRenderer.mPaused) if(mRenderer.mPaused)
return; return;
mRenderer.mPaused = true; mRenderer.mPaused = true;
mRenderer.nativeGlContextLostAsyncEvent(); //mRenderer.nativeGlContextLostAsyncEvent();
if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization? if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization?
mRenderer.accelerometer.stop(); mRenderer.accelerometer.stop();
super.onPause(); super.onPause();
@@ -805,8 +805,8 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
mRenderer.mPaused = false; mRenderer.mPaused = false;
super.onResume(); super.onResume();
Log.i("SDL", "libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused); Log.i("SDL", "libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers ) /*if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
mRenderer.nativeGlContextRecreated(); mRenderer.nativeGlContextRecreated();*/
if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization? if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
mRenderer.accelerometer.start(); mRenderer.accelerometer.start();
}; };

View File

@@ -9,6 +9,9 @@
#include "jniwrapperstuff.h" #include "jniwrapperstuff.h"
// System specific functions
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value ) JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
{ {