mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 23:55:24 +02:00
added auto switch to vive, checking for the proximity button on vive, to do: make sure ik is off for the head when in desktop mode.
This commit is contained in:
parent
ff9b0a1ac4
commit
da05692e5d
7 changed files with 36 additions and 4 deletions
|
@ -6611,6 +6611,8 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) {
|
|||
|
||||
|
||||
bool Application::isHMDMode() const {
|
||||
qDebug() << "the hmd is visible " << getActiveDisplayPlugin()->isDisplayVisible();
|
||||
qDebug() << "the hmd is active " << getActiveDisplayPlugin()->isHmd();
|
||||
return getActiveDisplayPlugin()->isHmd();
|
||||
}
|
||||
|
||||
|
@ -6690,6 +6692,7 @@ void Application::resetSensors(bool andReload) {
|
|||
}
|
||||
|
||||
void Application::hmdVisibleChanged(bool visible) {
|
||||
qDebug() << "hmd visible changed ";
|
||||
// TODO
|
||||
// calling start and stop will change audio input and ouput to default audio devices.
|
||||
// we need to add a pause/unpause functionality to AudioClient for this to work properly
|
||||
|
|
|
@ -48,6 +48,10 @@ static const glm::mat4 IDENTITY_MATRIX;
|
|||
//#define LIVE_SHADER_RELOAD 1
|
||||
extern glm::vec3 getPoint(float yaw, float pitch);
|
||||
|
||||
bool HmdDisplayPlugin::isHmd() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
glm::uvec2 HmdDisplayPlugin::getRecommendedUiSize() const {
|
||||
return CompositorHelper::VIRTUAL_SCREEN_SIZE;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class HmdDisplayPlugin : public OpenGLDisplayPlugin {
|
|||
using Parent = OpenGLDisplayPlugin;
|
||||
public:
|
||||
~HmdDisplayPlugin();
|
||||
bool isHmd() const override final { return true; }
|
||||
bool isHmd() const override final;
|
||||
float getIPD() const override final { return _ipd; }
|
||||
glm::mat4 getEyeToHeadTransform(Eye eye) const override final;
|
||||
glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override;
|
||||
|
|
|
@ -677,8 +677,8 @@ void OpenVrDisplayPlugin::postPreview() {
|
|||
break;
|
||||
case vr::EDeviceActivityLevel::k_EDeviceActivityLevel_Idle: qDebug() << "no activity 10 secs ";
|
||||
break;
|
||||
case vr::EDeviceActivityLevel::k_EDeviceActivityLevel_UserInteraction: qDebug() << "activity ";
|
||||
break;
|
||||
//case vr::EDeviceActivityLevel::k_EDeviceActivityLevel_UserInteraction: qDebug() << "activity ";
|
||||
// break;
|
||||
case vr::EDeviceActivityLevel::k_EDeviceActivityLevel_UserInteraction_Timeout: qDebug() << "idle for 0.5 secs ";
|
||||
break;
|
||||
case vr::EDeviceActivityLevel::k_EDeviceActivityLevel_Standby: qDebug() << "idle for 5 secs ";
|
||||
|
@ -704,7 +704,8 @@ void OpenVrDisplayPlugin::postPreview() {
|
|||
}
|
||||
|
||||
bool OpenVrDisplayPlugin::isHmdMounted() const {
|
||||
return _hmdActivityLevel == vr::k_EDeviceActivityLevel_UserInteraction;
|
||||
// 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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -282,7 +287,24 @@ void handleOpenVrEvents() {
|
|||
break;
|
||||
}
|
||||
#if DEV_BUILD
|
||||
if (event.data.controller.button == vr::k_EButton_ProximitySensor) {
|
||||
qDebug() << "fired the proximity sensor!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ";
|
||||
vr::VRControllerState_t controllerState = vr::VRControllerState_t();
|
||||
if (activeHmd->GetControllerState(vr::k_unTrackedDeviceIndex_Hmd, &controllerState, sizeof(vr::VRControllerState_t))) {
|
||||
ulong prox = controllerState.ulButtonPressed & (1UL << ((int)vr::k_EButton_ProximitySensor));
|
||||
qDebug() << "prox is -----------------------------> " << (int)prox;
|
||||
if (prox) {
|
||||
qDebug() << "headset is on";
|
||||
_headInHeadset = true;
|
||||
} else {
|
||||
qDebug() << "headset is off";
|
||||
_headInHeadset = false;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
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