Bug 1523351 - Part 1: GamepadTouch and GamepadLightIndicator WebAPI implementation. r=baku

Differential Revision: https://phabricator.services.mozilla.com/D20744

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daosheng Mu 2019-05-29 22:44:24 +00:00
parent 216f707c10
commit 7b8a1cc7ba
15 changed files with 466 additions and 9 deletions

View File

@ -22,7 +22,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Gamepad)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Gamepad, mParent, mButtons, mPose,
mHapticActuators)
mHapticActuators, mLightIndicators,
mTouchEvents)
void Gamepad::UpdateTimestamp() {
nsCOMPtr<nsPIDOMWindowInner> newWindow(do_QueryInterface(mParent));
@ -37,12 +38,14 @@ void Gamepad::UpdateTimestamp() {
Gamepad::Gamepad(nsISupports* aParent, const nsAString& aID, uint32_t aIndex,
uint32_t aHashKey, GamepadMappingType aMapping,
GamepadHand aHand, uint32_t aDisplayID, uint32_t aNumButtons,
uint32_t aNumAxes, uint32_t aNumHaptics)
uint32_t aNumAxes, uint32_t aNumHaptics,
uint32_t aNumLightIndicator, uint32_t aNumTouchEvents)
: mParent(aParent),
mID(aID),
mIndex(aIndex),
mHashKey(aHashKey),
mDisplayId(aDisplayID),
mTouchIdHashValue(0),
mMapping(aMapping),
mHand(aHand),
mConnected(true),
@ -58,6 +61,14 @@ Gamepad::Gamepad(nsISupports* aParent, const nsAString& aID, uint32_t aIndex,
mHapticActuators.AppendElement(
new GamepadHapticActuator(mParent, mHashKey, i));
}
for (uint32_t i = 0; i < aNumLightIndicator; ++i) {
mLightIndicators.AppendElement(
new GamepadLightIndicator(mParent, mHashKey, i));
}
for (uint32_t i = 0; i < aNumTouchEvents; ++i) {
mTouchEvents.AppendElement(new GamepadTouch(mParent));
}
UpdateTimestamp();
}
@ -88,11 +99,35 @@ void Gamepad::SetPose(const GamepadPoseState& aPose) {
UpdateTimestamp();
}
void Gamepad::SetLightIndicatorType(uint32_t aLightIndex,
GamepadLightIndicatorType aType) {
mLightIndicators[aLightIndex]->SetType(aType);
UpdateTimestamp();
}
void Gamepad::SetTouchEvent(uint32_t aTouchIndex,
const GamepadTouchState& aTouch) {
if (aTouchIndex >= mTouchEvents.Length()) {
MOZ_CRASH("Touch index exceeds the event array.");
return;
}
// Handling cross-origin tracking.
GamepadTouchState touchState(aTouch);
if (auto hashValue = mTouchIdHash.GetValue(touchState.touchId)) {
touchState.touchId = *hashValue;
} else {
touchState.touchId = mTouchIdHashValue;
mTouchIdHash.Put(aTouch.touchId, mTouchIdHashValue);
++mTouchIdHashValue;
}
mTouchEvents[aTouchIndex]->SetTouchState(touchState);
UpdateTimestamp();
}
void Gamepad::SetHand(GamepadHand aHand) { mHand = aHand; }
void Gamepad::SyncState(Gamepad* aOther) {
const char* kGamepadExtEnabledPref = "dom.gamepad.extensions.enabled";
if (mButtons.Length() != aOther->mButtons.Length() ||
mAxes.Length() != aOther->mAxes.Length()) {
return;
@ -114,13 +149,24 @@ void Gamepad::SyncState(Gamepad* aOther) {
Gamepad_Binding::ClearCachedAxesValue(this);
}
if (Preferences::GetBool(kGamepadExtEnabledPref)) {
if (StaticPrefs::dom_gamepad_extensions_enabled()) {
MOZ_ASSERT(aOther->GetPose());
mPose->SetPoseState(aOther->GetPose()->GetPoseState());
mHand = aOther->Hand();
for (uint32_t i = 0; i < mHapticActuators.Length(); ++i) {
mHapticActuators[i]->Set(aOther->mHapticActuators[i]);
}
if (StaticPrefs::dom_gamepad_extensions_lightindicator()) {
for (uint32_t i = 0; i < mLightIndicators.Length(); ++i) {
mLightIndicators[i]->Set(aOther->mLightIndicators[i]);
}
}
if (StaticPrefs::dom_gamepad_extensions_multitouch()) {
for (uint32_t i = 0; i < mTouchEvents.Length(); ++i) {
mTouchEvents[i]->Set(aOther->mTouchEvents[i]);
}
}
}
UpdateTimestamp();
@ -129,7 +175,8 @@ void Gamepad::SyncState(Gamepad* aOther) {
already_AddRefed<Gamepad> Gamepad::Clone(nsISupports* aParent) {
RefPtr<Gamepad> out =
new Gamepad(aParent, mID, mIndex, mHashKey, mMapping, mHand, mDisplayId,
mButtons.Length(), mAxes.Length(), mHapticActuators.Length());
mButtons.Length(), mAxes.Length(), mHapticActuators.Length(),
mLightIndicators.Length(), mTouchEvents.Length());
out->SyncState(this);
return out.forget();
}

View File

@ -12,6 +12,8 @@
#include "mozilla/dom/GamepadButton.h"
#include "mozilla/dom/GamepadPose.h"
#include "mozilla/dom/GamepadHapticActuator.h"
#include "mozilla/dom/GamepadLightIndicator.h"
#include "mozilla/dom/GamepadTouch.h"
#include "mozilla/dom/Performance.h"
#include <stdint.h>
#include "nsCOMPtr.h"
@ -40,7 +42,8 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
Gamepad(nsISupports* aParent, const nsAString& aID, uint32_t aIndex,
uint32_t aHashKey, GamepadMappingType aMapping, GamepadHand aHand,
uint32_t aDisplayID, uint32_t aNumButtons, uint32_t aNumAxes,
uint32_t aNumHaptics);
uint32_t aNumHaptics, uint32_t aNumLightIndicator,
uint32_t aNumTouchEvents);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Gamepad)
@ -50,6 +53,9 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
void SetAxis(uint32_t aAxis, double aValue);
void SetIndex(uint32_t aIndex);
void SetPose(const GamepadPoseState& aPose);
void SetLightIndicatorType(uint32_t aLightIndex,
GamepadLightIndicatorType aType);
void SetTouchEvent(uint32_t aTouchIndex, const GamepadTouchState& aTouch);
void SetHand(GamepadHand aHand);
// Make the state of this gamepad equivalent to other.
@ -93,6 +99,15 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
aHapticActuators = mHapticActuators;
}
void GetLightIndicators(
nsTArray<RefPtr<GamepadLightIndicator>>& aLightIndicators) const {
aLightIndicators = mLightIndicators;
}
void GetTouchEvents(nsTArray<RefPtr<GamepadTouch>>& aTouchEvents) const {
aTouchEvents = mTouchEvents;
}
private:
virtual ~Gamepad() {}
void UpdateTimestamp();
@ -104,6 +119,7 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
// the gamepad hash key in GamepadManager
uint32_t mHashKey;
uint32_t mDisplayId;
uint32_t mTouchIdHashValue;
// The mapping in use.
GamepadMappingType mMapping;
GamepadHand mHand;
@ -117,6 +133,9 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
DOMHighResTimeStamp mTimestamp;
RefPtr<GamepadPose> mPose;
nsTArray<RefPtr<GamepadHapticActuator>> mHapticActuators;
nsTArray<RefPtr<GamepadLightIndicator>> mLightIndicators;
nsTArray<RefPtr<GamepadTouch>> mTouchEvents;
nsDataHashtable<nsUint32HashKey, uint32_t> mTouchIdHash;
};
} // namespace dom

