diff --git a/changeAppSettings.sh b/changeAppSettings.sh index 5f257fd6d..18998e20b 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -896,6 +896,9 @@ echo >> AndroidAppSettings.cfg echo "# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4" >> AndroidAppSettings.cfg echo AppUsesGyroscope=$AppUsesGyroscope >> AndroidAppSettings.cfg echo >> AndroidAppSettings.cfg +echo "# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting" >> AndroidAppSettings.cfg +echo MoveMouseWithGyroscope=$MoveMouseWithGyroscope >> AndroidAppSettings.cfg +echo >> AndroidAppSettings.cfg echo "# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0" >> AndroidAppSettings.cfg echo AppUsesMultitouch=$AppUsesMultitouch >> AndroidAppSettings.cfg echo >> AndroidAppSettings.cfg @@ -1205,6 +1208,12 @@ else AppUsesGyroscope=false fi +if [ "$MoveMouseWithGyroscope" = "y" ] ; then + MoveMouseWithGyroscope=true +else + MoveMouseWithGyroscope=false +fi + if [ "$AppUsesMultitouch" = "y" ] ; then AppUsesMultitouch=true else @@ -1403,6 +1412,7 @@ $SEDI "s/public static boolean AppUsesSecondJoystick = .*;/public static boolean $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 MoveMouseWithGyroscope = .*;/public static boolean MoveMouseWithGyroscope = $MoveMouseWithGyroscope;/" project/src/Globals.java $SEDI "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" project/src/Globals.java $SEDI "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" project/src/Globals.java $SEDI "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" project/src/Globals.java diff --git a/project/java/Accelerometer.java b/project/java/Accelerometer.java index 978020850..b786bfb22 100644 --- a/project/java/Accelerometer.java +++ b/project/java/Accelerometer.java @@ -67,7 +67,8 @@ class AccelerometerReader implements SensorEventListener Log.i("SDL", "libSDL: starting accelerometer"); _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); } - if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null ) + if( (Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) && + _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null ) { Log.i("SDL", "libSDL: starting gyroscope"); _manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME); @@ -81,6 +82,7 @@ class AccelerometerReader implements SensorEventListener else nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested! } + public void onAccuracyChanged(Sensor s, int a) { } diff --git a/project/java/Globals.java b/project/java/Globals.java index d5449bbfa..781ecef17 100644 --- a/project/java/Globals.java +++ b/project/java/Globals.java @@ -77,7 +77,7 @@ class Globals public static String AdmobTestDeviceId = ""; public static String AdmobBannerSize = ""; - // Phone-specific config, modified by user in "Change phone config" startup dialog, TODO: move this to settings + // Phone-specific config, modified by user in "Change phone config" startup dialog public static boolean DownloadToSdcard = true; public static boolean PhoneHasTrackball = false; public static boolean PhoneHasArrowKeys = false; @@ -102,6 +102,8 @@ class Globals public static boolean MoveMouseWithJoystick = false; public static int MoveMouseWithJoystickSpeed = 0; public static int MoveMouseWithJoystickAccel = 0; + public static boolean MoveMouseWithGyroscope = true; + public static int MoveMouseWithGyroscopeSpeed = 2; public static boolean ClickMouseWithDpad = false; public static boolean RelativeMouseMovement = ForceRelativeMouseMode; // Laptop touchpad mode public static int RelativeMouseMovementSpeed = 2; diff --git a/project/java/Settings.java b/project/java/Settings.java index e061da2a6..7dddbb464 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -501,7 +501,9 @@ class Settings Globals.RelativeMouseMovementAccel, Globals.ShowMouseCursor ? 1 : 0, Globals.HoverJitterFilter ? 1 : 0, - Globals.RightMouseButtonLongPress ? 1 : 0); + Globals.RightMouseButtonLongPress ? 1 : 0, + Globals.MoveMouseWithGyroscope ? 1 : 0, + Globals.MoveMouseWithGyroscopeSpeed); } static void Apply(MainActivity p) @@ -774,7 +776,8 @@ class Settings int leftClickTimeout, int rightClickTimeout, int relativeMovement, int relativeMovementSpeed, int relativeMovementAccel, int showMouseCursor, - int HoverJitterFilter, int RightMouseButtonLongPress); + int HoverJitterFilter, int RightMouseButtonLongPress, + int MoveMouseWithGyroscope, int MoveMouseWithGyroscopeSpeed); private static native void nativeSetJoystickUsed(int amount); private static native void nativeSetAccelerometerUsed(); private static native void nativeSetMultitouchUsed(); diff --git a/project/java/SettingsMenuMisc.java b/project/java/SettingsMenuMisc.java index 2e9e30fd2..a3d9b1968 100644 --- a/project/java/SettingsMenuMisc.java +++ b/project/java/SettingsMenuMisc.java @@ -344,7 +344,7 @@ class SettingsMenuMisc extends SettingsMenu { debugMenuShowCount++; CharSequence[] items = { - p.getResources().getString(R.string.pointandclick_keepaspectratio), + p.getResources().getString(R.string.mouse_keepaspectratio), p.getResources().getString(R.string.video_smooth) }; boolean defaults[] = { @@ -355,7 +355,7 @@ class SettingsMenuMisc extends SettingsMenu if(Globals.SwVideoMode && !Globals.CompatibilityHacksVideo) { CharSequence[] items2 = { - p.getResources().getString(R.string.pointandclick_keepaspectratio), + p.getResources().getString(R.string.mouse_keepaspectratio), p.getResources().getString(R.string.video_smooth), p.getResources().getString(R.string.video_separatethread), }; @@ -371,7 +371,7 @@ class SettingsMenuMisc extends SettingsMenu if(Globals.Using_SDL_1_3) { CharSequence[] items2 = { - p.getResources().getString(R.string.pointandclick_keepaspectratio), + p.getResources().getString(R.string.mouse_keepaspectratio), }; boolean defaults2[] = { Globals.KeepAspectRatio, @@ -570,9 +570,9 @@ class SettingsMenuMisc extends SettingsMenu } void run (final MainActivity p) { - if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) ) + if( !(Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) || !AccelerometerReader.gyro.available(p) ) { - if( Globals.AppUsesGyroscope ) + if( Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope ) { Toast toast = Toast.makeText(p, p.getResources().getString(R.string.calibrate_gyroscope_not_supported), Toast.LENGTH_LONG); toast.show(); @@ -640,9 +640,9 @@ class SettingsMenuMisc extends SettingsMenu { for(int count = 1; count < 10; count++) { - p.setText("" + count + "0% ..."); + p.setText("" + count * 10 + "% ..."); try { - Thread.sleep(500); + Thread.sleep(200); } catch( Exception e ) {} } finishCalibration(p); @@ -752,4 +752,3 @@ class SettingsMenuMisc extends SettingsMenu } } } - diff --git a/project/java/SettingsMenuMouse.java b/project/java/SettingsMenuMouse.java index 226f84667..b24ecc850 100644 --- a/project/java/SettingsMenuMouse.java +++ b/project/java/SettingsMenuMouse.java @@ -409,27 +409,29 @@ class SettingsMenuMouse extends SettingsMenu { String title(final MainActivity p) { - return p.getResources().getString(R.string.pointandclick_question); + return p.getResources().getString(R.string.mouse_question); } void run (final MainActivity p) { CharSequence[] items = { - p.getResources().getString(R.string.hover_jitter_filter), - p.getResources().getString(R.string.pointandclick_joystickmouse), + p.getResources().getString(R.string.mouse_hover_jitter_filter), + p.getResources().getString(R.string.mouse_joystickmouse), p.getResources().getString(R.string.click_with_dpadcenter), - p.getResources().getString(R.string.pointandclick_relative) + p.getResources().getString(R.string.mouse_relative), + p.getResources().getString(R.string.mouse_gyroscope_mouse), }; boolean defaults[] = { Globals.HoverJitterFilter, Globals.MoveMouseWithJoystick, Globals.ClickMouseWithDpad, - Globals.RelativeMouseMovement + Globals.RelativeMouseMovement, + Globals.MoveMouseWithGyroscope, }; AlertDialog.Builder builder = new AlertDialog.Builder(p); - builder.setTitle(p.getResources().getString(R.string.pointandclick_question)); + builder.setTitle(p.getResources().getString(R.string.mouse_question)); builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int item, boolean isChecked) @@ -442,6 +444,8 @@ class SettingsMenuMouse extends SettingsMenu Globals.ClickMouseWithDpad = isChecked; if( item == 3 ) Globals.RelativeMouseMovement = isChecked; + if( item == 4 ) + Globals.MoveMouseWithGyroscope = isChecked; } }); builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() @@ -449,10 +453,45 @@ class SettingsMenuMouse extends SettingsMenu public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); - if( Globals.RelativeMouseMovement ) - showRelativeMouseMovementConfig(p); - else - goBack(p); + showGyroscopeMouseMovementConfig(p); + } + }); + builder.setOnCancelListener(new DialogInterface.OnCancelListener() + { + public void onCancel(DialogInterface dialog) + { + goBack(p); + } + }); + AlertDialog alert = builder.create(); + alert.setOwnerActivity(p); + alert.show(); + } + + static void showGyroscopeMouseMovementConfig(final MainActivity p) + { + if( !Globals.MoveMouseWithGyroscope ) + { + showRelativeMouseMovementConfig(p); + return; + } + + final CharSequence[] items = { p.getResources().getString(R.string.accel_veryslow), + p.getResources().getString(R.string.accel_slow), + p.getResources().getString(R.string.accel_medium), + p.getResources().getString(R.string.accel_fast), + p.getResources().getString(R.string.accel_veryfast) }; + + AlertDialog.Builder builder = new AlertDialog.Builder(p); + builder.setTitle(R.string.mouse_gyroscope_mouse_sensitivity); + builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int item) + { + Globals.MoveMouseWithGyroscopeSpeed = item; + + dialog.dismiss(); + showRelativeMouseMovementConfig(p); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() @@ -469,6 +508,12 @@ class SettingsMenuMouse extends SettingsMenu static void showRelativeMouseMovementConfig(final MainActivity p) { + if( !Globals.RelativeMouseMovement ) + { + goBack(p); + return; + } + final CharSequence[] items = { p.getResources().getString(R.string.accel_veryslow), p.getResources().getString(R.string.accel_slow), p.getResources().getString(R.string.accel_medium), @@ -476,10 +521,10 @@ class SettingsMenuMouse extends SettingsMenu p.getResources().getString(R.string.accel_veryfast) }; AlertDialog.Builder builder = new AlertDialog.Builder(p); - builder.setTitle(R.string.pointandclick_relative_speed); + builder.setTitle(R.string.mouse_relative_speed); builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int item) + public void onClick(DialogInterface dialog, int item) { Globals.RelativeMouseMovementSpeed = item; @@ -507,7 +552,7 @@ class SettingsMenuMouse extends SettingsMenu p.getResources().getString(R.string.accel_fast) }; AlertDialog.Builder builder = new AlertDialog.Builder(p); - builder.setTitle(R.string.pointandclick_relative_accel); + builder.setTitle(R.string.mouse_relative_accel); builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) @@ -535,7 +580,7 @@ class SettingsMenuMouse extends SettingsMenu { String title(final MainActivity p) { - return p.getResources().getString(R.string.pointandclick_joystickmousespeed); + return p.getResources().getString(R.string.mouse_joystickmousespeed); } boolean enabled() { @@ -548,7 +593,7 @@ class SettingsMenuMouse extends SettingsMenu p.getResources().getString(R.string.accel_fast) }; AlertDialog.Builder builder = new AlertDialog.Builder(p); - builder.setTitle(R.string.pointandclick_joystickmousespeed); + builder.setTitle(R.string.mouse_joystickmousespeed); builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) @@ -579,7 +624,7 @@ class SettingsMenuMouse extends SettingsMenu p.getResources().getString(R.string.accel_fast) }; AlertDialog.Builder builder = new AlertDialog.Builder(p); - builder.setTitle(R.string.pointandclick_joystickmouseaccel); + builder.setTitle(R.string.mouse_joystickmouseaccel); builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) diff --git a/project/java/translations/unsupported/values-de/strings.xml b/project/java/translations/unsupported/values-de/strings.xml index d3b2dc0b7..89d8a25fe 100644 --- a/project/java/translations/unsupported/values-de/strings.xml +++ b/project/java/translations/unsupported/values-de/strings.xml @@ -62,9 +62,9 @@ Menütaste Touch-Screen mit dem zweiten Finger Touchscreen mit Kraft -Erweiterte Funktionen -Halten 4:3-Bildschirm Seitenverhältnis -Show-Bildschirm unter dem Finger in einem separaten Fenster +Erweiterte Funktionen +Halten 4:3-Bildschirm Seitenverhältnis +Show-Bildschirm unter dem Finger in einem separaten Fenster Bitte schieben Sie den Finger über den Bildschirm für zwei Sekunden Deaktivieren der rechten Maustaste Linke Maustaste @@ -73,11 +73,11 @@ Touch-Screen mit dem zweiten Finger Touchscreen mit Kraft Trackball klicken Select-Taste -Bewegen Sie die Maus mit Joystick oder Trackball +Bewegen Sie die Maus mit Joystick oder Trackball Pressure %1$03d Radius %2$03d Linker Mausklick mit Trackball / Joystick Zentrum -Bewegen Sie die Maus mit Joystick-Geschwindigkeit -Bewegen Sie die Maus mit Joystick-Beschleunigung +Bewegen Sie die Maus mit Joystick-Geschwindigkeit +Bewegen Sie die Maus mit Joystick-Beschleunigung Keine On-Screen-Tastatur Transparenz Nicht sichtbar @@ -108,7 +108,7 @@ Passen Sie auf dem Bildschirm Tastatur-Layout Slide-Bildschirm hinzufügen Taste, drücken Sie Menü zum letzten Knopf rückgängig machen Physikalische Schlüssel -On-Screen-Lupe +On-Screen-Lupe Video-Einstellungen Glatte Video Sehr langsam @@ -121,9 +121,9 @@ 0,7 Sek. 1 Sek. 1,5 Sek. -Relative Bewegung der Maus (Laptop-Modus) -Relative Maus Bewegungsgeschwindigkeit -Relative Bewegung der Maus Beschleunigung +Relative Bewegung der Maus (Laptop-Modus) +Relative Maus Bewegungsgeschwindigkeit +Relative Bewegung der Maus Beschleunigung Downloads Separaten Thread für Video, FPS bei einigen Geräten zu erhöhen Tippen Sie auf der Eingabe beginnen, drücken Sie Zurück, wenn Sie fertig diff --git a/project/java/translations/unsupported/values-fi/strings.xml b/project/java/translations/unsupported/values-fi/strings.xml index bcab7a5a7..ed53e1491 100644 --- a/project/java/translations/unsupported/values-fi/strings.xml +++ b/project/java/translations/unsupported/values-fi/strings.xml @@ -62,9 +62,9 @@ Valikkonäppäin Kosketusnäyttö on toinen sormi Kosketusnäyttö voimalla -Lisäominaisuudet -Pidä 04:03 kuvasuhde -Näytä näytön alle sormi erillisessä ikkunassa +Lisäominaisuudet +Pidä 04:03 kuvasuhde +Näytä näytön alle sormi erillisessä ikkunassa Ole hyvä ja liu\u0026#39;uttamalla sormea näytöllä kaksi sekuntia Poista oikealla hiiren klikkauksella Vasen hiiren nappi @@ -73,11 +73,11 @@ Kosketusnäyttö on toinen sormi Kosketusnäyttö voimalla Trackball Valitse / Select-näppäintä -Siirrä hiiren ohjaimella tai trackball +Siirrä hiiren ohjaimella tai trackball Paine %1$03d säde %2$03d Vasen hiiren klikkaus trackball-ohjaimella keskusta -Siirrä hiiri ohjainta nopeasti -Siirrä hiiri ohjainta kiihtyvyys +Siirrä hiiri ohjainta nopeasti +Siirrä hiiri ohjainta kiihtyvyys Ei Näyttönäppäimistöllä avoimuutta Näkymätön @@ -108,7 +108,7 @@ Mukauta-ruudun näppäimistö Työnnä näytön lisätä painikkeen, paina Menu kumota viimeksi painike Fyysinen avain -Näytöllä suurennuslasi +Näytöllä suurennuslasi Videon asetukset Tasainen video Erittäin hidas @@ -121,9 +121,9 @@ 0,7 sekuntia 1 sek 1,5 sek -Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa) -Suhteellinen hiiren liikkeen nopeus -Suhteellinen hiiren liikkeen kiihtyvyys +Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa) +Suhteellinen hiiren liikkeen nopeus +Suhteellinen hiiren liikkeen kiihtyvyys Downloads Erillisessä säikeessä video, kasvaa FPS joissakin laitteissa Napauta aloittaa kirjoittamisen, paina Takaisin, kun olet valmis diff --git a/project/java/translations/values-fr/strings.xml b/project/java/translations/values-fr/strings.xml index 0d463eb8c..f76113c24 100644 --- a/project/java/translations/values-fr/strings.xml +++ b/project/java/translations/values-fr/strings.xml @@ -98,16 +98,16 @@ 1,5 sec Cliquez gauche de la souris avec le Trackball / centre du joystick -Fonctionnalités avancées -Gardez le format 4:3 écran -Afficher l\'écran sous le doigt dans une fenêtre séparée -Loupe à l\'écran -Déplacez la souris avec un trackball ou le joystick -Déplacez la souris avec la vitesse du joystick -Déplacez la souris avec l\'accélération du joystick -Mouvement relatif de la souris (mode portable) -Vitesse relative de la souris -Accélération relative de la souris +Fonctionnalités avancées +Gardez le format 4:3 écran +Afficher l\'écran sous le doigt dans une fenêtre séparée +Loupe à l\'écran +Déplacez la souris avec un trackball ou le joystick +Déplacez la souris avec la vitesse du joystick +Déplacez la souris avec l\'accélération du joystick +Mouvement relatif de la souris (mode portable) +Vitesse relative de la souris +Accélération relative de la souris Aucun diff --git a/project/java/translations/values-ru/strings.xml b/project/java/translations/values-ru/strings.xml index 7015b76b5..71a9f33e6 100644 --- a/project/java/translations/values-ru/strings.xml +++ b/project/java/translations/values-ru/strings.xml @@ -46,9 +46,9 @@ Кнопка меню Касание экрана вторым пальцем Нажатие на экран с силой -Расширенные функции -Сохранять соотношение сторон 4:3 на экране -Экранная лупа +Расширенные функции +Сохранять соотношение сторон 4:3 на экране +Экранная лупа Пожалуйста, проведите пальцем по экрану в течение двух секунд Давление %1$03d радиус %2$03d Очень мало (быстрые устройства) @@ -67,10 +67,10 @@ Касание двумя пальцами Нажатие с силой Нажатие на трекбол / центр джойстика -Перемещение мыши при помощи джойстика или трекбола +Перемещение мыши при помощи джойстика или трекбола Левый клик мыши при помощи трекбола / центра джойстика -Перемещение мыши джойстиком - скорость -Перемещение мыши джойстиком - ускорение +Перемещение мыши джойстиком - скорость +Перемещение мыши джойстиком - ускорение Нет Прозрачность клавиатуры Невидимый @@ -101,7 +101,7 @@ Настройка расположения кнопок Нажмите кнопку Назад/BACK для завершения. Проведите по пустому месту, чтобы изменить размер кнопки Физическая кнопка -Наэкранная лупа +Наэкранная лупа Настройки видео Линейное сглаживание видео Очень медленно @@ -114,9 +114,9 @@ 0,7 сек 1 сек 1,5 сек -Относительное движение мыши (режим ноутбука) -Скорость движения мыши -Ускорение движения мыши +Относительное движение мыши (режим ноутбука) +Скорость движения мыши +Ускорение движения мыши Загрузки Отдельный поток для видео, увеличит FPS на некоторых устройствах Нажмите, чтобы ввести текст, нажмите Назад, когда закончите diff --git a/project/java/translations/values-uk/strings.xml b/project/java/translations/values-uk/strings.xml index c8e583034..dbb411d75 100644 --- a/project/java/translations/values-uk/strings.xml +++ b/project/java/translations/values-uk/strings.xml @@ -46,9 +46,9 @@ Кнопка меню Торкання екрана другим пальцем Натиск на екран силою -Розширені функції -Зберігати співвідношення сторін 4:3 на екрані -Наекранна лупа +Розширені функції +Зберігати співвідношення сторін 4:3 на екрані +Наекранна лупа Будь-ласка, проведіть пальцем по екрану на протязі двох секунд Тиск %1$03d радіус %2$03d Дуже мало (швидкі пристрої) @@ -67,10 +67,10 @@ Натиск на екран другим пальцем >Натиск на екран з силою Натиск на трекбол / центр джойстику -Переміщення миші за допомогою джойстика або трекбола +Переміщення миші за допомогою джойстика або трекбола Лівий клік миші за допомогою трекбола / центра джойстика -Переміщення миші джойстиком - швидкiсть -Переміщення миші джойстиком - прискорення +Переміщення миші джойстиком - швидкiсть +Переміщення миші джойстиком - прискорення Немає Прозорість клавіатури Невидимий @@ -101,7 +101,7 @@ Налаштування положення кнопок Натисніть Назад/BACK для завершення. Проведiть по екрану, щоб змінити розмір кнопки Фізична кнопка -Наекранна лупа +Наекранна лупа Налаштування відео Лінійне сглажування відео Дуже повільно @@ -114,9 +114,9 @@ 0,7 секунд 1 сек 1,5 сек -Відносний рух миші (режим ноутбука) -Швидкість руху миші -Прискорення руху миші +Відносний рух миші (режим ноутбука) +Швидкість руху миші +Прискорення руху миші Завантаження Окремий потік для відео, збільшить FPS на деяких пристроях Натисніть, щоб ввести текст, натисніть Назад, коли закiнчете diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml index ea4c5ff43..f75e96bfb 100644 --- a/project/java/translations/values/strings.xml +++ b/project/java/translations/values/strings.xml @@ -98,17 +98,19 @@ 1.5 sec Left mouse click with trackball / joystick center - Advanced features - Keep 4:3 screen aspect ratio - Show screen under finger in separate window - On-screen magnifying glass - Move mouse with joystick or trackball - Move mouse with joystick speed - Move mouse with joystick acceleration - Relative mouse movement (laptop mode) - Relative mouse movement speed - Relative mouse movement acceleration - Filter jitter for stylus/finger hover + Advanced features + Keep 4:3 screen aspect ratio + Show screen under finger in separate window + On-screen magnifying glass + Move mouse with joystick or trackball + Move mouse with joystick speed + Move mouse with joystick acceleration + Relative mouse movement (laptop mode) + Relative mouse movement speed + Relative mouse movement acceleration + Filter jitter for stylus/finger hover + Control mouse with gyroscope + Gyroscope sensitivity None diff --git a/project/jni/application/xserver/AndroidAppSettings.cfg b/project/jni/application/xserver/AndroidAppSettings.cfg index 49fa4367f..bbb3e09c1 100644 --- a/project/jni/application/xserver/AndroidAppSettings.cfg +++ b/project/jni/application/xserver/AndroidAppSettings.cfg @@ -133,6 +133,9 @@ AppUsesAccelerometer=n # Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4 AppUsesGyroscope=n +# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting +MoveMouseWithGyroscope=y + # Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0 AppUsesMultitouch=y diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c index f2916c7d7..4a449359a 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c @@ -71,10 +71,10 @@ extern void SDL_ANDROID_PumpEvents() extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y) { - SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, x, y ); - SDL_ANDROID_currentMouseX = x; SDL_ANDROID_currentMouseY = y; + + SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, x, y ); } extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c index 2fe9ee593..00b956e45 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c @@ -133,6 +133,10 @@ enum { DEADZONE_HOVER_FINGER = 50, DEADZONE_HOVER_STYLUS = 80, HOVER_FREEZE_TIME static int hoverJitterFilter = 1; static int hoverX, hoverY, hoverTime = 0, hoverMouseFreeze = 0, hoverDeadzone = 0; static int rightMouseButtonLongPress = 1; +static int moveMouseWithGyroscope = 0; +static float moveMouseWithGyroscopeSpeed = 1.0f; +static int moveMouseWithGyroscopeX = 0; +static int moveMouseWithGyroscopeY = 0; static inline int InsideRect( const SDL_Rect * r, int x, int y ) { @@ -501,7 +505,7 @@ static void ProcessMouseUp( int x, int y ) abs(mouseInitialY - y) < SDL_ANDROID_sFakeWindowHeight / 16 && SDL_GetTicks() - mouseInitialTime < 700 ) { - SDL_ANDROID_MainThreadPushMouseMotion(mouseInitialX, mouseInitialY); + SDL_ANDROID_MainThreadPushMouseMotion( mouseInitialX, mouseInitialY ); SDL_ANDROID_MainThreadPushMouseButton( SDL_PRESSED, SDL_BUTTON_LEFT ); deferredMouseTap = 2; mouseInitialX = -1; @@ -527,6 +531,11 @@ static void ProcessMouseUp( int x, int y ) SDL_ANDROID_moveMouseWithKbY = -1; SDL_ANDROID_moveMouseWithKbSpeedX = 0; SDL_ANDROID_moveMouseWithKbSpeedY = 0; + if( !deferredMouseTap ) + { + moveMouseWithGyroscopeX = 0; + moveMouseWithGyroscopeY = 0; + } } static int ProcessMouseDown( int x, int y ) @@ -745,7 +754,38 @@ static void ProcessMouseHover( jint *xx, jint *yy, int action, int distance ) #endif } -JNIEXPORT void JNICALL +static void AdjustMouseWithGyroscope( jint *xx, jint *yy ) +{ + if( !moveMouseWithGyroscope || relativeMovement || + SDL_ANDROID_moveMouseWithKbX >= 0 || hardwareMouseDetected == MOUSE_HW_INPUT_MOUSE ) + return; + + static int oldX = 0, oldY = 0, count = 0; + count += abs(*xx - oldX) + abs(*yy - oldY); + oldX = *xx; + oldY = *yy; + + *xx += moveMouseWithGyroscopeX; + *yy += moveMouseWithGyroscopeY; + + // Decrease the adjustment values slowly, when we move mouse + int decrease = count / 10; + count %= 10; + +#define SIGN(x) ((x > 0) - (x < 0)) // -1, 0, or 1, depending on the value sign + + int signX = SIGN(moveMouseWithGyroscopeX); + moveMouseWithGyroscopeX -= signX * decrease; + if( signX != SIGN(moveMouseWithGyroscopeX) ) + moveMouseWithGyroscopeX = 0; + + int signY = SIGN(moveMouseWithGyroscopeY); + moveMouseWithGyroscopeY -= signY * decrease; + if( signY != SIGN(moveMouseWithGyroscopeY) ) + moveMouseWithGyroscopeY = 0; +} + +JNIEXPORT void JNICALL JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject thiz, jint x, jint y, jint action, jint pointerId, jint force, jint radius ) { int i; @@ -773,6 +813,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t if( !SDL_ANDROID_isMouseUsed ) return; + AdjustMouseWithGyroscope( &x, &y ); + ProcessMouseHover( &x, &y, action, force ); if( pointerId == firstMousePointerId ) @@ -790,7 +832,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t ClearOldTouchPointers( action, pointerId ); } -void ProcessDeferredMouseTap() +static void ProcessDeferredMouseTap() { if( deferredMouseTap > 0 ) { @@ -807,12 +849,44 @@ void ProcessDeferredMouseTap() if( SDL_ANDROID_currentMouseX + 1 < SDL_ANDROID_sFakeWindowWidth ) SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + 1, SDL_ANDROID_currentMouseY); SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT ); + moveMouseWithGyroscopeX = 0; + moveMouseWithGyroscopeY = 0; } else if( SDL_ANDROID_currentMouseX > 0 ) // Force application to redraw, and call SDL_Flip() SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX - 1, SDL_ANDROID_currentMouseY); } } +static void ProcessMoveMouseWithGyroscope(float gx, float gy, float gz) +{ + if( hardwareMouseDetected == MOUSE_HW_INPUT_MOUSE ) // We don't need all that stuff with a proper precise input device + return; + + gx += gz; // Ignore Z? + gx *= moveMouseWithGyroscopeSpeed; + gy *= moveMouseWithGyroscopeSpeed; + + // TODO: mutex here? + // If race condition happens, mouse will jump at random across the screen. Nothing serious. + + if( SDL_ANDROID_moveMouseWithKbX >= 0 ) + { + SDL_ANDROID_moveMouseWithKbX += gx; + SDL_ANDROID_moveMouseWithKbY += gy; + SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY); + return; + } + + if( relativeMovement ) + { + SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + gx, SDL_ANDROID_currentMouseY + gy); + return; + } + + moveMouseWithGyroscopeX += gx; + moveMouseWithGyroscopeY += gy; +} + void SDL_ANDROID_WarpMouse(int x, int y) { if(!relativeMovement) @@ -933,6 +1007,13 @@ JAVA_EXPORT_NAME(AccelerometerReader_nativeGyroscope) ( JNIEnv* env, jobject th if( !SDL_CurrentVideoSurface ) return; #endif + + if( moveMouseWithGyroscope ) + { + ProcessMoveMouseWithGyroscope(X, Y, Z); + return; + } + X *= 0.25f; Y *= 0.25f; Z *= 0.25f; @@ -982,7 +1063,8 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) (JNIEnv* env, jobject thiz, jint LeftClickKeycode, jint RightClickKeycode, jint LeftClickTimeout, jint RightClickTimeout, jint RelativeMovement, jint RelativeMovementSpeed, jint RelativeMovementAccel, - jint ShowMouseCursor, jint HoverJitterFilter, jint RightMouseButtonLongPress) + jint ShowMouseCursor, jint HoverJitterFilter, jint RightMouseButtonLongPress, + jint MoveMouseWithGyroscope, jint MoveMouseWithGyroscopeSpeed) { SDL_ANDROID_isMouseUsed = 1; rightClickMethod = RightClickMethod; @@ -1004,6 +1086,8 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) (JNIEnv* env, jobject thiz, SDL_ANDROID_ShowMouseCursor = ShowMouseCursor; hoverJitterFilter = HoverJitterFilter; rightMouseButtonLongPress = RightMouseButtonLongPress; + moveMouseWithGyroscope = MoveMouseWithGyroscope; + moveMouseWithGyroscopeSpeed = 0.0625f * MoveMouseWithGyroscopeSpeed * MoveMouseWithGyroscopeSpeed + 0.375 * MoveMouseWithGyroscopeSpeed + 1.0f; // Scale value from 0.5 to 2, with 1 at the middle //__android_log_print(ANDROID_LOG_INFO, "libSDL", "relativeMovementSpeed %d relativeMovementAccel %d", relativeMovementSpeed, relativeMovementAccel); } diff --git a/todo.txt b/todo.txt index 61cabaed3..2654338e3 100644 --- a/todo.txt +++ b/todo.txt @@ -18,3 +18,5 @@ TODO, which will get actually done - SuperTux: Update, enable OpenGL renderer, add touchscreen jump helper, add gamepad support, fix zoom in settings. - GIMP: x86 architecture support. + +- OpenTTD: logarithmic music volume, restore volume on new track.