Move mouse with gyroscope, not tested yet.

This commit is contained in:
pelya
2014-04-20 23:54:08 +03:00
parent ee1e41ef17
commit 343bfe673a
16 changed files with 247 additions and 95 deletions

View File

@@ -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

View File

@@ -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)
{
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -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
}
}
}

View File

@@ -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)

View File

@@ -62,9 +62,9 @@
<string name="rightclick_menu">Menütaste</string>
<string name="rightclick_multitouch">Touch-Screen mit dem zweiten Finger</string>
<string name="rightclick_pressure">Touchscreen mit Kraft</string>
<string name="pointandclick_question">Erweiterte Funktionen</string>
<string name="pointandclick_keepaspectratio">Halten 4:3-Bildschirm Seitenverhältnis</string>
<string name="pointandclick_showcreenunderfinger">Show-Bildschirm unter dem Finger in einem separaten Fenster</string>
<string name="mouse_question">Erweiterte Funktionen</string>
<string name="mouse_keepaspectratio">Halten 4:3-Bildschirm Seitenverhältnis</string>
<string name="mouse_showcreenunderfinger">Show-Bildschirm unter dem Finger in einem separaten Fenster</string>
<string name="measurepressure_touchplease">Bitte schieben Sie den Finger über den Bildschirm für zwei Sekunden</string>
<string name="rightclick_none">Deaktivieren der rechten Maustaste</string>
<string name="leftclick_question">Linke Maustaste</string>
@@ -73,11 +73,11 @@
<string name="leftclick_multitouch">Touch-Screen mit dem zweiten Finger</string>
<string name="leftclick_pressure">Touchscreen mit Kraft</string>
<string name="leftclick_dpadcenter">Trackball klicken Select-Taste</string>
<string name="pointandclick_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
<string name="mouse_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
<string name="measurepressure_response">Pressure %1$03d Radius %2$03d</string>
<string name="click_with_dpadcenter">Linker Mausklick mit Trackball / Joystick Zentrum</string>
<string name="pointandclick_joystickmousespeed">Bewegen Sie die Maus mit Joystick-Geschwindigkeit</string>
<string name="pointandclick_joystickmouseaccel">Bewegen Sie die Maus mit Joystick-Beschleunigung</string>
<string name="mouse_joystickmousespeed">Bewegen Sie die Maus mit Joystick-Geschwindigkeit</string>
<string name="mouse_joystickmouseaccel">Bewegen Sie die Maus mit Joystick-Beschleunigung</string>
<string name="none">Keine</string>
<string name="controls_screenkb_transparency">On-Screen-Tastatur Transparenz</string>
<string name="controls_screenkb_trans_0">Nicht sichtbar</string>
@@ -108,7 +108,7 @@
<string name="screenkb_custom_layout">Passen Sie auf dem Bildschirm Tastatur-Layout</string>
<string name="screenkb_custom_layout_help">Slide-Bildschirm hinzufügen Taste, drücken Sie Menü zum letzten Knopf rückgängig machen</string>
<string name="rightclick_key">Physikalische Schlüssel</string>
<string name="pointandclick_showcreenunderfinger2">On-Screen-Lupe</string>
<string name="mouse_showcreenunderfinger2">On-Screen-Lupe</string>
<string name="video">Video-Einstellungen</string>
<string name="video_smooth">Glatte Video</string>
<string name="accel_veryslow">Sehr langsam</string>
@@ -121,9 +121,9 @@
<string name="leftclick_timeout_time_2">0,7 Sek.</string>
<string name="leftclick_timeout_time_3">1 Sek.</string>
<string name="leftclick_timeout_time_4">1,5 Sek.</string>
<string name="pointandclick_relative">Relative Bewegung der Maus (Laptop-Modus)</string>
<string name="pointandclick_relative_speed">Relative Maus Bewegungsgeschwindigkeit</string>
<string name="pointandclick_relative_accel">Relative Bewegung der Maus Beschleunigung</string>
<string name="mouse_relative">Relative Bewegung der Maus (Laptop-Modus)</string>
<string name="mouse_relative_speed">Relative Maus Bewegungsgeschwindigkeit</string>
<string name="mouse_relative_accel">Relative Bewegung der Maus Beschleunigung</string>
<string name="downloads">Downloads</string>
<string name="video_separatethread">Separaten Thread für Video, FPS bei einigen Geräten zu erhöhen</string>
<string name="text_edit_click_here">Tippen Sie auf der Eingabe beginnen, drücken Sie Zurück, wenn Sie fertig</string>

