SDL: fixed on-screen key layout and keycode remap dialogs, moved screen gestures to a separate variable

This commit is contained in:
Sergii Pylypenko
2021-05-31 02:36:56 +03:00
parent 05615e643d
commit 50df6e53d0
6 changed files with 97 additions and 49 deletions

View File

@@ -90,43 +90,64 @@ fi
if [ -z "$AppVersionCode" -o "-$AUTO" != "-a" ]; then
echo
echo -n "Application version code (integer) ($AppVersionCode): "
read var
if [ -n "$var" ] ; then
AppVersionCode="$var"
CHANGED=1
fi
echo
echo -n "Application version code (integer) ($AppVersionCode): "
read var
if [ -n "$var" ] ; then
AppVersionCode="$var"
CHANGED=1
fi
fi
if [ -z "$AppVersionName" -o "-$AUTO" != "-a" ]; then
echo
echo -n "Application user-visible version name (string) ($AppVersionName): "
read var
if [ -n "$var" ] ; then
AppVersionName="$var"
CHANGED=1
fi
echo
echo -n "Application user-visible version name (string) ($AppVersionName): "
read var
if [ -n "$var" ] ; then
AppVersionName="$var"
CHANGED=1
fi
fi
if [ -z "$ResetSdlConfigForThisVersion" -o "-$AUTO" != "-a" ]; then
echo
echo -n "Reset SDL config when updating application to the new version (y) / (n) ($ResetSdlConfigForThisVersion): "
read var
if [ -n "$var" ] ; then
ResetSdlConfigForThisVersion="$var"
CHANGED=1
fi
echo
echo -n "Reset SDL config when updating application to the new version (y) / (n) ($ResetSdlConfigForThisVersion): "
read var
if [ -n "$var" ] ; then
ResetSdlConfigForThisVersion="$var"
CHANGED=1
fi
fi
if [ "-$AUTO" != "-a" ]; then
echo
echo -n "Delete application data files when upgrading (specify file/dir paths separated by spaces): ($DeleteFilesOnUpgrade): "
read var
if [ -n "$var" ] ; then
DeleteFilesOnUpgrade="$var"
CHANGED=1
echo
echo -n "Delete application data files when upgrading (specify file/dir paths separated by spaces): ($DeleteFilesOnUpgrade): "
read var
if [ -n "$var" ] ; then
DeleteFilesOnUpgrade="$var"
CHANGED=1
fi
fi
# Compatibility - if RedefinedKeysScreenGestures is empty, copy keycodes from RedefinedKeysScreenKb
KEY2=0
if [ -z "$RedefinedKeysScreenGestures" ] ; then
RedefinedKeysScreenGestures="$(
for KEY in $RedefinedKeysScreenKb; do
if [ $KEY2 -ge 6 ] && [ $KEY2 -le 9 ]; then
echo -n $KEY ' '
fi
KEY2=$(expr $KEY2 '+' 1)
done
)"
RedefinedKeysScreenKb="$(
for KEY in $RedefinedKeysScreenKb; do
if [ $KEY2 -lt 6 ] || [ $KEY2 -gt 9 ]; then
echo -n $KEY ' '
fi
KEY2=$(expr $KEY2 '+' 1)
done
)"
fi
if [ -n "$CHANGED" ]; then
@@ -348,8 +369,10 @@ echo >> AndroidAppSettings.cfg
echo "# Number of virtual keyboard keys - currently 12 keys is the maximum" >> AndroidAppSettings.cfg
echo AppTouchscreenKeyboardKeysAmount=$AppTouchscreenKeyboardKeysAmount >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) + 6 additional keyboard keys" >> AndroidAppSettings.cfg
echo "# Multitouch gestures should be moved to a separate variable, but are left here for compatibility" >> AndroidAppSettings.cfg
echo "# Define SDL keysyms for multitouch gestures - pinch-zoom in, pinch-zoom out, rotate left, rotate right" >> AndroidAppSettings.cfg
echo RedefinedKeysScreenGestures=\"$RedefinedKeysScreenGestures\" >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Redefine on-screen keyboard keys to SDL keysyms - currently 12 keys is the maximum" >> AndroidAppSettings.cfg
echo RedefinedKeysScreenKb=\"$RedefinedKeysScreenKb\" >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu" >> AndroidAppSettings.cfg
@@ -711,6 +734,12 @@ for KEY in $RedefinedKeys; do
KEY2=`expr $KEY2 '+' 1`
done
KEY2=0
for KEY in $RedefinedKeysScreenGestures; do
RedefinedSDLScreenGestures="$RedefinedSDLScreenGestures -DSDL_ANDROID_SCREEN_GESTURE_KEYCODE_$KEY2=$KEY"
KEY2=`expr $KEY2 '+' 1`
done
KEY2=0
for KEY in $RedefinedKeysScreenKb; do
RedefinedKeycodesScreenKb="$RedefinedKeycodesScreenKb -DSDL_ANDROID_SCREENKB_KEYCODE_$KEY2=$KEY"
@@ -1026,6 +1055,7 @@ cat project/jni/SettingsTemplate.mk | \
sed "s^USE_GL4ES :=.*^USE_GL4ES := $UseGl4es^" | \
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := \
$RedefinedKeycodes \
$RedefinedSDLScreenGestures \
$RedefinedKeycodesScreenKb \
$RedefinedKeycodesGamepad \
$CompatibilityHacksPreventAudioChopping \

