--- a/dom/gamepad/GamepadManager.cpp
+++ b/dom/gamepad/GamepadManager.cpp
@@ -500,30 +500,33 @@ GamepadManager::SetWindowHasSeenGamepad(
void
GamepadManager::Update(const GamepadChangeEvent& aEvent)
{
if (!mEnabled || mShuttingDown || nsContentUtils::ShouldResistFingerprinting()) {
return;
}
- if (aEvent.type() == GamepadChangeEvent::TGamepadAdded) {
- const GamepadAdded& a = aEvent.get_GamepadAdded();
- AddGamepad(a.index(), a.id(),
+ const uint32_t index = aEvent.index();
+ GamepadServiceType serviceType = aEvent.service_type();
+ GamepadChangeEventBody body = aEvent.body();
+
+ if (body.type() == GamepadChangeEventBody::TGamepadAdded) {
+ const GamepadAdded& a = body.get_GamepadAdded();
+ AddGamepad(index, a.id(),
static_cast<GamepadMappingType>(a.mapping()),
static_cast<GamepadHand>(a.hand()),
- a.service_type(),
+ serviceType,
a.display_id(),
a.num_buttons(), a.num_axes(),
a.num_haptics());
return;
}
- if (aEvent.type() == GamepadChangeEvent::TGamepadRemoved) {
- const GamepadRemoved& a = aEvent.get_GamepadRemoved();
- RemoveGamepad(a.index(), a.service_type());
+ if (body.type() == GamepadChangeEventBody::TGamepadRemoved) {
+ RemoveGamepad(index, serviceType);
return;
}
if (!SetGamepadByEvent(aEvent)) {
return;
}
// Hold on to listeners in a separate array because firing events
@@ -550,106 +553,85 @@ GamepadManager::MaybeConvertToNonstandar
nsGlobalWindow* aWindow)
{
MOZ_ASSERT(aWindow);
if (!mNonstandardEventsEnabled) {
return;
}
- RefPtr<Gamepad> gamepad;
+ RefPtr<Gamepad> gamepad = aWindow->GetGamepad(aEvent.index());
+ const GamepadChangeEventBody& body = aEvent.body();
- switch (aEvent.type()) {
- case GamepadChangeEvent::TGamepadButtonInformation:
+ if (gamepad) {
+ switch (body.type()) {
+ case GamepadChangeEventBody::TGamepadButtonInformation:
{
- const GamepadButtonInformation& a = aEvent.get_GamepadButtonInformation();
- gamepad = aWindow->GetGamepad(a.index());
- if (gamepad) {
- FireButtonEvent(aWindow, gamepad, a.button(), a.value());
- }
+ const GamepadButtonInformation& a = body.get_GamepadButtonInformation();
+ FireButtonEvent(aWindow, gamepad, a.button(), a.value());
+ break;
}
- break;
- case GamepadChangeEvent::TGamepadAxisInformation:
+ case GamepadChangeEventBody::TGamepadAxisInformation:
{
- const GamepadAxisInformation& a = aEvent.get_GamepadAxisInformation();
- gamepad = aWindow->GetGamepad(a.index());
- if (gamepad) {
- FireAxisMoveEvent(aWindow, gamepad, a.axis(), a.value());
- }
+ const GamepadAxisInformation& a = body.get_GamepadAxisInformation();
+ FireAxisMoveEvent(aWindow, gamepad, a.axis(), a.value());
+ break;
}
- break;
- default:
- break;
+ default:
+ break;
+ }
}
}
bool
GamepadManager::SetGamepadByEvent(const GamepadChangeEvent& aEvent, nsGlobalWindow *aWindow)
{
- uint32_t index;
- RefPtr<Gamepad> gamepad;
bool ret = false;
bool firstTime = false;
- switch (aEvent.type()) {
- case GamepadChangeEvent::TGamepadButtonInformation:
- {
- const GamepadButtonInformation& a = aEvent.get_GamepadButtonInformation();
- index = GetGamepadIndexWithServiceType(a.index(), a.service_type());
- if (aWindow) {
- firstTime = MaybeWindowHasSeenGamepad(aWindow, index);
- }
- gamepad = aWindow ? aWindow->GetGamepad(index) : GetGamepad(index);
- if (gamepad) {
+ 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();
+
+ if (gamepad) {
+ switch (body.type()) {
+ case GamepadChangeEventBody::TGamepadButtonInformation:
+ {
+ const GamepadButtonInformation& a = body.get_GamepadButtonInformation();
gamepad->SetButton(a.button(), a.pressed(), a.touched(), a.value());
- ret = true;
- }
- } break;
- case GamepadChangeEvent::TGamepadAxisInformation:
- {
- const GamepadAxisInformation& a = aEvent.get_GamepadAxisInformation();
- index = GetGamepadIndexWithServiceType(a.index(), a.service_type());
- if (aWindow) {
- firstTime = MaybeWindowHasSeenGamepad(aWindow, index);
- }
- gamepad = aWindow ? aWindow->GetGamepad(index) : GetGamepad(index);
- if (gamepad) {
- gamepad->SetAxis(a.axis(), a.value());
- ret = true;
+ break;
}
- } break;
- case GamepadChangeEvent::TGamepadPoseInformation:
- {
- const GamepadPoseInformation& a = aEvent.get_GamepadPoseInformation();
- index = GetGamepadIndexWithServiceType(a.index(), a.service_type());
- if (aWindow) {
- firstTime = MaybeWindowHasSeenGamepad(aWindow, index);
+ case GamepadChangeEventBody::TGamepadAxisInformation:
+ {
+ const GamepadAxisInformation& a = body.get_GamepadAxisInformation();
+ gamepad->SetAxis(a.axis(), a.value());
+ break;
}
- gamepad = aWindow ? aWindow->GetGamepad(index) : GetGamepad(index);
- if (gamepad) {
+ case GamepadChangeEventBody::TGamepadPoseInformation:
+ {
+ const GamepadPoseInformation& a = body.get_GamepadPoseInformation();
gamepad->SetPose(a.pose_state());
- ret = true;
+ break;
}
- } break;
- case GamepadChangeEvent::TGamepadHandInformation:
- {
- const GamepadHandInformation& a = aEvent.get_GamepadHandInformation();
- index = GetGamepadIndexWithServiceType(a.index(), a.service_type());
- if (aWindow) {
- firstTime = MaybeWindowHasSeenGamepad(aWindow, index);
+ case GamepadChangeEventBody::TGamepadHandInformation:
+ {
+ const GamepadHandInformation& a = body.get_GamepadHandInformation();
+ gamepad->SetHand(a.hand());
+ break;
}
- gamepad = aWindow ? aWindow->GetGamepad(index) : GetGamepad(index);
- if (gamepad) {
- gamepad->SetHand(a.hand());
- ret = true;
- }
- } break;
- default:
- MOZ_ASSERT(false);
- break;
+ default:
+ MOZ_ASSERT(false);
+ break;
+ }
+ ret = true;
}
if (aWindow && firstTime) {
FireConnectionEvent(aWindow, gamepad, true);
}
return ret;
}
--- a/dom/gamepad/GamepadPlatformService.cpp
+++ b/dom/gamepad/GamepadPlatformService.cpp
@@ -53,24 +53,25 @@ GamepadPlatformService::GetParentService
}
}
RefPtr<GamepadPlatformService> service(gGamepadPlatformServiceSingleton);
return service.forget();
}
template<class T>
void
-GamepadPlatformService::NotifyGamepadChange(const T& aInfo)
+GamepadPlatformService::NotifyGamepadChange(uint32_t aIndex, const T& aInfo)
{
// This method is called by monitor populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
- GamepadChangeEvent e(aInfo);
+ GamepadChangeEventBody body(aInfo);
+ GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
// mChannelParents may be accessed by background thread in the
// same time, we use mutex to prevent possible race condtion
MutexAutoLock autoLock(mMutex);
// Buffer all events if we have no Channel to dispatch, which
// may happen when performing Mochitest.
if (mChannelParents.IsEmpty()) {
@@ -91,48 +92,47 @@ GamepadPlatformService::AddGamepad(const
uint32_t aHaptics)
{
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
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,
- 0, aNumButtons, aNumAxes, aHaptics);
+ GamepadAdded a(NS_ConvertUTF8toUTF16(nsDependentCString(aID)),
+ aMapping, aHand, 0, aNumButtons, aNumAxes, aHaptics);
- NotifyGamepadChange<GamepadAdded>(a);
+ NotifyGamepadChange<GamepadAdded>(index, a);
return index;
}
void
GamepadPlatformService::RemoveGamepad(uint32_t aIndex)
{
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
- GamepadRemoved a(aIndex, GamepadServiceType::Standard);
- NotifyGamepadChange<GamepadRemoved>(a);
+ GamepadRemoved a;
+ NotifyGamepadChange<GamepadRemoved>(aIndex, a);
}
void
GamepadPlatformService::NewButtonEvent(uint32_t aIndex, uint32_t aButton,
bool aPressed, bool aTouched,
double aValue)
{
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
- GamepadButtonInformation a(aIndex, GamepadServiceType::Standard,
- aButton, aValue, aPressed, aTouched);
- NotifyGamepadChange<GamepadButtonInformation>(a);
+ GamepadButtonInformation a(aButton, aValue, aPressed, aTouched);
+ NotifyGamepadChange<GamepadButtonInformation>(aIndex, a);
}
void
GamepadPlatformService::NewButtonEvent(uint32_t aIndex, uint32_t aButton,
bool aPressed, bool aTouched)
{
// This method is called by monitor thread populated in
// platform-dependent backends
@@ -157,32 +157,30 @@ GamepadPlatformService::NewButtonEvent(u
void
GamepadPlatformService::NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis,
double aValue)
{
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
- GamepadAxisInformation a(aIndex, GamepadServiceType::Standard,
- aAxis, aValue);
- NotifyGamepadChange<GamepadAxisInformation>(a);
+ GamepadAxisInformation a(aAxis, aValue);
+ NotifyGamepadChange<GamepadAxisInformation>(aIndex, a);
}
void
GamepadPlatformService::NewPoseEvent(uint32_t aIndex,
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(aIndex, GamepadServiceType::Standard,
- aPose);
- NotifyGamepadChange<GamepadPoseInformation>(a);
+ GamepadPoseInformation a(aPose);
+ NotifyGamepadChange<GamepadPoseInformation>(aIndex, a);
}
void
GamepadPlatformService::ResetGamepadIndexes()
{
// This method is called by monitor thread populated in
// platform-dependent backends
MOZ_ASSERT(XRE_IsParentProcess());
--- a/dom/gamepad/GamepadPlatformService.h
+++ b/dom/gamepad/GamepadPlatformService.h
@@ -76,17 +76,17 @@ class GamepadPlatformService final
bool HasGamepadListeners();
void MaybeShutdown();
private:
GamepadPlatformService();
~GamepadPlatformService();
- template<class T> void NotifyGamepadChange(const T& aInfo);
+ template<class T> void NotifyGamepadChange(uint32_t aIndex, const T& aInfo);
// Flush all pending events buffered in mPendingEvents, must be called
// with mMutex held
void FlushPendingEvents();
void Cleanup();
// mGamepadIndex can only be accessed by monitor thread
uint32_t mGamepadIndex;
--- a/dom/gamepad/GamepadServiceTest.cpp
+++ b/dom/gamepad/GamepadServiceTest.cpp
@@ -119,21 +119,21 @@ GamepadServiceTest::AddGamepad(const nsA
uint32_t aNumHaptics,
ErrorResult& aRv)
{
if (mShuttingDown) {
return nullptr;
}
// Only VR controllers has displayID, we give 0 to the general gamepads.
- GamepadAdded a(nsString(aID), 0,
- aMapping, aHand,
- GamepadServiceType::Standard, 0,
+ GamepadAdded a(nsString(aID),
+ aMapping, aHand, 0,
aNumButtons, aNumAxes, aNumHaptics);
- GamepadChangeEvent e(a);
+ GamepadChangeEventBody body(a);
+ GamepadChangeEvent e(0, GamepadServiceType::Standard, body);
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
RefPtr<Promise> p = Promise::Create(go, aRv);
if (aRv.Failed()) {
return nullptr;
}
uint32_t id = ++mEventNumber;
@@ -149,18 +149,19 @@ GamepadServiceTest::AddGamepad(const nsA
void
GamepadServiceTest::RemoveGamepad(uint32_t aIndex)
{
if (mShuttingDown) {
return;
}
- GamepadRemoved a(aIndex, GamepadServiceType::Standard);
- GamepadChangeEvent e(a);
+ GamepadRemoved a;
+ GamepadChangeEventBody body(a);
+ GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
uint32_t id = ++mEventNumber;
if (mChild) {
mChild->SendGamepadTestEvent(id, e);
} else {
PendingOperation op(id, e);
mPendingOperations.AppendElement(op);
}
@@ -171,19 +172,19 @@ GamepadServiceTest::NewButtonEvent(uint3
uint32_t aButton,
bool aTouched,
bool aPressed)
{
if (mShuttingDown) {
return;
}
- GamepadButtonInformation a(aIndex, GamepadServiceType::Standard,
- aButton, aPressed ? 1.0 : 0, aPressed, aTouched);
- GamepadChangeEvent e(a);
+ GamepadButtonInformation a(aButton, aPressed ? 1.0 : 0, aPressed, aTouched);
+ GamepadChangeEventBody body(a);
+ GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
uint32_t id = ++mEventNumber;
if (mChild) {
mChild->SendGamepadTestEvent(id, e);
} else {
PendingOperation op(id, e);
mPendingOperations.AppendElement(op);
}
@@ -195,19 +196,19 @@ GamepadServiceTest::NewButtonValueEvent(
bool aPressed,
bool aTouched,
double aValue)
{
if (mShuttingDown) {
return;
}
- GamepadButtonInformation a(aIndex, GamepadServiceType::Standard,
- aButton, aValue, aPressed, aTouched);
- GamepadChangeEvent e(a);
+ GamepadButtonInformation a(aButton, aValue, aPressed, aTouched);
+ GamepadChangeEventBody body(a);
+ GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
uint32_t id = ++mEventNumber;
if (mChild) {
mChild->SendGamepadTestEvent(id, e);
} else {
PendingOperation op(id, e);
mPendingOperations.AppendElement(op);
}
@@ -217,19 +218,19 @@ void
GamepadServiceTest::NewAxisMoveEvent(uint32_t aIndex,
uint32_t aAxis,
double aValue)
{
if (mShuttingDown) {
return;
}
- GamepadAxisInformation a(aIndex, GamepadServiceType::Standard,
- aAxis, aValue);
- GamepadChangeEvent e(a);
+ GamepadAxisInformation a(aAxis, aValue);
+ GamepadChangeEventBody body(a);
+ GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
uint32_t id = ++mEventNumber;
if (mChild) {
mChild->SendGamepadTestEvent(id, e);
} else {
PendingOperation op(id, e);
mPendingOperations.AppendElement(op);
}
@@ -300,19 +301,19 @@ GamepadServiceTest::NewPoseMove(uint32_t
const Float32Array& value = aLinAcceleration.Value();
value.ComputeLengthAndData();
MOZ_ASSERT(value.Length() == 3);
poseState.linearAcceleration[0] = value.Data()[0];
poseState.linearAcceleration[1] = value.Data()[1];
poseState.linearAcceleration[2] = value.Data()[2];
}
- GamepadPoseInformation a(aIndex, GamepadServiceType::Standard,
- poseState);
- GamepadChangeEvent e(a);
+ GamepadPoseInformation a(poseState);
+ GamepadChangeEventBody body(a);
+ GamepadChangeEvent e(aIndex, GamepadServiceType::Standard, body);
uint32_t id = ++mEventNumber;
if (mChild) {
mChild->SendGamepadTestEvent(id, e);
} else {
PendingOperation op(id, e);
mPendingOperations.AppendElement(op);
}
--- a/dom/gamepad/ipc/GamepadEventTypes.ipdlh
+++ b/dom/gamepad/ipc/GamepadEventTypes.ipdlh
@@ -8,62 +8,55 @@ using mozilla::dom::GamepadMappingType f
using mozilla::dom::GamepadHand from "mozilla/dom/GamepadMessageUtils.h";
namespace mozilla {
namespace dom {
struct GamepadAdded {
nsString id;
- uint32_t index;
GamepadMappingType mapping;
GamepadHand hand;
- GamepadServiceType service_type;
uint32_t display_id;
uint32_t num_buttons;
uint32_t num_axes;
uint32_t num_haptics;
};
-struct GamepadRemoved {
- uint32_t index;
- GamepadServiceType service_type;
-};
+struct GamepadRemoved {};
struct GamepadAxisInformation {
- uint32_t index;
- GamepadServiceType service_type;
uint32_t axis;
double value;
};
struct GamepadButtonInformation {
- uint32_t index;
- GamepadServiceType service_type;
uint32_t button;
double value;
bool pressed;
bool touched;
};
struct GamepadPoseInformation {
- uint32_t index;
- GamepadServiceType service_type;
GamepadPoseState pose_state;
};
struct GamepadHandInformation {
- uint32_t index;
- GamepadServiceType service_type;
GamepadHand hand;
};
-union GamepadChangeEvent {
+union GamepadChangeEventBody {
GamepadAdded;
GamepadRemoved;
GamepadAxisInformation;
GamepadButtonInformation;
GamepadPoseInformation;
GamepadHandInformation;
};
+struct GamepadChangeEvent {
+ uint32_t index;
+ GamepadServiceType service_type;
+ GamepadChangeEventBody body;
+};
+
} // namespace dom
} // namespace mozilla
\ No newline at end of file
--- a/dom/gamepad/ipc/GamepadTestChannelParent.cpp
+++ b/dom/gamepad/ipc/GamepadTestChannelParent.cpp
@@ -13,50 +13,51 @@ namespace dom {
mozilla::ipc::IPCResult
GamepadTestChannelParent::RecvGamepadTestEvent(const uint32_t& aID,
const GamepadChangeEvent& aEvent)
{
mozilla::ipc::AssertIsOnBackgroundThread();
RefPtr<GamepadPlatformService> service =
GamepadPlatformService::GetParentService();
MOZ_ASSERT(service);
- if (aEvent.type() == GamepadChangeEvent::TGamepadAdded) {
- const GamepadAdded& a = aEvent.get_GamepadAdded();
+ const uint32_t index = aEvent.index();
+ const GamepadChangeEventBody& body = aEvent.body();
+ if (body.type() == GamepadChangeEventBody::TGamepadAdded) {
+ const GamepadAdded& a = body.get_GamepadAdded();
nsCString gamepadID;
LossyCopyUTF16toASCII(a.id(), gamepadID);
uint32_t index = service->AddGamepad(gamepadID.get(),
static_cast<GamepadMappingType>(a.mapping()),
a.hand(),
a.num_buttons(),
a.num_axes(),
a.num_haptics());
if (!mShuttingdown) {
Unused << SendReplyGamepadIndex(aID, index);
}
return IPC_OK();
}
- if (aEvent.type() == GamepadChangeEvent::TGamepadRemoved) {
- const GamepadRemoved& a = aEvent.get_GamepadRemoved();
- service->RemoveGamepad(a.index());
+ if (body.type() == GamepadChangeEventBody::TGamepadRemoved) {
+ service->RemoveGamepad(index);
return IPC_OK();
}
- if (aEvent.type() == GamepadChangeEvent::TGamepadButtonInformation) {
- const GamepadButtonInformation& a = aEvent.get_GamepadButtonInformation();
- service->NewButtonEvent(a.index(), a.button(), a.pressed(), a.touched(),
+ if (body.type() == GamepadChangeEventBody::TGamepadButtonInformation) {
+ const GamepadButtonInformation& a = body.get_GamepadButtonInformation();
+ service->NewButtonEvent(index, a.button(), a.pressed(), a.touched(),
a.value());
return IPC_OK();
}
- if (aEvent.type() == GamepadChangeEvent::TGamepadAxisInformation) {
- const GamepadAxisInformation& a = aEvent.get_GamepadAxisInformation();
- service->NewAxisMoveEvent(a.index(), a.axis(), a.value());
+ if (body.type() == GamepadChangeEventBody::TGamepadAxisInformation) {
+ const GamepadAxisInformation& a = body.get_GamepadAxisInformation();
+ service->NewAxisMoveEvent(index, a.axis(), a.value());
return IPC_OK();
}
- if (aEvent.type() == GamepadChangeEvent::TGamepadPoseInformation) {
- const GamepadPoseInformation& a = aEvent.get_GamepadPoseInformation();
- service->NewPoseEvent(a.index(), a.pose_state());
+ if (body.type() == GamepadChangeEventBody::TGamepadPoseInformation) {
+ const GamepadPoseInformation& a = body.get_GamepadPoseInformation();
+ service->NewPoseEvent(index, a.pose_state());
return IPC_OK();
}
NS_WARNING("Unknown event type.");
return IPC_FAIL_NO_REASON(this);
}
mozilla::ipc::IPCResult
--- a/gfx/vr/VRManager.cpp
+++ b/gfx/vr/VRManager.cpp
@@ -440,19 +440,20 @@ VRManager::CreateVRTestSystem()
if (mgr) {
mManagers.AppendElement(mgr);
mVRTestSystemCreated = true;
}
}
template<class T>
void
-VRManager::NotifyGamepadChange(const T& aInfo)
+VRManager::NotifyGamepadChange(uint32_t aIndex, const T& aInfo)
{
- dom::GamepadChangeEvent e(aInfo);
+ dom::GamepadChangeEventBody body(aInfo);
+ dom::GamepadChangeEvent e(aIndex, dom::GamepadServiceType::VR, body);
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
Unused << iter.Get()->GetKey()->SendGamepadUpdate(e);
}
}
void
VRManager::VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
--- a/gfx/vr/VRManager.h
+++ b/gfx/vr/VRManager.h
@@ -35,17 +35,17 @@ public:
void RemoveVRManagerParent(VRManagerParent* aVRManagerParent);
void NotifyVsync(const TimeStamp& aVsyncTimestamp);
void NotifyVRVsync(const uint32_t& aDisplayID);
void RefreshVRDisplays(bool aMustDispatch = false);
void RefreshVRControllers();
void ScanForControllers();
void RemoveControllers();
- template<class T> void NotifyGamepadChange(const T& aInfo);
+ template<class T> void NotifyGamepadChange(uint32_t aIndex, const T& aInfo);
RefPtr<gfx::VRDisplayHost> GetDisplay(const uint32_t& aDisplayID);
void GetVRDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayInfo);
void SubmitFrame(VRLayerParent* aLayer, layers::PTextureParent* aTexture,
const gfx::Rect& aLeftEyeRect,
const gfx::Rect& aRightEyeRect);
RefPtr<gfx::VRControllerHost> GetController(const uint32_t& aControllerID);
void GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo);
--- a/gfx/vr/gfxVR.cpp
+++ b/gfx/vr/gfxVR.cpp
@@ -64,74 +64,68 @@ VRFieldOfView::ConstructProjectionMatrix
return mobj;
}
void
VRSystemManager::AddGamepad(const VRControllerInfo& controllerInfo)
{
dom::GamepadAdded a(NS_ConvertUTF8toUTF16(controllerInfo.GetControllerName()),
- mControllerCount,
controllerInfo.GetMappingType(),
controllerInfo.GetHand(),
- dom::GamepadServiceType::VR,
controllerInfo.GetDisplayID(),
controllerInfo.GetNumButtons(),
controllerInfo.GetNumAxes(),
controllerInfo.GetNumHaptics());
VRManager* vm = VRManager::Get();
- vm->NotifyGamepadChange<dom::GamepadAdded>(a);
+ vm->NotifyGamepadChange<dom::GamepadAdded>(mControllerCount, a);
}
void
VRSystemManager::RemoveGamepad(uint32_t aIndex)
{
- dom::GamepadRemoved a(aIndex, dom::GamepadServiceType::VR);
+ dom::GamepadRemoved a;
VRManager* vm = VRManager::Get();
- vm->NotifyGamepadChange<dom::GamepadRemoved>(a);
+ vm->NotifyGamepadChange<dom::GamepadRemoved>(aIndex, a);
}
void
VRSystemManager::NewButtonEvent(uint32_t aIndex, uint32_t aButton,
bool aPressed, bool aTouched, double aValue)
{
- dom::GamepadButtonInformation a(aIndex, dom::GamepadServiceType::VR,
- aButton, aValue, aPressed, aTouched);
+ dom::GamepadButtonInformation a(aButton, aValue, aPressed, aTouched);
VRManager* vm = VRManager::Get();
- vm->NotifyGamepadChange<dom::GamepadButtonInformation>(a);
+ vm->NotifyGamepadChange<dom::GamepadButtonInformation>(aIndex, a);
}
void
VRSystemManager::NewAxisMove(uint32_t aIndex, uint32_t aAxis,
double aValue)
{
- dom::GamepadAxisInformation a(aIndex, dom::GamepadServiceType::VR,
- aAxis, aValue);
+ dom::GamepadAxisInformation a(aAxis, aValue);
VRManager* vm = VRManager::Get();
- vm->NotifyGamepadChange<dom::GamepadAxisInformation>(a);
+ vm->NotifyGamepadChange<dom::GamepadAxisInformation>(aIndex, a);
}
void
VRSystemManager::NewPoseState(uint32_t aIndex,
const dom::GamepadPoseState& aPose)
{
- dom::GamepadPoseInformation a(aIndex, dom::GamepadServiceType::VR,
- aPose);
+ dom::GamepadPoseInformation a(aPose);
VRManager* vm = VRManager::Get();
- vm->NotifyGamepadChange<dom::GamepadPoseInformation>(a);
+ vm->NotifyGamepadChange<dom::GamepadPoseInformation>(aIndex, a);
}
void
VRSystemManager::NewHandChangeEvent(uint32_t aIndex,
const dom::GamepadHand aHand)
{
- dom::GamepadHandInformation a(aIndex, dom::GamepadServiceType::VR,
- aHand);
+ dom::GamepadHandInformation a(aHand);
VRManager* vm = VRManager::Get();
- vm->NotifyGamepadChange<dom::GamepadHandInformation>(a);
+ vm->NotifyGamepadChange<dom::GamepadHandInformation>(aIndex, a);
}