From b173205f5e1fa84713b87aa427fb7a38d61c8ded Mon Sep 17 00:00:00 2001
From: Daniel Varga
Date: Thu, 30 May 2019 01:10:11 +0300
Subject: [PATCH] Backed out 5 changesets (bug 1523351) for build bustage at
builds/worker/workspace/build/src/dom/gamepad/GamepadRemapping.cpp on a
CLOSED TREE
Backed out changeset 723d0a919d71 (bug 1523351)
Backed out changeset 13dcba81ff07 (bug 1523351)
Backed out changeset 6209717410be (bug 1523351)
Backed out changeset 80b34e6ce876 (bug 1523351)
Backed out changeset 7bdb7982c3af (bug 1523351)
---
.../test_hide_gamepad_info_iframe.html | 2 -
dom/gamepad/Gamepad.cpp | 59 +---
dom/gamepad/Gamepad.h | 21 +-
dom/gamepad/GamepadLightIndicator.cpp | 69 -----
dom/gamepad/GamepadLightIndicator.h | 53 ----
dom/gamepad/GamepadManager.cpp | 68 +----
dom/gamepad/GamepadManager.h | 12 +-
dom/gamepad/GamepadMonitoring.h | 3 -
dom/gamepad/GamepadPlatformService.cpp | 32 +--
dom/gamepad/GamepadPlatformService.h | 11 +-
dom/gamepad/GamepadRemapping.cpp | 97 -------
dom/gamepad/GamepadRemapping.h | 10 -
dom/gamepad/GamepadServiceTest.cpp | 38 +--
dom/gamepad/GamepadServiceTest.h | 12 +-
dom/gamepad/GamepadTouch.cpp | 87 ------
dom/gamepad/GamepadTouch.h | 48 ----
dom/gamepad/GamepadTouchState.h | 44 ---
dom/gamepad/android/AndroidGamepad.cpp | 11 +-
dom/gamepad/cocoa/CocoaGamepad.cpp | 11 +-
dom/gamepad/ipc/GamepadEventChannelChild.cpp | 2 +-
dom/gamepad/ipc/GamepadEventChannelChild.h | 3 +-
dom/gamepad/ipc/GamepadEventChannelParent.cpp | 24 +-
dom/gamepad/ipc/GamepadEventChannelParent.h | 6 +-
dom/gamepad/ipc/GamepadEventTypes.ipdlh | 18 +-
dom/gamepad/ipc/GamepadMessageUtils.h | 39 ---
dom/gamepad/ipc/GamepadTestChannelParent.cpp | 8 +-
dom/gamepad/ipc/PGamepadEventChannel.ipdl | 6 +-
dom/gamepad/linux/LinuxGamepad.cpp | 11 +-
dom/gamepad/moz.build | 5 -
dom/gamepad/windows/WindowsGamepad.cpp | 118 +-------
dom/tests/mochitest/gamepad/mochitest.ini | 4 -
.../gamepad/test_check_timestamp_iframe.html | 2 -
.../test_gamepad_connect_events_iframe.html | 2 -
.../test_gamepad_extensions_iframe.html | 52 +---
.../test_gamepad_frame_state_sync_iframe.html | 2 -
.../test_gamepad_hidden_frame_iframe.html | 2 -
.../gamepad/test_gamepad_iframe.html | 2 -
.../test_gamepad_multitouch_crossorigin.html | 20 --
...gamepad_multitouch_crossorigin_iframe.html | 261 ------------------
.../test_navigator_gamepads_iframe.html | 4 -
.../mochitest/general/test_interfaces.js | 4 -
dom/webidl/Gamepad.webidl | 6 -
dom/webidl/GamepadLightIndicator.webidl | 27 --
dom/webidl/GamepadServiceTest.webidl | 8 +-
dom/webidl/GamepadTouch.webidl | 16 --
dom/webidl/moz.build | 2 -
gfx/vr/VRDisplayClient.cpp | 2 +-
gfx/vr/gfxVR.cpp | 2 +-
modules/libpref/init/StaticPrefList.h | 32 ---
modules/libpref/init/all.js | 2 +
50 files changed, 65 insertions(+), 1315 deletions(-)
delete mode 100644 dom/gamepad/GamepadLightIndicator.cpp
delete mode 100644 dom/gamepad/GamepadLightIndicator.h
delete mode 100644 dom/gamepad/GamepadTouch.cpp
delete mode 100644 dom/gamepad/GamepadTouch.h
delete mode 100644 dom/gamepad/GamepadTouchState.h
delete mode 100644 dom/tests/mochitest/gamepad/test_gamepad_multitouch_crossorigin.html
delete mode 100644 dom/tests/mochitest/gamepad/test_gamepad_multitouch_crossorigin_iframe.html
delete mode 100644 dom/webidl/GamepadLightIndicator.webidl
delete mode 100644 dom/webidl/GamepadTouch.webidl
diff --git a/browser/components/resistfingerprinting/test/mochitest/test_hide_gamepad_info_iframe.html b/browser/components/resistfingerprinting/test/mochitest/test_hide_gamepad_info_iframe.html
index 0eceae06480dc..dbee775f6e7b5 100644
--- a/browser/components/resistfingerprinting/test/mochitest/test_hide_gamepad_info_iframe.html
+++ b/browser/components/resistfingerprinting/test/mochitest/test_hide_gamepad_info_iframe.html
@@ -19,8 +19,6 @@
GamepadService.noHand,
4, // buttons
2,
- 0,
- 0,
0).then((aIndex) => new Promise((aResolve) => {
// Press a button to make the gamepad visible to the page.
GamepadService.newButtonEvent(aIndex, 0, true, true);
diff --git a/dom/gamepad/Gamepad.cpp b/dom/gamepad/Gamepad.cpp
index cded7cab0061e..4ff5d18c0081b 100644
--- a/dom/gamepad/Gamepad.cpp
+++ b/dom/gamepad/Gamepad.cpp
@@ -22,8 +22,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Gamepad)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Gamepad, mParent, mButtons, mPose,
- mHapticActuators, mLightIndicators,
- mTouchEvents)
+ mHapticActuators)
void Gamepad::UpdateTimestamp() {
nsCOMPtr newWindow(do_QueryInterface(mParent));
@@ -38,14 +37,12 @@ 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 aNumLightIndicator, uint32_t aNumTouchEvents)
+ uint32_t aNumAxes, uint32_t aNumHaptics)
: mParent(aParent),
mID(aID),
mIndex(aIndex),
mHashKey(aHashKey),
mDisplayId(aDisplayID),
- mTouchIdHashValue(0),
mMapping(aMapping),
mHand(aHand),
mConnected(true),
@@ -61,14 +58,6 @@ 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();
}
@@ -99,35 +88,11 @@ 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;
@@ -149,24 +114,13 @@ void Gamepad::SyncState(Gamepad* aOther) {
Gamepad_Binding::ClearCachedAxesValue(this);
}
- if (StaticPrefs::dom_gamepad_extensions_enabled()) {
+ if (Preferences::GetBool(kGamepadExtEnabledPref)) {
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();
@@ -175,8 +129,7 @@ void Gamepad::SyncState(Gamepad* aOther) {
already_AddRefed Gamepad::Clone(nsISupports* aParent) {
RefPtr out =
new Gamepad(aParent, mID, mIndex, mHashKey, mMapping, mHand, mDisplayId,
- mButtons.Length(), mAxes.Length(), mHapticActuators.Length(),
- mLightIndicators.Length(), mTouchEvents.Length());
+ mButtons.Length(), mAxes.Length(), mHapticActuators.Length());
out->SyncState(this);
return out.forget();
}
diff --git a/dom/gamepad/Gamepad.h b/dom/gamepad/Gamepad.h
index ce55e94da0f3f..66fd9d627c105 100644
--- a/dom/gamepad/Gamepad.h
+++ b/dom/gamepad/Gamepad.h
@@ -12,8 +12,6 @@
#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
#include "nsCOMPtr.h"
@@ -42,8 +40,7 @@ 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 aNumLightIndicator,
- uint32_t aNumTouchEvents);
+ uint32_t aNumHaptics);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Gamepad)
@@ -53,9 +50,6 @@ 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.
@@ -99,15 +93,6 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
aHapticActuators = mHapticActuators;
}
- void GetLightIndicators(
- nsTArray>& aLightIndicators) const {
- aLightIndicators = mLightIndicators;
- }
-
- void GetTouchEvents(nsTArray>& aTouchEvents) const {
- aTouchEvents = mTouchEvents;
- }
-
private:
virtual ~Gamepad() {}
void UpdateTimestamp();
@@ -119,7 +104,6 @@ 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;
@@ -133,9 +117,6 @@ class Gamepad final : public nsISupports, public nsWrapperCache {
DOMHighResTimeStamp mTimestamp;
RefPtr mPose;
nsTArray> mHapticActuators;
- nsTArray> mLightIndicators;
- nsTArray> mTouchEvents;
- nsDataHashtable mTouchIdHash;
};
} // namespace dom
diff --git a/dom/gamepad/GamepadLightIndicator.cpp b/dom/gamepad/GamepadLightIndicator.cpp
deleted file mode 100644
index 0ee948fecf5fb..0000000000000
--- a/dom/gamepad/GamepadLightIndicator.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- 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 aGivenProto) {
- return GamepadLightIndicator_Binding::Wrap(aCx, this, aGivenProto);
-}
-
-nsISupports* GamepadLightIndicator::GetParentObject() const { return mParent; }
-
-already_AddRefed GamepadLightIndicator::SetColor(
- const GamepadLightColor& color, ErrorResult& aRv) {
- nsCOMPtr global = do_QueryInterface(GetParentObject());
- MOZ_ASSERT(global);
-
- RefPtr gamepadManager(GamepadManager::GetService());
- MOZ_ASSERT(gamepadManager);
-
- RefPtr 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
diff --git a/dom/gamepad/GamepadLightIndicator.h b/dom/gamepad/GamepadLightIndicator.h
deleted file mode 100644
index 6f5850e65737a..0000000000000
--- a/dom/gamepad/GamepadLightIndicator.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- 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 aGivenProto) override;
-
- already_AddRefed SetColor(const GamepadLightColor& color,
- ErrorResult& aRv);
-
- void SetType(GamepadLightIndicatorType aType) { mType = aType; }
-
- GamepadLightIndicatorType Type() const;
-
- void Set(const GamepadLightIndicator* aOther);
-
- private:
- virtual ~GamepadLightIndicator();
-
- nsCOMPtr mParent;
- GamepadLightIndicatorType mType;
- uint32_t mGamepadId;
- uint32_t mIndex;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_gamepad_GamepadLightIndicator_h
diff --git a/dom/gamepad/GamepadManager.cpp b/dom/gamepad/GamepadManager.cpp
index 652fe1c794a24..35cb8c528900a 100644
--- a/dom/gamepad/GamepadManager.cpp
+++ b/dom/gamepad/GamepadManager.cpp
@@ -225,17 +225,14 @@ void GamepadManager::AddGamepad(uint32_t aIndex, const nsAString& aId,
GamepadMappingType aMapping, GamepadHand aHand,
GamepadServiceType aServiceType,
uint32_t aDisplayID, uint32_t aNumButtons,
- uint32_t aNumAxes, uint32_t aNumHaptics,
- uint32_t aNumLightIndicator,
- uint32_t aNumTouchEvents) {
+ uint32_t aNumAxes, uint32_t aNumHaptics) {
uint32_t newIndex = GetGamepadIndexWithServiceType(aIndex, aServiceType);
// TODO: bug 852258: get initial button/axis state
- RefPtr gamepad =
- new Gamepad(nullptr, aId,
- 0, // index is set by global window
- newIndex, aMapping, aHand, aDisplayID, aNumButtons, aNumAxes,
- aNumHaptics, aNumLightIndicator, aNumTouchEvents);
+ RefPtr gamepad = new Gamepad(nullptr, aId,
+ 0, // index is set by global window
+ newIndex, aMapping, aHand, aDisplayID,
+ aNumButtons, aNumAxes, aNumHaptics);
// We store the gamepad related to its index given by the parent process,
// and no duplicate index is allowed.
@@ -474,8 +471,7 @@ void GamepadManager::Update(const GamepadChangeEvent& aEvent) {
const GamepadAdded& a = body.get_GamepadAdded();
AddGamepad(index, a.id(), static_cast(a.mapping()),
static_cast(a.hand()), serviceType, a.display_id(),
- a.num_buttons(), a.num_axes(), a.num_haptics(), a.num_lights(),
- a.num_touches());
+ a.num_buttons(), a.num_axes(), a.num_haptics());
return;
}
if (body.type() == GamepadChangeEventBody::TGamepadRemoved) {
@@ -565,25 +561,6 @@ bool GamepadManager::SetGamepadByEvent(const GamepadChangeEvent& aEvent,
gamepad->SetPose(a.pose_state());
break;
}
- case GamepadChangeEventBody::TGamepadLightIndicatorTypeInformation: {
- const GamepadLightIndicatorTypeInformation& a =
- body.get_GamepadLightIndicatorTypeInformation();
- gamepad->SetLightIndicatorType(a.light(), a.type());
- break;
- }
- case GamepadChangeEventBody::TGamepadTouchInformation: {
- // Avoid GamepadTouch's touchId be accessed in cross-origin tracking.
- for (uint32_t i = 0; i < mListeners.Length(); i++) {
- RefPtr listenerGamepad = mListeners[i]->GetGamepad(index);
- if (listenerGamepad && mListeners[i]->IsCurrentInnerWindow() &&
- !mListeners[i]->GetOuterWindow()->IsBackground()) {
- const GamepadTouchInformation& a =
- body.get_GamepadTouchInformation();
- listenerGamepad->SetTouchEvent(a.index(), a.touch_state());
- }
- }
- break;
- }
case GamepadChangeEventBody::TGamepadHandInformation: {
const GamepadHandInformation& a = body.get_GamepadHandInformation();
gamepad->SetHand(a.hand());
@@ -606,12 +583,13 @@ bool GamepadManager::SetGamepadByEvent(const GamepadChangeEvent& aEvent,
already_AddRefed GamepadManager::VibrateHaptic(
uint32_t aControllerIdx, uint32_t aHapticIndex, double aIntensity,
double aDuration, nsIGlobalObject* aGlobal, ErrorResult& aRv) {
+ const char* kGamepadHapticEnabledPref = "dom.gamepad.haptic_feedback.enabled";
RefPtr promise = Promise::Create(aGlobal, aRv);
if (NS_WARN_IF(aRv.Failed())) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
- if (StaticPrefs::dom_gamepad_haptic_feedback_enabled()) {
+ if (Preferences::GetBool(kGamepadHapticEnabledPref)) {
if (aControllerIdx >= VR_GAMEPAD_IDX_OFFSET) {
if (gfx::VRManagerChild::IsCreated()) {
const uint32_t index = aControllerIdx - VR_GAMEPAD_IDX_OFFSET;
@@ -634,7 +612,8 @@ already_AddRefed GamepadManager::VibrateHaptic(
}
void GamepadManager::StopHaptics() {
- if (!StaticPrefs::dom_gamepad_haptic_feedback_enabled()) {
+ const char* kGamepadHapticEnabledPref = "dom.gamepad.haptic_feedback.enabled";
+ if (!Preferences::GetBool(kGamepadHapticEnabledPref)) {
return;
}
@@ -654,32 +633,5 @@ void GamepadManager::StopHaptics() {
}
}
-already_AddRefed GamepadManager::SetLightIndicatorColor(
- uint32_t aControllerIdx, uint32_t aLightColorIndex, uint8_t aRed,
- uint8_t aGreen, uint8_t aBlue, nsIGlobalObject* aGlobal, ErrorResult& aRv) {
- RefPtr promise = Promise::Create(aGlobal, aRv);
- if (NS_WARN_IF(aRv.Failed())) {
- aRv.Throw(NS_ERROR_FAILURE);
- return nullptr;
- }
- if (StaticPrefs::dom_gamepad_extensions_lightindicator()) {
- for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
- const uint32_t gamepadIndex = iter.UserData()->HashKey();
- if (gamepadIndex >= VR_GAMEPAD_IDX_OFFSET) {
- MOZ_ASSERT(false && "We don't support light indicator in VR.");
- } else {
- for (auto& channelChild : mChannelChildren) {
- channelChild->AddPromise(mPromiseID, promise);
- channelChild->SendLightIndicatorColor(aControllerIdx,
- aLightColorIndex, aRed, aGreen,
- aBlue, mPromiseID);
- }
- }
- }
- }
-
- ++mPromiseID;
- return promise.forget();
-}
} // namespace dom
} // namespace mozilla
diff --git a/dom/gamepad/GamepadManager.h b/dom/gamepad/GamepadManager.h
index f0ef270848449..11565c9ddb65d 100644
--- a/dom/gamepad/GamepadManager.h
+++ b/dom/gamepad/GamepadManager.h
@@ -49,8 +49,8 @@ class GamepadManager final : public nsIObserver {
void AddGamepad(uint32_t aIndex, const nsAString& aID,
GamepadMappingType aMapping, GamepadHand aHand,
GamepadServiceType aServiceType, uint32_t aDisplayID,
- uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics,
- uint32_t aNumLightIndicator, uint32_t aNumTouchEvents);
+ uint32_t aNumButtons, uint32_t aNumAxes,
+ uint32_t aNumHaptics);
// Remove the gamepad at |aIndex| from the list of known gamepads.
void RemoveGamepad(uint32_t aIndex, GamepadServiceType aServiceType);
@@ -78,14 +78,6 @@ class GamepadManager final : public nsIObserver {
// Send stop haptic events to gamepad channels.
void StopHaptics();
- // Set light indicator color event to gamepad channels.
- already_AddRefed SetLightIndicatorColor(uint32_t aControllerIdx,
- uint32_t aLightColorIndex,
- uint8_t aRed, uint8_t aGreen,
- uint8_t aBlue,
- nsIGlobalObject* aGlobal,
- ErrorResult& aRv);
-
protected:
GamepadManager();
~GamepadManager(){};
diff --git a/dom/gamepad/GamepadMonitoring.h b/dom/gamepad/GamepadMonitoring.h
index 871cfd46b2d59..e3e1c4b00bcec 100644
--- a/dom/gamepad/GamepadMonitoring.h
+++ b/dom/gamepad/GamepadMonitoring.h
@@ -17,9 +17,6 @@ void MaybeStopGamepadMonitoring();
// (linux/LinuxGamepad.cpp, cocoa/CocoaGamepad.cpp, etc)
void StartGamepadMonitoring();
void StopGamepadMonitoring();
-void SetGamepadLightIndicatorColor(uint32_t aControllerIdx,
- uint32_t aLightColorIndex, uint8_t aRed,
- uint8_t aGreen, uint8_t aBlue);
} // namespace dom
} // namespace mozilla
diff --git a/dom/gamepad/GamepadPlatformService.cpp b/dom/gamepad/GamepadPlatformService.cpp
index acf6bf589d606..1d527ed91421e 100644
--- a/dom/gamepad/GamepadPlatformService.cpp
+++ b/dom/gamepad/GamepadPlatformService.cpp
@@ -79,8 +79,7 @@ void GamepadPlatformService::NotifyGamepadChange(uint32_t aIndex,
uint32_t GamepadPlatformService::AddGamepad(
const char* aID, GamepadMappingType aMapping, GamepadHand aHand,
- uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aHaptics,
- uint32_t aNumLightIndicator, uint32_t aNumTouchEvents) {
+ uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aHaptics) {
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
@@ -90,8 +89,7 @@ uint32_t GamepadPlatformService::AddGamepad(
// Only VR controllers has displayID, we give 0 to the general gamepads.
GamepadAdded a(NS_ConvertUTF8toUTF16(nsDependentCString(aID)), aMapping,
- aHand, 0, aNumButtons, aNumAxes, aHaptics, aNumLightIndicator,
- aNumTouchEvents);
+ aHand, 0, aNumButtons, aNumAxes, aHaptics);
NotifyGamepadChange(index, a);
return index;
@@ -147,38 +145,16 @@ void GamepadPlatformService::NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis,
NotifyGamepadChange(aIndex, a);
}
-void GamepadPlatformService::NewLightIndicatorTypeEvent(
- uint32_t aIndex, uint32_t aLight, GamepadLightIndicatorType aType) {
- // This method is called by monitor thread populated in
- // platform-dependent backends
- MOZ_ASSERT(XRE_IsParentProcess());
- MOZ_ASSERT(!NS_IsMainThread());
- GamepadLightIndicatorTypeInformation a(aLight, aType);
- NotifyGamepadChange(aIndex, a);
-}
-
void GamepadPlatformService::NewPoseEvent(uint32_t aIndex,
- const GamepadPoseState& aState) {
+ const GamepadPoseState& aPose) {
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
- GamepadPoseInformation a(aState);
+ GamepadPoseInformation a(aPose);
NotifyGamepadChange(aIndex, a);
}
-void GamepadPlatformService::NewMultiTouchEvent(
- uint32_t aIndex, uint32_t aTouchArrayIndex,
- const GamepadTouchState& aState) {
- // This method is called by monitor thread populated in
- // platform-dependent backends
- MOZ_ASSERT(XRE_IsParentProcess());
- MOZ_ASSERT(!NS_IsMainThread());
-
- GamepadTouchInformation a(aTouchArrayIndex, aState);
- NotifyGamepadChange(aIndex, a);
-}
-
void GamepadPlatformService::ResetGamepadIndexes() {
// This method is called by monitor thread populated in
// platform-dependent backends
diff --git a/dom/gamepad/GamepadPlatformService.h b/dom/gamepad/GamepadPlatformService.h
index dc4fba3c5ec20..9036a6b994991 100644
--- a/dom/gamepad/GamepadPlatformService.h
+++ b/dom/gamepad/GamepadPlatformService.h
@@ -38,8 +38,7 @@ class GamepadPlatformService final {
// Add a gamepad to the list of known gamepads, and return its index.
uint32_t AddGamepad(const char* aID, GamepadMappingType aMapping,
GamepadHand aHand, uint32_t aNumButtons,
- uint32_t aNumAxes, uint32_t aNumHaptics,
- uint32_t aNumLightIndicator, uint32_t aNumTouchEvents);
+ uint32_t aNumAxes, uint32_t aNumHaptics);
// Remove the gamepad at |aIndex| from the list of known gamepads.
void RemoveGamepad(uint32_t aIndex);
@@ -63,14 +62,6 @@ class GamepadPlatformService final {
// Update the state of |aState| for the gamepad at |aIndex| for all
// windows that are listening and visible.
void NewPoseEvent(uint32_t aIndex, const GamepadPoseState& aState);
- // Update the type of |aType| for the gamepad at |aIndex| for all
- // windows that are listening and visible.
- void NewLightIndicatorTypeEvent(uint32_t aIndex, uint32_t aLight,
- GamepadLightIndicatorType aType);
- // Update the state of |aState| for the gamepad at |aIndex| with
- // |aTouchArrayIndex| for all windows that are listening and visible.
- void NewMultiTouchEvent(uint32_t aIndex, uint32_t aTouchArrayIndex,
- const GamepadTouchState& aState);
// When shutting down the platform communications for gamepad, also reset the
// indexes.
diff --git a/dom/gamepad/GamepadRemapping.cpp b/dom/gamepad/GamepadRemapping.cpp
index b91a672ffd69a..7c00479c4ba3e 100644
--- a/dom/gamepad/GamepadRemapping.cpp
+++ b/dom/gamepad/GamepadRemapping.cpp
@@ -47,10 +47,6 @@ enum CanonicalAxisIndex {
AXIS_INDEX_COUNT
};
-float NormalizeTouch(long aValue, long aMin, long aMax) {
- return (2.f * (aValue - aMin) / static_cast(aMax - aMin)) - 1.f;
-}
-
bool AxisNegativeAsButton(float input) {
const float value = (input < -0.5f) ? 1.f : 0.f;
return value > 0.1f;
@@ -367,92 +363,6 @@ class Dualshock4Remapper final : public GamepadRemapper {
return DUALSHOCK_BUTTON_COUNT;
}
- virtual uint32_t GetLightIndicatorCount() const override {
- return LIGHT_INDICATOR_COUNT;
- }
-
- virtual void GetLightIndicators(
- nsTArray& aTypes) const override {
- const uint32_t len = GetLightIndicatorCount();
- aTypes.SetLength(len);
- for (uint32_t i = 0; i < len; ++i) {
- aTypes[i] = GamepadLightIndicatorType::Rgb;
- }
- }
-
- virtual uint32_t GetTouchEventCount() const override {
- return TOUCH_EVENT_COUNT;
- }
-
- virtual void GetLightColorReport(
- uint8_t aRed, uint8_t aGreen, uint8_t aBlue,
- std::vector& aReport) const override {
- const size_t report_length = 32;
- aReport.resize(report_length);
- aReport.assign(report_length, 0);
-
- aReport[0] = 0x05; // report ID USB only
- aReport[1] = 0x02; // LED only
- aReport[6] = aRed;
- aReport[7] = aGreen;
- aReport[8] = aBlue;
- }
-
- virtual void GetTouchData(uint32_t aIndex, void* aInput) override {
- nsTArray touches(TOUCH_EVENT_COUNT);
- touches.SetLength(TOUCH_EVENT_COUNT);
- uint8_t* rawData = (uint8_t*)aInput;
-
- bool touch0Pressed = (((rawData[35] & 0xff) >> 7) == 0);
- bool touch1Pressed = (((rawData[39] & 0xff) >> 7) == 0);
-
- if (!touch0Pressed && !touch1Pressed) {
- return;
- }
-
- if ((touch0Pressed && (rawData[35] & 0xff) < mLastTouch0Id) ||
- (touch1Pressed && (rawData[39] & 0xff) < mLastTouch1Id)) {
- mTouchIdBase += 128;
- }
-
- const uint32_t kTouchDimensionX = 1920;
- const uint32_t kTouchDimensionY = 942;
-
- touches[0].touchId = mTouchIdBase + (rawData[35] & 0x7f);
- touches[0].surfaceId = 0;
- touches[0].position[0] = NormalizeTouch(
- ((rawData[37] & 0xf) << 8) | rawData[36], 0, (kTouchDimensionX - 1));
- touches[0].position[1] =
- NormalizeTouch(rawData[38] << 4 | ((rawData[37] & 0xf0) >> 4), 0,
- (kTouchDimensionY - 1));
- touches[0].surfaceDimensions[0] = kTouchDimensionX;
- touches[0].surfaceDimensions[1] = kTouchDimensionY;
- touches[0].isSurfaceDimensionsValid = true;
- mLastTouch0Id = rawData[35] & 0x7f;
-
- touches[1].touchId = mTouchIdBase + (rawData[39] & 0x7f);
- touches[1].surfaceId = 0;
- touches[1].position[0] =
- NormalizeTouch(((rawData[41] & 0xf) << 8) | rawData[40] + 1, 0,
- (kTouchDimensionX - 1));
- touches[1].position[1] =
- NormalizeTouch(rawData[42] << 4 | ((rawData[41] & 0xf0) >> 4), 0,
- (kTouchDimensionY - 1));
- touches[1].surfaceDimensions[0] = kTouchDimensionX;
- touches[1].surfaceDimensions[1] = kTouchDimensionY;
- touches[1].isSurfaceDimensionsValid = true;
- mLastTouch1Id = rawData[39] & 0x7f;
-
- RefPtr service =
- GamepadPlatformService::GetParentService();
- if (!service) {
- return;
- }
-
- service->NewMultiTouchEvent(aIndex, 0, touches[0]);
- service->NewMultiTouchEvent(aIndex, 1, touches[1]);
- }
-
virtual void RemapAxisMoveEvent(uint32_t aIndex, uint32_t aAxis,
double aValue) const override {
RefPtr service =
@@ -533,13 +443,6 @@ class Dualshock4Remapper final : public GamepadRemapper {
DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
DUALSHOCK_BUTTON_COUNT
};
-
- static const uint32_t LIGHT_INDICATOR_COUNT = 1;
- static const uint32_t TOUCH_EVENT_COUNT = 2;
-
- unsigned long mLastTouch0Id = 0;
- unsigned long mLastTouch1Id = 0;
- unsigned long mTouchIdBase = 0;
};
class LogitechDInputRemapper final : public GamepadRemapper {
diff --git a/dom/gamepad/GamepadRemapping.h b/dom/gamepad/GamepadRemapping.h
index 77b131464a519..fe9f49d0b3fbe 100644
--- a/dom/gamepad/GamepadRemapping.h
+++ b/dom/gamepad/GamepadRemapping.h
@@ -7,8 +7,6 @@
#ifndef mozilla_dom_GamepadRemapping_h_
#define mozilla_dom_GamepadRemapping_h_
-#include "mozilla/dom/GamepadLightIndicator.h"
-
namespace mozilla {
namespace dom {
@@ -72,19 +70,11 @@ class GamepadRemapper {
public:
virtual uint32_t GetAxisCount() const = 0;
virtual uint32_t GetButtonCount() const = 0;
- virtual uint32_t GetLightIndicatorCount() const { return 0; }
- virtual void GetLightIndicators(
- nsTArray& aTypes) const {}
- virtual uint32_t GetTouchEventCount() const { return 0; }
- virtual void GetLightColorReport(uint8_t aRed, uint8_t aGreen, uint8_t aBlue,
- std::vector& aReport) const {}
-
virtual void SetAxisCount(uint32_t aButtonCount) {}
virtual void SetButtonCount(uint32_t aButtonCount) {}
virtual GamepadMappingType GetMappingType() const {
return GamepadMappingType::Standard;
}
- virtual void GetTouchData(uint32_t aIndex, void* aInput) {}
virtual void RemapAxisMoveEvent(uint32_t aIndex, uint32_t aAxis,
double aValue) const = 0;
virtual void RemapButtonEvent(uint32_t aIndex, uint32_t aButton,
diff --git a/dom/gamepad/GamepadServiceTest.cpp b/dom/gamepad/GamepadServiceTest.cpp
index b372f864cd2af..e6d1f9924cce9 100644
--- a/dom/gamepad/GamepadServiceTest.cpp
+++ b/dom/gamepad/GamepadServiceTest.cpp
@@ -90,14 +90,14 @@ void GamepadServiceTest::DestroyPBackgroundActor() {
already_AddRefed GamepadServiceTest::AddGamepad(
const nsAString& aID, GamepadMappingType aMapping, GamepadHand aHand,
uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics,
- uint32_t aNumLightIndicator, uint32_t aNumTouchEvents, ErrorResult& aRv) {
+ ErrorResult& aRv) {
if (mShuttingDown) {
return nullptr;
}
// Only VR controllers has displayID, we give 0 to the general gamepads.
GamepadAdded a(nsString(aID), aMapping, aHand, 0, aNumButtons, aNumAxes,
- aNumHaptics, aNumLightIndicator, aNumTouchEvents);
+ aNumHaptics);
GamepadChangeEventBody body(a);
GamepadChangeEvent e(0, GamepadServiceType::Standard, body);
@@ -246,40 +246,6 @@ void GamepadServiceTest::NewPoseMove(
mChild->SendGamepadTestEvent(id, e);
}
-void GamepadServiceTest::NewTouch(uint32_t aIndex, uint32_t aTouchArrayIndex,
- uint32_t aTouchId, uint8_t aSurfaceId,
- const Float32Array& aPos,
- const Nullable& aSurfDim) {
- if (mShuttingDown) {
- return;
- }
-
- GamepadTouchState touchState;
- touchState.touchId = aTouchId;
- touchState.surfaceId = aSurfaceId;
- const Float32Array& value = aPos;
- value.ComputeLengthAndData();
- MOZ_ASSERT(value.Length() == 2);
- touchState.position[0] = value.Data()[0];
- touchState.position[1] = value.Data()[1];
-
- if (!aSurfDim.IsNull()) {
- const Float32Array& value = aSurfDim.Value();
- value.ComputeLengthAndData();
- MOZ_ASSERT(value.Length() == 2);
- touchState.surfaceDimensions[0] = value.Data()[0];
- touchState.surfaceDimensions[1] = value.Data()[1];
- touchState.isSurfaceDimensionsValid = true;
- }
-
- GamepadTouchInformation a(aTouchArrayIndex, touchState);
- GamepadChangeEventBody body(a);
- GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
-
- uint32_t id = ++mEventNumber;
- mChild->SendGamepadTestEvent(id, e);
-}
-
JSObject* GamepadServiceTest::WrapObject(JSContext* aCx,
JS::HandleObject aGivenProto) {
return GamepadServiceTest_Binding::Wrap(aCx, this, aGivenProto);
diff --git a/dom/gamepad/GamepadServiceTest.h b/dom/gamepad/GamepadServiceTest.h
index 3e97a04385150..f4e8bf927b08e 100644
--- a/dom/gamepad/GamepadServiceTest.h
+++ b/dom/gamepad/GamepadServiceTest.h
@@ -33,10 +33,11 @@ class GamepadServiceTest final : public DOMEventTargetHelper {
GamepadHand LeftHand() const { return GamepadHand::Left; }
GamepadHand RightHand() const { return GamepadHand::Right; }
- already_AddRefed AddGamepad(
- const nsAString& aID, GamepadMappingType aMapping, GamepadHand aHand,
- uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics,
- uint32_t aNumLightIndicator, uint32_t aNumTouchEvents, ErrorResult& aRv);
+ already_AddRefed AddGamepad(const nsAString& aID,
+ GamepadMappingType aMapping,
+ GamepadHand aHand, uint32_t aNumButtons,
+ uint32_t aNumAxes, uint32_t aNumHaptics,
+ ErrorResult& aRv);
void RemoveGamepad(uint32_t aIndex);
void NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed,
bool aTouched);
@@ -49,9 +50,6 @@ class GamepadServiceTest final : public DOMEventTargetHelper {
const Nullable& aAngAcceleration,
const Nullable& aLinVelocity,
const Nullable& aLinAcceleration);
- void NewTouch(uint32_t aIndex, uint32_t aTouchArrayIndex, uint32_t aTouchId,
- uint8_t aSurfaceId, const Float32Array& aPos,
- const Nullable& aSurfDim);
void Shutdown();
static already_AddRefed CreateTestService(
diff --git a/dom/gamepad/GamepadTouch.cpp b/dom/gamepad/GamepadTouch.cpp
deleted file mode 100644
index 227b1b0cb1292..0000000000000
--- a/dom/gamepad/GamepadTouch.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- 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 aGivenProto) {
- return GamepadTouch_Binding::Wrap(aCx, this, aGivenProto);
-}
-
-void GamepadTouch::GetPosition(JSContext* aCx,
- JS::MutableHandle 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 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
diff --git a/dom/gamepad/GamepadTouch.h b/dom/gamepad/GamepadTouch.h
deleted file mode 100644
index eb961f57a0c00..0000000000000
--- a/dom/gamepad/GamepadTouch.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- 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 aGivenProto) override;
- uint32_t TouchId() const { return mTouchState.touchId; }
- uint32_t SurfaceId() const { return mTouchState.surfaceId; }
- void GetPosition(JSContext* aCx, JS::MutableHandle aRetval,
- ErrorResult& aRv);
- void GetSurfaceDimensions(JSContext* aCx,
- JS::MutableHandle aRetval,
- ErrorResult& aRv);
- void SetTouchState(const GamepadTouchState& aTouch);
- void Set(const GamepadTouch* aOther);
-
- private:
- virtual ~GamepadTouch();
-
- nsCOMPtr mParent;
- JS::Heap mPosition;
- JS::Heap mSurfaceDimensions;
- GamepadTouchState mTouchState;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_gamepad_GamepadTouch_h
diff --git a/dom/gamepad/GamepadTouchState.h b/dom/gamepad/GamepadTouchState.h
deleted file mode 100644
index 03bebf9dc4163..0000000000000
--- a/dom/gamepad/GamepadTouchState.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- 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_
diff --git a/dom/gamepad/android/AndroidGamepad.cpp b/dom/gamepad/android/AndroidGamepad.cpp
index 7bc661208d89c..9f21e825bbc94 100644
--- a/dom/gamepad/android/AndroidGamepad.cpp
+++ b/dom/gamepad/android/AndroidGamepad.cpp
@@ -26,10 +26,8 @@ class AndroidGamepadManager final
if (aAdded) {
const int svc_id = service->AddGamepad(
"android", GamepadMappingType::Standard, GamepadHand::_empty,
- kStandardGamepadButtons, kStandardGamepadAxes, 0, 0,
- 0); // TODO: Bug 680289, implement gamepad haptics for Android.
- // TODO: Bug 1523355, implement gamepad lighindicator and touch for
- // Android.
+ kStandardGamepadButtons, kStandardGamepadAxes,
+ 0); // TODO: Bug 680289, implement gamepad haptics for Android
java::AndroidGamepadManager::OnGamepadAdded(aID, svc_id);
} else {
@@ -79,10 +77,5 @@ void StopGamepadMonitoring() {
java::GeckoAppShell::GetApplicationContext());
}
-void SetGamepadLightIndicatorColor(uint32_t aControllerIdx, uint32_t aLightColorIndex,
- uint8_t aRed, uint8_t aGreen, uint8_t aBlue) {
- NS_WARNING("Android doesn't support gamepad light indicator.");
-}
-
} // namespace dom
} // namespace mozilla
diff --git a/dom/gamepad/cocoa/CocoaGamepad.cpp b/dom/gamepad/cocoa/CocoaGamepad.cpp
index d71487c27dc31..32e9fbd9f164e 100644
--- a/dom/gamepad/cocoa/CocoaGamepad.cpp
+++ b/dom/gamepad/cocoa/CocoaGamepad.cpp
@@ -304,9 +304,8 @@ void DarwinGamepadService::DeviceAdded(IOHIDDeviceRef device) {
uint32_t index = service->AddGamepad(
buffer, mozilla::dom::GamepadMappingType::_empty,
mozilla::dom::GamepadHand::_empty, (int)mGamepads[slot].numButtons(),
- (int)mGamepads[slot].numAxes(), 0, 0,
- 0); // TODO: Bug 680289, implement gamepad haptics for cocoa.
- // TODO: Bug 1523355, implement gamepad lighindicator and touch for cocoa.
+ (int)mGamepads[slot].numAxes(),
+ 0); // TODO: Bug 680289, implement gamepad haptics for cocoa
mGamepads[slot].mSuperIndex = index;
}
@@ -599,11 +598,5 @@ void StopGamepadMonitoring() {
gService->Shutdown();
}
-void SetGamepadLightIndicatorColor(uint32_t aControllerIdx, uint32_t aLightColorIndex,
- uint8_t aRed, uint8_t aGreen, uint8_t aBlue) {
- // TODO: Bug 1523353.
- NS_WARNING("Mac OS doesn't support gamepad light indicator.");
-}
-
} // namespace dom
} // namespace mozilla
diff --git a/dom/gamepad/ipc/GamepadEventChannelChild.cpp b/dom/gamepad/ipc/GamepadEventChannelChild.cpp
index 418a6aad665fb..1d5bcfbe903ab 100644
--- a/dom/gamepad/ipc/GamepadEventChannelChild.cpp
+++ b/dom/gamepad/ipc/GamepadEventChannelChild.cpp
@@ -43,7 +43,7 @@ void GamepadEventChannelChild::AddPromise(const uint32_t& aID,
mPromiseList.Put(aID, aPromise);
}
-mozilla::ipc::IPCResult GamepadEventChannelChild::RecvReplyGamepadPromise(
+mozilla::ipc::IPCResult GamepadEventChannelChild::RecvReplyGamepadVibrateHaptic(
const uint32_t& aPromiseID) {
RefPtr p;
if (!mPromiseList.Get(aPromiseID, getter_AddRefs(p))) {
diff --git a/dom/gamepad/ipc/GamepadEventChannelChild.h b/dom/gamepad/ipc/GamepadEventChannelChild.h
index c5c5cc86ba116..d87de8ef84274 100644
--- a/dom/gamepad/ipc/GamepadEventChannelChild.h
+++ b/dom/gamepad/ipc/GamepadEventChannelChild.h
@@ -17,7 +17,8 @@ class GamepadEventChannelChild final : public PGamepadEventChannelChild {
~GamepadEventChannelChild() {}
mozilla::ipc::IPCResult RecvGamepadUpdate(
const GamepadChangeEvent& aGamepadEvent);
- mozilla::ipc::IPCResult RecvReplyGamepadPromise(const uint32_t& aPromiseID);
+ mozilla::ipc::IPCResult RecvReplyGamepadVibrateHaptic(
+ const uint32_t& aPromiseID);
void AddPromise(const uint32_t& aID, dom::Promise* aPromise);
private:
diff --git a/dom/gamepad/ipc/GamepadEventChannelParent.cpp b/dom/gamepad/ipc/GamepadEventChannelParent.cpp
index d90aedfba4b8a..a6e50e4526dc4 100644
--- a/dom/gamepad/ipc/GamepadEventChannelParent.cpp
+++ b/dom/gamepad/ipc/GamepadEventChannelParent.cpp
@@ -76,37 +76,19 @@ mozilla::ipc::IPCResult GamepadEventChannelParent::RecvVibrateHaptic(
const uint32_t& aPromiseID) {
// TODO: Bug 680289, implement for standard gamepads
- if (SendReplyGamepadPromise(aPromiseID)) {
+ if (SendReplyGamepadVibrateHaptic(aPromiseID)) {
return IPC_OK();
}
- return IPC_FAIL(this, "SendReplyGamepadPromise fail.");
+ return IPC_FAIL(this, "SendReplyGamepadVibrateHaptic fail.");
}
mozilla::ipc::IPCResult GamepadEventChannelParent::RecvStopVibrateHaptic(
- const uint32_t& aControllerIdx) {
+ const uint32_t& aGamepadIndex) {
// TODO: Bug 680289, implement for standard gamepads
return IPC_OK();
}
-mozilla::ipc::IPCResult GamepadEventChannelParent::RecvLightIndicatorColor(
- const uint32_t& aControllerIdx, const uint32_t& aLightColorIndex,
- const uint8_t& aRed, const uint8_t& aGreen, const uint8_t& aBlue,
- const uint32_t& aPromiseID) {
- // It may be called because IPDL child side crashed, we'll
- // not receive RecvGamepadListenerRemoved in that case
- if (mHasGamepadListener) {
- SetGamepadLightIndicatorColor(aControllerIdx, aLightColorIndex, aRed,
- aGreen, aBlue);
- }
-
- if (SendReplyGamepadPromise(aPromiseID)) {
- return IPC_OK();
- }
-
- return IPC_FAIL(this, "SendReplyGamepadPromise fail.");
-}
-
void GamepadEventChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
AssertIsOnBackgroundThread();
diff --git a/dom/gamepad/ipc/GamepadEventChannelParent.h b/dom/gamepad/ipc/GamepadEventChannelParent.h
index 3e39b8d3ac634..03d05a95c0c8f 100644
--- a/dom/gamepad/ipc/GamepadEventChannelParent.h
+++ b/dom/gamepad/ipc/GamepadEventChannelParent.h
@@ -23,11 +23,7 @@ class GamepadEventChannelParent final : public PGamepadEventChannelParent {
const double& aIntensity,
const double& aDuration,
const uint32_t& aPromiseID);
- mozilla::ipc::IPCResult RecvStopVibrateHaptic(const uint32_t& aControllerIdx);
- mozilla::ipc::IPCResult RecvLightIndicatorColor(
- const uint32_t& aControllerIdx, const uint32_t& aLightColorIndex,
- const uint8_t& aRed, const uint8_t& aGreen, const uint8_t& aBlue,
- const uint32_t& aPromiseID);
+ mozilla::ipc::IPCResult RecvStopVibrateHaptic(const uint32_t& aGamepadIndex);
void DispatchUpdateEvent(const GamepadChangeEvent& aEvent);
bool HasGamepadListener() const { return mHasGamepadListener; }
diff --git a/dom/gamepad/ipc/GamepadEventTypes.ipdlh b/dom/gamepad/ipc/GamepadEventTypes.ipdlh
index 3278f8a1cba4f..609dd296cc35a 100644
--- a/dom/gamepad/ipc/GamepadEventTypes.ipdlh
+++ b/dom/gamepad/ipc/GamepadEventTypes.ipdlh
@@ -4,8 +4,6 @@
using mozilla::dom::GamepadServiceType from "mozilla/dom/GamepadMessageUtils.h";
using mozilla::dom::GamepadPoseState from "mozilla/dom/GamepadMessageUtils.h";
-using mozilla::dom::GamepadTouchState from "mozilla/dom/GamepadMessageUtils.h";
-using mozilla::dom::GamepadLightIndicatorType from "mozilla/dom/GamepadMessageUtils.h";
using mozilla::dom::GamepadMappingType from "mozilla/dom/GamepadMessageUtils.h";
using mozilla::dom::GamepadHand from "mozilla/dom/GamepadMessageUtils.h";
@@ -21,8 +19,6 @@ struct GamepadAdded {
uint32_t num_buttons;
uint32_t num_axes;
uint32_t num_haptics;
- uint32_t num_lights;
- uint32_t num_touches;
};
struct GamepadRemoved {};
@@ -43,29 +39,17 @@ struct GamepadPoseInformation {
GamepadPoseState pose_state;
};
-struct GamepadLightIndicatorTypeInformation {
- uint32_t light;
- GamepadLightIndicatorType type;
-};
-
struct GamepadHandInformation {
GamepadHand hand;
};
-struct GamepadTouchInformation {
- uint32_t index;
- GamepadTouchState touch_state;
-};
-
union GamepadChangeEventBody {
GamepadAdded;
GamepadRemoved;
GamepadAxisInformation;
GamepadButtonInformation;
- GamepadHandInformation;
- GamepadLightIndicatorTypeInformation;
GamepadPoseInformation;
- GamepadTouchInformation;
+ GamepadHandInformation;
};
struct GamepadChangeEvent {
diff --git a/dom/gamepad/ipc/GamepadMessageUtils.h b/dom/gamepad/ipc/GamepadMessageUtils.h
index 8270751e00935..238538b6619a5 100644
--- a/dom/gamepad/ipc/GamepadMessageUtils.h
+++ b/dom/gamepad/ipc/GamepadMessageUtils.h
@@ -9,21 +9,11 @@
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/GamepadBinding.h"
-#include "mozilla/dom/GamepadLightIndicatorBinding.h"
#include "mozilla/dom/GamepadPoseState.h"
#include "mozilla/dom/GamepadServiceType.h"
-#include "mozilla/dom/GamepadTouchState.h"
namespace IPC {
-template <>
-struct ParamTraits
- : public ContiguousEnumSerializer<
- mozilla::dom::GamepadLightIndicatorType,
- mozilla::dom::GamepadLightIndicatorType(0),
- mozilla::dom::GamepadLightIndicatorType(
- mozilla::dom::GamepadLightIndicatorType::EndGuard_)> {};
-
template <>
struct ParamTraits
: public ContiguousEnumSerializer<
@@ -109,35 +99,6 @@ struct ParamTraits {
}
};
-template <>
-struct ParamTraits {
- typedef mozilla::dom::GamepadTouchState paramType;
-
- static void Write(Message* aMsg, const paramType& aParam) {
- WriteParam(aMsg, aParam.touchId);
- WriteParam(aMsg, aParam.surfaceId);
- WriteParam(aMsg, aParam.position[0]);
- WriteParam(aMsg, aParam.position[1]);
- WriteParam(aMsg, aParam.surfaceDimensions[0]);
- WriteParam(aMsg, aParam.surfaceDimensions[1]);
- WriteParam(aMsg, aParam.isSurfaceDimensionsValid);
- }
-
- static bool Read(const Message* aMsg, PickleIterator* aIter,
- paramType* aResult) {
- if (!ReadParam(aMsg, aIter, &(aResult->touchId)) ||
- !ReadParam(aMsg, aIter, &(aResult->surfaceId)) ||
- !ReadParam(aMsg, aIter, &(aResult->position[0])) ||
- !ReadParam(aMsg, aIter, &(aResult->position[1])) ||
- !ReadParam(aMsg, aIter, &(aResult->surfaceDimensions[0])) ||
- !ReadParam(aMsg, aIter, &(aResult->surfaceDimensions[1])) ||
- !ReadParam(aMsg, aIter, &(aResult->isSurfaceDimensionsValid))) {
- return false;
- }
- return true;
- }
-};
-
} // namespace IPC
#endif // mozilla_dom_gamepad_GamepadMessageUtils_h
diff --git a/dom/gamepad/ipc/GamepadTestChannelParent.cpp b/dom/gamepad/ipc/GamepadTestChannelParent.cpp
index 1e99be534bd40..a9afeb03c1af9 100644
--- a/dom/gamepad/ipc/GamepadTestChannelParent.cpp
+++ b/dom/gamepad/ipc/GamepadTestChannelParent.cpp
@@ -26,8 +26,7 @@ mozilla::ipc::IPCResult GamepadTestChannelParent::RecvGamepadTestEvent(
LossyCopyUTF16toASCII(a.id(), gamepadID);
uint32_t index = service->AddGamepad(
gamepadID.get(), static_cast(a.mapping()), a.hand(),
- a.num_buttons(), a.num_axes(), a.num_haptics(), a.num_lights(),
- a.num_touches());
+ a.num_buttons(), a.num_axes(), a.num_haptics());
if (!mShuttingdown) {
Unused << SendReplyGamepadIndex(aID, index);
}
@@ -53,11 +52,6 @@ mozilla::ipc::IPCResult GamepadTestChannelParent::RecvGamepadTestEvent(
service->NewPoseEvent(index, a.pose_state());
return IPC_OK();
}
- if (body.type() == GamepadChangeEventBody::TGamepadTouchInformation) {
- const GamepadTouchInformation& a = body.get_GamepadTouchInformation();
- service->NewMultiTouchEvent(index, a.index(), a.touch_state());
- return IPC_OK();
- }
NS_WARNING("Unknown event type.");
return IPC_FAIL_NO_REASON(this);
diff --git a/dom/gamepad/ipc/PGamepadEventChannel.ipdl b/dom/gamepad/ipc/PGamepadEventChannel.ipdl
index 28b8908663803..a8d53b37bd06b 100644
--- a/dom/gamepad/ipc/PGamepadEventChannel.ipdl
+++ b/dom/gamepad/ipc/PGamepadEventChannel.ipdl
@@ -14,14 +14,12 @@ async protocol PGamepadEventChannel {
async GamepadListenerRemoved();
async VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
double aIntensity, double aDuration, uint32_t aPromiseID);
- async StopVibrateHaptic(uint32_t aControllerIdx);
- async LightIndicatorColor(uint32_t aControllerIdx, uint32_t aLightColorIndex,
- uint8_t aRed, uint8_t aGreen, uint8_t aBlue, uint32_t aPromiseID);
+ async StopVibrateHaptic(uint32_t aGamepadIndex);
child:
async __delete__();
async GamepadUpdate(GamepadChangeEvent aGamepadEvent);
- async ReplyGamepadPromise(uint32_t aPromiseID);
+ async ReplyGamepadVibrateHaptic(uint32_t aPromiseID);
};
}
diff --git a/dom/gamepad/linux/LinuxGamepad.cpp b/dom/gamepad/linux/LinuxGamepad.cpp
index 0b2e92285092f..bb6af15c8c903 100644
--- a/dom/gamepad/linux/LinuxGamepad.cpp
+++ b/dom/gamepad/linux/LinuxGamepad.cpp
@@ -138,9 +138,8 @@ void LinuxGamepadService::AddDevice(struct udev_device* dev) {
gamepad.index = service->AddGamepad(
gamepad.idstring, mozilla::dom::GamepadMappingType::_empty,
- mozilla::dom::GamepadHand::_empty, gamepad.numButtons, gamepad.numAxes, 0,
- 0, 0); // TODO: Bug 680289, implement gamepad haptics for Linux.
- // TODO: Bug 1523355, implement gamepad lighindicator and touch for Linux.
+ mozilla::dom::GamepadHand::_empty, gamepad.numButtons, gamepad.numAxes,
+ 0); // TODO: Bug 680289, implement gamepad haptics for Linux.
gamepad.source_id =
g_io_add_watch(channel, GIOCondition(G_IO_IN | G_IO_ERR | G_IO_HUP),
@@ -343,11 +342,5 @@ void StopGamepadMonitoring() {
gService = nullptr;
}
-void SetGamepadLightIndicatorColor(uint32_t aControllerIdx, uint32_t aLightColorIndex,
- uint8_t aRed, uint8_t aGreen, uint8_t aBlue) {
- // TODO: Bug 1523355.
- NS_WARNING("Linux doesn't support gamepad light indicator.");
-}
-
} // namespace dom
} // namespace mozilla
diff --git a/dom/gamepad/moz.build b/dom/gamepad/moz.build
index 51b813f56ea76..fb3d752f59ee0 100644
--- a/dom/gamepad/moz.build
+++ b/dom/gamepad/moz.build
@@ -17,7 +17,6 @@ EXPORTS.mozilla.dom += [
'Gamepad.h',
'GamepadButton.h',
'GamepadHapticActuator.h',
- 'GamepadLightIndicator.h',
'GamepadManager.h',
'GamepadMonitoring.h',
'GamepadPlatformService.h',
@@ -25,8 +24,6 @@ EXPORTS.mozilla.dom += [
'GamepadPoseState.h',
'GamepadRemapping.h',
'GamepadServiceTest.h',
- 'GamepadTouch.h',
- 'GamepadTouchState.h',
'ipc/GamepadEventChannelChild.h',
'ipc/GamepadEventChannelParent.h',
'ipc/GamepadMessageUtils.h',
@@ -39,14 +36,12 @@ 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',
diff --git a/dom/gamepad/windows/WindowsGamepad.cpp b/dom/gamepad/windows/WindowsGamepad.cpp
index c32993b37410e..ca7eebb2fdb56 100644
--- a/dom/gamepad/windows/WindowsGamepad.cpp
+++ b/dom/gamepad/windows/WindowsGamepad.cpp
@@ -318,9 +318,7 @@ class WindowsGamepadService {
void Shutdown();
// Parse gamepad input from a WM_INPUT message.
bool HandleRawInput(HRAWINPUT handle);
- void SetLightIndicatorColor(uint32_t aControllerIdx, uint32_t aLightIndex,
- uint8_t aRed, uint8_t aGreen, uint8_t aBlue);
- size_t WriteOutputReport(const std::vector& aReport);
+
static void XInputMessageLoopOnceCallback(nsITimer* aTimer, void* aClosure);
static void DevicesChangeCallback(nsITimer* aTimer, void* aService);
@@ -344,7 +342,6 @@ class WindowsGamepadService {
nsTArray mGamepads;
HIDLoader mHID;
- nsAutoHandle mHidHandle;
XInputLoader mXInput;
nsCOMPtr mDirectInputTimer;
@@ -437,7 +434,7 @@ bool WindowsGamepadService::ScanForXInputDevices() {
gamepad.state = state;
gamepad.id = service->AddGamepad(
"xinput", GamepadMappingType::Standard, GamepadHand::_empty,
- kStandardGamepadButtons, kStandardGamepadAxes, 0, 0,
+ kStandardGamepadButtons, kStandardGamepadAxes,
0); // TODO: Bug 680289, implement gamepad haptics for Windows.
mGamepads.AppendElement(gamepad);
}
@@ -628,19 +625,18 @@ bool WindowsGamepadService::GetRawGamepad(HANDLE handle) {
wchar_t name[128] = {0};
size = sizeof(name);
nsTArray gamepad_name;
- // Creating this file with FILE_FLAG_OVERLAPPED to perform
- // an asynchronous request in WriteOutputReport.
- mHidHandle.own(CreateFile(devname.Elements(), GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
- OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr));
- if (mHidHandle != INVALID_HANDLE_VALUE) {
- if (mHID.mHidD_GetProductString(mHidHandle, &name, size)) {
+ const HANDLE hid_handle = CreateFile(
+ devname.Elements(), GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ if (hid_handle) {
+ if (mHID.mHidD_GetProductString(hid_handle, &name, size)) {
int bytes = WideCharToMultiByte(CP_UTF8, 0, name, -1, nullptr, 0, nullptr,
nullptr);
gamepad_name.SetLength(bytes);
WideCharToMultiByte(CP_UTF8, 0, name, -1, gamepad_name.Elements(), bytes,
nullptr, nullptr);
}
+ CloseHandle(hid_handle);
}
if (gamepad_name.Length() == 0 || !gamepad_name[0]) {
const char kUnknown[] = "Unknown Gamepad";
@@ -721,21 +717,9 @@ bool WindowsGamepadService::GetRawGamepad(HANDLE handle) {
}
gamepad.remapper = remapper.forget();
- // TODO: Bug 680289, implement gamepad haptics for Windows.
gamepad.id = service->AddGamepad(
gamepad_id, gamepad.remapper->GetMappingType(), GamepadHand::_empty,
- gamepad.remapper->GetButtonCount(), gamepad.remapper->GetAxisCount(), 0,
- gamepad.remapper->GetLightIndicatorCount(),
- gamepad.remapper->GetTouchEventCount());
-
- nsTArray lightTypes;
- gamepad.remapper->GetLightIndicators(lightTypes);
- for (uint32_t i = 0; i < lightTypes.Length(); ++i) {
- if (lightTypes[i] != GamepadLightIndicator::DefaultType()) {
- service->NewLightIndicatorTypeEvent(gamepad.id, i, lightTypes[i]);
- }
- }
-
+ gamepad.remapper->GetButtonCount(), gamepad.remapper->GetAxisCount(), 0);
mGamepads.AppendElement(gamepad);
return true;
}
@@ -849,81 +833,9 @@ bool WindowsGamepadService::HandleRawInput(HRAWINPUT handle) {
}
}
- BYTE* rawData = raw->data.hid.bRawData;
- gamepad->remapper->GetTouchData(gamepad->id, rawData);
-
return true;
}
-void WindowsGamepadService::SetLightIndicatorColor(uint32_t aControllerIdx,
- uint32_t aLightColorIndex,
- uint8_t aRed, uint8_t aGreen,
- uint8_t aBlue) {
- // We get aControllerIdx from GamepadPlatformService::AddGamepad(),
- // It begins from 1 and is stored at Gamepad.id.
- const Gamepad* gamepad = nullptr;
- for (const auto& pad : mGamepads) {
- if (pad.id == aControllerIdx) {
- gamepad = &pad;
- break;
- }
- }
- if (!gamepad) {
- MOZ_ASSERT(false);
- return;
- }
-
- RefPtr remapper = gamepad->remapper;
- if (!remapper || remapper->GetLightIndicatorCount() <= aLightColorIndex) {
- MOZ_ASSERT(false);
- return;
- }
-
- std::vector report;
- remapper->GetLightColorReport(aRed, aGreen, aBlue, report);
- WriteOutputReport(report);
-}
-
-size_t WindowsGamepadService::WriteOutputReport(
- const std::vector& aReport) {
- DCHECK(static_cast(aReport.data()));
- DCHECK_GE(aReport.size(), 1U);
- if (!mHidHandle) return 0;
-
- nsAutoHandle eventHandle(::CreateEvent(nullptr, FALSE, FALSE, nullptr));
- OVERLAPPED overlapped = {0};
- overlapped.hEvent = eventHandle;
-
- // Doing an asynchronous write to allows us to time out
- // if the write takes too long.
- DWORD bytesWritten = 0;
- BOOL writeSuccess =
- ::WriteFile(mHidHandle, static_cast(aReport.data()),
- aReport.size(), &bytesWritten, &overlapped);
- if (!writeSuccess) {
- DWORD error = ::GetLastError();
- if (error == ERROR_IO_PENDING) {
- // Wait for the write to complete. This causes WriteOutputReport to behave
- // synchronously but with a timeout.
- DWORD wait_object = ::WaitForSingleObject(overlapped.hEvent, 100);
- if (wait_object == WAIT_OBJECT_0) {
- if (!::GetOverlappedResult(mHidHandle, &overlapped, &bytesWritten,
- TRUE)) {
- return 0;
- }
- } else {
- // Wait failed, or the timeout was exceeded before the write completed.
- // Cancel the write request.
- if (::CancelIo(mHidHandle)) {
- wait_object = ::WaitForSingleObject(overlapped.hEvent, INFINITE);
- MOZ_ASSERT(wait_object == WAIT_OBJECT_0);
- }
- }
- }
- }
- return writeSuccess ? bytesWritten : 0;
-}
-
void WindowsGamepadService::Startup() { ScanForDevices(); }
void WindowsGamepadService::Shutdown() { Cleanup(); }
@@ -939,7 +851,6 @@ void WindowsGamepadService::Cleanup() {
if (mDeviceChangeTimer) {
mDeviceChangeTimer->Cancel();
}
-
mGamepads.Clear();
}
@@ -1090,16 +1001,5 @@ void StopGamepadMonitoring() {
gMonitorThread = nullptr;
}
-void SetGamepadLightIndicatorColor(uint32_t aControllerIdx,
- uint32_t aLightColorIndex, uint8_t aRed,
- uint8_t aGreen, uint8_t aBlue) {
- MOZ_ASSERT(gService);
- if (!gService) {
- return;
- }
- gService->SetLightIndicatorColor(aControllerIdx, aLightColorIndex, aRed,
- aGreen, aBlue);
-}
-
} // namespace dom
} // namespace mozilla
diff --git a/dom/tests/mochitest/gamepad/mochitest.ini b/dom/tests/mochitest/gamepad/mochitest.ini
index 7b2ce6f72827d..1ea908fd792bb 100644
--- a/dom/tests/mochitest/gamepad/mochitest.ini
+++ b/dom/tests/mochitest/gamepad/mochitest.ini
@@ -12,13 +12,9 @@ support-files = test_gamepad_iframe.html
support-files = test_gamepad_connect_events_iframe.html
[test_gamepad_extensions.html]
support-files = test_gamepad_extensions_iframe.html
-scheme = https
[test_gamepad_frame_state_sync.html]
support-files = test_gamepad_frame_state_sync_iframe.html
[test_gamepad_hidden_frame.html]
support-files = test_gamepad_hidden_frame_iframe.html
-[test_gamepad_multitouch_crossorigin.html]
-support-files = test_gamepad_multitouch_crossorigin_iframe.html
-scheme = https
[test_navigator_gamepads.html]
support-files = test_navigator_gamepads_iframe.html
diff --git a/dom/tests/mochitest/gamepad/test_check_timestamp_iframe.html b/dom/tests/mochitest/gamepad/test_check_timestamp_iframe.html
index 44fef0fee61fd..d9830cda5c947 100644
--- a/dom/tests/mochitest/gamepad/test_check_timestamp_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_check_timestamp_iframe.html
@@ -30,8 +30,6 @@
GamepadService.noHand,
4,
2,
- 0,
- 0,
0).then(function(i) {
index = i;
// Press a button to make the gamepad visible
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_connect_events_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_connect_events_iframe.html
index 5848508bd5241..352a7076335ac 100644
--- a/dom/tests/mochitest/gamepad/test_gamepad_connect_events_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_connect_events_iframe.html
@@ -37,8 +37,6 @@
GamepadService.noHand,
4, // buttons
2,
- 0,
- 0,
0).then(function(i) {
gamepad_index = i;
gamepad_connected()
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html
index 91f0ea76362a6..02352e1582f70 100644
--- a/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html
@@ -17,9 +17,7 @@
var tests = [
poseadd,
posecheck,
- touchadd,
- touchcheck,
- haptictest // Keep haptictest at the last because it will test removing gamepad from the service.
+ haptictest
];
var gamepad_index = 0;
var testNum = 0;
@@ -29,8 +27,6 @@
var poseAngAcc = new Float32Array([-0.494, 0.476, -0.241]);
var poseLinVel = new Float32Array([0.003,0.024,-0.068]);
var poseLinAcc = new Float32Array([-1.211,21.427,-2.348]);
-var touchData = [{touchId: 0, surfaceId: 0, pos: new Float32Array([-0.5, 0.5]), surf: new Float32Array([100, 100])},
- {touchId: 1, surfaceId: 0, pos: new Float32Array([-0.1, 1.0]), surf: new Float32Array([100, 100])}];
window.addEventListener("gamepadconnected", connecthandler);
window.addEventListener("gamepadbuttondown", function() {
@@ -44,19 +40,14 @@
}
function startTest() {
- SpecialPowers.pushPrefEnv({ "set": [
- ["dom.gamepad.extensions.enabled", true],
- ["dom.gamepad.extensions.lightindicator", true],
- ["dom.gamepad.extensions.multitouch", true]] });
+ SpecialPowers.pushPrefEnv({ "set": [["dom.gamepad.extensions.enabled", true]] });
// Add a gamepad
GamepadService.addGamepad("test gamepad", // id
GamepadService.standardMapping,
GamepadService.leftHand,
4,
2,
- 1,
- 1,
- 2).then(function(i) {
+ 1).then(function(i) {
gamepad_index = i;
// Simulate button events on the gamepad we added
pressButton();
@@ -73,8 +64,6 @@
is(e.gamepad.buttons.length, 4, "correct number of buttons");
is(e.gamepad.axes.length, 2, "correct number of axes");
is(e.gamepad.hapticActuators.length, 1, "correct number of haptics");
- is(e.gamepad.lightIndicators.length, 1, "correct number of light indicators");
- is(e.gamepad.touchEvents.length, 2, "correct number of touches");
}
function checkValueInFloat32Array(array1, array2) {
@@ -140,41 +129,6 @@
setFrameVisible(f1, false);
}
-function touchadd() {
- var count = 0;
- touchData.forEach(function(touch) {
- GamepadService.newTouch(gamepad_index, count, touch.touchId,
- touch.surfaceId, touch.pos,
- touch.surf);
- ++count;
- });
-
- pressButton();
-}
-
-function touchcheck() {
- var gamepads = navigator.getGamepads();
- var touches = gamepads[0].touchEvents;
-
- is(touches.length, 2, " number of touches");
-
- var count = 0;
- touches.forEach(function(touch) {
- is(touch.touchId, touchData[count].touchId,
- "correct GamepadTouch touchId");
- is(touch.surfaceId, touchData[count].surfaceId,
- "correct GamepadTouch surfaceId");
- is(checkValueInFloat32Array(touch.position, touchData[count].pos), true,
- "correct touch position");
- is(checkValueInFloat32Array(touch.surfaceDimensions, touchData[count].surf), true,
- "correct touch surfaceDimensions");
-
- ++count;
- });
-
- pressButton();
-}
-
-
-
-
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html
index 808f88243a18c..71fdd83b86546 100644
--- a/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html
@@ -32,8 +32,6 @@
GamepadService.noHand,
4, // buttons
2,
- 0,
- 0,
0).then(function(i) {
index = i;
gamepad_loaded();
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html
index 818dcd5ce9a0f..c12b773cb2334 100644
--- a/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html
@@ -39,8 +39,6 @@
GamepadService.noHand,
4, // buttons
2,
- 0,
- 0,
0).then(function(i) {
index = i;
gamepad_loaded();
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_iframe.html
index 3247f24c91484..5ca7df3d6286f 100644
--- a/dom/tests/mochitest/gamepad/test_gamepad_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_iframe.html
@@ -39,8 +39,6 @@
GamepadService.noHand,
4,
2,
- 0,
- 0,
0).then(function(i) {
index = i;
// Simulate button events on the gamepad we added
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_multitouch_crossorigin.html b/dom/tests/mochitest/gamepad/test_gamepad_multitouch_crossorigin.html
deleted file mode 100644
index 244b2f18dcd49..0000000000000
--- a/dom/tests/mochitest/gamepad/test_gamepad_multitouch_crossorigin.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-