Bug 911510 - Add a pref to override the dead zone threshold. r=bnicholson

This commit is contained in:
Kartikaya Gupta 2013-09-04 21:58:40 -04:00
parent 1da92b26d5
commit 3b7a53f8ad
3 changed files with 17 additions and 1 deletions

View File

@ -653,6 +653,9 @@ pref("ui.scrolling.min_scrollable_distance", -1);
pref("ui.scrolling.axis_lock_mode", "standard");
// Negate scrollY, true will make the mouse scroll wheel move the screen the same direction as with most desktops or laptops.
pref("ui.scrolling.negate_wheel_scrollY", true);
// Determine the dead zone for gamepad joysticks. Higher values result in larger dead zones; use a negative value to
// auto-detect based on reported hardware values
pref("ui.scrolling.gamepad_dead_zone", 10);
// Enable accessibility mode if platform accessibility is enabled.

View File

@ -147,7 +147,9 @@ class JavaPanZoomController
mMode = AxisLockMode.STANDARD;
String[] prefs = { "ui.scrolling.axis_lock_mode", "ui.scrolling.negate_wheel_scrollY" };
String[] prefs = { "ui.scrolling.axis_lock_mode",
"ui.scrolling.negate_wheel_scrollY",
"ui.scrolling.gamepad_dead_zone" };
mNegateWheelScrollY = false;
PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() {
@Override public void prefValue(String pref, String value) {
@ -161,6 +163,13 @@ class JavaPanZoomController
}
}
}
@Override public void prefValue(String pref, int value) {
if (pref.equals("ui.scrolling.gamepad_dead_zone")) {
GamepadUtils.overrideDeadZoneThreshold((float)value / 1000f);
}
}
@Override public void prefValue(String pref, boolean value) {
if (pref.equals("ui.scrolling.negate_wheel_scrollY")) {
mNegateWheelScrollY = value;

View File

@ -42,6 +42,10 @@ public final class GamepadUtils {
return (isGamepadKey(event) && (event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_B));
}
public static void overrideDeadZoneThreshold(float threshold) {
sDeadZoneThresholdOverride = threshold;
}
public static boolean isValueInDeadZone(MotionEvent event, int axis) {
if (Build.VERSION.SDK_INT < 9) {
return false;