View File

@@ -1008,7 +1008,7 @@ public class Settings
int HoverJitterFilter, int RightMouseButtonLongPress,
int MoveMouseWithGyroscope, int MoveMouseWithGyroscopeSpeed,
int ForceScreenUpdateMouseClick, int ScreenFollowsMouse);
private static native void nativeSetJoystickUsed(int amount);
public static native void nativeSetJoystickUsed(int amount);
private static native void nativeSetAccelerometerUsed();
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();

View File

@@ -457,7 +457,12 @@ class SettingsMenuKeyboard extends SettingsMenu
goBack(p);
return;
}
if( ! Globals.ScreenKbControlsShown[currentButton + 2] )
if( currentButton < 6 && ! Globals.ScreenKbControlsShown[currentButton + 2] )
{
showRemapScreenKbConfig2(p, currentButton + 1);
return;
}
if( currentButton >= 6 && ! Globals.ScreenKbControlsShown[currentButton + 4] )
{
showRemapScreenKbConfig2(p, currentButton + 1);
return;
@@ -672,6 +677,12 @@ class SettingsMenuKeyboard extends SettingsMenu
public CustomizeScreenKbLayoutTool(MainActivity _p)
{
if( buttons.length != Globals.ScreenKbControlsLayout.length )
{
Log.i("SDL", "Assertion failed: buttons.length != Globals.ScreenKbControlsLayout.length" );
throw new RuntimeException("Assertion failed: buttons.length != Globals.ScreenKbControlsLayout.length");
}
p = _p;
layout = new FrameLayout(p);
p.getVideoLayout().addView(layout);
@@ -694,6 +705,7 @@ class SettingsMenuKeyboard extends SettingsMenu
if( Globals.TouchscreenKeyboardSize != Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
{
DemoRenderer.nativeResize(displayX, displayY, 0);
Settings.nativeSetJoystickUsed( Globals.AppUsesThirdJoystick ? 3 : (Globals.AppUsesSecondJoystick ? 2 : (Globals.AppUsesJoystick ? 1 : 0)) );
Settings.nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
Globals.TouchscreenKeyboardDrawSize,
Globals.TouchscreenKeyboardTheme,

View File

@@ -118,10 +118,10 @@ static int touchPointers[MAX_MULTITOUCH_POINTERS] = {0};
static int firstMousePointerId = -1, secondMousePointerId = -1;
enum { MAX_MULTITOUCH_GESTURES = 4 };
static int multitouchGestureKeycode[MAX_MULTITOUCH_GESTURES] = {
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_6)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_7)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_8)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_9))
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREEN_GESTURE_KEYCODE_0)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREEN_GESTURE_KEYCODE_1)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREEN_GESTURE_KEYCODE_2)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREEN_GESTURE_KEYCODE_3))
};
static int multitouchGestureSensitivity = 0;
static int multitouchGestureDist = -1;

