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:
ykeara
2019-06-14 12:33:56 -05:00
committed by GitHub
parent 8e34e9edca
commit b473f4d7db
32 changed files with 419 additions and 130 deletions
-37
View File
@@ -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(
+29 -7
View File
@@ -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
+5 -1
View File
@@ -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,
+2 -5
View File
@@ -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;
}