Fixed the NO_REMAP implementation, fixed few minor bg in Settings.java

This commit is contained in:
pelya
2011-05-30 15:25:08 +03:00
parent f06e5643e7
commit b10fefba4f
9 changed files with 31 additions and 72 deletions

View File

@@ -513,47 +513,8 @@ else
fi
KEY2=0
NoRemapMask=""
for KEY in $RedefinedKeys; do
if [ "$KEY" = "NO_REMAP" ] ; then
case $KEY2 in
0)
#not used at the moment
;;
1)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_DPAD_CENTER"
;;
2)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_VOLUME_UP"
;;
3)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_VOLUME_DOWN"
;;
4)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_MENU"
;;
5)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_BACK"
;;
6)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_CAMERA"
;;
7)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_ENTER"
;;
8)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_DEL"
;;
9)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_SEARCH"
;;
10)
NoRemapMask="$NoRemapMask|KeyEvent.KEYCODE_CALL"
;;
esac
else
RedefinedKeycodes="$RedefinedKeycodes -DSDL_ANDROID_KEYCODE_$KEY2=$KEY"
fi
RedefinedKeycodes="$RedefinedKeycodes -DSDL_ANDROID_KEYCODE_$KEY2=$KEY"
KEY2=`expr $KEY2 '+' 1`
done
@@ -625,8 +586,7 @@ cat project/src/Globals.java | \
sed "s/public static int AppTouchscreenKeyboardKeysAmountAutoFire = .*;/public static int AppTouchscreenKeyboardKeysAmountAutoFire = $AppTouchscreenKeyboardKeysAmountAutoFire;/" | \
sed "s%public static String ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" | \
sed "s%public static String CommandLine = .*%public static String CommandLine = \"$AppCmdline\";%" | \
sed "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" | \
sed "s/public static int RemapKeymask = .*;/public static int RemapKeymask = 0$NoRemapMask;/" > \
sed "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" > \
project/src/Globals.java.1
mv -f project/src/Globals.java.1 project/src/Globals.java

View File

@@ -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;
}

View File

@@ -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
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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) ) )

View File

@@ -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

View File

@@ -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