View File

@@ -62,9 +62,9 @@
<string name="rightclick_menu">Valikkonäppäin</string>
<string name="rightclick_multitouch">Kosketusnäyttö on toinen sormi</string>
<string name="rightclick_pressure">Kosketusnäyttö voimalla</string>
<string name="pointandclick_question">Lisäominaisuudet</string>
<string name="pointandclick_keepaspectratio">Pidä 04:03 kuvasuhde</string>
<string name="pointandclick_showcreenunderfinger">Näytä näytön alle sormi erillisessä ikkunassa</string>
<string name="mouse_question">Lisäominaisuudet</string>
<string name="mouse_keepaspectratio">Pidä 04:03 kuvasuhde</string>
<string name="mouse_showcreenunderfinger">Näytä näytön alle sormi erillisessä ikkunassa</string>
<string name="measurepressure_touchplease">Ole hyvä ja liu\u0026#39;uttamalla sormea näytöllä kaksi sekuntia</string>
<string name="rightclick_none">Poista oikealla hiiren klikkauksella</string>
<string name="leftclick_question">Vasen hiiren nappi</string>
@@ -73,11 +73,11 @@
<string name="leftclick_multitouch">Kosketusnäyttö on toinen sormi</string>
<string name="leftclick_pressure">Kosketusnäyttö voimalla</string>
<string name="leftclick_dpadcenter">Trackball Valitse / Select-näppäintä</string>
<string name="pointandclick_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
<string name="mouse_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
<string name="measurepressure_response">Paine %1$03d säde %2$03d</string>
<string name="click_with_dpadcenter">Vasen hiiren klikkaus trackball-ohjaimella keskusta</string>
<string name="pointandclick_joystickmousespeed">Siirrä hiiri ohjainta nopeasti</string>
<string name="pointandclick_joystickmouseaccel">Siirrä hiiri ohjainta kiihtyvyys</string>
<string name="mouse_joystickmousespeed">Siirrä hiiri ohjainta nopeasti</string>
<string name="mouse_joystickmouseaccel">Siirrä hiiri ohjainta kiihtyvyys</string>
<string name="none">Ei</string>
<string name="controls_screenkb_transparency">Näyttönäppäimistöllä avoimuutta</string>
<string name="controls_screenkb_trans_0">Näkymätön</string>
@@ -108,7 +108,7 @@
<string name="screenkb_custom_layout">Mukauta-ruudun näppäimistö</string>
<string name="screenkb_custom_layout_help">Työnnä näytön lisätä painikkeen, paina Menu kumota viimeksi painike</string>
<string name="rightclick_key">Fyysinen avain</string>
<string name="pointandclick_showcreenunderfinger2">Näytöllä suurennuslasi</string>
<string name="mouse_showcreenunderfinger2">Näytöllä suurennuslasi</string>
<string name="video">Videon asetukset</string>
<string name="video_smooth">Tasainen video</string>
<string name="accel_veryslow">Erittäin hidas</string>
@@ -121,9 +121,9 @@
<string name="leftclick_timeout_time_2">0,7 sekuntia</string>
<string name="leftclick_timeout_time_3">1 sek</string>
<string name="leftclick_timeout_time_4">1,5 sek</string>
<string name="pointandclick_relative">Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa)</string>
<string name="pointandclick_relative_speed">Suhteellinen hiiren liikkeen nopeus</string>
<string name="pointandclick_relative_accel">Suhteellinen hiiren liikkeen kiihtyvyys</string>
<string name="mouse_relative">Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa)</string>
<string name="mouse_relative_speed">Suhteellinen hiiren liikkeen nopeus</string>
<string name="mouse_relative_accel">Suhteellinen hiiren liikkeen kiihtyvyys</string>
<string name="downloads">Downloads</string>
<string name="video_separatethread">Erillisessä säikeessä video, kasvaa FPS joissakin laitteissa</string>
<string name="text_edit_click_here">Napauta aloittaa kirjoittamisen, paina Takaisin, kun olet valmis</string>

