mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 03:22:27 +02:00
track oculus controllers while in oculus home
This commit is contained in:
parent
6d297d91f6
commit
1941e53cc3
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 <Preferences.h>
|
||||
#include <RenderShadowTask.h>
|
||||
#include <plugins/PluginUtils.h>
|
||||
#include <display-plugins/CompositorHelper.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
using namespace hifi;
|
||||
|
||||
const char* OculusControllerManager::NAME = "Oculus";
|
||||
const QString OCULUS_LAYOUT = "OculusConfiguration.qml";
|
||||
|
||||
const quint64 LOST_TRACKING_DELAY = 3000000;
|
||||
|
||||
|
@ -43,6 +44,22 @@ bool OculusControllerManager::activate() {
|
|||
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() {
|
||||
if (_touch && _remote) {
|
||||
return;
|
||||
|
@ -215,13 +232,14 @@ void OculusControllerManager::TouchDevice::update(float deltaTime,
|
|||
quint64 currentTime = usecTimestampNow();
|
||||
static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked | ovrStatus_PositionTracked;
|
||||
bool hasInputFocus = ovr::hasInputFocus();
|
||||
bool trackControllersInOculusHome = _trackControllersInOculusHome.get();
|
||||
auto tracking = ovr::getTrackingState(); // ovr_GetTrackingState(_parent._session, 0, false);
|
||||
ovr::for_each_hand([&](ovrHandType hand) {
|
||||
++numTrackedControllers;
|
||||
int controller = (hand == ovrHand_Left ? controller::LEFT_HAND : controller::RIGHT_HAND);
|
||||
|
||||
// Disable hand tracking while in Oculus Dash (Dash renders it's own hands)
|
||||
if (!hasInputFocus) {
|
||||
if (!hasInputFocus && !trackControllersInOculusHome) {
|
||||
_poseStateMap.erase(controller);
|
||||
_poseStateMap[controller].valid = false;
|
||||
return;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <controllers/InputDevice.h>
|
||||
#include <plugins/InputPlugin.h>
|
||||
|
||||
|
@ -28,7 +29,11 @@ public:
|
|||
const QString getName() const override { return NAME; }
|
||||
bool isHandController() const override { return _touch != nullptr; }
|
||||
bool isHeadController() const override { return true; }
|
||||
bool configurable() override { return true; }
|
||||
QString configurationLayout() override;
|
||||
QStringList getSubdeviceNames() override;
|
||||
void setConfigurationSettings(const QJsonObject configurationSetting) override;
|
||||
QJsonObject configurationSettings() override;
|
||||
|
||||
bool activate() override;
|
||||
void deactivate() override;
|
||||
|
@ -93,6 +98,7 @@ private:
|
|||
float _leftHapticStrength { 0.0f };
|
||||
float _rightHapticDuration { 0.0f };
|
||||
float _rightHapticStrength { 0.0f };
|
||||
Setting::Handle<bool> _trackControllersInOculusHome { "trackControllersInOculusHome", false };
|
||||
mutable std::recursive_mutex _lock;
|
||||
std::map<int, bool> _lostTracking;
|
||||
std::map<int, quint64> _regainTrackingDeadline;
|
||||
|
|
Loading…
Reference in a new issue