diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh index 06f707421..1d43d07f3 100755 --- a/ChangeAppSettings.sh +++ b/ChangeAppSettings.sh @@ -1,6 +1,6 @@ #!/bin/sh -CHANGE_APP_SETTINGS_VERSION=13 +CHANGE_APP_SETTINGS_VERSION=14 AUTO= if [ "X$1" = "X-a" ]; then @@ -102,13 +102,21 @@ fi fi if [ -z "$AppUsesMouse" -o -z "$AUTO" ]; then -echo -n "\nApplication uses mouse, disables touchscreen keyboard currently (y) or (n) ($AppUsesMouse): " +echo -n "\nApplication uses mouse (y) or (n) ($AppUsesMouse): " read var if [ -n "$var" ] ; then AppUsesMouse="$var" fi fi +if [ -z "$AppNeedsTwoButtonMouse" -o -z "$AUTO" ]; then +echo -n "\nApplication needs two-button mouse, will also enable advanced point-and-click features (y) or (n) ($AppNeedsTwoButtonMouse): " +read var +if [ -n "$var" ] ; then + AppNeedsTwoButtonMouse="$var" +fi +fi + if [ -z "$AppNeedsArrowKeys" -o -z "$AUTO" ]; then echo -n "\nApplication needs arrow keys (y) or (n), if (y) the accelerometer or touchscreen keyboard\nwill be used as arrow keys if phone does not have dpad/trackball ($AppNeedsArrowKeys): " read var @@ -305,6 +313,7 @@ echo SdlVideoResize=$SdlVideoResize >> AndroidAppSettings.cfg echo SdlVideoResizeKeepAspect=$SdlVideoResizeKeepAspect >> AndroidAppSettings.cfg echo NeedDepthBuffer=$NeedDepthBuffer >> AndroidAppSettings.cfg echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg +echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg echo AppNeedsTextInput=$AppNeedsTextInput >> AndroidAppSettings.cfg echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg @@ -363,16 +372,18 @@ else NeedDepthBuffer=false fi -MouseKeycode=UNKNOWN if [ "$AppUsesMouse" = "y" ] ; then AppUsesMouse=true -elif [ "$AppUsesMouse" = "n" ] ; then - AppUsesMouse=false else - MouseKeycode=$AppUsesMouse AppUsesMouse=false fi +if [ "$AppNeedsTwoButtonMouse" = "y" ] ; then + AppNeedsTwoButtonMouse=true +else + AppNeedsTwoButtonMouse=false +fi + if [ "$AppNeedsArrowKeys" = "y" ] ; then AppNeedsArrowKeys=true else diff --git a/project/java/Globals.java b/project/java/Globals.java index c9918cf58..6e2296eb8 100644 --- a/project/java/Globals.java +++ b/project/java/Globals.java @@ -23,6 +23,8 @@ class Globals { public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n"); public static boolean AppUsesMouse = false; + + public static boolean AppNeedsTwoButtonMouse = false; public static boolean AppNeedsArrowKeys = true; @@ -55,6 +57,14 @@ class Globals { public static int TrackballDampening = 0; public static int AudioBufferConfig = 0; public static boolean OptionalDataDownload[] = null; + public static final int RIGHT_CLICK_WITH_MENU_BUTTON = 0; + public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1; + public static final int RIGHT_CLICK_WITH_PRESSURE = 2; + public static int RightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON; + public static boolean LeftClickUsesPressure = false; + public static boolean ShowScreenUnderFinger = false; + public static int ClickScreenPressure = 0; + public static int ClickScreenTouchspotSize = 0; } class LoadLibrary { diff --git a/project/java/Settings.java b/project/java/Settings.java index fd58c4f60..7df351a05 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -49,6 +49,12 @@ class Settings for(int i = 0; i < Globals.OptionalDataDownload.length; i++) out.writeBoolean(Globals.OptionalDataDownload[i]); out.writeInt(Globals.TouchscreenKeyboardTheme); + out.writeInt(Globals.RightClickMethod); + out.writeBoolean(Globals.ShowScreenUnderFinger); + out.writeBoolean(Globals.LeftClickUsesPressure); + out.writeInt(Globals.ClickScreenPressure); + out.writeInt(Globals.ClickScreenTouchspotSize); + out.close(); settingsLoaded = true; @@ -80,6 +86,11 @@ class Settings for(int i = 0; i < Globals.OptionalDataDownload.length; i++) Globals.OptionalDataDownload[i] = settingsFile.readBoolean(); Globals.TouchscreenKeyboardTheme = settingsFile.readInt(); + Globals.RightClickMethod = settingsFile.readInt(); + Globals.ShowScreenUnderFinger = settingsFile.readBoolean(); + Globals.LeftClickUsesPressure = settingsFile.readBoolean(); + Globals.ClickScreenPressure = settingsFile.readInt(); + Globals.ClickScreenTouchspotSize = settingsFile.readInt(); settingsLoaded = true; @@ -281,7 +292,7 @@ class Settings if( item == 0 ) Globals.UseTouchscreenKeyboard = isChecked; if( item == 1 ) - Globals.UseAccelerometerAsArrowKeys = isChecked; + Globals.UseAccelerometerAsArrowKeys = isChecked; } }); builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() @@ -395,7 +406,7 @@ class Settings Globals.TouchscreenKeyboardTheme = 0; if( ! Globals.UseTouchscreenKeyboard ) { - showAudioConfig(p); + showRightClickConfigConfig(p); return; } @@ -415,10 +426,79 @@ class Settings if( item == 1 ) Globals.TouchscreenKeyboardTheme = 0; + dialog.dismiss(); + showRightClickConfigConfig(p); + } + }); + AlertDialog alert = builder.create(); + alert.setOwnerActivity(p); + alert.show(); + } + + static void showRightClickConfigConfig(final MainActivity p) + { + Globals.RightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON; + if( ! Globals.AppNeedsTwoButtonMouse ) + { + showAdvancedPointAndClickConfigConfig(p); + return; + } + final CharSequence[] items = { p.getResources().getString(R.string.rightclick_menu), + p.getResources().getString(R.string.rightclick_multitouch), + p.getResources().getString(R.string.rightclick_pressure) }; + + AlertDialog.Builder builder = new AlertDialog.Builder(p); + builder.setTitle(R.string.rightclick_question); + builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int item) + { + Globals.RightClickMethod = item; + dialog.dismiss(); + showAdvancedPointAndClickConfigConfig(p); + } + }); + AlertDialog alert = builder.create(); + alert.setOwnerActivity(p); + alert.show(); + } + + static void showAdvancedPointAndClickConfigConfig(final MainActivity p) + { + Globals.ShowScreenUnderFinger = false; + Globals.LeftClickUsesPressure = false; + + if( ! Globals.AppNeedsTwoButtonMouse ) + { + showAudioConfig(p); + return; + } + final CharSequence[] items = (Globals.RightClickMethod == RIGHT_CLICK_WITH_PRESSURE) ? + { p.getResources().getString(R.string.pointandclick_showcreenunderfinger) } : + { p.getResources().getString(R.string.pointandclick_showcreenunderfinger), + p.getResources().getString(R.string.pointandclick_usepressure) }; + + AlertDialog.Builder builder = new AlertDialog.Builder(p); + builder.setTitle(p.getResources().getString(R.string.pointandclick_question)); + builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() + { + public void onClick(DialogInterface dialog, int item, boolean isChecked) + { + if( item == 0 ) + Globals.ShowScreenUnderFinger = isChecked; + if( item == 1 ) + Globals.LeftClickUsesPressure = isChecked; + } + }); + builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int item) + { dialog.dismiss(); showAudioConfig(p); } }); + AlertDialog alert = builder.create(); alert.setOwnerActivity(p); alert.show(); @@ -455,7 +535,11 @@ class Settings if( Globals.PhoneHasTrackball ) nativeSetTrackballUsed(); if( Globals.AppUsesMouse ) - nativeSetMouseUsed(); + nativeSetMouseUsed( Globals.RightClickMethod, + Globals.ShowScreenUnderFinger ? 1 : 0, + Globals.LeftClickUsesPressure ? 1 : 0, + Globals.ClickScreenPressure, + Globals.ClickScreenTouchspotSize ); if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) ) nativeSetJoystickUsed(); if( Globals.AppUsesMultitouch ) @@ -514,7 +598,7 @@ class Settings private static native void nativeSetTrackballUsed(); private static native void nativeSetTrackballDampening(int value); private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos); - private static native void nativeSetMouseUsed(); + private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickUsesPressure, int MaxForce, int MaxRadius); private static native void nativeSetJoystickUsed(); private static native void nativeSetMultitouchUsed(); private static native void nativeSetTouchscreenKeyboardUsed(); diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml index 6ce5e80bc..9fb6d3d90 100644 --- a/project/java/translations/values/strings.xml +++ b/project/java/translations/values/strings.xml @@ -59,6 +59,13 @@ Fixed to table desk orientation Accelerometer center position + Right mouse click triggered by: + Menu key + Touching screen with second finger (device should support that) + Pressing screen with force (device should support that) + + Right mouse click triggered by: + Very small (fast devices, less lag) Small Medium diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c index c8336bfd1..558260775 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c @@ -46,6 +46,12 @@ SDLKey SDL_android_keymap[KEYCODE_LAST+1]; static int isTrackballUsed = 0; static int isMouseUsed = 0; +enum { RIGHT_CLICK_WITH_MENU_BUTTON = 0, RIGHT_CLICK_WITH_MULTITOUCH = 1, RIGHT_CLICK_WITH_PRESSURE = 2 }; +static int rightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON; +static int showScreenUnderFinger = 0; +static int leftClickUsesPressure = 0; +static int maxForce = 0; +static int maxRadius = 0; int SDL_ANDROID_isJoystickUsed = 0; static int isMultitouchUsed = 0; SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1] = {NULL}; @@ -199,9 +205,14 @@ JAVA_EXPORT_NAME(Settings_nativeSetTrackballUsed) ( JNIEnv* env, jobject thiz) } JNIEXPORT void JNICALL -JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz) +JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz, jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickUsesPressure, jint MaxForce, jint MaxRadius) { isMouseUsed = 1; + rightClickMethod = RightClickMethod; + showScreenUnderFinger = ShowScreenUnderFinger; + leftClickUsesPressure = LeftClickUsesPressure; + maxForce = MaxForce; + maxRadius = MaxRadius; } JNIEXPORT void JNICALL