View File

@@ -98,16 +98,16 @@
<string name="leftclick_timeout_time_4">1,5 sec</string>
<string name="click_with_dpadcenter">Cliquez gauche de la souris avec le Trackball / centre du joystick </string>
<string name="pointandclick_question">Fonctionnalités avancées</string>
<string name="pointandclick_keepaspectratio">Gardez le format 4:3 écran</string>
<string name="pointandclick_showcreenunderfinger">Afficher l\'écran sous le doigt dans une fenêtre séparée</string>
<string name="pointandclick_showcreenunderfinger2">Loupe à l\'écran</string>
<string name="pointandclick_joystickmouse">Déplacez la souris avec un trackball ou le joystick</string>
<string name="pointandclick_joystickmousespeed">Déplacez la souris avec la vitesse du joystick</string>
<string name="pointandclick_joystickmouseaccel">Déplacez la souris avec l\'accélération du joystick</string>
<string name="pointandclick_relative">Mouvement relatif de la souris (mode portable)</string>
<string name="pointandclick_relative_speed">Vitesse relative de la souris</string>
<string name="pointandclick_relative_accel">Accélération relative de la souris</string>
<string name="mouse_question">Fonctionnalités avancées</string>
<string name="mouse_keepaspectratio">Gardez le format 4:3 écran</string>
<string name="mouse_showcreenunderfinger">Afficher l\'écran sous le doigt dans une fenêtre séparée</string>
<string name="mouse_showcreenunderfinger2">Loupe à l\'écran</string>
<string name="mouse_joystickmouse">Déplacez la souris avec un trackball ou le joystick</string>
<string name="mouse_joystickmousespeed">Déplacez la souris avec la vitesse du joystick</string>
<string name="mouse_joystickmouseaccel">Déplacez la souris avec l\'accélération du joystick</string>
<string name="mouse_relative">Mouvement relatif de la souris (mode portable)</string>
<string name="mouse_relative_speed">Vitesse relative de la souris</string>
<string name="mouse_relative_accel">Accélération relative de la souris</string>
<string name="none">Aucun</string>

View File

