Skip to content

Commit

Permalink
Bug 1315896 - Part 3: Remove MOZ_GAMEPAD in VR module; r=kip
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: I9vJvxgFgIh

--HG--
extra : rebase_source : 270e971ace44b00d9877a67f68f349bbd9b550c1
  • Loading branch information
daoshengmu committed Dec 8, 2016
1 parent 94effe3 commit 370aa4a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
6 changes: 2 additions & 4 deletions gfx/vr/gfxVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include <math.h>

#include "gfxVR.h"
#ifdef MOZ_GAMEPAD
#include "mozilla/dom/GamepadEventTypes.h"
#include "mozilla/dom/GamepadBinding.h"
#endif

#ifndef M_PI
# define M_PI 3.14159265358979323846
Expand Down Expand Up @@ -68,8 +66,8 @@ VRControllerManager::AllocateControllerID()
}

void
VRControllerManager::AddGamepad(const char* aID, uint32_t aMapping, uint32_t aHand,
uint32_t aNumButtons, uint32_t aNumAxes)
VRControllerManager::AddGamepad(const char* aID, dom::GamepadMappingType aMapping,
dom::GamepadHand aHand, uint32_t aNumButtons, uint32_t aNumAxes)
{
dom::GamepadAdded a(NS_ConvertUTF8toUTF16(nsDependentCString(aID)), mControllerCount,
aMapping, aHand, dom::GamepadServiceType::VR, aNumButtons,
Expand Down
9 changes: 5 additions & 4 deletions gfx/vr/gfxVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PTextureParent;
}
namespace dom {
enum class GamepadMappingType : uint32_t;
enum class GamepadHand : uint32_t;
struct GamepadPoseState;
}
namespace gfx {
Expand Down Expand Up @@ -219,14 +220,14 @@ struct VRControllerInfo
VRDeviceType GetType() const { return mType; }
uint32_t GetControllerID() const { return mControllerID; }
const nsCString& GetControllerName() const { return mControllerName; }
uint32_t GetMappingType() const { return mMappingType; }
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;
uint32_t mMappingType;
dom::GamepadMappingType mMappingType;
uint32_t mNumButtons;
uint32_t mNumAxes;

Expand Down Expand Up @@ -258,8 +259,8 @@ class VRControllerManager {
void NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed);
void NewAxisMove(uint32_t aIndex, uint32_t aAxis, double aValue);
void NewPoseState(uint32_t aIndex, const dom::GamepadPoseState& aPose);
void AddGamepad(const char* aID, uint32_t aMapping, uint32_t aHand,
uint32_t aNumButtons, uint32_t aNumAxes);
void AddGamepad(const char* aID, dom::GamepadMappingType aMapping,
dom::GamepadHand aHand, uint32_t aNumButtons, uint32_t aNumAxes);
void RemoveGamepad(uint32_t aIndex);

protected:
Expand Down
15 changes: 3 additions & 12 deletions gfx/vr/gfxVROpenVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
#include "nsIScreenManager.h"
#include "openvr/openvr.h"

#ifdef MOZ_GAMEPAD
#include "mozilla/dom/GamepadEventTypes.h"
#include "mozilla/dom/GamepadBinding.h"
#endif

#ifndef M_PI
# define M_PI 3.14159265358979323846
Expand Down Expand Up @@ -490,9 +488,7 @@ VRControllerOpenVR::VRControllerOpenVR()
{
MOZ_COUNT_CTOR_INHERITED(VRControllerOpenVR, VRControllerHost);
mControllerInfo.mControllerName.AssignLiteral("OpenVR HMD");
#ifdef MOZ_GAMEPAD
mControllerInfo.mMappingType = static_cast<uint32_t>(GamepadMappingType::_empty);
#endif
mControllerInfo.mMappingType = GamepadMappingType::_empty;
mControllerInfo.mNumButtons = gNumOpenVRButtonMask;
mControllerInfo.mNumAxes = gNumOpenVRAxis;
}
Expand Down Expand Up @@ -744,7 +740,6 @@ VRControllerManagerOpenVR::ScanForDevices()
// Re-adding controllers to VRControllerManager.
for (vr::TrackedDeviceIndex_t i = 0; i < newControllerCount; ++i) {
vr::TrackedDeviceIndex_t trackedDevice = trackedIndexArray[i];
#ifdef MOZ_GAMEPAD
vr::ETrackedControllerRole role =
mVRSystem->GetControllerRoleForTrackedDeviceIndex(trackedDevice);
GamepadHand hand;
Expand All @@ -760,19 +755,15 @@ VRControllerManagerOpenVR::ScanForDevices()
hand = GamepadHand::Right;
break;
}
#endif
RefPtr<VRControllerOpenVR> openVRController = new VRControllerOpenVR();
openVRController->SetIndex(mControllerCount);
openVRController->SetTrackedIndex(trackedDevice);
mOpenVRController.AppendElement(openVRController);

// Only in MOZ_GAMEPAD platform, We add gamepads.
#ifdef MOZ_GAMEPAD
// Not already present, add it.
AddGamepad("OpenVR Gamepad", static_cast<uint32_t>(GamepadMappingType::_empty),
static_cast<uint32_t>(hand), gNumOpenVRButtonMask, gNumOpenVRAxis);
AddGamepad("OpenVR Gamepad", GamepadMappingType::_empty,
hand, gNumOpenVRButtonMask, gNumOpenVRAxis);
++mControllerCount;
#endif
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions gfx/vr/ipc/VRManagerChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
#include "mozilla/dom/ContentChild.h"
#include "mozilla/layers/TextureClient.h"
#include "nsContentUtils.h"

#ifdef MOZ_GAMEPAD
#include "mozilla/dom/GamepadManager.h"
#endif

using layers::TextureClient;

Expand Down Expand Up @@ -479,7 +476,6 @@ VRManagerChild::RecvNotifyVRVSync(const uint32_t& aDisplayID)
mozilla::ipc::IPCResult
VRManagerChild::RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
{
#ifdef MOZ_GAMEPAD
// VRManagerChild could be at other processes, but GamepadManager
// only exists at the content process or the same process
// in non-e10s mode.
Expand All @@ -489,7 +485,6 @@ VRManagerChild::RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
if (gamepadManager) {
gamepadManager->Update(aGamepadEvent);
}
#endif

return IPC_OK();
}
Expand Down

0 comments on commit 370aa4a

Please sign in to comment.