зеркало из https://github.com/mozilla/gecko-dev.git
bug 857092 - put non-standard Gamepad events behind another pref. r=smaug
This commit is contained in:
Родитель
98dadecb4e
Коммит
fbf6191cd8
|
@ -31,6 +31,8 @@ namespace dom {
|
|||
|
||||
namespace {
|
||||
const char* kGamepadEnabledPref = "dom.gamepad.enabled";
|
||||
const char* kGamepadEventsEnabledPref =
|
||||
"dom.gamepad.non_standard_events.enabled";
|
||||
// Amount of time to wait before cleaning up gamepad resources
|
||||
// when no pages are listening for events.
|
||||
const int kCleanupDelayMS = 2000;
|
||||
|
@ -50,6 +52,8 @@ GamepadService::GamepadService()
|
|||
mShuttingDown(false)
|
||||
{
|
||||
mEnabled = IsAPIEnabled();
|
||||
mNonstandardEventsEnabled =
|
||||
Preferences::GetBool(kGamepadEventsEnabledPref, false);
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
observerService->AddObserver(this,
|
||||
|
@ -219,8 +223,10 @@ GamepadService::NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed,
|
|||
nsRefPtr<Gamepad> gamepad = listeners[i]->GetGamepad(aIndex);
|
||||
if (gamepad) {
|
||||
gamepad->SetButton(aButton, aPressed, aValue);
|
||||
// Fire event
|
||||
FireButtonEvent(listeners[i], gamepad, aButton, aValue);
|
||||
if (mNonstandardEventsEnabled) {
|
||||
// Fire event
|
||||
FireButtonEvent(listeners[i], gamepad, aButton, aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,8 +283,10 @@ GamepadService::NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue)
|
|||
nsRefPtr<Gamepad> gamepad = listeners[i]->GetGamepad(aIndex);
|
||||
if (gamepad) {
|
||||
gamepad->SetAxis(aAxis, aValue);
|
||||
// Fire event
|
||||
FireAxisMoveEvent(listeners[i], gamepad, aAxis, aValue);
|
||||
if (mNonstandardEventsEnabled) {
|
||||
// Fire event
|
||||
FireAxisMoveEvent(listeners[i], gamepad, aAxis, aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,8 @@ class GamepadService : public nsIObserver
|
|||
|
||||
// true if this feature is enabled in preferences
|
||||
bool mEnabled;
|
||||
// true if non-standard events are enabled in preferences
|
||||
bool mNonstandardEventsEnabled;
|
||||
// true if the platform-specific backend has started work
|
||||
bool mStarted;
|
||||
// true when shutdown has begun
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.enabled",
|
||||
[Pref="dom.gamepad.non_standard_events.enabled",
|
||||
Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict),
|
||||
HeaderFile="GeneratedEventClasses.h"]
|
||||
interface GamepadAxisMoveEvent : GamepadEvent
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.enabled",
|
||||
[Pref="dom.gamepad.non_standard_events.enabled",
|
||||
Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict),
|
||||
HeaderFile="GeneratedEventClasses.h"]
|
||||
interface GamepadButtonEvent : GamepadEvent
|
||||
|
|
|
@ -92,8 +92,10 @@ pref("dom.enable_performance", true);
|
|||
// Whether the Gamepad API is enabled
|
||||
#ifdef RELEASE_BUILD
|
||||
pref("dom.gamepad.enabled", false);
|
||||
pref("dom.gamepad.non_standard_events.enabled", false);
|
||||
#else
|
||||
pref("dom.gamepad.enabled", true);
|
||||
pref("dom.gamepad.non_standard_events.enabled", true);
|
||||
#endif
|
||||
|
||||
// Fastback caching - if this pref is negative, then we calculate the number
|
||||
|
|
|
@ -129,3 +129,4 @@ user_pref("network.http.bypass-cachelock-threshold", 200000);
|
|||
|
||||
// Enable Gamepad
|
||||
user_pref("dom.gamepad.enabled", true);
|
||||
user_pref("dom.gamepad.non_standard_events.enabled", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче