Prox sensor re-integration (#220)
* added arbitrary orientation change * removed commented code * updated to OVR 1.4.18 * changed two instances using new to init via array * moved prox sensor action to haptic instead of Misc * fixed json file, added prox sensor back for mic mute/un-mute * added proximity sensor to audio and haptic chaperone warnings * fixed fall-through behavior * removed bad prox code
This commit is contained in:
@@ -302,7 +302,7 @@ bool SteamIVRInput::chaperoneToggle()
|
||||
|
||||
bool SteamIVRInput::proxState()
|
||||
{
|
||||
return isDigitalActionActivatedConstant( m_pushToTalk );
|
||||
return isDigitalActionActivatedConstant( m_proxSensor );
|
||||
}
|
||||
|
||||
bool SteamIVRInput::keyboardOne()
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace action_keys
|
||||
|
||||
constexpr auto hapticsLeft = "/actions/haptic/out/HapticsLeft";
|
||||
constexpr auto hapticsRight = "/actions/haptic/out/HapticsRight";
|
||||
constexpr auto proxSensor = "/actions/misc/in/ProxSensor";
|
||||
constexpr auto proxSensor = "/actions/haptic/in/ProxSensor";
|
||||
|
||||
constexpr auto chaperoneToggle = "/actions/misc/in/ChaperoneToggle";
|
||||
|
||||
|
||||
@@ -33,7 +33,25 @@ OverlayController::OverlayController( bool desktopMode,
|
||||
QQmlEngine& qmlEngine )
|
||||
: QObject(), m_desktopMode( desktopMode ), m_noSound( noSound ), m_actions()
|
||||
{
|
||||
m_runtimePathUrl = QUrl::fromLocalFile( vr::VR_RuntimePath() );
|
||||
// Arbitrarily chosen Max Length of Directory path, should be sufficient for
|
||||
// Any set-up
|
||||
const uint32_t maxLength = 16192;
|
||||
uint32_t requiredLength;
|
||||
|
||||
char tempRuntimePath[maxLength];
|
||||
bool pathIsGood
|
||||
= vr::VR_GetRuntimePath( tempRuntimePath, maxLength, &requiredLength );
|
||||
|
||||
// Throw Error If over 16k characters in path string
|
||||
if ( !pathIsGood )
|
||||
{
|
||||
LOG( ERROR ) << "Error Finding VR Runtime Path, Attempting Recovery: ";
|
||||
uint32_t maxLengthRe = requiredLength;
|
||||
LOG( INFO ) << "Open VR reporting Required path length of: "
|
||||
<< maxLengthRe;
|
||||
}
|
||||
|
||||
m_runtimePathUrl = QUrl::fromLocalFile( tempRuntimePath );
|
||||
LOG( INFO ) << "VR Runtime Path: " << m_runtimePathUrl.toLocalFile();
|
||||
|
||||
QString activationSoundFile = m_runtimePathUrl.toLocalFile().append(
|
||||
@@ -587,12 +605,32 @@ void OverlayController::processChaperoneBindings()
|
||||
m_chaperoneTabController.setDisableChaperone(
|
||||
!( m_chaperoneTabController.disableChaperone() ), true );
|
||||
}
|
||||
m_chaperoneTabController.setProxState( m_actions.proxState() );
|
||||
}
|
||||
|
||||
void OverlayController::processPushToTalkBindings()
|
||||
{
|
||||
const auto pushToTalkCannotChange = !m_audioTabController.pttChangeValid();
|
||||
const auto pushToTalkEnabled = m_audioTabController.pttEnabled();
|
||||
|
||||
const auto proxSensorActivated = m_actions.proxState();
|
||||
const auto useProxSensor = m_audioTabController.micProximitySensorCanMute();
|
||||
|
||||
if ( useProxSensor )
|
||||
{
|
||||
if ( !proxSensorActivated )
|
||||
{
|
||||
m_audioTabController.setMicMuted( true );
|
||||
return;
|
||||
}
|
||||
// strictly speaking this is not the most elegant solution, but should
|
||||
// work well enough.
|
||||
else if ( !pushToTalkEnabled )
|
||||
{
|
||||
m_audioTabController.setMicMuted( false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( pushToTalkCannotChange || !pushToTalkEnabled )
|
||||
{
|
||||
return;
|
||||
@@ -600,6 +638,7 @@ void OverlayController::processPushToTalkBindings()
|
||||
|
||||
const auto pushToTalkButtonActivated = m_actions.pushToTalk();
|
||||
const auto pushToTalkCurrentlyActive = m_audioTabController.pttActive();
|
||||
|
||||
if ( pushToTalkButtonActivated && !pushToTalkCurrentlyActive )
|
||||
{
|
||||
m_audioTabController.startPtt();
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "/actions/misc/in/ProxSensor",
|
||||
"name": "/actions/haptic/in/ProxSensor",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -235,7 +235,7 @@
|
||||
"/actions/misc/in/ZAxisLockToggle" : "Z-Axis Lock Toggle",
|
||||
"/actions/misc/in/PushToTalk" : "Push To Talk",
|
||||
"/actions/misc/in/ChaperoneToggle" : "Chaperone Toggle",
|
||||
"/actions/misc/in/ProxSensor" : "Proximity Sensor",
|
||||
"/actions/haptic/in/ProxSensor" : "Proximity Sensor",
|
||||
"/actions/misc/in/KeyboardOne" : "Keyboard Shortcut One",
|
||||
"/actions/misc/in/KeyboardTwo" : "Keyboard Shortcut Two",
|
||||
"/actions/misc/in/KeyboardThree" : "Keyboard Shortcut Three"
|
||||
|
||||
+2
-2
@@ -5,12 +5,12 @@
|
||||
"app_key" : "ovras-team.advancedsettings",
|
||||
"bindings":
|
||||
{
|
||||
"/actions/misc" : {
|
||||
"/actions/haptic" : {
|
||||
"sources" : [
|
||||
{
|
||||
"inputs" : {
|
||||
"click" : {
|
||||
"output" : "/actions/misc/in/ProxSensor"
|
||||
"output" : "/actions/haptic/in/ProxSensor"
|
||||
}
|
||||
},
|
||||
"mode" : "button",
|
||||
|
||||
@@ -4,7 +4,8 @@ import QtQuick.Layouts 1.3
|
||||
import QtQuick.Dialogs 1.2
|
||||
import ovras.advsettings 1.0
|
||||
import "." // QTBUG-34418, singletons require explicit import to load qmldir file
|
||||
import "common"
|
||||
import "../common"
|
||||
import "change_orientation"
|
||||
|
||||
MyStackViewPage {
|
||||
headerText: "Chaperone Settings"
|
||||
@@ -489,15 +490,8 @@ MyStackViewPage {
|
||||
mainView.push(chaperoneWarningsPage)
|
||||
}
|
||||
}
|
||||
ChangeOrientationGroupBox { }
|
||||
|
||||
MyPushButton {
|
||||
id: chaperoneFlipOrientationButton
|
||||
text: "Flip Orientation"
|
||||
Layout.preferredWidth: 250
|
||||
onClicked: {
|
||||
ChaperoneTabController.flipOrientation()
|
||||
}
|
||||
}
|
||||
|
||||
Item { Layout.fillHeight: true; Layout.fillWidth: true}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.3
|
||||
import ovras.advsettings 1.0
|
||||
import "../../common"
|
||||
import "." // QTBUG-34418, singletons require explicit import to load qmldir file
|
||||
|
||||
GroupBox {
|
||||
id: changeOrientationGroupBox
|
||||
Layout.fillWidth: true
|
||||
|
||||
label: MyText {
|
||||
leftPadding: 10
|
||||
text: "Rotate Orientation (permanent)"
|
||||
bottomPadding: -10
|
||||
}
|
||||
background: Rectangle {
|
||||
color: "transparent"
|
||||
border.color: "#ffffff"
|
||||
radius: 8
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Rectangle {
|
||||
color: "#ffffff"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
Layout.bottomMargin: 5
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
RowLayout {
|
||||
MyPushButton2 {
|
||||
id: spaceRotationMinusButton
|
||||
Layout.preferredWidth: 40
|
||||
text: "-"
|
||||
onClicked: {
|
||||
var val = spaceRotationSlider.value - 45
|
||||
if (val <= -180){
|
||||
val = -180;
|
||||
}
|
||||
spaceRotationSlider.value = val
|
||||
spaceRotationText.text = val
|
||||
}
|
||||
}
|
||||
|
||||
MySlider {
|
||||
id: spaceRotationSlider
|
||||
from: -180
|
||||
to: 180
|
||||
stepSize: 1
|
||||
value: 0
|
||||
Layout.fillWidth: true
|
||||
onValueChanged: {
|
||||
var val = this.value
|
||||
spaceRotationText.text = val
|
||||
}
|
||||
}
|
||||
|
||||
MyPushButton2 {
|
||||
id: spaceRotationPlusButton
|
||||
Layout.preferredWidth: 40
|
||||
text: "+"
|
||||
onClicked: {
|
||||
var val = spaceRotationSlider.value + 45
|
||||
if (val >= 180){
|
||||
val = 180;
|
||||
}
|
||||
spaceRotationSlider.value = val
|
||||
spaceRotationText.text = val
|
||||
}
|
||||
}
|
||||
|
||||
MyTextField {
|
||||
id: spaceRotationText
|
||||
text: "0°"
|
||||
keyBoardUID: 311
|
||||
Layout.preferredWidth: 150
|
||||
Layout.leftMargin: 10
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
function onInputEvent(input) {
|
||||
var val = parseFloat(input)
|
||||
if (!isNaN(val)) {
|
||||
spaceRotationText.text = val + "°"
|
||||
spaceRotationSlider.value = val
|
||||
}
|
||||
}
|
||||
}
|
||||
MyPushButton {
|
||||
id: spaceRotationApplyButton
|
||||
Layout.preferredWidth: 145
|
||||
text:"Apply"
|
||||
onClicked: {
|
||||
ChaperoneTabController.flipOrientation(spaceRotationSlider.value)
|
||||
spaceRotationSlider.value = 0
|
||||
spaceRotationText.text = "0°"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import "../audio_page"
|
||||
import "../motion_page"
|
||||
import "../video_page"
|
||||
import "../desktop_overlay_page"
|
||||
import "../chaperone_page"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
@@ -172,43 +172,6 @@ void AudioTabController::eventLoopTick()
|
||||
|
||||
if ( settingsUpdateCounter >= k_audioSettingsUpdateCounter )
|
||||
{
|
||||
// Not usable until OpenVR 1.4.x?
|
||||
// Will require updates to action based system
|
||||
/*
|
||||
if ( m_micProximitySensorCanMute )
|
||||
{
|
||||
vr::VRControllerState_t controllerState;
|
||||
if ( vr::VRSystem()->GetControllerState(
|
||||
vr::k_unTrackedDeviceIndex_Hmd,
|
||||
&controllerState,
|
||||
sizeof( vr::VRControllerState_t ) ) )
|
||||
{
|
||||
if ( ( controllerState.ulButtonPressed
|
||||
& vr::ButtonMaskFromId( vr::k_EButton_ProximitySensor ) )
|
||||
== 0 )
|
||||
{
|
||||
if ( !m_micMuted )
|
||||
{
|
||||
setMicMuted( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_micMuted )
|
||||
{
|
||||
setMicMuted( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !parent->isDashboardVisible() )
|
||||
{
|
||||
LOG( ERROR ) << "Could not read proximity sensor!";
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
char mirrorDeviceId[1024];
|
||||
vr::VRSettings()->GetString(
|
||||
|
||||
@@ -42,8 +42,8 @@ void ChaperoneTabController::initStage1()
|
||||
m_fadeDistanceRemembered
|
||||
= settings->value( "fadeDistanceRemembered", 0.5f ).toFloat();
|
||||
settings->endGroup();
|
||||
// initHaptics();
|
||||
reloadChaperoneProfiles();
|
||||
|
||||
eventLoopTick( nullptr, 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
|
||||
@@ -362,6 +362,15 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
|
||||
vr::VRSystem()->GetControllerState( vr::k_unTrackedDeviceIndex_Hmd,
|
||||
&hmdState,
|
||||
sizeof( vr::VRControllerState_t ) );
|
||||
// If proximity Sensor is True (only can be true if exists)
|
||||
// Then use prox sensor else use hmd activity level.
|
||||
// Needed as detection since the "has prox sensor" property is unreliable.
|
||||
// Note m_isProxActive should only ever be set to true if there is a prox
|
||||
// sensor AND its currently on.
|
||||
|
||||
bool proxSensorOverrideState = false;
|
||||
m_HMDHasProx ? ( proxSensorOverrideState = m_isProxActive )
|
||||
: ( proxSensorOverrideState = m_isHMDActive );
|
||||
|
||||
// Switch to Beginner Mode
|
||||
if ( m_enableChaperoneSwitchToBeginner )
|
||||
@@ -439,7 +448,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
|
||||
float activationDistance = m_chaperoneHapticFeedbackDistance
|
||||
* m_chaperoneVelocityModifierCurrent;
|
||||
|
||||
if ( distance <= activationDistance && m_isHMDActive )
|
||||
if ( distance <= activationDistance && proxSensorOverrideState )
|
||||
{
|
||||
if ( !m_chaperoneHapticFeedbackActive )
|
||||
{
|
||||
@@ -493,7 +502,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
|
||||
this );
|
||||
}
|
||||
}
|
||||
else if ( ( distance > activationDistance || !m_isHMDActive )
|
||||
else if ( ( distance > activationDistance || !proxSensorOverrideState )
|
||||
&& m_chaperoneHapticFeedbackActive )
|
||||
{
|
||||
m_chaperoneHapticFeedbackActive = false;
|
||||
@@ -507,7 +516,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
|
||||
float activationDistance = m_chaperoneAlarmSoundDistance
|
||||
* m_chaperoneVelocityModifierCurrent;
|
||||
|
||||
if ( distance <= activationDistance && m_isHMDActive )
|
||||
if ( distance <= activationDistance && proxSensorOverrideState )
|
||||
{
|
||||
if ( !m_chaperoneAlarmSoundActive )
|
||||
{
|
||||
@@ -529,7 +538,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
|
||||
parent->setAlarm01SoundVolume( 1.0f );
|
||||
}
|
||||
}
|
||||
else if ( ( distance > activationDistance || !m_isHMDActive )
|
||||
else if ( ( distance > activationDistance || !proxSensorOverrideState )
|
||||
&& m_chaperoneAlarmSoundActive )
|
||||
{
|
||||
parent->cancelAlarm01Sound();
|
||||
@@ -1311,11 +1320,14 @@ void ChaperoneTabController::setDisableChaperone( bool value, bool notify )
|
||||
}
|
||||
}
|
||||
|
||||
void ChaperoneTabController::flipOrientation()
|
||||
void ChaperoneTabController::flipOrientation( double degrees )
|
||||
{
|
||||
parent->m_moveCenterTabController.reset();
|
||||
double rad = 0;
|
||||
rad = degrees * ( M_PI / 180.0 );
|
||||
|
||||
parent->RotateUniverseCenter( vr::TrackingUniverseStanding,
|
||||
static_cast<float>( M_PI ) );
|
||||
static_cast<float>( rad ) );
|
||||
parent->m_moveCenterTabController.zeroOffsets();
|
||||
}
|
||||
|
||||
@@ -1728,6 +1740,16 @@ void ChaperoneTabController::setLeftInputHandle(
|
||||
m_leftInputHandle = handle;
|
||||
}
|
||||
|
||||
void ChaperoneTabController::setProxState( bool value )
|
||||
{
|
||||
if ( value )
|
||||
{
|
||||
m_HMDHasProx = true;
|
||||
}
|
||||
|
||||
m_isProxActive = value;
|
||||
}
|
||||
|
||||
void ChaperoneTabController::shutdown()
|
||||
{
|
||||
if ( m_enableChaperoneSwitchToBeginner
|
||||
|
||||
@@ -175,6 +175,8 @@ private:
|
||||
|
||||
bool m_isHapticGood = true;
|
||||
bool m_isHMDActive = false;
|
||||
bool m_isProxActive = false;
|
||||
bool m_HMDHasProx = false;
|
||||
|
||||
int m_updateTicksChaperoneReload = 0;
|
||||
|
||||
@@ -210,6 +212,8 @@ public:
|
||||
void setRightInputHandle( vr::VRInputValueHandle_t handle );
|
||||
void setLeftInputHandle( vr::VRInputValueHandle_t handle );
|
||||
|
||||
void setProxState( bool value );
|
||||
|
||||
bool isChaperoneSwitchToBeginnerEnabled() const;
|
||||
float chaperoneSwitchToBeginnerDistance() const;
|
||||
|
||||
@@ -263,7 +267,7 @@ public slots:
|
||||
void setChaperoneVelocityModifierEnabled( bool value, bool notify = true );
|
||||
void setChaperoneVelocityModifier( float value, bool notify = true );
|
||||
|
||||
void flipOrientation();
|
||||
void flipOrientation( double degrees = 180 );
|
||||
void reloadFromDisk();
|
||||
|
||||
void addChaperoneProfile( QString name,
|
||||
|
||||
@@ -229,14 +229,14 @@ void FixFloorTabController::eventLoopTick(
|
||||
int FixFloorTabController::getControllerType(
|
||||
vr::TrackedDeviceIndex_t controllerRole )
|
||||
{
|
||||
int maxLength = 64;
|
||||
const uint32_t maxLength = 64;
|
||||
/*
|
||||
vr::k_unMaxPropertyStringSize is Theoretical Max Size, however it is
|
||||
1024*32, and its pretty unrealistic to expect a controller name to be that
|
||||
big. We are just going to set 64 as an arbitrary size, and print error to
|
||||
log if too small
|
||||
*/
|
||||
char* controllerTypeString = new char[maxLength];
|
||||
char controllerTypeString[maxLength];
|
||||
vr::ETrackedPropertyError error;
|
||||
auto stringLength = vr::VRSystem()->GetStringTrackedDeviceProperty(
|
||||
controllerRole,
|
||||
@@ -255,15 +255,12 @@ int FixFloorTabController::getControllerType(
|
||||
}
|
||||
else if ( strcmp( controllerTypeString, "knuckles" ) == 0 )
|
||||
{
|
||||
delete[] controllerTypeString;
|
||||
return Controller_Knuckles;
|
||||
}
|
||||
else if ( strcmp( controllerTypeString, "vive_controller" ) == 0 )
|
||||
{
|
||||
delete[] controllerTypeString;
|
||||
return Controller_Wand;
|
||||
}
|
||||
delete[] controllerTypeString;
|
||||
return Controller_Unknown;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user