diff --git a/dom/gamepad/GamepadManager.cpp b/dom/gamepad/GamepadManager.cpp index 44ec2d0b1e13..8f99acf8047a 100644 --- a/dom/gamepad/GamepadManager.cpp +++ b/dom/gamepad/GamepadManager.cpp @@ -226,6 +226,7 @@ GamepadManager::AddGamepad(uint32_t aIndex, GamepadMappingType aMapping, GamepadHand aHand, GamepadServiceType aServiceType, + uint32_t aDisplayID, uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics) @@ -240,6 +241,7 @@ GamepadManager::AddGamepad(uint32_t aIndex, newIndex, aMapping, aHand, + aDisplayID, aNumButtons, aNumAxes, aNumHaptics); @@ -509,6 +511,7 @@ GamepadManager::Update(const GamepadChangeEvent& aEvent) static_cast(a.mapping()), static_cast(a.hand()), a.service_type(), + a.display_id(), a.num_buttons(), a.num_axes(), a.num_haptics()); return; diff --git a/dom/gamepad/GamepadManager.h b/dom/gamepad/GamepadManager.h index 88afde38a449..1ac2127ea82f 100644 --- a/dom/gamepad/GamepadManager.h +++ b/dom/gamepad/GamepadManager.h @@ -51,7 +51,7 @@ class GamepadManager final : public nsIObserver, // Add a gamepad to the list of known gamepads. void AddGamepad(uint32_t aIndex, const nsAString& aID, GamepadMappingType aMapping, - GamepadHand aHand, GamepadServiceType aServiceType, + GamepadHand aHand, GamepadServiceType aServiceType, uint32_t aDisplayID, uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics); // Remove the gamepad at |aIndex| from the list of known gamepads. diff --git a/dom/gamepad/GamepadPlatformService.cpp b/dom/gamepad/GamepadPlatformService.cpp index 5ecd0cf9a091..b09cd7f43205 100644 --- a/dom/gamepad/GamepadPlatformService.cpp +++ b/dom/gamepad/GamepadPlatformService.cpp @@ -96,9 +96,10 @@ GamepadPlatformService::AddGamepad(const char* aID, MOZ_ASSERT(!NS_IsMainThread()); uint32_t index = ++mGamepadIndex; + // Only VR controllers has displayID, we give 0 to the general gamepads. GamepadAdded a(NS_ConvertUTF8toUTF16(nsDependentCString(aID)), index, aMapping, aHand, GamepadServiceType::Standard, - aNumButtons, aNumAxes, aHaptics); + 0, aNumButtons, aNumAxes, aHaptics); NotifyGamepadChange(a); return index; diff --git a/dom/gamepad/GamepadServiceTest.cpp b/dom/gamepad/GamepadServiceTest.cpp index a1bd71a71cf2..d833dd66c28b 100644 --- a/dom/gamepad/GamepadServiceTest.cpp +++ b/dom/gamepad/GamepadServiceTest.cpp @@ -123,9 +123,10 @@ GamepadServiceTest::AddGamepad(const nsAString& aID, return nullptr; } + // Only VR controllers has displayID, we give 0 to the general gamepads. GamepadAdded a(nsString(aID), 0, aMapping, aHand, - GamepadServiceType::Standard, + GamepadServiceType::Standard, 0, aNumButtons, aNumAxes, aNumHaptics); GamepadChangeEvent e(a); nsCOMPtr go = do_QueryInterface(mWindow); diff --git a/dom/gamepad/ipc/GamepadEventTypes.ipdlh b/dom/gamepad/ipc/GamepadEventTypes.ipdlh index b13a22e9f937..36a224dd5389 100644 --- a/dom/gamepad/ipc/GamepadEventTypes.ipdlh +++ b/dom/gamepad/ipc/GamepadEventTypes.ipdlh @@ -17,6 +17,7 @@ struct GamepadAdded { GamepadMappingType mapping; GamepadHand hand; GamepadServiceType service_type; + uint32_t display_id; uint32_t num_buttons; uint32_t num_axes; uint32_t num_haptics;