Fixed the NO_REMAP implementation, fixed few minor bg in Settings.java
This commit is contained in:
@@ -513,47 +513,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
KEY2=0
|
KEY2=0
|
||||||
NoRemapMask=""
|
|
||||||
for KEY in $RedefinedKeys; do
|
for KEY in $RedefinedKeys; do
|
||||||
if [ "$KEY" = "NO_REMAP" ] ; then
|
RedefinedKeycodes="$RedefinedKeycodes -DSDL_ANDROID_KEYCODE_$KEY2=$KEY"
|
||||||
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
|
|
||||||
KEY2=`expr $KEY2 '+' 1`
|
KEY2=`expr $KEY2 '+' 1`
|
||||||
done
|
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 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 ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" | \
|
||||||
sed "s%public static String CommandLine = .*%public static String CommandLine = \"$AppCmdline\";%" | \
|
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 String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" > \
|
||||||
sed "s/public static int RemapKeymask = .*;/public static int RemapKeymask = 0$NoRemapMask;/" > \
|
|
||||||
project/src/Globals.java.1
|
project/src/Globals.java.1
|
||||||
mv -f project/src/Globals.java.1 project/src/Globals.java
|
mv -f project/src/Globals.java.1 project/src/Globals.java
|
||||||
|
|
||||||
|
|||||||
@@ -103,5 +103,4 @@ class Globals {
|
|||||||
public static String DataDir = new String("");
|
public static String DataDir = new String("");
|
||||||
public static boolean SmoothVideo = false;
|
public static boolean SmoothVideo = false;
|
||||||
public static boolean MultiThreadedVideo = 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_EURO = 321;
|
||||||
public static final int SDLK_UNDO = 322;
|
public static final int SDLK_UNDO = 322;
|
||||||
|
|
||||||
|
public static final int SDLK_NO_REMAP = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autogenerated by hand with a command:
|
// 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_EJECT = 281;
|
||||||
public static final int SDLK_SLEEP = 282;
|
public static final int SDLK_SLEEP = 282;
|
||||||
|
|
||||||
|
public static final int SDLK_NO_REMAP = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SDL_Keys
|
class SDL_Keys
|
||||||
@@ -511,7 +513,7 @@ class SDL_Keys
|
|||||||
public static Integer [] namesSortedIdx = null;
|
public static Integer [] namesSortedIdx = null;
|
||||||
public static Integer [] namesSortedBackIdx = 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
|
static
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -320,13 +320,12 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
||||||
{
|
{
|
||||||
// Overrides Back key to use in our app
|
|
||||||
if(_screenKeyboard != null)
|
if(_screenKeyboard != null)
|
||||||
_screenKeyboard.onKeyDown(keyCode, event);
|
_screenKeyboard.onKeyDown(keyCode, event);
|
||||||
else
|
else
|
||||||
if( mGLView != null )
|
if( mGLView != null )
|
||||||
{
|
{
|
||||||
if( !mGLView.callNativeKey( keyCode, 1 ) )
|
if( mGLView.nativeKey( keyCode, 1 ) == 0 )
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -353,7 +352,7 @@ public class MainActivity extends Activity {
|
|||||||
else
|
else
|
||||||
if( mGLView != null )
|
if( mGLView != null )
|
||||||
{
|
{
|
||||||
if( !mGLView.callNativeKey( keyCode, 0 ) )
|
if( mGLView.nativeKey( keyCode, 0 ) == 0 )
|
||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1341,7 +1341,7 @@ class Settings
|
|||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
public void onKeyEvent(final int keyCode)
|
||||||
{
|
{
|
||||||
p.touchListener = null;
|
p.keyListener = null;
|
||||||
int keyIndex = keyCode;
|
int keyIndex = keyCode;
|
||||||
if( keyIndex < 0 )
|
if( keyIndex < 0 )
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
@@ -1712,7 +1712,7 @@ class Settings
|
|||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
public void onKeyEvent(final int keyCode)
|
||||||
{
|
{
|
||||||
p.touchListener = null;
|
p.keyListener = null;
|
||||||
int keyIndex = keyCode;
|
int keyIndex = keyCode;
|
||||||
if( keyIndex < 0 )
|
if( keyIndex < 0 )
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
|
|||||||
@@ -399,27 +399,18 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
mRenderer.nativeGlContextRecreated();
|
mRenderer.nativeGlContextRecreated();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This seems like redundant code - it handled in MainActivity.java
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
||||||
if( !callNativeKey( keyCode, 1 ) )
|
if( nativeKey( keyCode, 1 ) == 0 )
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
||||||
if( !callNativeKey( keyCode, 0 ) )
|
if( nativeKey( keyCode, 0 ) == 0 )
|
||||||
return super.onKeyUp(keyCode, event);
|
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 );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +419,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
DifferentTouchInput touchInput = null;
|
DifferentTouchInput touchInput = null;
|
||||||
|
|
||||||
public static native void nativeMouse( int x, int y, int action, int pointerId, int pressure, int radius );
|
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();
|
public static native void initJavaCallbacks();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -652,29 +652,34 @@ void SDL_ANDROID_WarpMouse(int x, int y)
|
|||||||
|
|
||||||
static int processAndroidTrackball(int key, int action);
|
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 )
|
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint key, jint action )
|
||||||
{
|
{
|
||||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
#else
|
#else
|
||||||
if( !SDL_CurrentVideoSurface )
|
if( !SDL_CurrentVideoSurface )
|
||||||
return;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( isTrackballUsed )
|
if( isTrackballUsed )
|
||||||
if( processAndroidTrackball(key, action) )
|
if( processAndroidTrackball(key, action) )
|
||||||
return;
|
return 1;
|
||||||
if( key == rightClickKey && rightClickMethod == RIGHT_CLICK_WITH_KEY )
|
if( key == rightClickKey && rightClickMethod == RIGHT_CLICK_WITH_KEY )
|
||||||
{
|
{
|
||||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
|
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) )
|
if( (key == leftClickKey && leftClickMethod == LEFT_CLICK_WITH_KEY) || (clickMouseWithDpadCenter && key == KEYCODE_DPAD_CENTER) )
|
||||||
{
|
{
|
||||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
|
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) );
|
SDL_ANDROID_MainThreadPushKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key) );
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * textInputBuffer = NULL;
|
static char * textInputBuffer = NULL;
|
||||||
@@ -762,6 +767,7 @@ static int getClickTimeout(int v)
|
|||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mwahaha overkill!
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||||
jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickMethod,
|
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];
|
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
|
||||||
|
|
||||||
|
|
||||||
if( moveMouseWithArrowKeys && (
|
if( moveMouseWithArrowKeys && (
|
||||||
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
|
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
|
||||||
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
|
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
|
||||||
|
|||||||
@@ -52,6 +52,9 @@
|
|||||||
|
|
||||||
/* JNI-C++ wrapper stuff */
|
/* 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)
|
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||||
|
|
||||||
#define SDL_KEY2(X) SDL_SCANCODE_ ## X
|
#define SDL_KEY2(X) SDL_SCANCODE_ ## X
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ KEYCODE_MEDIA_REWIND = 89,
|
|||||||
KEYCODE_MEDIA_FAST_FORWARD = 90,
|
KEYCODE_MEDIA_FAST_FORWARD = 90,
|
||||||
KEYCODE_MUTE = 91,
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user