mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1299928 - Part 3: Construct IPC channel between Gamepad and VRManager; r=kip
MozReview-Commit-ID: 9hpxlLlIdh7 --HG-- extra : rebase_source : f50bf15bef94129a4a8fbd659c8551a3f153e32c
This commit is contained in:
parent
3803722838
commit
570a208647
@ -28,6 +28,7 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "VRManagerChild.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
@ -109,6 +110,11 @@ GamepadManager::StopMonitoring()
|
||||
}
|
||||
mChannelChildren.Clear();
|
||||
mGamepads.Clear();
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX)
|
||||
mVRChannelChild = gfx::VRManagerChild::Get();
|
||||
mVRChannelChild->SendControllerListenerRemoved();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -615,8 +621,12 @@ GamepadManager::ActorCreated(PBackgroundChild *aActor)
|
||||
child->SendGamepadListenerAdded();
|
||||
mChannelChildren.AppendElement(child);
|
||||
|
||||
// TODO: Add more event channels to mChannelChildren if you would
|
||||
// like to support more kinds of devices.
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX)
|
||||
// Construct VRManagerChannel and ask adding the connected
|
||||
// VR controllers to GamepadManager
|
||||
mVRChannelChild = gfx::VRManagerChild::Get();
|
||||
mVRChannelChild->SendControllerListenerAdded();
|
||||
#endif
|
||||
}
|
||||
|
||||
//Override nsIIPCBackgroundChildCreateCallback
|
||||
|
@ -15,6 +15,9 @@
|
||||
class nsGlobalWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class VRManagerChild;
|
||||
} // namespace gfx
|
||||
namespace dom {
|
||||
|
||||
class EventTarget;
|
||||
@ -113,6 +116,7 @@ class GamepadManager final : public nsIObserver,
|
||||
// will be destroyed during the IPDL shutdown chain, so we
|
||||
// don't need to refcount it here.
|
||||
nsTArray<GamepadEventChannelChild *> mChannelChildren;
|
||||
gfx::VRManagerChild* mVRChannelChild;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "mozilla/dom/GamepadBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -209,6 +210,36 @@ protected:
|
||||
virtual ~VRDisplayManager() { }
|
||||
};
|
||||
|
||||
struct VRControllerInfo
|
||||
{
|
||||
VRDeviceType GetType() const { return mType; }
|
||||
uint32_t GetControllerID() const { return mControllerID; }
|
||||
const nsCString& GetControllerName() const { return mControllerName; }
|
||||
dom::GamepadMappingType GetMappingType() const { return mMappingType; }
|
||||
uint32_t GetNumButtons() const { return mNumButtons; }
|
||||
uint32_t GetNumAxes() const { return mNumAxes; }
|
||||
|
||||
uint32_t mControllerID;
|
||||
VRDeviceType mType;
|
||||
nsCString mControllerName;
|
||||
dom::GamepadMappingType mMappingType;
|
||||
uint32_t mNumButtons;
|
||||
uint32_t mNumAxes;
|
||||
|
||||
bool operator==(const VRControllerInfo& other) const {
|
||||
return mType == other.mType &&
|
||||
mControllerID == other.mControllerID &&
|
||||
mControllerName == other.mControllerName &&
|
||||
mMappingType == other.mMappingType &&
|
||||
mNumButtons == other.mNumButtons &&
|
||||
mNumAxes == other.mNumAxes;
|
||||
}
|
||||
|
||||
bool operator!=(const VRControllerInfo& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -10,6 +10,7 @@ include protocol PLayer;
|
||||
include protocol PTexture;
|
||||
include protocol PVRLayer;
|
||||
include LayersMessages;
|
||||
include GamepadEventTypes;
|
||||
|
||||
include "VRMessageUtils.h";
|
||||
|
||||
@ -17,6 +18,7 @@ using struct mozilla::gfx::VRFieldOfView from "gfxVR.h";
|
||||
using struct mozilla::gfx::VRDisplayInfo from "gfxVR.h";
|
||||
using struct mozilla::gfx::VRSensorUpdate from "gfxVR.h";
|
||||
using struct mozilla::gfx::VRHMDSensorState from "gfxVR.h";
|
||||
using struct mozilla::gfx::VRControllerInfo from "gfxVR.h";
|
||||
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
|
||||
using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h";
|
||||
|
||||
@ -56,6 +58,12 @@ parent:
|
||||
sync GetImmediateSensorState(uint32_t aDisplayID) returns(VRHMDSensorState aState);
|
||||
sync SetHaveEventListener(bool aHaveEventListener);
|
||||
|
||||
async ControllerListenerAdded();
|
||||
async ControllerListenerRemoved();
|
||||
// GetControllers synchronously returns the VR controllers that have already been
|
||||
// enumerated by RefreshVRControllers() but does not enumerate new ones.
|
||||
sync GetControllers() returns(VRControllerInfo[] aControllerInfo);
|
||||
|
||||
child:
|
||||
|
||||
async ParentAsyncMessages(AsyncParentMessageData[] aMessages);
|
||||
@ -68,6 +76,7 @@ child:
|
||||
|
||||
async NotifyVSync();
|
||||
async NotifyVRVSync(uint32_t aDisplayID);
|
||||
async GamepadUpdate(GamepadChangeEvent aGamepadEvent);
|
||||
|
||||
async __delete__();
|
||||
|
||||
|
@ -8,12 +8,14 @@
|
||||
#include "VRManagerChild.h"
|
||||
#include "VRManagerParent.h"
|
||||
#include "VRDisplayClient.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/layers/CompositorThread.h" // for CompositorThread
|
||||
#include "mozilla/dom/Navigator.h"
|
||||
#include "mozilla/dom/VREventObserver.h"
|
||||
#include "mozilla/dom/WindowBinding.h" // for FrameRequestCallback
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/GamepadManager.h"
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
@ -481,6 +483,22 @@ VRManagerChild::RecvNotifyVRVSync(const uint32_t& aDisplayID)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
VRManagerChild::RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
|
||||
{
|
||||
// VRManagerChild could be at other processes,
|
||||
// but GamepadManager is only allowed to be run at Content process.
|
||||
if (XRE_IsContentProcess()) {
|
||||
RefPtr<dom::GamepadManager> serivce(dom::GamepadManager::GetService());
|
||||
|
||||
if (serivce) {
|
||||
serivce->Update(aGamepadEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
VRManagerChild::RunFrameRequestCallbacks()
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ protected:
|
||||
|
||||
virtual bool RecvNotifyVSync() override;
|
||||
virtual bool RecvNotifyVRVSync(const uint32_t& aDisplayID) override;
|
||||
|
||||
virtual bool RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent) override;
|
||||
|
||||
// ShmemAllocator
|
||||
|
||||
|
@ -159,6 +159,35 @@ struct ParamTraits<mozilla::gfx::VRFieldOfView>
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::VRControllerInfo>
|
||||
{
|
||||
typedef mozilla::gfx::VRControllerInfo paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, aParam.mType);
|
||||
WriteParam(aMsg, aParam.mControllerID);
|
||||
WriteParam(aMsg, aParam.mControllerName);
|
||||
WriteParam(aMsg, aParam.mMappingType);
|
||||
WriteParam(aMsg, aParam.mNumButtons);
|
||||
WriteParam(aMsg, aParam.mNumAxes);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
if (!ReadParam(aMsg, aIter, &(aResult->mType)) ||
|
||||
!ReadParam(aMsg, aIter, &(aResult->mControllerID)) ||
|
||||
!ReadParam(aMsg, aIter, &(aResult->mControllerName)) ||
|
||||
!ReadParam(aMsg, aIter, &(aResult->mMappingType)) ||
|
||||
!ReadParam(aMsg, aIter, &(aResult->mNumButtons)) ||
|
||||
!ReadParam(aMsg, aIter, &(aResult->mNumAxes))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_gfx_vr_VRMessageUtils_h
|
||||
|
@ -16,6 +16,7 @@ EXPORTS += [
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/dom/base',
|
||||
'/gfx/layers/d3d11',
|
||||
'/gfx/thebes',
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user