Permalink
Browse files

Third on-screen joystick, overkill!

  • Loading branch information...
pelya committed Mar 2, 2014
1 parent 3ceac1c commit 5ab47cd41044ca3477164485044efa47820bc315
View
@@ -887,6 +887,9 @@ echo >> AndroidAppSettings.cfg
echo "# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)" >> AndroidAppSettings.cfg
echo AppUsesSecondJoystick=$AppUsesSecondJoystick >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
+echo "# Application uses third on-screen joystick, as SDL joystick 0 axes 20-21 (y)/(n)" >> AndroidAppSettings.cfg
+echo AppUsesThirdJoystick=$AppUsesThirdJoystick >> AndroidAppSettings.cfg
+echo >> AndroidAppSettings.cfg
echo "# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7" >> AndroidAppSettings.cfg
echo AppUsesAccelerometer=$AppUsesAccelerometer >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
@@ -1184,6 +1187,12 @@ else
AppUsesSecondJoystick=false
fi
+if [ "$AppUsesThirdJoystick" = "y" ] ; then
+ AppUsesThirdJoystick=true
+else
+ AppUsesThirdJoystick=false
+fi
+
if [ "$AppUsesAccelerometer" = "y" ] ; then
AppUsesAccelerometer=true
else
@@ -1391,6 +1400,7 @@ $SEDI "s/public static boolean AppNeedsArrowKeys = .*;/public static boolean App
$SEDI "s/public static boolean AppNeedsTextInput = .*;/public static boolean AppNeedsTextInput = $AppNeedsTextInput;/" project/src/Globals.java
$SEDI "s/public static boolean AppUsesJoystick = .*;/public static boolean AppUsesJoystick = $AppUsesJoystick;/" project/src/Globals.java
$SEDI "s/public static boolean AppUsesSecondJoystick = .*;/public static boolean AppUsesSecondJoystick = $AppUsesSecondJoystick;/" project/src/Globals.java
+$SEDI "s/public static boolean AppUsesThirdJoystick = .*;/public static boolean AppUsesThirdJoystick = $AppUsesThirdJoystick;/" project/src/Globals.java
$SEDI "s/public static boolean AppUsesAccelerometer = .*;/public static boolean AppUsesAccelerometer = $AppUsesAccelerometer;/" project/src/Globals.java
$SEDI "s/public static boolean AppUsesGyroscope = .*;/public static boolean AppUsesGyroscope = $AppUsesGyroscope;/" project/src/Globals.java
$SEDI "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" project/src/Globals.java
@@ -59,6 +59,7 @@ Java source code (C) 2009-2012 Sergii Pylypenko
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 @@ Java source code (C) 2009-2012 Sergii Pylypenko
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 */
@@ -216,6 +216,8 @@ static void Load( final MainActivity p )
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 @@ static void Apply(MainActivity p)
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 @@ private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScre
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();
@@ -386,6 +386,13 @@ void run (final MainActivity p)
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 @@ void run (final MainActivity p)
R.drawable.b4,
R.drawable.b5,
R.drawable.b6,
+ R.drawable.dpad,
R.drawable.dpad
};
int oldX = 0, oldY = 0;
@@ -661,6 +669,7 @@ public CustomizeScreenKbLayoutTool(MainActivity _p)
R.drawable.sun_b4,
R.drawable.sun_b5,
R.drawable.sun_b6,
+ R.drawable.sun_dpad,
R.drawable.sun_dpad
};
}
@@ -756,6 +765,8 @@ void setupButton(int i)
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);
}
@@ -28,17 +28,14 @@ DeleteFilesOnUpgrade="%"
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/
-ReadmeText='Tap left joystick while aiming to launch hook\\\\nSwipe left joystick up or down to jump^ouya:'
+ReadmeText=''
# libSDL version to use (1.2/1.3/2.0)
LibSdlVersion=1.2
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
ScreenOrientation=h
-# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
-InhibitSuspend=y
-
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
VideoDepthBpp=24
@@ -63,6 +60,12 @@ SdlVideoResize=n
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
SdlVideoResizeKeepAspect=n
+# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
+InhibitSuspend=y
+
+# Create Android service, so the app is less likely to be killed while in background
+CreateService=
+
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
CompatibilityHacks=n
@@ -99,6 +102,10 @@ AppUsesMouse=y
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
AppNeedsTwoButtonMouse=n
+# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n)
+# If you disable it, swiping with two fingers will send mouse wheel events
+RightMouseButtonLongPress=
+
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
@@ -120,6 +127,9 @@ AppUsesJoystick=y
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
AppUsesSecondJoystick=y
+# Application uses third on-screen joystick, as SDL joystick 0 axes 20-21 (y)/(n)
+AppUsesThirdJoystick=y
+
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
AppUsesAccelerometer=n
@@ -137,6 +147,9 @@ AppRecordsAudio=n
# Application needs to access SD card. If your data files are bigger than 5 Mb, enable it. (y) / (n)
AccessSdCard=
+# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)
+AccessInternet=
+
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
ImmersiveMode=
@@ -156,9 +169,6 @@ RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP"
# Number of virtual keyboard keys (currently 6 is maximum)
AppTouchscreenKeyboardKeysAmount=4
-# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
-AppTouchscreenKeyboardKeysAmountAutoFire=0
-
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
RedefinedKeysScreenKb="RETURN PAGEDOWN PAGEUP TAB SPACE RCTRL"
@@ -191,7 +201,7 @@ FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
-MultiABI=all
+MultiABI='all'
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0
@@ -55,6 +55,7 @@ enum {
SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, /* Joystick/D-Pad button */
SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2, /* Second joystick button */
+ SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3, /* Third joystick button */
SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM
};
@@ -80,11 +80,10 @@ int SDL_ANDROID_moveMouseWithKbAccelX = 0, SDL_ANDROID_moveMouseWithKbAccelY = 0
int SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded = 0;
static int maxForce = 0;
static int maxRadius = 0;
-int SDL_ANDROID_isJoystickUsed = 0;
-int SDL_ANDROID_isSecondJoystickUsed = 0;
+int SDL_ANDROID_joysticksAmount = 0;
static int SDL_ANDROID_isAccelerometerUsed = 0;
static int isMultitouchUsed = 0;
-SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1];
+SDL_Joystick *SDL_ANDROID_CurrentJoysticks[JOY_GAMEPAD4+1];
static int TrackballDampening = 0; // in milliseconds
static Uint32 lastTrackballAction = 0;
enum { TOUCH_PTR_UP = 0, TOUCH_PTR_MOUSE = 1, TOUCH_PTR_SCREENKB = 2 };
@@ -192,8 +191,8 @@ static int BumpPointerId( int pointerId )
{
if(pointerId < 0)
pointerId = 0;
- if(pointerId > MAX_MULTITOUCH_POINTERS)
- pointerId = MAX_MULTITOUCH_POINTERS;
+ if(pointerId >= MAX_MULTITOUCH_POINTERS)
+ pointerId = MAX_MULTITOUCH_POINTERS-1;
return pointerId;
}
@@ -924,7 +923,7 @@ JAVA_EXPORT_NAME(AccelerometerReader_nativeAccelerometer) ( JNIEnv* env, jobjec
}
-JNIEXPORT void JNICALL
+JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(AccelerometerReader_nativeGyroscope) ( JNIEnv* env, jobject thiz, jfloat X, jfloat Y, jfloat Z )
{
#if SDL_VERSION_ATLEAST(1,3,0)
@@ -1148,10 +1147,9 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz,
}
JNIEXPORT void JNICALL
-JAVA_EXPORT_NAME(Settings_nativeSetJoystickUsed) (JNIEnv* env, jobject thiz, jint first, jint second)
+JAVA_EXPORT_NAME(Settings_nativeSetJoystickUsed) (JNIEnv* env, jobject thiz, jint amount)
{
- SDL_ANDROID_isJoystickUsed = first;
- SDL_ANDROID_isSecondJoystickUsed = second;
+ SDL_ANDROID_joysticksAmount = amount;
}
JNIEXPORT void JNICALL
@@ -1408,7 +1406,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
joystick->naxes = 4; // Two on-screen joysticks (I'm planning to implement second joystick soon)
if(isMultitouchUsed)
{
- joystick->naxes = 4 + MAX_MULTITOUCH_POINTERS; // Joystick plus accelerometer, plus touch pressure/size
+ joystick->naxes = 6 + MAX_MULTITOUCH_POINTERS; // Three joysticks plus touch pressure/size
joystick->nbuttons = MAX_MULTITOUCH_POINTERS;
joystick->nballs = MAX_MULTITOUCH_POINTERS;
}
@@ -1518,44 +1516,6 @@ JAVA_EXPORT_NAME(Settings_nativeSetKeymapKey) (JNIEnv* env, jobject thiz, jint j
SDL_android_keymap[javakey] = key;
}
-JNIEXPORT jint JNICALL
-JAVA_EXPORT_NAME(Settings_nativeGetKeymapKeyScreenKb) (JNIEnv* env, jobject thiz, jint keynum)
-{
- if( keynum < 0 || keynum > SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 + 4 )
- return SDL_KEY(UNKNOWN);
-
- if( keynum <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 )
- return SDL_ANDROID_GetScreenKeyboardButtonKey(keynum + SDL_ANDROID_SCREENKEYBOARD_BUTTON_0);
-
- return SDL_KEY(UNKNOWN);
-}
-
-JNIEXPORT void JNICALL
-JAVA_EXPORT_NAME(Settings_nativeSetKeymapKeyScreenKb) (JNIEnv* env, jobject thiz, jint keynum, jint key)
-{
- if( keynum < 0 || keynum > SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 + 4 )
- return;
-
- if( keynum <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 )
- SDL_ANDROID_SetScreenKeyboardButtonKey(keynum + SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, key);
-}
-
-JNIEXPORT void JNICALL
-JAVA_EXPORT_NAME(Settings_nativeSetScreenKbKeyUsed) (JNIEnv* env, jobject thiz, jint keynum, jint used)
-{
- SDL_Rect rect = {0, 0, 0, 0};
- int key = -1;
- if( keynum == 0 )
- key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD;
- if( keynum == 1 )
- key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT;
- if( keynum - 2 >= 0 && keynum - 2 <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 )
- key = keynum - 2 + SDL_ANDROID_SCREENKEYBOARD_BUTTON_0;
-
- if( key >= 0 && !used )
- SDL_ANDROID_SetScreenKeyboardButtonPos(key, &rect);
-}
-
JNIEXPORT jint JNICALL
JAVA_EXPORT_NAME(Settings_nativeGetKeymapKeyMultitouchGesture) (JNIEnv* env, jobject thiz, jint keynum)
{
@@ -88,8 +88,7 @@ extern SDL_Window * ANDROID_CurrentWindow;
// Exports from SDL_androidinput.c - SDL_androidinput.h is too encumbered
enum { MAX_MULTITOUCH_POINTERS = 16 };
extern void ANDROID_InitOSKeymap();
-extern int SDL_ANDROID_isJoystickUsed;
-extern int SDL_ANDROID_isSecondJoystickUsed;
+extern int SDL_ANDROID_joysticksAmount;
// Events have to be sent only from main thread from PumpEvents(), so we'll buffer them here
extern void SDL_ANDROID_PumpEvents();
extern void SDL_ANDROID_SetHoverDeadzone();
Oops, something went wrong.

0 comments on commit 5ab47cd

Please sign in to comment.