Bug 1382438 - Part 1: Get gamepads from globalWindow correctly for button and axis events; r=Lenzak
authorDaosheng Mu <daoshengmu@gmail.com>
Thu, 27 Jul 2017 11:22:29 +0800
changeset 422640 f29dc4908f511f15c2664417f6b96b571c39f8f8
parent 422639 047029e0a1d4b5a5dcad3c70d31a25f8352d38ab
child 422641 425118d805ee9b3b71c942ad29a32b15c769fbea
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersLenzak
bugs1382438
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382438 - Part 1: Get gamepads from globalWindow correctly for button and axis events; r=Lenzak MozReview-Commit-ID: rB9ahFuozO
dom/gamepad/GamepadManager.cpp
--- a/dom/gamepad/GamepadManager.cpp
+++ b/dom/gamepad/GamepadManager.cpp
@@ -553,17 +553,19 @@ GamepadManager::MaybeConvertToNonstandar
                                                       nsGlobalWindow* aWindow)
 {
   MOZ_ASSERT(aWindow);
 
   if (!mNonstandardEventsEnabled) {
     return;
   }
 
-  RefPtr<Gamepad> gamepad = aWindow->GetGamepad(aEvent.index());
+  const uint32_t index = GetGamepadIndexWithServiceType(aEvent.index(),
+                                                        aEvent.service_type());
+  RefPtr<Gamepad> gamepad = aWindow->GetGamepad(index);
   const GamepadChangeEventBody& body = aEvent.body();
 
   if (gamepad) {
     switch (body.type()) {
       case GamepadChangeEventBody::TGamepadButtonInformation:
       {
         const GamepadButtonInformation& a = body.get_GamepadButtonInformation();
         FireButtonEvent(aWindow, gamepad, a.button(), a.value());
@@ -581,17 +583,16 @@ GamepadManager::MaybeConvertToNonstandar
   }
 }
 
 bool
 GamepadManager::SetGamepadByEvent(const GamepadChangeEvent& aEvent, nsGlobalWindow *aWindow)
 {
   bool ret = false;
   bool firstTime = false;
-
   const uint32_t index = GetGamepadIndexWithServiceType(aEvent.index(),
                                                         aEvent.service_type());
   if (aWindow) {
     firstTime = MaybeWindowHasSeenGamepad(aWindow, index);
   }
 
   RefPtr<Gamepad> gamepad = aWindow ? aWindow->GetGamepad(index) : GetGamepad(index);
   const GamepadChangeEventBody& body = aEvent.body();