mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-19 19:33:41 +00:00
Shuffle some Android settings around
This commit is contained in:
parent
acade0076b
commit
c0fd258c40
@ -38,7 +38,33 @@ public class Apple2JoystickCalibration implements Apple2MenuView {
|
||||
private int mSavedTouchDevice = Apple2SettingsMenu.TouchDeviceVariant.NONE.ordinal();
|
||||
private Thread joystickPollerThread = null;
|
||||
|
||||
public Apple2JoystickCalibration(Apple2Activity activity, ArrayList<Apple2MenuView> viewStack, Apple2SettingsMenu.TouchDeviceVariant variant) {
|
||||
public static void startCalibration(Apple2Activity activity, Apple2SettingsMenu.TouchDeviceVariant variant) {
|
||||
|
||||
ArrayList<Apple2MenuView> viewStack = new ArrayList<Apple2MenuView>();
|
||||
{
|
||||
int idx = 0;
|
||||
while (true) {
|
||||
Apple2MenuView apple2MenuView = activity.peekApple2View(idx);
|
||||
if (apple2MenuView == null) {
|
||||
break;
|
||||
}
|
||||
viewStack.add(apple2MenuView);
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
Apple2JoystickCalibration calibration = new Apple2JoystickCalibration(activity, viewStack, variant);
|
||||
|
||||
// show this new view...
|
||||
calibration.show();
|
||||
|
||||
// ...with nothing else underneath 'cept the emulator OpenGL layer
|
||||
for (Apple2MenuView apple2MenuView : viewStack) {
|
||||
activity.popApple2View(apple2MenuView);
|
||||
}
|
||||
}
|
||||
|
||||
private Apple2JoystickCalibration(Apple2Activity activity, ArrayList<Apple2MenuView> viewStack, Apple2SettingsMenu.TouchDeviceVariant variant) {
|
||||
mActivity = activity;
|
||||
mViewStack = viewStack;
|
||||
if (!(variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK || variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK_KEYPAD)) {
|
||||
|
@ -38,9 +38,16 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
public final static int TAPDELAY_NUM_CHOICES = (30 + 1); // 0-30 (30Frames == ~0.5sec)
|
||||
|
||||
private Apple2SettingsMenu.TouchDeviceVariant mVariant;
|
||||
|
||||
public Apple2JoystickSettingsMenu(Apple2Activity activity) {
|
||||
public Apple2JoystickSettingsMenu(Apple2Activity activity, Apple2SettingsMenu.TouchDeviceVariant variant) {
|
||||
super(activity);
|
||||
|
||||
if (!(variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK || variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK_KEYPAD)) {
|
||||
throw new RuntimeException("You're doing it wrong");
|
||||
}
|
||||
|
||||
mVariant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,6 +86,33 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
}
|
||||
|
||||
protected enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
JOYSTICK_CALIBRATE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_calibrate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_calibrate_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrefDefault() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
Apple2JoystickSettingsMenu thisMenu = (Apple2JoystickSettingsMenu)settingsMenu;
|
||||
Apple2JoystickCalibration.startCalibration(activity, thisMenu.mVariant);
|
||||
}
|
||||
},
|
||||
JOYSTICK_TAP_BUTTON {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
@ -324,6 +358,67 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
});
|
||||
}
|
||||
},
|
||||
JOYSTICK_AXIS_SENSITIVITY {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_axis_sensitivity_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "axisSensitivity";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrefDefault() {
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
final IMenuEnum self = this;
|
||||
return _sliderView(activity, this, JOYSTICK_AXIS_SENSITIVITY_NUM_CHOICES, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
final int pivot = JOYSTICK_AXIS_SENSITIVITY_DEC_NUMCHOICES;
|
||||
float sensitivity = 1.f;
|
||||
if (progress < pivot) {
|
||||
int decAmount = (pivot - progress);
|
||||
sensitivity -= (JOYSTICK_AXIS_SENSITIVITY_DEC_STEP * decAmount);
|
||||
} else if (progress > pivot) {
|
||||
int incAmount = (progress - pivot);
|
||||
sensitivity += (JOYSTICK_AXIS_SENSITIVITY_INC_STEP * incAmount);
|
||||
}
|
||||
Apple2Preferences.setJSONPref(self, sensitivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
float sensitivity = Apple2Preferences.getFloatJSONPref(self);
|
||||
int pivot = JOYSTICK_AXIS_SENSITIVITY_DEC_NUMCHOICES;
|
||||
if (sensitivity < 1.f) {
|
||||
pivot = Math.round((sensitivity - JOYSTICK_AXIS_SENSITIVITY_MIN) / JOYSTICK_AXIS_SENSITIVITY_DEC_STEP);
|
||||
} else if (sensitivity > 1.f) {
|
||||
sensitivity -= 1.f;
|
||||
pivot += Math.round(sensitivity / JOYSTICK_AXIS_SENSITIVITY_INC_STEP);
|
||||
}
|
||||
return pivot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
saveInt(progress);
|
||||
int percent = (int) (Apple2Preferences.getFloatJSONPref(self) * 100.f);
|
||||
seekBarValue.setText("" + percent + "%");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
JOYSTICK_ADVANCED {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
@ -337,7 +432,7 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
new Apple2JoystickSettingsMenu.JoystickAdvanced(activity, Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK).show();
|
||||
new Apple2JoystickSettingsMenu.JoystickAdvanced(activity).show();
|
||||
}
|
||||
};
|
||||
|
||||
@ -381,16 +476,8 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
private final static String TAG = "JoystickAdvanced";
|
||||
|
||||
private Apple2SettingsMenu.TouchDeviceVariant mVariant;
|
||||
|
||||
public JoystickAdvanced(Apple2Activity activity, Apple2SettingsMenu.TouchDeviceVariant variant) {
|
||||
public JoystickAdvanced(Apple2Activity activity) {
|
||||
super(activity);
|
||||
|
||||
if (!(variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK || variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK_KEYPAD)) {
|
||||
throw new RuntimeException("You're doing it wrong");
|
||||
}
|
||||
|
||||
mVariant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -417,54 +504,6 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
}
|
||||
|
||||
protected enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
JOYSTICK_CALIBRATE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_calibrate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_calibrate_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrefDefault() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
ArrayList<Apple2MenuView> viewStack = new ArrayList<Apple2MenuView>();
|
||||
{
|
||||
int idx = 0;
|
||||
while (true) {
|
||||
Apple2MenuView apple2MenuView = activity.peekApple2View(idx);
|
||||
if (apple2MenuView == null) {
|
||||
break;
|
||||
}
|
||||
viewStack.add(apple2MenuView);
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
JoystickAdvanced advancedMenu = (JoystickAdvanced)settingsMenu;
|
||||
Apple2JoystickCalibration calibration = new Apple2JoystickCalibration(activity, viewStack, advancedMenu.mVariant);
|
||||
|
||||
// show this new view...
|
||||
calibration.show();
|
||||
|
||||
// ...with nothing else underneath 'cept the emulator OpenGL layer
|
||||
for (Apple2MenuView apple2MenuView : viewStack) {
|
||||
activity.popApple2View(apple2MenuView);
|
||||
}
|
||||
}
|
||||
},
|
||||
JOYSTICK_VISIBILITY {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
@ -572,7 +611,7 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
float millis = progress * 16.688f;
|
||||
String millis = String.format(java.util.Locale.ROOT, "%.3f", progress * 16.688f);
|
||||
String framesStr = activity.getResources().getString(R.string.string_frames);
|
||||
String millisStr = activity.getResources().getString(R.string.string_millis);
|
||||
String textSummary = "" + progress + " " + framesStr + " (" + millis + " " + millisStr + ")";
|
||||
@ -581,67 +620,6 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
|
||||
});
|
||||
}
|
||||
},
|
||||
JOYSTICK_AXIS_SENSITIVITY {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_axis_sensitivity_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "axisSensitivity";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrefDefault() {
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final Apple2Activity activity, View convertView) {
|
||||
final IMenuEnum self = this;
|
||||
return _sliderView(activity, this, JOYSTICK_AXIS_SENSITIVITY_NUM_CHOICES, new IPreferenceSlider() {
|
||||
@Override
|
||||
public void saveInt(int progress) {
|
||||
final int pivot = JOYSTICK_AXIS_SENSITIVITY_DEC_NUMCHOICES;
|
||||
float sensitivity = 1.f;
|
||||
if (progress < pivot) {
|
||||
int decAmount = (pivot - progress);
|
||||
sensitivity -= (JOYSTICK_AXIS_SENSITIVITY_DEC_STEP * decAmount);
|
||||
} else if (progress > pivot) {
|
||||
int incAmount = (progress - pivot);
|
||||
sensitivity += (JOYSTICK_AXIS_SENSITIVITY_INC_STEP * incAmount);
|
||||
}
|
||||
Apple2Preferences.setJSONPref(self, sensitivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
float sensitivity = Apple2Preferences.getFloatJSONPref(self);
|
||||
int pivot = JOYSTICK_AXIS_SENSITIVITY_DEC_NUMCHOICES;
|
||||
if (sensitivity < 1.f) {
|
||||
pivot = Math.round((sensitivity - JOYSTICK_AXIS_SENSITIVITY_MIN) / JOYSTICK_AXIS_SENSITIVITY_DEC_STEP);
|
||||
} else if (sensitivity > 1.f) {
|
||||
sensitivity -= 1.f;
|
||||
pivot += Math.round(sensitivity / JOYSTICK_AXIS_SENSITIVITY_INC_STEP);
|
||||
}
|
||||
return pivot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showValue(int progress, final TextView seekBarValue) {
|
||||
saveInt(progress);
|
||||
int percent = (int) (Apple2Preferences.getFloatJSONPref(self) * 100.f);
|
||||
seekBarValue.setText("" + percent + "%");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
JOYSTICK_BUTTON_THRESHOLD {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
|
@ -31,8 +31,16 @@ public class Apple2KeypadSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
public final static int ROSETTE_SIZE = 9;
|
||||
|
||||
public Apple2KeypadSettingsMenu(Apple2Activity activity) {
|
||||
private Apple2SettingsMenu.TouchDeviceVariant mVariant;
|
||||
|
||||
public Apple2KeypadSettingsMenu(Apple2Activity activity, Apple2SettingsMenu.TouchDeviceVariant variant) {
|
||||
super(activity);
|
||||
|
||||
if (!(variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK || variant == Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK_KEYPAD)) {
|
||||
throw new RuntimeException("You're doing it wrong");
|
||||
}
|
||||
|
||||
mVariant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -502,6 +510,33 @@ public class Apple2KeypadSettingsMenu extends Apple2AbstractMenu {
|
||||
}
|
||||
|
||||
enum SETTINGS implements Apple2AbstractMenu.IMenuEnum {
|
||||
JOYSTICK_CALIBRATE {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_calibrate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getSummary(Apple2Activity activity) {
|
||||
return activity.getResources().getString(R.string.joystick_calibrate_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrefDefault() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
Apple2KeypadSettingsMenu thisMenu = (Apple2KeypadSettingsMenu)settingsMenu;
|
||||
Apple2JoystickCalibration.startCalibration(activity, thisMenu.mVariant);
|
||||
}
|
||||
},
|
||||
KEYPAD_CHOOSE_KEYS {
|
||||
@Override
|
||||
public final String getTitle(Apple2Activity activity) {
|
||||
@ -609,7 +644,7 @@ public class Apple2KeypadSettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@Override
|
||||
public void handleSelection(Apple2Activity activity, Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
new Apple2JoystickSettingsMenu.JoystickAdvanced(activity, Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK_KEYPAD).show();
|
||||
new Apple2JoystickSettingsMenu.JoystickAdvanced(activity).show();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
new Apple2JoystickSettingsMenu(activity).show();
|
||||
new Apple2JoystickSettingsMenu(activity, Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK).show();
|
||||
}
|
||||
},
|
||||
KEYPAD_CONFIGURE {
|
||||
@ -177,7 +177,7 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||
|
||||
@Override
|
||||
public void handleSelection(final Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) {
|
||||
new Apple2KeypadSettingsMenu(activity).show();
|
||||
new Apple2KeypadSettingsMenu(activity, Apple2SettingsMenu.TouchDeviceVariant.JOYSTICK_KEYPAD).show();
|
||||
}
|
||||
},
|
||||
KEYBOARD_CONFIGURE {
|
||||
|
Loading…
x
Reference in New Issue
Block a user