Configurable speed and accel to move mouse with joystick

This commit is contained in:
pelya
2010-12-06 13:12:03 +02:00
parent 0dae7b3c5b
commit 4bdec438c6
11 changed files with 191 additions and 62 deletions

View File

@@ -63,6 +63,7 @@ class Globals {
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
public static final int LEFT_CLICK_WITH_DPAD = 4;
public static int LeftClickMethod = LEFT_CLICK_NORMAL;
public static final int RIGHT_CLICK_NONE = 0;
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
@@ -70,6 +71,8 @@ class Globals {
public static final int RIGHT_CLICK_WITH_MENU_BUTTON = 3;
public static int RightClickMethod = RIGHT_CLICK_NONE;
public static boolean MoveMouseWithJoystick = false;
public static int MoveMouseWithJoystickSpeed = 0;
public static int MoveMouseWithJoystickAccel = 0;
public static boolean ClickMouseWithDpad = false;
public static boolean ShowScreenUnderFinger = false;
public static boolean KeepAspectRatio = false;

View File

@@ -57,6 +57,8 @@ class Settings
out.writeInt(Globals.ClickScreenPressure);
out.writeInt(Globals.ClickScreenTouchspotSize);
out.writeBoolean(Globals.KeepAspectRatio);
out.writeInt(Globals.MoveMouseWithJoystickSpeed);
out.writeInt(Globals.MoveMouseWithJoystickAccel);
out.close();
settingsLoaded = true;
@@ -97,6 +99,8 @@ class Settings
Globals.ClickScreenPressure = settingsFile.readInt();
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
Globals.KeepAspectRatio = settingsFile.readBoolean();
Globals.MoveMouseWithJoystickSpeed = settingsFile.readInt();
Globals.MoveMouseWithJoystickAccel = settingsFile.readInt();
settingsLoaded = true;
@@ -167,6 +171,9 @@ class Settings
if( Globals.AppUsesMouse )
items.add(p.getResources().getString(R.string.leftclick_question));
if( Globals.MoveMouseWithJoystick )
items.add(p.getResources().getString(R.string.pointandclick_joystickmouse));
items.add(p.getResources().getString(R.string.audiobuf_question));
@@ -180,48 +187,65 @@ class Settings
{
MainMenuLastSelected = item;
dialog.dismiss();
int selected = 0;
if( item == 0 )
if( item == selected )
showDownloadConfig(p);
selected++;
if( Globals.DataDownloadUrl.split("\\^").length <= 1 )
item += 1;
else
if( item == 1 )
if( item == selected )
showOptionalDownloadConfig(p);
selected++;
if( item == 2 )
showAdditionalInputConfig(p);
selected++;
if( ! Globals.AppNeedsArrowKeys && ! Globals.MoveMouseWithJoystick )
item += 1;
else
if( item == 3 )
if( item == selected )
showKeyboardConfig(p);
selected++;
if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity )
item += 1;
else
if( item == 4 )
if( item == selected )
showAccelerometerConfig(p);
selected++;
if( ! Globals.UseTouchscreenKeyboard )
item += 1;
else
if( item == 5 )
if( item == selected )
showScreenKeyboardConfig(p);
selected++;
if( ! Globals.AppUsesMouse )
item += 1;
else
if( item == 6 )
if( item == selected )
showLeftClickConfig(p);
if( item == 7 )
showAudioConfig(p);
selected++;
if( item == 8 )
if( ! Globals.MoveMouseWithJoystick )
item += 1;
else
if( item == selected )
showJoystickMouseConfig(p);
selected++;
if( item == selected )
showAudioConfig(p);
selected++;
if( item == selected )
showTouchPressureMeasurementTool(p);
selected++;
}
});
AlertDialog alert = builder.create();
@@ -315,7 +339,7 @@ class Settings
p.getResources().getString(R.string.pointandclick_keepaspectratio),
p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
p.getResources().getString(R.string.pointandclick_joystickmouse),
p.getResources().getString(R.string.leftclick_dpadcenter) };
p.getResources().getString(R.string.click_with_dpadcenter) };
boolean defaults[] = {
Globals.UseTouchscreenKeyboard,
@@ -538,7 +562,8 @@ class Settings
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
p.getResources().getString(R.string.leftclick_near_cursor),
p.getResources().getString(R.string.leftclick_multitouch),
p.getResources().getString(R.string.leftclick_pressure) };
p.getResources().getString(R.string.leftclick_pressure),
p.getResources().getString(R.string.leftclick_dpadcenter) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_question);
@@ -648,6 +673,67 @@ class Settings
alert.show();
}
static void showJoystickMouseConfig(final MainActivity p)
{
if( ! Globals.MoveMouseWithJoystick )
{
Globals.MoveMouseWithJoystickSpeed = 0;
showJoystickMouseAccelConfig(p);
return;
}
final CharSequence[] items = { p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium),
p.getResources().getString(R.string.accel_fast) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.pointandclick_joystickmousespeed);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.MoveMouseWithJoystickSpeed = item;
dialog.dismiss();
showJoystickMouseAccelConfig(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showJoystickMouseAccelConfig(final MainActivity p)
{
if( ! Globals.MoveMouseWithJoystick )
{
Globals.MoveMouseWithJoystickAccel = 0;
showConfigMainMenu(p);
return;
}
final CharSequence[] items = { p.getResources().getString(R.string.none),
p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium),
p.getResources().getString(R.string.accel_fast) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.pointandclick_joystickmousespeed);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.MoveMouseWithJoystickAccel = item;
dialog.dismiss();
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showTouchPressureMeasurementTool(final MainActivity p)
{
if( Globals.RightClickMethod == Globals.RIGHT_CLICK_WITH_PRESSURE || Globals.LeftClickMethod == Globals.LEFT_CLICK_WITH_PRESSURE )
@@ -727,7 +813,9 @@ class Settings
Globals.MoveMouseWithJoystick ? 1 : 0,
Globals.ClickMouseWithDpad ? 1 : 0,
Globals.ClickScreenPressure,
Globals.ClickScreenTouchspotSize );
Globals.ClickScreenTouchspotSize,
Globals.MoveMouseWithJoystickSpeed,
Globals.MoveMouseWithJoystickAccel );
if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) )
nativeSetJoystickUsed();
if( Globals.AppUsesMultitouch )
@@ -787,7 +875,9 @@ 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(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod, int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius);
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
int MoveMouseWithJoystickSpeed, int MoveMouseWithJoystickAccel);
private static native void nativeSetJoystickUsed();
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();

