Third on-screen joystick, overkill!

This commit is contained in:
pelya
2014-03-02 19:05:52 +02:00
parent 3ceac1c8a1
commit 5ab47cd410
11 changed files with 135 additions and 77 deletions

View File

@@ -59,6 +59,7 @@ class Globals
public static boolean AppNeedsTextInput = true;
public static boolean AppUsesJoystick = false;
public static boolean AppUsesSecondJoystick = false;
public static boolean AppUsesThirdJoystick = false;
public static boolean AppUsesAccelerometer = false;
public static boolean AppUsesGyroscope = false;
public static boolean AppUsesMultitouch = false;
@@ -112,7 +113,9 @@ class Globals
public static boolean HoverJitterFilter = true;
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
public static int RemapScreenKbKeycode[] = new int[6];
public static int ScreenKbControlsLayout[][] = AppUsesSecondJoystick ? // Values for 800x480 resolution
public static int ScreenKbControlsLayout[][] = AppUsesThirdJoystick ? // Values for 800x480 resolution
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 400, 392, 488, 480 }, { 312, 392, 400, 480 }, { 400, 304, 488, 392 }, { 312, 304, 400, 392 }, { 400, 216, 488, 304 }, { 312, 216, 400, 304 }, { 623, 303, 800, 480 }, { 623, 126, 800, 303 } } :
AppUsesSecondJoystick ?
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 400, 392, 488, 480 }, { 312, 392, 400, 480 }, { 400, 304, 488, 392 }, { 312, 304, 400, 392 }, { 400, 216, 488, 304 }, { 312, 216, 400, 304 }, { 623, 303, 800, 480 } } :
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 712, 392, 800, 480 }, { 624, 392, 712, 480 }, { 712, 304, 800, 392 }, { 624, 304, 712, 392 }, { 712, 216, 800, 304 }, { 624, 216, 712, 304 } };
public static boolean ScreenKbControlsShown[] = new boolean[ScreenKbControlsLayout.length]; /* Also joystick and text input button added */

View File

@@ -216,6 +216,8 @@ class Settings
Globals.ScreenKbControlsShown[i] = ( i - 2 < Globals.AppTouchscreenKeyboardKeysAmount );
if( Globals.AppUsesSecondJoystick )
Globals.ScreenKbControlsShown[8] = true;
if( Globals.AppUsesThirdJoystick )
Globals.ScreenKbControlsShown[9] = true;
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
{
int sdlKey = nativeGetKeymapKeyMultitouchGesture(i);
@@ -520,7 +522,7 @@ class Settings
if( Globals.PhoneHasTrackball )
nativeSetTrackballUsed();
applyMouseEmulationOptions();
nativeSetJoystickUsed(Globals.AppUsesJoystick ? 1 : 0, Globals.AppUsesSecondJoystick ? 1 : 0);
nativeSetJoystickUsed( Globals.AppUsesThirdJoystick ? 3 : (Globals.AppUsesSecondJoystick ? 2 : (Globals.AppUsesJoystick ? 1 : 0)) );
if( Globals.AppUsesAccelerometer )
nativeSetAccelerometerUsed();
if( Globals.AppUsesMultitouch )
@@ -769,7 +771,7 @@ class Settings
int relativeMovement, int relativeMovementSpeed,
int relativeMovementAccel, int showMouseCursor,
int HoverJitterFilter, int RightMouseButtonLongPress);
private static native void nativeSetJoystickUsed(int firstJoystickUsed, int secondJoystickUsed);
private static native void nativeSetJoystickUsed(int amount);
private static native void nativeSetAccelerometerUsed();
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();

View File

@@ -386,6 +386,13 @@ class SettingsMenuKeyboard extends SettingsMenu
defaults = Arrays.copyOf(defaults, defaults.length + 1);
defaults[defaults.length - 1] = true;
}
if( Globals.AppUsesThirdJoystick )
{
items = Arrays.copyOf(items, items.length + 1);
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3";
defaults = Arrays.copyOf(defaults, defaults.length + 1);
defaults[defaults.length - 1] = true;
}
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
@@ -633,6 +640,7 @@ class SettingsMenuKeyboard extends SettingsMenu
R.drawable.b4,
R.drawable.b5,
R.drawable.b6,
R.drawable.dpad,
R.drawable.dpad
};
int oldX = 0, oldY = 0;
@@ -661,6 +669,7 @@ class SettingsMenuKeyboard extends SettingsMenu
R.drawable.sun_b4,
R.drawable.sun_b5,
R.drawable.sun_b6,
R.drawable.sun_dpad,
R.drawable.sun_dpad
};
}
@@ -756,6 +765,8 @@ class SettingsMenuKeyboard extends SettingsMenu
buttonText = "Text input";
if( i == 8 )
buttonText = "Joystick 2";
if( i == 9 )
buttonText = "Joystick 3";
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
}