mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:48:56 +02:00
Merge pull request #15090 from danteruiz/oculus-tracking-controllers
Case 21167: When using Oculus HMD, continue to track hand position and movement when focus is off High Fidelity
This commit is contained in:
commit
cc154be12d
4 changed files with 85 additions and 1 deletions
59
interface/resources/qml/hifi/tablet/OculusConfiguration.qml
Normal file
59
interface/resources/qml/hifi/tablet/OculusConfiguration.qml
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
//
|
||||||
|
// Created by Dante Ruiz on 3/4/19.
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
import QtQuick 2.5
|
||||||
|
|
||||||
|
import stylesUit 1.0
|
||||||
|
import controlsUit 1.0 as HifiControls
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
anchors.fill: parent
|
||||||
|
property string pluginName: ""
|
||||||
|
property var displayInformation: null
|
||||||
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
|
color: hifi.colors.baseGray
|
||||||
|
|
||||||
|
HifiControls.CheckBox {
|
||||||
|
id: box
|
||||||
|
width: 15
|
||||||
|
height: 15
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: root.left
|
||||||
|
leftMargin: 75
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
sendConfigurationSettings( { trackControllersInOculusHome: checked });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: head
|
||||||
|
|
||||||
|
text: "Track hand controllers in Oculus Home"
|
||||||
|
size: 12
|
||||||
|
|
||||||
|
color: "white"
|
||||||
|
anchors.left: box.right
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayConfiguration() {
|
||||||
|
var configurationSettings = InputConfiguration.configurationSettings(root.pluginName);
|
||||||
|
box.checked = configurationSettings.trackControllersInOculusHome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendConfigurationSettings(settings) {
|
||||||
|
InputConfiguration.setConfigurationSettings(settings, root.pluginName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <RenderShadowTask.h>
|
#include <RenderShadowTask.h>
|
||||||
|
#include <plugins/PluginUtils.h>
|
||||||
#include <display-plugins/CompositorHelper.h>
|
#include <display-plugins/CompositorHelper.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
using namespace hifi;
|
using namespace hifi;
|
||||||
|
|
||||||
const char* OculusControllerManager::NAME = "Oculus";
|
const char* OculusControllerManager::NAME = "Oculus";
|
||||||
|
const QString OCULUS_LAYOUT = "OculusConfiguration.qml";
|
||||||
|
|
||||||
const quint64 LOST_TRACKING_DELAY = 3000000;
|
const quint64 LOST_TRACKING_DELAY = 3000000;
|
||||||
|
|
||||||
|
@ -43,6 +44,22 @@ bool OculusControllerManager::activate() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString OculusControllerManager::configurationLayout() {
|
||||||
|
return OCULUS_LAYOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OculusControllerManager::setConfigurationSettings(const QJsonObject configurationSettings) {
|
||||||
|
if (configurationSettings.contains("trackControllersInOculusHome")) {
|
||||||
|
_touch->_trackControllersInOculusHome.set(configurationSettings["trackControllersInOculusHome"].toBool());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject OculusControllerManager::configurationSettings() {
|
||||||
|
QJsonObject configurationSettings;
|
||||||
|
configurationSettings["trackControllersInOculusHome"] = _touch->_trackControllersInOculusHome.get();
|
||||||
|
return configurationSettings;
|
||||||
|
}
|
||||||
|
|
||||||
void OculusControllerManager::checkForConnectedDevices() {
|
void OculusControllerManager::checkForConnectedDevices() {
|
||||||
if (_touch && _remote) {
|
if (_touch && _remote) {
|
||||||
return;
|
return;
|
||||||
|
@ -215,13 +232,14 @@ void OculusControllerManager::TouchDevice::update(float deltaTime,
|
||||||
quint64 currentTime = usecTimestampNow();
|
quint64 currentTime = usecTimestampNow();
|
||||||
static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked | ovrStatus_PositionTracked;
|
static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked | ovrStatus_PositionTracked;
|
||||||
bool hasInputFocus = ovr::hasInputFocus();
|
bool hasInputFocus = ovr::hasInputFocus();
|
||||||
|
bool trackControllersInOculusHome = _trackControllersInOculusHome.get();
|
||||||
auto tracking = ovr::getTrackingState(); // ovr_GetTrackingState(_parent._session, 0, false);
|
auto tracking = ovr::getTrackingState(); // ovr_GetTrackingState(_parent._session, 0, false);
|
||||||
ovr::for_each_hand([&](ovrHandType hand) {
|
ovr::for_each_hand([&](ovrHandType hand) {
|
||||||
++numTrackedControllers;
|
++numTrackedControllers;
|
||||||
int controller = (hand == ovrHand_Left ? controller::LEFT_HAND : controller::RIGHT_HAND);
|
int controller = (hand == ovrHand_Left ? controller::LEFT_HAND : controller::RIGHT_HAND);
|
||||||
|
|
||||||
// Disable hand tracking while in Oculus Dash (Dash renders it's own hands)
|
// Disable hand tracking while in Oculus Dash (Dash renders it's own hands)
|
||||||
if (!hasInputFocus) {
|
if (!hasInputFocus && !trackControllersInOculusHome) {
|
||||||
_poseStateMap.erase(controller);
|
_poseStateMap.erase(controller);
|
||||||
_poseStateMap[controller].valid = false;
|
_poseStateMap[controller].valid = false;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
|
|
||||||
|
#include <SettingHandle.h>
|
||||||
#include <controllers/InputDevice.h>
|
#include <controllers/InputDevice.h>
|
||||||
#include <plugins/InputPlugin.h>
|
#include <plugins/InputPlugin.h>
|
||||||
|
|
||||||
|
@ -28,7 +29,11 @@ public:
|
||||||
const QString getName() const override { return NAME; }
|
const QString getName() const override { return NAME; }
|
||||||
bool isHandController() const override { return _touch != nullptr; }
|
bool isHandController() const override { return _touch != nullptr; }
|
||||||
bool isHeadController() const override { return true; }
|
bool isHeadController() const override { return true; }
|
||||||
|
bool configurable() override { return true; }
|
||||||
|
QString configurationLayout() override;
|
||||||
QStringList getSubdeviceNames() override;
|
QStringList getSubdeviceNames() override;
|
||||||
|
void setConfigurationSettings(const QJsonObject configurationSetting) override;
|
||||||
|
QJsonObject configurationSettings() override;
|
||||||
|
|
||||||
bool activate() override;
|
bool activate() override;
|
||||||
void deactivate() override;
|
void deactivate() override;
|
||||||
|
@ -93,6 +98,7 @@ private:
|
||||||
float _leftHapticStrength { 0.0f };
|
float _leftHapticStrength { 0.0f };
|
||||||
float _rightHapticDuration { 0.0f };
|
float _rightHapticDuration { 0.0f };
|
||||||
float _rightHapticStrength { 0.0f };
|
float _rightHapticStrength { 0.0f };
|
||||||
|
Setting::Handle<bool> _trackControllersInOculusHome { "trackControllersInOculusHome", false };
|
||||||
mutable std::recursive_mutex _lock;
|
mutable std::recursive_mutex _lock;
|
||||||
std::map<int, bool> _lostTracking;
|
std::map<int, bool> _lostTracking;
|
||||||
std::map<int, quint64> _regainTrackingDeadline;
|
std::map<int, quint64> _regainTrackingDeadline;
|
||||||
|
|
Loading…
Reference in a new issue