View File

@@ -216,17 +216,18 @@ extern int SDL_ANDROID_isTouchscreenKeyboardUsed;
#ifndef SDL_ANDROID_SCREENKB_KEYCODE_11
#define SDL_ANDROID_SCREENKB_KEYCODE_11 UNKNOWN
#endif
#ifndef SDL_ANDROID_SCREENKB_KEYCODE_12
#define SDL_ANDROID_SCREENKB_KEYCODE_12 UNKNOWN
#ifndef SDL_ANDROID_SCREEN_GESTURE_KEYCODE_0
#define SDL_ANDROID_SCREEN_GESTURE_KEYCODE_0 UNKNOWN
#endif
#ifndef SDL_ANDROID_SCREENKB_KEYCODE_13
#define SDL_ANDROID_SCREENKB_KEYCODE_13 UNKNOWN
#ifndef SDL_ANDROID_SCREEN_GESTURE_KEYCODE_1
#define SDL_ANDROID_SCREEN_GESTURE_KEYCODE_1 UNKNOWN
#endif
#ifndef SDL_ANDROID_SCREENKB_KEYCODE_14
#define SDL_ANDROID_SCREENKB_KEYCODE_14 UNKNOWN
#ifndef SDL_ANDROID_SCREEN_GESTURE_KEYCODE_2
#define SDL_ANDROID_SCREEN_GESTURE_KEYCODE_2 UNKNOWN
#endif
#ifndef SDL_ANDROID_SCREENKB_KEYCODE_15
#define SDL_ANDROID_SCREENKB_KEYCODE_15 UNKNOWN
#ifndef SDL_ANDROID_SCREEN_GESTURE_KEYCODE_3
#define SDL_ANDROID_SCREEN_GESTURE_KEYCODE_3 UNKNOWN
#endif
// Gamepad keys

View File

@@ -81,12 +81,12 @@ SDLK_UNKNOWN, // Text input
SDLK_UNKNOWN, // Joystick 0
SDLK_UNKNOWN, // Joystick 1
SDLK_UNKNOWN, // Joystick 2
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_6)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_7)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_8)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_9)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_10)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_11)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_12)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_13)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_14)),
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_15)),
};
enum { ARROW_LEFT = 1, ARROW_RIGHT = 2, ARROW_UP = 4, ARROW_DOWN = 8 };
@@ -886,12 +886,17 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz
for(ii = 0; ii < 2; ii++)
{
// Custom button ordering
int iii = ii + i*2;
int iii = ii + i * 2;
buttons[iii].w = buttonSizePixels;
buttons[iii].h = buttons[iii].w;
// Move to the screen edge
buttons[iii].x = SDL_ANDROID_sRealWindowWidth - buttons[iii].w * (ii + 1);
buttons[iii].y = SDL_ANDROID_sRealWindowHeight - buttons[iii].h * (i + 1);
// Second set of buttons to the left
buttons[iii + SDL_ANDROID_SCREENKEYBOARD_BUTTON_6].x = buttons[iii].x - buttonSizePixels * 2;
buttons[iii + SDL_ANDROID_SCREENKEYBOARD_BUTTON_6].y = buttons[iii].y;
buttons[iii + SDL_ANDROID_SCREENKEYBOARD_BUTTON_6].w = buttons[iii].w;
buttons[iii + SDL_ANDROID_SCREENKEYBOARD_BUTTON_6].h = buttons[iii].h;
}
if( SDL_ANDROID_joysticksAmount >= 2 )
{