diff --git a/project/java/Globals.java b/project/java/Globals.java index 98d844203..66634231d 100644 --- a/project/java/Globals.java +++ b/project/java/Globals.java @@ -55,6 +55,7 @@ class Globals { public static boolean UseTouchscreenKeyboard = true; public static int TouchscreenKeyboardSize = 0; public static int TouchscreenKeyboardTheme = 2; + public static int TouchscreenKeyboardTransparency = 2; public static int AccelerometerSensitivity = 2; public static int AccelerometerCenterPos = 2; public static int TrackballDampening = 0; diff --git a/project/java/Settings.java b/project/java/Settings.java index 7abaa87d9..f4931b8c3 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -76,6 +76,7 @@ class Settings { out.writeBoolean(Globals.ScreenKbControlsShown[i]); } + out.writeInt(Globals.TouchscreenKeyboardTransparency); out.close(); settingsLoaded = true; @@ -161,6 +162,7 @@ class Settings { Globals.ScreenKbControlsShown[i] = settingsFile.readBoolean(); } + Globals.TouchscreenKeyboardTransparency = settingsFile.readInt(); settingsLoaded = true; @@ -386,9 +388,11 @@ class Settings { ArrayList items = new ArrayList (); + items.add(p.getResources().getString(R.string.controls_screenkb_theme)); + items.add(p.getResources().getString(R.string.controls_screenkb_size)); - items.add(p.getResources().getString(R.string.controls_screenkb_theme)); + items.add(p.getResources().getString(R.string.controls_screenkb_transparency)); items.add(p.getResources().getString(R.string.remap_screenkb)); @@ -404,12 +408,16 @@ class Settings dialog.dismiss(); int selected = 0; + if( item == selected ) + showScreenKeyboardThemeConfig(p); + selected++; + if( item == selected ) showScreenKeyboardSizeConfig(p); selected++; if( item == selected ) - showScreenKeyboardThemeConfig(p); + showScreenKeyboardTransparencyConfig(p); selected++; if( item == selected ) @@ -607,13 +615,6 @@ class Settings static void showScreenKeyboardSizeConfig(final MainActivity p) { - if( ! Globals.UseTouchscreenKeyboard ) - { - Globals.TouchscreenKeyboardSize = 0; - showScreenKeyboardConfigMainMenu(p); - return; - } - final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large), p.getResources().getString(R.string.controls_screenkb_medium), p.getResources().getString(R.string.controls_screenkb_small), @@ -638,13 +639,6 @@ class Settings static void showScreenKeyboardThemeConfig(final MainActivity p) { - if( ! Globals.UseTouchscreenKeyboard ) - { - Globals.TouchscreenKeyboardTheme = 0; - showScreenKeyboardConfigMainMenu(p); - return; - } - final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_by, "Ugly Arrows", "pelya"), p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"), @@ -668,6 +662,32 @@ class Settings alert.show(); } + static void showScreenKeyboardTransparencyConfig(final MainActivity p) + { + final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_trans_0), + p.getResources().getString(R.string.controls_screenkb_trans_1), + p.getResources().getString(R.string.controls_screenkb_trans_2), + p.getResources().getString(R.string.controls_screenkb_trans_3), + p.getResources().getString(R.string.controls_screenkb_trans_4), + }; + + AlertDialog.Builder builder = new AlertDialog.Builder(p); + builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency)); + builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int item) + { + Globals.TouchscreenKeyboardTransparency = item; + + dialog.dismiss(); + showScreenKeyboardConfigMainMenu(p); + } + }); + AlertDialog alert = builder.create(); + alert.setOwnerActivity(p); + alert.show(); + } + static void showAudioConfig(final MainActivity p) { final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_verysmall), @@ -1204,10 +1224,8 @@ class Settings nativeSetTouchscreenKeyboardUsed(); nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize, Globals.TouchscreenKeyboardTheme, - 8, // Globals.AppTouchscreenKeyboardKeysAmount, - set later by nativeSetScreenKbKeyUsed() Globals.AppTouchscreenKeyboardKeysAmountAutoFire, - 1, //Globals.AppNeedsArrowKeys ? 1 : 0, - 1 ); //Globals.AppNeedsTextInput ? 1 : 0 ); + Globals.TouchscreenKeyboardTransparency ); } SetupTouchscreenKeyboardGraphics(p); for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) @@ -1276,7 +1294,7 @@ class Settings private static native void nativeSetJoystickUsed(); private static native void nativeSetMultitouchUsed(); private static native void nativeSetTouchscreenKeyboardUsed(); - private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttons, int nbuttonsAutoFire, int showArrows, int showTextInput); + private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttonsAutoFire, int transparency); private static native void nativeSetupScreenKeyboardButtons(byte[] img); private static native void nativeInitKeymap(); private static native int nativeGetKeymapKey(int key); diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml index e55e51fed..d797f202b 100644 --- a/project/java/translations/values/strings.xml +++ b/project/java/translations/values/strings.xml @@ -42,6 +42,12 @@ Tiny On-screen keyboard theme %1$s by %2$s + On-screen keyboard transparency + Invisible + Almost invisible + Transparent + Semi-transparent + Non-transparent No dampening Fast diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index 2248e8d3e..202a90175 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -13,7 +13,7 @@ AppUsesMouse=y AppNeedsTwoButtonMouse=y AppNeedsArrowKeys=y AppNeedsTextInput=y -AppUsesJoystick=y +AppUsesJoystick=n AppHandlesJoystickSensitivity=n AppUsesMultitouch=n NonBlockingSwapBuffers=n diff --git a/project/jni/application/sc2/src/libs/input/sdl/vcontrol.c b/project/jni/application/sc2/src/libs/input/sdl/vcontrol.c index 28a31056f..eb11eefb0 100644 --- a/project/jni/application/sc2/src/libs/input/sdl/vcontrol.c +++ b/project/jni/application/sc2/src/libs/input/sdl/vcontrol.c @@ -817,9 +817,6 @@ VControl_ProcessJoyAxis (int port, int axis, int value) int t; if (!joysticks[port].stick) return; -#ifdef ANDROID - value = -value; // Axes are swapped, too lazy to fix that on SDL side -#endif joysticks[port].axes[axis].value = value; t = joysticks[port].threshold; if (value > t) diff --git a/project/jni/application/sc2/src/uqm/gameinp.c b/project/jni/application/sc2/src/uqm/gameinp.c index fe3ce51c9..9ecd3ef3a 100644 --- a/project/jni/application/sc2/src/uqm/gameinp.c +++ b/project/jni/application/sc2/src/uqm/gameinp.c @@ -568,7 +568,7 @@ BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction) angle -= atan2i_PI * 2; angle = angle * SHIP_DIRECTIONS / atan2i_PI / 2; - diff = angle - direction - SHIP_DIRECTIONS / 4; + diff = angle - direction + SHIP_DIRECTIONS / 4; while( diff >= SHIP_DIRECTIONS ) diff -= SHIP_DIRECTIONS; while( diff < 0 ) diff --git a/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c index 104f6123c..2d1234c80 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c @@ -62,6 +62,7 @@ static int touchscreenKeyboardTheme = 0; static int touchscreenKeyboardShown = 1; static int AutoFireButtonsNum = 0; static int buttonsize = 1; +static int transparency = 128; static SDL_Rect arrows, buttons[MAX_BUTTONS], buttonsAutoFireRect[MAX_BUTTONS_AUTOFIRE]; static SDLKey buttonKeysyms[MAX_BUTTONS] = { @@ -231,13 +232,13 @@ int SDL_ANDROID_drawTouchscreenKeyboard() beginDrawingWireframe(); // Draw arrow keys drawCharWireframe( FONT_LEFT, arrows.x + arrows.w / 4, arrows.y + arrows.h / 2, 0, - 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 255 : 0, 128 ); + 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 255 : 0, transparency ); drawCharWireframe( FONT_RIGHT, arrows.x + arrows.w / 4 * 3, arrows.y + arrows.h / 2, 0, - 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 255 : 0, 128 ); + 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 255 : 0, transparency ); drawCharWireframe( FONT_UP, arrows.x + arrows.w / 2, arrows.y + arrows.h / 4, 0, - 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 255 : 0, 128 ); + 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 255 : 0, transparency ); drawCharWireframe( FONT_DOWN, arrows.x + arrows.w / 2, arrows.y + arrows.h / 4 * 3, 0, - 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 255 : 0, 128 ); + 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 255 : 0, transparency ); // Draw buttons for( i = 0; i < MAX_BUTTONS; i++ ) @@ -245,7 +246,7 @@ int SDL_ANDROID_drawTouchscreenKeyboard() if( ! buttons[i].h || ! buttons[i].w ) continue; drawCharWireframe( FONT_BTN1 + i, buttons[i].x + buttons[i].w / 2, buttons[i].y + buttons[i].h / 2, ( i < AutoFireButtonsNum ? ButtonAutoFireRot[i] * 0x10000 : 0 ), - ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? 0 : 255, 255, SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? 255 : 0, 128 ); + ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? 0 : 255, 255, SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? 255 : 0, transparency ); } endDrawingWireframe(); } @@ -257,17 +258,17 @@ int SDL_ANDROID_drawTouchscreenKeyboard() ( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 ); beginDrawingTex(); if( blendFactor == 0 ) - drawCharTex( &arrowImages[0], NULL, &arrows, 255, 255, 255, 128 ); + drawCharTex( &arrowImages[0], NULL, &arrows, 255, 255, 255, transparency ); else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ) - drawCharTex( &arrowImages[1], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); + drawCharTex( &arrowImages[1], NULL, &arrows, 255, 255, 255, transparency / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ) - drawCharTex( &arrowImages[2], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); + drawCharTex( &arrowImages[2], NULL, &arrows, 255, 255, 255, transparency / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ) - drawCharTex( &arrowImages[3], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); + drawCharTex( &arrowImages[3], NULL, &arrows, 255, 255, 255, transparency / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ) - drawCharTex( &arrowImages[4], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); + drawCharTex( &arrowImages[4], NULL, &arrows, 255, 255, 255, transparency / blendFactor ); } for( i = 0; i < MAX_BUTTONS; i++ ) @@ -303,7 +304,7 @@ int SDL_ANDROID_drawTouchscreenKeyboard() autoFireDest.w = pos1dst; drawCharTex( &buttonImages[i*2+1], - &autoFireCrop, &autoFireDest, 255, 255, 255, 128 ); + &autoFireCrop, &autoFireDest, 255, 255, 255, transparency ); autoFireCrop.x = pos2src; autoFireCrop.w = buttonImages[i*2+1].w - pos2src; @@ -311,7 +312,7 @@ int SDL_ANDROID_drawTouchscreenKeyboard() autoFireDest.w = buttons[i].w - pos2dst; drawCharTex( &buttonImages[i*2+1], - &autoFireCrop, &autoFireDest, 255, 255, 255, 128 ); + &autoFireCrop, &autoFireDest, 255, 255, 255, transparency ); autoFireCrop.x = pos1src; autoFireCrop.w = pos2src - pos1src; @@ -319,13 +320,13 @@ int SDL_ANDROID_drawTouchscreenKeyboard() autoFireDest.w = pos2dst - pos1dst; drawCharTex( &buttonAutoFireImages[i*2+1], - &autoFireCrop, &autoFireDest, 255, 255, 255, 128 ); + &autoFireCrop, &autoFireDest, 255, 255, 255, transparency ); } else { drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] : &buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ], - NULL, &buttons[i], 255, 255, 255, 128 ); + NULL, &buttons[i], 255, 255, 255, transparency ); } } endDrawingTex(); @@ -390,8 +391,8 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer pointerInButtonRect[MAX_BUTTONS] = pointerId; if( SDL_ANDROID_isJoystickUsed ) { - SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, -(x - arrows.x - arrows.w / 2) * 65534 / arrows.w ); - SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, -(y - arrows.y - arrows.h / 2) * 65534 / arrows.h ); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, (x - arrows.x - arrows.w / 2) * 65534 / arrows.w ); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, (y - arrows.y - arrows.h / 2) * 65534 / arrows.h ); } else { @@ -644,18 +645,26 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer }; JNIEXPORT void JNICALL -JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz, jint size, jint theme, jint _nbuttons, jint nbuttonsAutoFire, jint showArrows, jint showTextInput ) +JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz, jint size, jint theme, jint nbuttonsAutoFire, jint _transparency ) { int i, ii; int nbuttons1row, nbuttons2row; + int _nbuttons = MAX_BUTTONS; touchscreenKeyboardTheme = theme; - if( _nbuttons >= MAX_BUTTONS ) - _nbuttons = MAX_BUTTONS; AutoFireButtonsNum = nbuttonsAutoFire; if( AutoFireButtonsNum > MAX_BUTTONS_AUTOFIRE ) AutoFireButtonsNum = MAX_BUTTONS_AUTOFIRE; // TODO: works for horizontal screen orientation only! buttonsize = size; + switch(_transparency) + { + case 0: transparency = 16; break; + case 1: transparency = 32; break; + case 2: transparency = 64; break; + case 3: transparency = 128; break; + case 4: transparency = 192; break; + default: transparency = 128; break; + } if(touchscreenKeyboardTheme == 0) { @@ -736,22 +745,6 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi buttons[6].h = SDL_ANDROID_sWindowHeight/10; } - for( i = 0; i < MAX_BUTTONS; i++ ) - __android_log_print(ANDROID_LOG_INFO, "libSDL", "Settings_nativeSetupScreenKeyboard(): button %d pos %d %d %d %d", i, (int)buttons[i].x, (int)buttons[i].y, (int)buttons[i].w, (int)buttons[i].h); - if( !showArrows ) - { - arrows.w = 0; - arrows.h = 0; - } - for( i = 0; i < MAX_BUTTONS; i++ ) - { - if( i >= _nbuttons && ( i != BUTTON_TEXT_INPUT || !showTextInput ) ) - { - buttons[i].w = 0; - buttons[i].h = 0; - } - } - for( i = 0; i < sizeof(pointerInButtonRect)/sizeof(pointerInButtonRect[0]); i++ ) { pointerInButtonRect[i] = -1; @@ -763,8 +756,6 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi buttonsAutoFireRect[i].x = buttons[i].x - buttons[i].w / 2; buttonsAutoFireRect[i].y = buttons[i].y - buttons[i].h / 2; } - for( i = 0; i < MAX_BUTTONS; i++ ) - __android_log_print(ANDROID_LOG_INFO, "libSDL", "Settings_nativeSetupScreenKeyboard() 2: button %d pos %d %d %d %d", i, (int)buttons[i].x, (int)buttons[i].y, (int)buttons[i].w, (int)buttons[i].h); };