@@ -46,9 +46,9 @@
<string name="rightclick_menu">Кнопка меню</string>
<string name="rightclick_multitouch">Касание экрана вторым пальцем</string>
<string name="rightclick_pressure">Нажатие на экран с силой</string>
<string name="pointandclick_question">Расширенные функции</string>
<string name="pointandclick_keepaspectratio">Сохранять соотношение сторон 4:3 на экране</string>
<string name="pointandclick_showcreenunderfinger">Экранная лупа</string>
<string name="mouse_question">Расширенные функции</string>
<string name="mouse_keepaspectratio">Сохранять соотношение сторон 4:3 на экране</string>
<string name="mouse_showcreenunderfinger">Экранная лупа</string>
<string name="measurepressure_touchplease">Пожалуйста, проведите пальцем по экрану в течение двух секунд</string>
<string name="measurepressure_response">Давление %1$03d радиус %2$03d </string>
<string name="audiobuf_verysmall">Очень мало (быстрые устройства)</string>
@@ -67,10 +67,10 @@
<string name="leftclick_multitouch">Касание двумя пальцами</string>
<string name="leftclick_pressure">Нажатие с силой</string>
<string name="leftclick_dpadcenter">Нажатие на трекбол / центр джойстика</string>
<string name="pointandclick_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
<string name="mouse_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
<string name="click_with_dpadcenter">Левый клик мыши при помощи трекбола / центра джойстика</string>
<string name="pointandclick_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
<string name="pointandclick_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
<string name="mouse_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
<string name="mouse_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
<string name="none">Нет</string>
<string name="controls_screenkb_transparency">Прозрачность клавиатуры</string>
<string name="controls_screenkb_trans_0">Невидимый</string>
@@ -101,7 +101,7 @@
<string name="screenkb_custom_layout">Настройка расположения кнопок</string>
<string name="screenkb_custom_layout_help">Нажмите кнопку Назад/BACK для завершения. Проведите по пустому месту, чтобы изменить размер кнопки</string>
<string name="rightclick_key">Физическая кнопка</string>
<string name="pointandclick_showcreenunderfinger2">Наэкранная лупа</string>
<string name="mouse_showcreenunderfinger2">Наэкранная лупа</string>
<string name="video">Настройки видео</string>
<string name="video_smooth">Линейное сглаживание видео</string>
<string name="accel_veryslow">Очень медленно</string>
@@ -114,9 +114,9 @@
<string name="leftclick_timeout_time_2">0,7 сек</string>
<string name="leftclick_timeout_time_3">1 сек</string>
<string name="leftclick_timeout_time_4">1,5 сек</string>
<string name="pointandclick_relative">Относительное движение мыши (режим ноутбука)</string>
<string name="pointandclick_relative_speed">Скорость движения мыши</string>
<string name="pointandclick_relative_accel">Ускорение движения мыши</string>
<string name="mouse_relative">Относительное движение мыши (режим ноутбука)</string>
<string name="mouse_relative_speed">Скорость движения мыши</string>
<string name="mouse_relative_accel">Ускорение движения мыши</string>
<string name="downloads">Загрузки</string>
<string name="video_separatethread">Отдельный поток для видео, увеличит FPS на некоторых устройствах</string>
<string name="text_edit_click_here">Нажмите, чтобы ввести текст, нажмите Назад, когда закончите</string>

View File

