@@ -22,8 +22,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Gamepad)
22
22
NS_INTERFACE_MAP_END
23
23
24
24
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE (Gamepad, mParent , mButtons , mPose ,
25
- mHapticActuators , mLightIndicators ,
26
- mTouchEvents )
25
+ mHapticActuators )
27
26
28
27
void Gamepad::UpdateTimestamp () {
29
28
nsCOMPtr<nsPIDOMWindowInner> newWindow (do_QueryInterface (mParent ));
@@ -38,14 +37,12 @@ void Gamepad::UpdateTimestamp() {
38
37
Gamepad::Gamepad (nsISupports* aParent, const nsAString& aID, uint32_t aIndex,
39
38
uint32_t aHashKey, GamepadMappingType aMapping,
40
39
GamepadHand aHand, uint32_t aDisplayID, uint32_t aNumButtons,
41
- uint32_t aNumAxes, uint32_t aNumHaptics,
42
- uint32_t aNumLightIndicator, uint32_t aNumTouchEvents)
40
+ uint32_t aNumAxes, uint32_t aNumHaptics)
43
41
: mParent (aParent),
44
42
mID (aID),
45
43
mIndex(aIndex),
46
44
mHashKey(aHashKey),
47
45
mDisplayId(aDisplayID),
48
- mTouchIdHashValue(0 ),
49
46
mMapping(aMapping),
50
47
mHand(aHand),
51
48
mConnected(true ),
@@ -61,14 +58,6 @@ Gamepad::Gamepad(nsISupports* aParent, const nsAString& aID, uint32_t aIndex,
61
58
mHapticActuators .AppendElement (
62
59
new GamepadHapticActuator (mParent , mHashKey , i));
63
60
}
64
- for (uint32_t i = 0 ; i < aNumLightIndicator; ++i) {
65
- mLightIndicators .AppendElement (
66
- new GamepadLightIndicator (mParent , mHashKey , i));
67
- }
68
- for (uint32_t i = 0 ; i < aNumTouchEvents; ++i) {
69
- mTouchEvents .AppendElement (new GamepadTouch (mParent ));
70
- }
71
-
72
61
UpdateTimestamp ();
73
62
}
74
63
@@ -99,35 +88,11 @@ void Gamepad::SetPose(const GamepadPoseState& aPose) {
99
88
UpdateTimestamp ();
100
89
}
101
90
102
- void Gamepad::SetLightIndicatorType (uint32_t aLightIndex,
103
- GamepadLightIndicatorType aType) {
104
- mLightIndicators [aLightIndex]->SetType (aType);
105
- UpdateTimestamp ();
106
- }
107
-
108
- void Gamepad::SetTouchEvent (uint32_t aTouchIndex,
109
- const GamepadTouchState& aTouch) {
110
- if (aTouchIndex >= mTouchEvents .Length ()) {
111
- MOZ_CRASH (" Touch index exceeds the event array." );
112
- return ;
113
- }
114
-
115
- // Handling cross-origin tracking.
116
- GamepadTouchState touchState (aTouch);
117
- if (auto hashValue = mTouchIdHash .GetValue (touchState.touchId )) {
118
- touchState.touchId = *hashValue;
119
- } else {
120
- touchState.touchId = mTouchIdHashValue ;
121
- mTouchIdHash .Put (aTouch.touchId , mTouchIdHashValue );
122
- ++mTouchIdHashValue ;
123
- }
124
- mTouchEvents [aTouchIndex]->SetTouchState (touchState);
125
- UpdateTimestamp ();
126
- }
127
-
128
91
void Gamepad::SetHand (GamepadHand aHand) { mHand = aHand; }
129
92
130
93
void Gamepad::SyncState (Gamepad* aOther) {
94
+ const char * kGamepadExtEnabledPref = " dom.gamepad.extensions.enabled" ;
95
+
131
96
if (mButtons .Length () != aOther->mButtons .Length () ||
132
97
mAxes .Length () != aOther->mAxes .Length ()) {
133
98
return ;
@@ -149,24 +114,13 @@ void Gamepad::SyncState(Gamepad* aOther) {
149
114
Gamepad_Binding::ClearCachedAxesValue (this );
150
115
}
151
116
152
- if (StaticPrefs::dom_gamepad_extensions_enabled ( )) {
117
+ if (Preferences::GetBool ( kGamepadExtEnabledPref )) {
153
118
MOZ_ASSERT (aOther->GetPose ());
154
119
mPose ->SetPoseState (aOther->GetPose ()->GetPoseState ());
155
120
mHand = aOther->Hand ();
156
121
for (uint32_t i = 0 ; i < mHapticActuators .Length (); ++i) {
157
122
mHapticActuators [i]->Set (aOther->mHapticActuators [i]);
158
123
}
159
-
160
- if (StaticPrefs::dom_gamepad_extensions_lightindicator ()) {
161
- for (uint32_t i = 0 ; i < mLightIndicators .Length (); ++i) {
162
- mLightIndicators [i]->Set (aOther->mLightIndicators [i]);
163
- }
164
- }
165
- if (StaticPrefs::dom_gamepad_extensions_multitouch ()) {
166
- for (uint32_t i = 0 ; i < mTouchEvents .Length (); ++i) {
167
- mTouchEvents [i]->Set (aOther->mTouchEvents [i]);
168
- }
169
- }
170
124
}
171
125
172
126
UpdateTimestamp ();
@@ -175,8 +129,7 @@ void Gamepad::SyncState(Gamepad* aOther) {
175
129
already_AddRefed<Gamepad> Gamepad::Clone (nsISupports* aParent) {
176
130
RefPtr<Gamepad> out =
177
131
new Gamepad (aParent, mID , mIndex , mHashKey , mMapping , mHand , mDisplayId ,
178
- mButtons .Length (), mAxes .Length (), mHapticActuators .Length (),
179
- mLightIndicators .Length (), mTouchEvents .Length ());
132
+ mButtons .Length (), mAxes .Length (), mHapticActuators .Length ());
180
133
out->SyncState (this );
181
134
return out.forget ();
182
135
}
0 commit comments