Take into account device screen small axis when calculating button switch threshold

This commit is contained in:
Aaron Culliney 2016-01-07 22:37:14 -08:00
parent 18c02d3673
commit 9bbfca3193
3 changed files with 16 additions and 4 deletions

View File

@ -439,7 +439,7 @@ public class Apple2JoystickSettingsMenu extends Apple2AbstractMenu {
@Override
public void showValue(int progress, final TextView seekBarValue) {
int threshold = progress * Apple2Preferences.JOYSTICK_BUTTON_THRESHOLD_STEP;
int threshold = progress * Apple2Preferences.getJoystickButtonSwitchThresholdScale(activity);
seekBarValue.setText("" + threshold + " pts");
}
});

View File

@ -321,7 +321,8 @@ public enum Apple2Preferences {
@Override
public void load(Apple2Activity activity) {
int tick = intValue(activity);
nativeSetTouchJoystickButtonSwitchThreshold(tick * JOYSTICK_BUTTON_THRESHOLD_STEP);
tick *= getJoystickButtonSwitchThresholdScale(activity);
nativeSetTouchJoystickButtonSwitchThreshold(tick);
}
@Override
@ -893,7 +894,6 @@ public enum Apple2Preferences {
public final static String TAG = "Apple2Preferences";
public final static int JOYSTICK_BUTTON_THRESHOLD_NUM_CHOICES = DECENT_AMOUNT_OF_CHOICES;
public final static int JOYSTICK_BUTTON_THRESHOLD_STEP = 5;
public final static float JOYSTICK_AXIS_SENSITIVITY_MIN = 0.25f;
public final static float JOYSTICK_AXIS_SENSITIVITY_DEFAULT = 1.f;
@ -1002,6 +1002,18 @@ public enum Apple2Preferences {
return toString() + "_SCAN";
}
public static int getJoystickButtonSwitchThresholdScale(Apple2Activity activity) {
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
int smallScreenAxis = dm.widthPixels < dm.heightPixels ? dm.widthPixels : dm.heightPixels;
int oneThirdScreenAxis = smallScreenAxis/3;
// largest switch threshold value is 1/3 small dimension of screen
return oneThirdScreenAxis/JOYSTICK_BUTTON_THRESHOLD_NUM_CHOICES;
}
// ------------------------------------------------------------------------
// internals ...

View File

@ -57,7 +57,7 @@
<string name="joystick_button_swipe_up_button_summary">Button to fire on swipe up</string>
<string name="joystick_button_swipe_down_button">Swipe down fire</string>
<string name="joystick_button_swipe_down_button_summary">Button to fire on swipe down</string>
<string name="joystick_button_threshold_summary">Joystick/keypad button switch threshold in pts</string>
<string name="joystick_button_threshold_summary">Joystick/keypad button switch threshold in pts (max: &#8531; screen height)</string>
<string name="joystick_calibrate">Calibrate…</string>
<string name="joystick_calibrate_summary">Configure and test current settings</string>
<string name="joystick_configure">Configure joystick…</string>