Bug 1375816 - Part 1: Add displayId attribute in Gamepad; r=qdot

MozReview-Commit-ID: 7nrOrKRemGY

--HG--
extra : rebase_source : c5f4ffe0afec269a2c6c6c4dd459d436748bd5b7
This commit is contained in:
Daosheng Mu 2017-07-14 16:53:03 +08:00
parent 1d9a118a36
commit 4f33b3d9da
3 changed files with 20 additions and 6 deletions

View File

@ -41,12 +41,13 @@ Gamepad::Gamepad(nsISupports* aParent,
uint32_t aHashKey,
GamepadMappingType aMapping,
GamepadHand aHand,
uint32_t aNumButtons, uint32_t aNumAxes,
uint32_t aNumHaptics)
uint32_t aDisplayID, uint32_t aNumButtons,
uint32_t aNumAxes, uint32_t aNumHaptics)
: mParent(aParent),
mID(aID),
mIndex(aIndex),
mHashKey(aHashKey),
mDisplayId(aDisplayID),
mMapping(aMapping),
mHand(aHand),
mConnected(true),
@ -155,7 +156,7 @@ Gamepad::Clone(nsISupports* aParent)
{
RefPtr<Gamepad> out =
new Gamepad(aParent, mID, mIndex, mHashKey, mMapping,
mHand, mButtons.Length(), mAxes.Length(),
mHand, mDisplayId, mButtons.Length(), mAxes.Length(),
mHapticActuators.Length());
out->SyncState(this);
return out.forget();

View File

@ -44,8 +44,8 @@ public:
const nsAString& aID, uint32_t aIndex,
uint32_t aHashKey,
GamepadMappingType aMapping, GamepadHand aHand,
uint32_t aNumButtons, uint32_t aNumAxes,
uint32_t aNumHaptics);
uint32_t aDisplayID, uint32_t aNumButtons,
uint32_t aNumAxes, uint32_t aNumHaptics);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Gamepad)
@ -87,6 +87,11 @@ public:
return mMapping;
}
uint32_t DisplayId() const
{
return mDisplayId;
}
GamepadHand Hand()
{
return mHand;
@ -137,7 +142,7 @@ protected:
uint32_t mIndex;
// the gamepad hash key in GamepadManager
uint32_t mHashKey;
uint32_t mDisplayId;
// The mapping in use.
GamepadMappingType mMapping;
GamepadHand mHand;

View File

@ -6,6 +6,7 @@
* The origin of this IDL file is
* https://w3c.github.io/gamepad/
* https://w3c.github.io/gamepad/extensions.html
* https://w3c.github.io/webvr/spec/1.1/#interface-gamepad
*/
[Pref="dom.gamepad.enabled"]
@ -52,6 +53,13 @@ interface Gamepad {
[Pref="dom.gamepad.extensions.enabled"]
readonly attribute GamepadHand hand;
/**
* The displayId in use for as an association point in the VRDisplay API
* to identify which VRDisplay that the gamepad is associated with.
*/
[Pref="dom.vr.enabled"]
readonly attribute unsigned long displayId;
/**
* true if this gamepad is currently connected to the system.
*/