mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-14 13:36:02 +02:00
Merge pull request #14620 from amantley/hmdSmoothFix
VIVE can now auto-detect hmd and desktop modes
This commit is contained in:
commit
7143689ddf
4 changed files with 17 additions and 4 deletions
|
@ -671,8 +671,6 @@ void OpenVrDisplayPlugin::postPreview() {
|
|||
PoseData nextRender, nextSim;
|
||||
nextRender.frameIndex = presentCount();
|
||||
|
||||
_hmdActivityLevel = _system->GetTrackedDeviceActivityLevel(vr::k_unTrackedDeviceIndex_Hmd);
|
||||
|
||||
if (!_threadedSubmit) {
|
||||
vr::VRCompositor()->WaitGetPoses(nextRender.vrPoses, vr::k_unMaxTrackedDeviceCount, nextSim.vrPoses,
|
||||
vr::k_unMaxTrackedDeviceCount);
|
||||
|
@ -692,7 +690,7 @@ void OpenVrDisplayPlugin::postPreview() {
|
|||
}
|
||||
|
||||
bool OpenVrDisplayPlugin::isHmdMounted() const {
|
||||
return _hmdActivityLevel == vr::k_EDeviceActivityLevel_UserInteraction;
|
||||
return isHeadInHeadset();
|
||||
}
|
||||
|
||||
void OpenVrDisplayPlugin::updatePresentPose() {
|
||||
|
|
|
@ -37,6 +37,7 @@ class OpenVrDisplayPlugin : public HmdDisplayPlugin {
|
|||
public:
|
||||
bool isSupported() const override;
|
||||
const QString getName() const override;
|
||||
bool getSupportsAutoSwitch() override final { return true; }
|
||||
|
||||
glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override;
|
||||
glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override;
|
||||
|
@ -78,7 +79,6 @@ protected:
|
|||
|
||||
private:
|
||||
vr::IVRSystem* _system { nullptr };
|
||||
std::atomic<vr::EDeviceActivityLevel> _hmdActivityLevel { vr::k_EDeviceActivityLevel_Unknown };
|
||||
std::atomic<uint32_t> _keyboardSupressionCount{ 0 };
|
||||
|
||||
vr::HmdMatrix34_t _lastGoodHMDPose;
|
||||
|
|
|
@ -37,6 +37,11 @@ static int refCount { 0 };
|
|||
static Mutex mutex;
|
||||
static vr::IVRSystem* activeHmd { nullptr };
|
||||
static bool _openVrQuitRequested { false };
|
||||
static bool _headInHeadset { false };
|
||||
|
||||
bool isHeadInHeadset() {
|
||||
return _headInHeadset;
|
||||
}
|
||||
|
||||
bool openVrQuitRequested() {
|
||||
return _openVrQuitRequested;
|
||||
|
@ -272,6 +277,15 @@ void handleOpenVrEvents() {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (event.data.controller.button == vr::k_EButton_ProximitySensor) {
|
||||
vr::VRControllerState_t controllerState = vr::VRControllerState_t();
|
||||
if (activeHmd->GetControllerState(vr::k_unTrackedDeviceIndex_Hmd, &controllerState, sizeof(vr::VRControllerState_t))) {
|
||||
ulong promitySensorFlag = (1UL << ((int)vr::k_EButton_ProximitySensor));
|
||||
_headInHeadset = (controllerState.ulButtonPressed & promitySensorFlag) == promitySensorFlag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if DEV_BUILD
|
||||
qDebug() << "OpenVR: Event " << activeHmd->GetEventTypeNameFromEnum((vr::EVREventType)event.eventType) << "(" << event.eventType << ")";
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,7 @@ vr::IVRSystem* acquireOpenVrSystem();
|
|||
void releaseOpenVrSystem();
|
||||
void handleOpenVrEvents();
|
||||
bool openVrQuitRequested();
|
||||
bool isHeadInHeadset();
|
||||
void enableOpenVrKeyboard(PluginContainer* container);
|
||||
void disableOpenVrKeyboard();
|
||||
bool isOpenVrKeyboardShown();
|
||||
|
|
Loading…
Reference in a new issue