Bug 1382438 - Part 2: Replace vr controller displayId test with gamepadbuttondown event; r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Thu, 27 Jul 2017 11:25:45 +0800
changeset 420239 425118d805ee9b3b71c942ad29a32b15c769fbea
parent 420238 f29dc4908f511f15c2664417f6b96b571c39f8f8
child 420240 4faf41ca4755a791330ebff0bcb86f86f1ae5a8b
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
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 2: Replace vr controller displayId test with gamepadbuttondown event; r=kip MozReview-Commit-ID: DSTg2IS407e
dom/vr/test/mochitest/mochitest.ini
dom/vr/test/mochitest/test_vrController_displayId.html
gfx/vr/gfxVRPuppet.cpp
--- a/dom/vr/test/mochitest/mochitest.ini
+++ b/dom/vr/test/mochitest/mochitest.ini
@@ -1,18 +1,18 @@
 [DEFAULT]
 support-files =
   VRSimulationDriver.js
   requestPresent.js
   runVRTest.js
   WebVRHelpers.js
 
 [test_vrController_displayId.html]
-# Enable Linux after Bug 1310655 # TIMED_OUT for nonE10s and Android.
-skip-if = (os != "win" && release_or_beta) || (!e10s) || (os == "android")
+# Enable Linux after Bug 1310655 # TIMED_OUT for Android.
+skip-if = (os != "win" && release_or_beta) || (os == "android")
 [test_vrDisplay_canvas2d.html]
 skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655
 [test_vrDisplay_exitPresent.html]
 skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655
 [test_vrDisplay_getFrameData.html]
 skip-if = (os != "win" && release_or_beta) # Enable Linux after Bug 1310655
 [test_vrDisplay_onvrdisplaydeactivate_crosscontent.html]
 skip-if = true
--- a/dom/vr/test/mochitest/test_vrController_displayId.html
+++ b/dom/vr/test/mochitest/test_vrController_displayId.html
@@ -20,35 +20,35 @@
           return VRSimulationDriver.AttachVRController().then((controller) => {
             controller.newButtonEvent(0, true);
           });
         }, "Finish to add VRController.");
       }
 
       function listenControllerEvents() {
         async_test(function(t) {
-          window.addEventListener("gamepadconnected", function() {
-              var gamepads = navigator.getGamepads();
-              assert_equals(gamepads[controllerCount].displayId, vrDisplay.displayId, "gamepad.displayId should be equal to vrDisplay.");
+          window.addEventListener("gamepadbuttondown", function(e) {
+              assert_equals(e.gamepad.displayId, vrDisplay.displayId, "gamepad.displayId should be equal to vrDisplay.");
               ++controllerCount;
-              if (controllerCount == 1) {
+              if (controllerCount == 2) {
                 t.done();
               }
           });
         }, "Finish to verify VRController.displayId.");
       }
 
       function startTest() {
         promise_test((test) => {
           listenControllerEvents();
           return navigator.getVRDisplays().then((displays) => {
             vrDisplay = displays[0];
             assert_equals(displays.length, 1, "displays.length must be one after attach.");
             assert_equals(displays[0].displayId, 1, "displayId must be one.");
             addController();
+            addController();
           });
         }, "Finish to add VRDisplay.");
       }
 
       runVRTest(startTest);
     </script>
   </body>
 </html>
\ No newline at end of file
--- a/gfx/vr/gfxVRPuppet.cpp
+++ b/gfx/vr/gfxVRPuppet.cpp
@@ -493,16 +493,17 @@ VRDisplayPuppet::NotifyVSync()
   mDisplayInfo.mIsConnected = true;
 
   VRDisplayHost::NotifyVSync();
 }
 
 VRControllerPuppet::VRControllerPuppet(dom::GamepadHand aHand, uint32_t aDisplayID)
   : VRControllerHost(VRDeviceType::Puppet, aHand, aDisplayID)
   , mButtonPressState(0)
+  , mButtonTouchState(0)
 {
   MOZ_COUNT_CTOR_INHERITED(VRControllerPuppet, VRControllerHost);
   mControllerInfo.mControllerName.AssignLiteral("Puppet Gamepad");
   mControllerInfo.mNumButtons = kNumPuppetButtonMask;
   mControllerInfo.mNumAxes = kNumPuppetAxis;
   mControllerInfo.mNumHaptics = kNumPuppetHaptcs;
 }
 
@@ -646,20 +647,21 @@ VRSystemManagerPuppet::GetIsPresenting()
 
 void
 VRSystemManagerPuppet::HandleInput()
 {
   RefPtr<impl::VRControllerPuppet> controller;
   for (uint32_t i = 0; i < mPuppetController.Length(); ++i) {
     controller = mPuppetController[i];
     for (uint32_t j = 0; j < kNumPuppetButtonMask; ++j) {
-      HandleButtonPress(i, j, kPuppetButtonMask[i], controller->GetButtonPressState(),
+      HandleButtonPress(i, j, kPuppetButtonMask[j], controller->GetButtonPressState(),
                         controller->GetButtonTouchState());
     }
     controller->SetButtonPressed(controller->GetButtonPressState());
+    controller->SetButtonTouched(controller->GetButtonTouchState());
 
     for (uint32_t j = 0; j < kNumPuppetAxis; ++j) {
       HandleAxisMove(i, j, controller->GetAxisMoveState(j));
     }
     HandlePoseTracking(i, controller->GetPoseMoveState(), controller);
   }
 }