From 68f38de58566fe6499c5dac64483dfb538b4134a Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 4 Sep 2013 21:58:40 -0400 Subject: [PATCH] Bug 911510 - Add a pref to override the dead zone threshold. r=bnicholson --- mobile/android/app/mobile.js | 3 +++ mobile/android/base/gfx/JavaPanZoomController.java | 11 ++++++++++- mobile/android/base/util/GamepadUtils.java | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index 4a7c60093e0..76b216ecbba 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -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. diff --git a/mobile/android/base/gfx/JavaPanZoomController.java b/mobile/android/base/gfx/JavaPanZoomController.java index c6c319a854a..92a799901e5 100644 --- a/mobile/android/base/gfx/JavaPanZoomController.java +++ b/mobile/android/base/gfx/JavaPanZoomController.java @@ -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; diff --git a/mobile/android/base/util/GamepadUtils.java b/mobile/android/base/util/GamepadUtils.java index 22916b555db..9ef6d317464 100644 --- a/mobile/android/base/util/GamepadUtils.java +++ b/mobile/android/base/util/GamepadUtils.java @@ -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;