View File

@@ -75,4 +75,8 @@
<string name="leftclick_dpadcenter">Trackball klicken Select-Taste</string>
<string name="pointandclick_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
<string name="measurepressure_response">Pressure %03d Radius %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="none">Keine</string>
</resources>

View File

@@ -75,4 +75,8 @@
<string name="leftclick_dpadcenter">Trackball Valitse / Select-näppäintä</string>
<string name="pointandclick_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
<string name="measurepressure_response">Paine %03d säde %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="none">Ei</string>
</resources>

View File

@@ -78,4 +78,8 @@
<string name="leftclick_dpadcenter">Trackball cliquez / touche de sélection</string>
<string name="pointandclick_joystickmouse">Déplacez la souris ou un trackball avec joystick</string>
<string name="measurepressure_response">pression %03d rayon %03d</string>
<string name="click_with_dpadcenter">cliquez gauche de la souris avec trackball centre du joystick /</string>
<string name="pointandclick_joystickmousespeed">Déplacez la souris avec la vitesse joystick</string>
<string name="pointandclick_joystickmouseaccel">Déplacez la souris avec une accélération joystick</string>
<string name="none">Aucun</string>
</resources>

View File

@@ -68,4 +68,8 @@
<string name="leftclick_pressure">Нажатие с силой</string>
<string name="leftclick_dpadcenter">Нажатие на трекбол / центр джойстика</string>
<string name="pointandclick_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
<string name="click_with_dpadcenter">Левый клик мыши при помощи трекбола / центра джойстика</string>
<string name="pointandclick_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
<string name="pointandclick_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
<string name="none">Нет</string>
</resources>

View File

@@ -68,4 +68,8 @@
<string name="leftclick_pressure">>Натиск на екран з силою</string>
<string name="leftclick_dpadcenter">Натиск на трекбол / центр джойстику</string>
<string name="pointandclick_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
<string name="click_with_dpadcenter">Лівий клік миші за допомогою трекбола / центра джойстика</string>
<string name="pointandclick_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
<string name="pointandclick_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
<string name="none">Немає</string>
</resources>

View File

@@ -71,11 +71,15 @@
<string name="leftclick_multitouch">Touch screen with second finger</string>
<string name="leftclick_pressure">Touch screen with force</string>
<string name="leftclick_dpadcenter">Trackball click / joystick center</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_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="none">None</string>
<string name="measurepressure_touchplease">Please slide finger across the screen for two seconds</string>
<string name="measurepressure_response">Pressure %03d radius %03d</string>