@@ -46,9 +46,9 @@
<string name="rightclick_menu">Кнопка меню</string>
<string name="rightclick_multitouch">Торкання екрана другим пальцем</string>
<string name="rightclick_pressure">Натиск на екран силою</string>
<string name="pointandclick_question">Розширені функції</string>
<string name="pointandclick_keepaspectratio">Зберігати співвідношення сторін 4:3 на екрані</string>
<string name="pointandclick_showcreenunderfinger">Наекранна лупа</string>
<string name="mouse_question">Розширені функції</string>
<string name="mouse_keepaspectratio">Зберігати співвідношення сторін 4:3 на екрані</string>
<string name="mouse_showcreenunderfinger">Наекранна лупа</string>
<string name="measurepressure_touchplease">Будь-ласка, проведіть пальцем по екрану на протязі двох секунд</string>
<string name="measurepressure_response">Тиск %1$03d радіус %2$03d </string>
<string name="audiobuf_verysmall">Дуже мало (швидкі пристрої)</string>
@@ -67,10 +67,10 @@
<string name="leftclick_multitouch">Натиск на екран другим пальцем</string>
<string name="leftclick_pressure">>Натиск на екран з силою</string>
<string name="leftclick_dpadcenter">Натиск на трекбол / центр джойстику</string>
<string name="pointandclick_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
<string name="mouse_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
<string name="click_with_dpadcenter">Лівий клік миші за допомогою трекбола / центра джойстика</string>
<string name="pointandclick_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
<string name="pointandclick_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
<string name="mouse_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
<string name="mouse_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
<string name="none">Немає</string>
<string name="controls_screenkb_transparency">Прозорість клавіатури</string>
<string name="controls_screenkb_trans_0">Невидимий</string>
@@ -101,7 +101,7 @@
<string name="screenkb_custom_layout">Налаштування положення кнопок</string>
<string name="screenkb_custom_layout_help">Натисніть Назад/BACK для завершення. Проведiть по екрану, щоб змінити розмір кнопки</string>
<string name="rightclick_key">Фізична кнопка</string>
<string name="pointandclick_showcreenunderfinger2">Наекранна лупа</string>
<string name="mouse_showcreenunderfinger2">Наекранна лупа</string>
<string name="video">Налаштування відео</string>
<string name="video_smooth">Лінійне сглажування відео</string>
<string name="accel_veryslow">Дуже повільно</string>
@@ -114,9 +114,9 @@
<string name="leftclick_timeout_time_2">0,7 секунд</string>
<string name="leftclick_timeout_time_3">1 сек</string>
<string name="leftclick_timeout_time_4">1,5 сек</string>
<string name="pointandclick_relative">Відносний рух миші (режим ноутбука)</string>
<string name="pointandclick_relative_speed">Швидкість руху миші</string>
<string name="pointandclick_relative_accel">Прискорення руху миші</string>
<string name="mouse_relative">Відносний рух миші (режим ноутбука)</string>
<string name="mouse_relative_speed">Швидкість руху миші</string>
<string name="mouse_relative_accel">Прискорення руху миші</string>
<string name="downloads">Завантаження</string>
<string name="video_separatethread">Окремий потік для відео, збільшить FPS на деяких пристроях</string>
<string name="text_edit_click_here">Натисніть, щоб ввести текст, натисніть Назад, коли закiнчете</string>

View File

@@ -98,17 +98,19 @@
<string name="leftclick_timeout_time_4">1.5 sec</string>
<string name="click_with_dpadcenter">Left mouse click with trackball / joystick center</string>
<string name="pointandclick_question">Advanced features</string>
<string name="pointandclick_keepaspectratio">Keep 4:3 screen aspect ratio</string>
<string name="pointandclick_showcreenunderfinger">Show screen under finger in separate window</string>
<string name="pointandclick_showcreenunderfinger2">On-screen magnifying glass</string>
<string name="pointandclick_joystickmouse">Move mouse with joystick or trackball</string>
<string name="pointandclick_joystickmousespeed">Move mouse with joystick speed</string>
<string name="pointandclick_joystickmouseaccel">Move mouse with joystick acceleration</string>
<string name="pointandclick_relative">Relative mouse movement (laptop mode)</string>
<string name="pointandclick_relative_speed">Relative mouse movement speed</string>
<string name="pointandclick_relative_accel">Relative mouse movement acceleration</string>
<string name="hover_jitter_filter">Filter jitter for stylus/finger hover</string>
<string name="mouse_question">Advanced features</string>
<string name="mouse_keepaspectratio">Keep 4:3 screen aspect ratio</string>
<string name="mouse_showcreenunderfinger">Show screen under finger in separate window</string>
<string name="mouse_showcreenunderfinger2">On-screen magnifying glass</string>
<string name="mouse_joystickmouse">Move mouse with joystick or trackball</string>
<string name="mouse_joystickmousespeed">Move mouse with joystick speed</string>
<string name="mouse_joystickmouseaccel">Move mouse with joystick acceleration</string>
<string name="mouse_relative">Relative mouse movement (laptop mode)</string>
<string name="mouse_relative_speed">Relative mouse movement speed</string>
<string name="mouse_relative_accel">Relative mouse movement acceleration</string>
<string name="mouse_hover_jitter_filter">Filter jitter for stylus/finger hover</string>
<string name="mouse_gyroscope_mouse">Control mouse with gyroscope</string>
<string name="mouse_gyroscope_mouse_sensitivity">Gyroscope sensitivity</string>
<string name="none">None</string>

View File

@@ -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

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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.