View File

@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/GamepadLightIndicator.h"
#include "mozilla/dom/GamepadManager.h"
#include "mozilla/dom/Promise.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTING_ADDREF(GamepadLightIndicator)
NS_IMPL_CYCLE_COLLECTING_RELEASE(GamepadLightIndicator)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GamepadLightIndicator)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(GamepadLightIndicator, mParent)
GamepadLightIndicator::GamepadLightIndicator(nsISupports* aParent,
uint32_t aGamepadId,
uint32_t aIndex)
: mParent(aParent),
mType(DefaultType()),
mGamepadId(aGamepadId),
mIndex(aIndex) {}
GamepadLightIndicator::~GamepadLightIndicator() {
mozilla::DropJSObjects(this);
}
/* virtual */ JSObject* GamepadLightIndicator::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return GamepadLightIndicator_Binding::Wrap(aCx, this, aGivenProto);
}
nsISupports* GamepadLightIndicator::GetParentObject() const { return mParent; }
already_AddRefed<Promise> GamepadLightIndicator::SetColor(
const GamepadLightColor& color, ErrorResult& aRv) {
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
MOZ_ASSERT(global);
RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
MOZ_ASSERT(gamepadManager);
RefPtr<Promise> promise = gamepadManager->SetLightIndicatorColor(
mGamepadId, mIndex, color.mRed, color.mGreen, color.mBlue, global, aRv);
if (!promise) {
return nullptr;
}
return promise.forget();
}
GamepadLightIndicatorType GamepadLightIndicator::Type() const { return mType; }
void GamepadLightIndicator::Set(const GamepadLightIndicator* aOther) {
MOZ_ASSERT(aOther);
mGamepadId = aOther->mGamepadId;
mType = aOther->mType;
mIndex = aOther->mIndex;
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_gamepad_GamepadLightIndicator_h
#define mozilla_dom_gamepad_GamepadLightIndicator_h
#include "mozilla/dom/GamepadLightIndicatorBinding.h"
namespace mozilla {
namespace dom {
class GamepadLightIndicator final : public nsISupports, public nsWrapperCache {
public:
GamepadLightIndicator(nsISupports* aParent, uint32_t aGamepadId,
uint32_t aIndex);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GamepadLightIndicator)
static GamepadLightIndicatorType DefaultType() {
return GamepadLightIndicatorType::Rgb;
}
nsISupports* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
already_AddRefed<Promise> SetColor(const GamepadLightColor& color,
ErrorResult& aRv);
void SetType(GamepadLightIndicatorType aType) { mType = aType; }
GamepadLightIndicatorType Type() const;
void Set(const GamepadLightIndicator* aOther);
private:
virtual ~GamepadLightIndicator();
nsCOMPtr<nsISupports> mParent;
GamepadLightIndicatorType mType;
uint32_t mGamepadId;
uint32_t mIndex;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_gamepad_GamepadLightIndicator_h

View File

@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/GamepadTouch.h"
#include "mozilla/dom/GamepadManager.h"
#include "mozilla/dom/Promise.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(GamepadTouch)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(GamepadTouch)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->mPosition = nullptr;
tmp->mSurfaceDimensions = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(GamepadTouch)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(GamepadTouch)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mPosition)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mSurfaceDimensions)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(GamepadTouch, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(GamepadTouch, Release)
GamepadTouch::GamepadTouch(nsISupports* aParent)
: mParent(aParent), mPosition(nullptr), mSurfaceDimensions(nullptr) {
mozilla::HoldJSObjects(this);
mTouchState = GamepadTouchState();
}
GamepadTouch::~GamepadTouch() { mozilla::DropJSObjects(this); }
/* virtual */ JSObject* GamepadTouch::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return GamepadTouch_Binding::Wrap(aCx, this, aGivenProto);
}
void GamepadTouch::GetPosition(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv) {
mPosition = Float32Array::Create(aCx, this, 2, mTouchState.position);
if (!mPosition) {
aRv.NoteJSContextException(aCx);
return;
}
aRetval.set(mPosition);
}
void GamepadTouch::GetSurfaceDimensions(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv) {
mSurfaceDimensions = Uint32Array::Create(aCx, this, 2,
mTouchState.isSurfaceDimensionsValid
? mTouchState.surfaceDimensions
: nullptr);
if (!mSurfaceDimensions) {
aRv.NoteJSContextException(aCx);
return;
}
aRetval.set(mSurfaceDimensions);
}
void GamepadTouch::SetTouchState(const GamepadTouchState& aTouch) {
mTouchState = aTouch;
}
void GamepadTouch::Set(const GamepadTouch* aOther) {
MOZ_ASSERT(aOther);
mTouchState = aOther->mTouchState;
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_gamepad_GamepadTouch_h
#define mozilla_dom_gamepad_GamepadTouch_h
#include "mozilla/dom/GamepadTouchBinding.h"
#include "mozilla/dom/GamepadTouchState.h"
namespace mozilla {
namespace dom {
class GamepadTouch final : public nsWrapperCache {
public:
explicit GamepadTouch(nsISupports* aParent);
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(GamepadTouch)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(GamepadTouch)
nsISupports* GetParentObject() const { return mParent; }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
uint32_t TouchId() const { return mTouchState.touchId; }
uint32_t SurfaceId() const { return mTouchState.surfaceId; }
void GetPosition(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv);
void GetSurfaceDimensions(JSContext* aCx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv);
void SetTouchState(const GamepadTouchState& aTouch);
void Set(const GamepadTouch* aOther);
private:
virtual ~GamepadTouch();
nsCOMPtr<nsISupports> mParent;
JS::Heap<JSObject*> mPosition;
JS::Heap<JSObject*> mSurfaceDimensions;
GamepadTouchState mTouchState;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_gamepad_GamepadTouch_h

View File

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_gamepad_GamepadTouchState_h_
#define mozilla_dom_gamepad_GamepadTouchState_h_
namespace mozilla {
namespace dom {
struct GamepadTouchState {
uint32_t touchId;
uint32_t surfaceId;
float position[2];
uint32_t surfaceDimensions[2];
bool isSurfaceDimensionsValid;
GamepadTouchState()
: touchId(0),
surfaceId(0),
position{0, 0},
surfaceDimensions{0, 0},
isSurfaceDimensionsValid(false) {}
bool operator==(const GamepadTouchState& aTouch) const {
return touchId == aTouch.touchId && touchId == aTouch.touchId &&
surfaceId == aTouch.surfaceId && position[0] == aTouch.position[0] &&
position[1] == aTouch.position[1] &&
surfaceDimensions[0] == aTouch.surfaceDimensions[0] &&
surfaceDimensions[1] == aTouch.surfaceDimensions[1] &&
isSurfaceDimensionsValid == aTouch.isSurfaceDimensionsValid;
}
bool operator!=(const GamepadTouchState& aTouch) const {
return !(*this == aTouch);
}
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_gamepad_GamepadTouchState_h_

View File

@ -17,6 +17,7 @@ EXPORTS.mozilla.dom += [
'Gamepad.h',
'GamepadButton.h',
'GamepadHapticActuator.h',
'GamepadLightIndicator.h',
'GamepadManager.h',
'GamepadMonitoring.h',
'GamepadPlatformService.h',
@ -24,6 +25,8 @@ EXPORTS.mozilla.dom += [
'GamepadPoseState.h',
'GamepadRemapping.h',
'GamepadServiceTest.h',
'GamepadTouch.h',
'GamepadTouchState.h',
'ipc/GamepadEventChannelChild.h',
'ipc/GamepadEventChannelParent.h',
'ipc/GamepadMessageUtils.h',
@ -36,12 +39,14 @@ UNIFIED_SOURCES = [
'Gamepad.cpp',
'GamepadButton.cpp',
'GamepadHapticActuator.cpp',
'GamepadLightIndicator.cpp',
'GamepadManager.cpp',
'GamepadMonitoring.cpp',
'GamepadPlatformService.cpp',
'GamepadPose.cpp',
'GamepadRemapping.cpp',
'GamepadServiceTest.cpp',
'GamepadTouch.cpp',
'ipc/GamepadEventChannelChild.cpp',
'ipc/GamepadEventChannelParent.cpp',
'ipc/GamepadTestChannelChild.cpp',

View File

@ -391,8 +391,12 @@ var interfaceNamesInGlobalScope =
{name: "GamepadEvent", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "GamepadHapticActuator", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "GamepadLightIndicator", insecureContext: false, disabled: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "GamepadPose", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "GamepadTouch", insecureContext: false, disabled: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "HashChangeEvent", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -96,4 +96,10 @@ interface Gamepad {
*/
[Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled"]
readonly attribute sequence<GamepadHapticActuator> hapticActuators;
[Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled", Pref="dom.gamepad.extensions.lightindicator"]
readonly attribute sequence<GamepadLightIndicator> lightIndicators;
[Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled", Pref="dom.gamepad.extensions.multitouch"]
readonly attribute sequence<GamepadTouch> touchEvents;
};

View File

@ -0,0 +1,27 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://github.com/knyg/gamepad/blob/lightindicator/extensions.html
*/
enum GamepadLightIndicatorType {
"on-off",
"rgb"
};
dictionary GamepadLightColor {
required octet red;
required octet green;
required octet blue;
};
[SecureContext, Pref="dom.gamepad.extensions.lightindicator"]
interface GamepadLightIndicator
{
readonly attribute GamepadLightIndicatorType type;
[Throws, NewObject]
Promise<boolean> setColor(GamepadLightColor color);
};

View File

@ -0,0 +1,16 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://github.com/knyg/gamepad/blob/multitouch/extensions.html
*/
[SecureContext, Pref="dom.gamepad.extensions.multitouch"]
interface GamepadTouch {
readonly attribute unsigned long touchId;
readonly attribute octet surfaceId;
[Constant, Throws] readonly attribute Float32Array position;
[Constant, Throws] readonly attribute Uint32Array? surfaceDimensions;
};

View File

@ -519,8 +519,10 @@ WEBIDL_FILES = [
'GainNode.webidl',
'Gamepad.webidl',
'GamepadHapticActuator.webidl',
'GamepadLightIndicator.webidl',
'GamepadPose.webidl',
'GamepadServiceTest.webidl',
'GamepadTouch.webidl',
'Geolocation.webidl',
'GeometryUtils.webidl',
'GetUserMediaRequest.webidl',

View File

@ -1169,6 +1169,38 @@ VARCACHE_PREF(
bool, false
)
// Is Gamepad Extension API enabled?
VARCACHE_PREF(
Live,
"dom.gamepad.extensions.enabled",
dom_gamepad_extensions_enabled,
bool, true
)
// Is LightIndcator API enabled in Gamepad Extension API?
VARCACHE_PREF(
Live,
"dom.gamepad.extensions.lightindicator",
dom_gamepad_extensions_lightindicator,
bool, false
)
// Is MultiTouch API enabled in Gamepad Extension API?
VARCACHE_PREF(
Live,
"dom.gamepad.extensions.multitouch",
dom_gamepad_extensions_multitouch,
bool, false
)
// Is Gamepad vibrate haptic feedback function enabled?
VARCACHE_PREF(
Live,
"dom.gamepad.haptic_feedback.enabled",
dom_gamepad_haptic_feedback_enabled,
bool, true
)
// Enable passing the "storage" option to indexedDB.open.
VARCACHE_PREF(
Live,

View File

@ -183,8 +183,6 @@ pref("dom.gamepad.non_standard_events.enabled", false);
#else
pref("dom.gamepad.non_standard_events.enabled", true);
#endif
pref("dom.gamepad.extensions.enabled", true);
pref("dom.gamepad.haptic_feedback.enabled", true);
// If this is true, TextEventDispatcher dispatches keydown and keyup events
// even during composition (keypress events are never fired during composition