Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Third on-screen joystick, overkill!

  • Loading branch information...
commit 5ab47cd41044ca3477164485044efa47820bc315 1 parent 3ceac1c
@pelya authored
View
10 changeAppSettings.sh
@@ -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
View
5 project/java/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 */
View
6 project/java/Settings.java
@@ -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();
View
11 project/java/SettingsMenuKeyboard.java
@@ -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);
}
View
26 project/jni/application/teeworlds/AndroidAppSettings.cfg
@@ -28,7 +28,7 @@ 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
@@ -36,9 +36,6 @@ 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
2  project/jni/application/teeworlds/src
@@ -1 +1 @@
-Subproject commit e5489c8c089e57d88bbaa90df0176d5e5d4c6351
+Subproject commit 37b9351ac13c25513a95547044abdd2465820030
View
1  project/jni/sdl-1.2/include/SDL_screenkeyboard.h
@@ -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
};
View
56 project/jni/sdl-1.2/src/video/android/SDL_androidinput.c
@@ -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;
}
@@ -1519,44 +1517,6 @@ JAVA_EXPORT_NAME(Settings_nativeSetKeymapKey) (JNIEnv* env, jobject thiz, jint j
}
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)
{
if( keynum < 0 || keynum >= MAX_MULTITOUCH_GESTURES )
View
3  project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h
@@ -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();
View
90 project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c
@@ -44,7 +44,7 @@
// TODO: this code is a HUGE MESS
-enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_JOYSTICKS = 2, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD } ; // Max amount of custom buttons
+enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_JOYSTICKS = 3, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD } ; // Max amount of custom buttons
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
static short touchscreenKeyboardTheme = 0;
@@ -245,7 +245,7 @@ static void drawTouchscreenKeyboardLegacy()
( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 );
- if( blendFactor == 0 || SDL_ANDROID_isJoystickUsed )
+ if( blendFactor == 0 || SDL_ANDROID_joysticksAmount >= 1 )
drawCharTex( &arrowImages[0], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency );
else
{
@@ -258,8 +258,10 @@ static void drawTouchscreenKeyboardLegacy()
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
drawCharTex( &arrowImages[4], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency / blendFactor );
}
- if( SDL_ANDROID_isSecondJoystickUsed )
+ if( SDL_ANDROID_joysticksAmount >= 2 )
drawCharTex( &arrowImages[0], NULL, &arrowsDraw[1], 1.0f, 1.0f, 1.0f, transparency );
+ if( SDL_ANDROID_joysticksAmount >= 3 )
+ drawCharTex( &arrowImages[0], NULL, &arrowsDraw[2], 1.0f, 1.0f, 1.0f, transparency );
for( i = 0; i < MAX_BUTTONS; i++ )
{
@@ -275,7 +277,7 @@ static void drawTouchscreenKeyboardSun()
{
int i;
- for( i = 0; i <= SDL_ANDROID_isSecondJoystickUsed; i++ )
+ for( i = 0; i < SDL_ANDROID_joysticksAmount || (i == 0 && arrowsDraw[0].w > 0); i++ )
{
drawCharTex( &arrowImages[0], NULL, &arrowsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
if(pointerInButtonRect[BUTTON_ARROWS+i] != -1)
@@ -357,6 +359,9 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
{
int i, j;
unsigned processed = 0;
+ int joyAmount = SDL_ANDROID_joysticksAmount;
+ if( joyAmount == 0 && arrows[0].w > 0 )
+ joyAmount = 1;
if( !touchscreenKeyboardShown )
return 0;
@@ -364,7 +369,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
if( action == MOUSE_DOWN )
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "touch %03dx%03d ptr %d action %d", x, y, pointerId, action);
- for( j = 0; j <= SDL_ANDROID_isSecondJoystickUsed; j++ )
+ for( j = 0; j < joyAmount; j++ )
{
if( InsideRect( &arrows[j], x, y ) )
{
@@ -374,7 +379,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
pointerInButtonRect[BUTTON_ARROWS+j] = pointerId;
joystickTouchPoints[0+j*2] = x;
joystickTouchPoints[1+j*2] = y;
- if( SDL_ANDROID_isJoystickUsed )
+ if( SDL_ANDROID_joysticksAmount > 0 )
{
int xx = (x - arrows[j].x - arrows[j].w / 2) * 65534 / arrows[j].w;
if( xx == 0 ) // Do not allow (0,0) coordinate, when the user touches the joystick
@@ -423,13 +428,13 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
if( action == MOUSE_UP )
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "touch %03dx%03d ptr %d action %d", x, y, pointerId, action);
- for( j = 0; j <= SDL_ANDROID_isSecondJoystickUsed; j++ )
+ for( j = 0; j < joyAmount; j++ )
{
if( pointerInButtonRect[BUTTON_ARROWS+j] == pointerId )
{
processed |= 1<<(BUTTON_ARROWS+j);
pointerInButtonRect[BUTTON_ARROWS+j] = -1;
- if( SDL_ANDROID_isJoystickUsed )
+ if( SDL_ANDROID_joysticksAmount > 0 )
{
SDL_ANDROID_MainThreadPushJoystickAxis(0, 0+j*2, 0 );
SDL_ANDROID_MainThreadPushJoystickAxis(0, 1+j*2, 0 );
@@ -477,7 +482,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
// Process cases when pointer leaves button area
// TODO: huge code size, split it or somehow make it more readable
- for( j = 0; j <= SDL_ANDROID_isSecondJoystickUsed; j++ )
+ for( j = 0; j < joyAmount; j++ )
{
if( pointerInButtonRect[BUTTON_ARROWS+j] == pointerId )
{
@@ -485,7 +490,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
if( ! InsideRect( &arrowsExtended[j], x, y ) )
{
pointerInButtonRect[BUTTON_ARROWS+j] = -1;
- if( SDL_ANDROID_isJoystickUsed )
+ if( SDL_ANDROID_joysticksAmount > 0 )
{
SDL_ANDROID_MainThreadPushJoystickAxis(0, 0+j*2, 0 );
SDL_ANDROID_MainThreadPushJoystickAxis(0, 1+j*2, 0 );
@@ -503,7 +508,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
{
joystickTouchPoints[0+j*2] = x;
joystickTouchPoints[1+j*2] = y;
- if( SDL_ANDROID_isJoystickUsed )
+ if( SDL_ANDROID_joysticksAmount > 0 )
{
SDL_ANDROID_MainThreadPushJoystickAxis(0, 0+j*2, (x - arrows[j].x - arrows[j].w / 2) * 65534 / arrows[j].w );
SDL_ANDROID_MainThreadPushJoystickAxis(0, 1+j*2, (y - arrows[j].y - arrows[j].h / 2) * 65534 / arrows[j].h );
@@ -617,6 +622,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
arrowsExtended[1].x = arrows[1].x + arrows[1].w / 2 - arrowsExtended[1].w / 2;
arrowsExtended[1].y = arrows[1].y + arrows[1].h / 2 - arrowsExtended[1].h / 2;
+ arrows[2].w = arrows[1].w;
+ arrows[2].h = arrows[1].h;
+ arrows[2].x = arrows[1].x;
+ arrows[2].y = arrows[1].y - arrows[1].h;
+
+ arrowsExtended[2].w = arrows[2].w * 2;
+ arrowsExtended[2].h = arrows[2].h * 2;
+ arrowsExtended[2].x = arrows[2].x + arrows[2].w / 2 - arrowsExtended[2].w / 2;
+ arrowsExtended[2].y = arrows[2].y + arrows[2].h / 2 - arrowsExtended[2].h / 2;
+
// Buttons to the lower-right in 2 rows
for(i = 0; i < 3; i++)
for(ii = 0; ii < 2; ii++)
@@ -629,7 +644,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
buttons[iii].x = SDL_ANDROID_sRealWindowWidth - buttons[iii].w * (ii + 1);
buttons[iii].y = SDL_ANDROID_sRealWindowHeight - buttons[iii].h * (i + 1);
}
- if( SDL_ANDROID_isSecondJoystickUsed )
+ if( SDL_ANDROID_joysticksAmount >= 2 )
{
// Move all buttons to center, 5-th and 6-th button will be misplaced, but we don't care much about that.
ii = SDL_ANDROID_sRealWindowWidth / 2 - buttons[0].w;
@@ -823,13 +838,56 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboardButtons) ( JNIEnv* env, jobj
(*env)->ReleaseByteArrayElements(env, charBufJava, (jbyte *)charBuf, 0);
}
+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( keynum == SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2 )
+ key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2;
+ if( keynum == SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3 )
+ key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3;
+
+ if( key >= 0 && !used )
+ SDL_ANDROID_SetScreenKeyboardButtonPos(key, &rect);
+}
+
int SDL_ANDROID_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos)
{
if( buttonId < 0 || buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM || ! pos )
return 0;
- if( buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD && buttonId <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2 )
+ if( buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD && buttonId <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3 )
{
int i = buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD;
arrows[i] = *pos;
@@ -853,7 +911,7 @@ int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonImagePos(int buttonId, SDL_Rect *
if( buttonId < 0 || buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM || ! pos )
return 0;
- if( buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD && buttonId <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2 )
+ if( buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD && buttonId <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3 )
arrowsDraw[buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD] = *pos;
else
buttonsDraw[buttonId] = *pos;
@@ -866,7 +924,7 @@ int SDL_ANDROID_GetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos)
if( buttonId < 0 || buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM || ! pos )
return 0;
- if( buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD && buttonId <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2 )
+ if( buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD && buttonId <= SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3 )
{
*pos = arrows[buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD];
}
@@ -1016,6 +1074,8 @@ JAVA_EXPORT_NAME(Settings_nativeSetScreenKbKeyLayout) (JNIEnv* env, jobject thiz
key = keynum - 2 + SDL_ANDROID_SCREENKEYBOARD_BUTTON_0;
if( keynum == SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2 ) // This one is consistent by chance
key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD2;
+ if( keynum == SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3 ) // This one is consistent by chance
+ key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD3;
if( key >= 0 )
{
View
2  todo.txt
@@ -1,6 +1,8 @@
TODO, which will get actually done
==================================
+- TeeWorlds: after exiting phone lock screen the video is screwed up.
+
- TeeWorlds: infinite loop while trying to enter chat text with gamepad.
- TeeWorlds: navigate UI with gamepad.
Please sign in to comment.
Something went wrong with that request. Please try again.