Added settings for relative mouse movement - to Java only, they are not processed on C side yet

This commit is contained in:
pelya
2011-02-07 15:27:12 +00:00
parent c794561f84
commit d840a57e2c
5 changed files with 357 additions and 24 deletions

View File

@@ -37,7 +37,7 @@ import android.text.Editable;
// TODO: too much code here, split into multiple files
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
class Settings
{
static String SettingsFileName = "libsdl-settings.cfg";
@@ -111,6 +111,11 @@ class Settings
out.writeInt(Globals.LeftClickKey);
out.writeInt(Globals.RightClickKey);
out.writeBoolean(Globals.SmoothVideo);
out.writeInt(Globals.LeftClickTimeout);
out.writeInt(Globals.RightClickTimeout);
out.writeBoolean(Globals.RelativeMouseMovement);
out.writeInt(Globals.RelativeMouseMovementSpeed);
out.writeInt(Globals.RelativeMouseMovementAccel);
out.close();
settingsLoaded = true;
@@ -236,6 +241,11 @@ class Settings
Globals.LeftClickKey = settingsFile.readInt();
Globals.RightClickKey = settingsFile.readInt();
Globals.SmoothVideo = settingsFile.readBoolean();
Globals.LeftClickTimeout = settingsFile.readInt();
Globals.RightClickTimeout = settingsFile.readInt();
Globals.RelativeMouseMovement = settingsFile.readBoolean();
Globals.RelativeMouseMovementSpeed = settingsFile.readInt();
Globals.RelativeMouseMovementAccel = settingsFile.readInt();
settingsLoaded = true;
@@ -400,6 +410,13 @@ class Settings
}
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -474,6 +491,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -530,6 +554,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -570,6 +601,13 @@ class Settings
}
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -595,6 +633,13 @@ class Settings
showCommandLineConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -620,6 +665,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -665,7 +717,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -703,7 +761,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -734,6 +798,13 @@ class Settings
showAccelerometerCenterConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -764,6 +835,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -793,6 +871,13 @@ class Settings
showScreenKeyboardConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -817,6 +902,13 @@ class Settings
showScreenKeyboardConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -828,8 +920,7 @@ class Settings
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),
};
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));
@@ -843,6 +934,13 @@ class Settings
showScreenKeyboardConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -866,6 +964,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -883,7 +988,10 @@ class Settings
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.rightclick_key) };
p.getResources().getString(R.string.rightclick_key),
p.getResources().getString(R.string.leftclick_timeout),
p.getResources().getString(R.string.leftclick_tap),
p.getResources().getString(R.string.leftclick_tap_or_timeout) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_question);
@@ -895,10 +1003,49 @@ class Settings
dialog.dismiss();
if( item == Globals.LEFT_CLICK_WITH_KEY )
p.keyListener = new KeyRemapToolMouseClick(p, true);
else if( item == Globals.LEFT_CLICK_WITH_TIMEOUT || item == Globals.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
showLeftClickTimeoutConfig(p);
else
showMouseConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showLeftClickTimeoutConfig(final MainActivity p) {
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
p.getResources().getString(R.string.leftclick_timeout_time_1),
p.getResources().getString(R.string.leftclick_timeout_time_2),
p.getResources().getString(R.string.leftclick_timeout_time_3),
p.getResources().getString(R.string.leftclick_timeout_time_4) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_timeout_time);
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.LeftClickTimeout = item;
dialog.dismiss();
showMouseConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -915,7 +1062,8 @@ class Settings
final CharSequence[] items = { p.getResources().getString(R.string.rightclick_none),
p.getResources().getString(R.string.rightclick_multitouch),
p.getResources().getString(R.string.rightclick_pressure),
p.getResources().getString(R.string.rightclick_key) };
p.getResources().getString(R.string.rightclick_key),
p.getResources().getString(R.string.leftclick_timeout) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.rightclick_question);
@@ -927,10 +1075,49 @@ class Settings
dialog.dismiss();
if( item == Globals.RIGHT_CLICK_WITH_KEY )
p.keyListener = new KeyRemapToolMouseClick(p, false);
else if( item == Globals.RIGHT_CLICK_WITH_TIMEOUT )
showRightClickTimeoutConfig(p);
else
showMouseConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showRightClickTimeoutConfig(final MainActivity p) {
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
p.getResources().getString(R.string.leftclick_timeout_time_1),
p.getResources().getString(R.string.leftclick_timeout_time_2),
p.getResources().getString(R.string.leftclick_timeout_time_3),
p.getResources().getString(R.string.leftclick_timeout_time_4) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_timeout_time);
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.RightClickTimeout = item;
dialog.dismiss();
showMouseConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -970,19 +1157,21 @@ class Settings
CharSequence[] items = {
p.getResources().getString(R.string.pointandclick_showcreenunderfinger2),
p.getResources().getString(R.string.pointandclick_joystickmouse),
p.getResources().getString(R.string.click_with_dpadcenter)
p.getResources().getString(R.string.click_with_dpadcenter),
p.getResources().getString(R.string.pointandclick_relative)
};
boolean defaults[] = {
Globals.ShowScreenUnderFinger,
Globals.MoveMouseWithJoystick,
Globals.ClickMouseWithDpad
Globals.ClickMouseWithDpad,
Globals.RelativeMouseMovement
};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.pointandclick_question));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
@@ -992,17 +1181,58 @@ class Settings
Globals.MoveMouseWithJoystick = isChecked;
if( item == 2 )
Globals.ClickMouseWithDpad = isChecked;
if( item == 3 )
Globals.RelativeMouseMovement = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
showMouseConfigMainMenu(p);
if( Globals.RelativeMouseMovement )
showRelativeMouseMovementConfig(p);
else
showMouseConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showRelativeMouseMovementConfig1(final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.accel_fast),
p.getResources().getString(R.string.accel_medium),
p.getResources().getString(R.string.accel_slow) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.pointandclick_relative_accel);
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.RelativeMouseMovementAccel = item;
dialog.dismiss();
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1036,6 +1266,13 @@ class Settings
showTrackballConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1067,6 +1304,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1097,6 +1341,13 @@ class Settings
showJoystickMouseAccelConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1128,6 +1379,13 @@ class Settings
showMouseConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1236,6 +1494,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1285,7 +1550,13 @@ class Settings
showRemapScreenKbConfig2(p, 0);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1325,6 +1596,13 @@ class Settings
showRemapScreenKbConfig2(p, currentButton + 1);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1363,7 +1641,13 @@ class Settings
showScreenGesturesConfig2(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1390,6 +1674,13 @@ class Settings
showScreenGesturesConfig3(p, 0);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1427,6 +1718,13 @@ class Settings
showScreenGesturesConfig3(p, currentButton + 1);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1665,7 +1963,13 @@ class Settings
showConfigMainMenu(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -1690,7 +1994,12 @@ class Settings
Globals.MoveMouseWithJoystickSpeed,
Globals.MoveMouseWithJoystickAccel,
Globals.LeftClickKey,
Globals.RightClickKey );
Globals.RightClickKey,
Globals.LeftClickTimeout,
Globals.RightClickTimeout,
Globals.RelativeMouseMovement,
Globals.RelativeMouseMovementSpeed,
Globals.RelativeMouseMovementAccel );
if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) )
nativeSetJoystickUsed();
if( Globals.AppUsesMultitouch )
@@ -1786,7 +2095,9 @@ class Settings
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
int MoveMouseWithJoystickSpeed, int MoveMouseWithJoystickAccel,
int leftClickKeycode, int rightClickKeycode);
int leftClickKeycode, int rightClickKeycode,
int leftClickTimeout, int rightClickTimeout,
int relativeMovement, int relativeMovementSpeed, int relativeMovementAccel);
private static native void nativeSetJoystickUsed();
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();