Fixed the NO_REMAP implementation, fixed few minor bg in Settings.java
This commit is contained in:
@@ -103,5 +103,4 @@ class Globals {
|
||||
public static String DataDir = new String("");
|
||||
public static boolean SmoothVideo = false;
|
||||
public static boolean MultiThreadedVideo = false;
|
||||
public static int RemapKeymask = 0;
|
||||
}
|
||||
|
||||
@@ -254,6 +254,7 @@ class SDL_1_2_Keycodes {
|
||||
public static final int SDLK_EURO = 321;
|
||||
public static final int SDLK_UNDO = 322;
|
||||
|
||||
public static final int SDLK_NO_REMAP = 512;
|
||||
}
|
||||
|
||||
// Autogenerated by hand with a command:
|
||||
@@ -500,6 +501,7 @@ class SDL_1_3_Keycodes {
|
||||
public static final int SDLK_EJECT = 281;
|
||||
public static final int SDLK_SLEEP = 282;
|
||||
|
||||
public static final int SDLK_NO_REMAP = 512;
|
||||
}
|
||||
|
||||
class SDL_Keys
|
||||
@@ -511,7 +513,7 @@ class SDL_Keys
|
||||
public static Integer [] namesSortedIdx = null;
|
||||
public static Integer [] namesSortedBackIdx = null;
|
||||
|
||||
static final int JAVA_KEYCODE_LAST = 110; // Android 2.3 added several new gaming keys, it ends up at keycode 110 currently - plz keep in sync with javakeycodes.h
|
||||
static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
|
||||
|
||||
static
|
||||
{
|
||||
|
||||
@@ -320,13 +320,12 @@ public class MainActivity extends Activity {
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
||||
{
|
||||
// Overrides Back key to use in our app
|
||||
if(_screenKeyboard != null)
|
||||
_screenKeyboard.onKeyDown(keyCode, event);
|
||||
else
|
||||
if( mGLView != null )
|
||||
{
|
||||
if( !mGLView.callNativeKey( keyCode, 1 ) )
|
||||
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
else
|
||||
@@ -353,7 +352,7 @@ public class MainActivity extends Activity {
|
||||
else
|
||||
if( mGLView != null )
|
||||
{
|
||||
if( !mGLView.callNativeKey( keyCode, 0 ) )
|
||||
if( mGLView.nativeKey( keyCode, 0 ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1341,7 +1341,7 @@ class Settings
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
@@ -1712,7 +1712,7 @@ class Settings
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
|
||||
@@ -399,27 +399,18 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
mRenderer.nativeGlContextRecreated();
|
||||
};
|
||||
|
||||
// This seems like redundant code - it handled in MainActivity.java
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
||||
if( !callNativeKey( keyCode, 1 ) )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
if( nativeKey( keyCode, 1 ) == 0 )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
||||
if( !callNativeKey( keyCode, 0 ) )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean callNativeKey(int keyCode, int down) {
|
||||
if( (Globals.RemapKeymask & keyCode ) == keyCode )
|
||||
{
|
||||
// no remap made for the key
|
||||
return false;
|
||||
}
|
||||
nativeKey( keyCode, down );
|
||||
if( nativeKey( keyCode, 0 ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -428,7 +419,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
DifferentTouchInput touchInput = null;
|
||||
|
||||
public static native void nativeMouse( int x, int y, int action, int pointerId, int pressure, int radius );
|
||||
public static native void nativeKey( int keyCode, int down );
|
||||
public static native int nativeKey( int keyCode, int down );
|
||||
public static native void initJavaCallbacks();
|
||||
|
||||
}
|
||||
|
||||
@@ -652,29 +652,34 @@ void SDL_ANDROID_WarpMouse(int x, int y)
|
||||
|
||||
static int processAndroidTrackball(int key, int action);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNIEXPORT jint JNICALL
|
||||
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint key, jint action )
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#else
|
||||
if( !SDL_CurrentVideoSurface )
|
||||
return;
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
if( isTrackballUsed )
|
||||
if( processAndroidTrackball(key, action) )
|
||||
return;
|
||||
return 1;
|
||||
if( key == rightClickKey && rightClickMethod == RIGHT_CLICK_WITH_KEY )
|
||||
{
|
||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
if( (key == leftClickKey && leftClickMethod == LEFT_CLICK_WITH_KEY) || (clickMouseWithDpadCenter && key == KEYCODE_DPAD_CENTER) )
|
||||
{
|
||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( TranslateKey(key) == SDLK_NO_REMAP )
|
||||
return 0;
|
||||
|
||||
SDL_ANDROID_MainThreadPushKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char * textInputBuffer = NULL;
|
||||
@@ -762,6 +767,7 @@ static int getClickTimeout(int v)
|
||||
return 1000;
|
||||
}
|
||||
|
||||
// Mwahaha overkill!
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||
jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickMethod,
|
||||
@@ -1331,7 +1337,6 @@ extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
|
||||
|
||||
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||
|
||||
|
||||
if( moveMouseWithArrowKeys && (
|
||||
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
|
||||
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
|
||||
/* JNI-C++ wrapper stuff */
|
||||
|
||||
// Special key to signal that key should be handled by Java internally, such as Volume Up/Down keys
|
||||
#define SDLK_NO_REMAP 512
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
#define SDL_KEY2(X) SDL_SCANCODE_ ## X
|
||||
|
||||
@@ -97,7 +97,7 @@ KEYCODE_MEDIA_REWIND = 89,
|
||||
KEYCODE_MEDIA_FAST_FORWARD = 90,
|
||||
KEYCODE_MUTE = 91,
|
||||
|
||||
KEYCODE_LAST = 110 // Android 2.3 added several new gaming keys, it ends up at keycode 110 currently - plz keep in sync with Keycodes.java
|
||||
KEYCODE_LAST = 255 // Android 2.3 added several new gaming keys, Android 3.1 added even more - plz keep in sync with Keycodes.java
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user