2017-03-01 13:33:28 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_VRServiceTest_h_
|
|
|
|
#define mozilla_dom_VRServiceTest_h_
|
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "mozilla/dom/VRServiceTestBinding.h"
|
|
|
|
|
2017-05-08 14:34:00 +03:00
|
|
|
#include "gfxVR.h"
|
|
|
|
|
2017-03-01 13:33:28 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class VRMockDisplay final : public DOMEventTargetHelper {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRMockDisplay, DOMEventTargetHelper)
|
|
|
|
|
|
|
|
VRMockDisplay(const nsCString& aID, uint32_t aDeviceID);
|
|
|
|
void SetEyeParameter(VREye aEye, double aOffsetX, double aOffsetY,
|
|
|
|
double aOffsetZ, double aUpDegree, double aRightDegree,
|
|
|
|
double aDownDegree, double aLeftDegree);
|
|
|
|
void SetEyeResolution(unsigned long aRenderWidth,
|
|
|
|
unsigned long aRenderHeight);
|
|
|
|
void SetPose(const Nullable<Float32Array>& aPosition,
|
|
|
|
const Nullable<Float32Array>& aLinearVelocity,
|
|
|
|
const Nullable<Float32Array>& aLinearAcceleration,
|
|
|
|
const Nullable<Float32Array>& aOrientation,
|
|
|
|
const Nullable<Float32Array>& aAngularVelocity,
|
|
|
|
const Nullable<Float32Array>& aAngularAcceleration);
|
2018-03-14 03:09:54 +03:00
|
|
|
void SetMountState(bool aIsMounted) {
|
|
|
|
mDisplayInfo.mDisplayState.mIsMounted = aIsMounted;
|
|
|
|
}
|
2017-03-01 13:33:28 +03:00
|
|
|
void Update();
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
~VRMockDisplay() = default;
|
|
|
|
|
|
|
|
uint32_t mDeviceID;
|
|
|
|
gfx::VRDisplayInfo mDisplayInfo;
|
|
|
|
gfx::VRHMDSensorState mSensorState;
|
2017-03-15 08:49:39 +03:00
|
|
|
TimeStamp mTimestamp;
|
2017-03-01 13:33:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class VRMockController : public DOMEventTargetHelper {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRMockController,
|
|
|
|
DOMEventTargetHelper)
|
|
|
|
|
|
|
|
VRMockController(const nsCString& aID, uint32_t aDeviceID);
|
|
|
|
void NewButtonEvent(unsigned long aButton, bool aPressed);
|
|
|
|
void NewAxisMoveEvent(unsigned long aAxis, double aValue);
|
|
|
|
void NewPoseMove(const Nullable<Float32Array>& aPosition,
|
|
|
|
const Nullable<Float32Array>& aLinearVelocity,
|
|
|
|
const Nullable<Float32Array>& aLinearAcceleration,
|
|
|
|
const Nullable<Float32Array>& aOrientation,
|
|
|
|
const Nullable<Float32Array>& aAngularVelocity,
|
|
|
|
const Nullable<Float32Array>& aAngularAcceleration);
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-03-01 13:33:28 +03:00
|
|
|
private:
|
|
|
|
~VRMockController() = default;
|
|
|
|
|
|
|
|
nsCString mID;
|
|
|
|
uint32_t mDeviceID;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VRServiceTest final : public DOMEventTargetHelper {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRServiceTest, DOMEventTargetHelper)
|
|
|
|
|
|
|
|
already_AddRefed<Promise> AttachVRDisplay(const nsAString& aID,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<Promise> AttachVRController(const nsAString& aID,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
static already_AddRefed<VRServiceTest> CreateTestService(
|
|
|
|
nsPIDOMWindowInner* aWindow);
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit VRServiceTest(nsPIDOMWindowInner* aWindow);
|
2017-11-20 07:00:31 +03:00
|
|
|
~VRServiceTest() = default;
|
2017-03-01 13:33:28 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
|
|
|
bool mShuttingDown;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-03-27 06:26:19 +03:00
|
|
|
#endif // mozilla_dom_VRServiceTest_h_
|