Add an optional pop-up notification when auto-turn is toggled (#496)
* Implement (most of) pop-up notification when autoturn is enabled * Add neato fading: doesn't appear to impact performance * formatting * added macro and UI for notification of auto-turn * changed notification default to true for auto-turn * added common issue for trackers * added warning for custom keys * minor documentation markdown format fixes * fix qml syntax error in atgb * gasd Co-authored-by: ykeara <ykeara1@gmail.com>
This commit is contained in:
@@ -63,18 +63,6 @@ void AudioTabController::initStage1()
|
||||
eventLoopTick();
|
||||
}
|
||||
|
||||
std::optional<std::string> verifyIconFilePath( std::string filename )
|
||||
{
|
||||
const auto notifIconPath = paths::binaryDirectoryFindFile( filename );
|
||||
if ( !notifIconPath.has_value() )
|
||||
{
|
||||
LOG( ERROR ) << "Could not find push to talk icon \"" << filename
|
||||
<< "\"";
|
||||
}
|
||||
|
||||
return notifIconPath;
|
||||
}
|
||||
|
||||
void AudioTabController::initStage2()
|
||||
{
|
||||
const auto pushToTalkOverlayKey
|
||||
@@ -102,9 +90,9 @@ void AudioTabController::initStage2()
|
||||
= "/res/img/audio/microphone/ptm_notification.png";
|
||||
|
||||
const auto pushToTalkIconFilePath
|
||||
= verifyIconFilePath( pushToTalkIconFilepath );
|
||||
= paths::verifyIconFilePath( pushToTalkIconFilepath );
|
||||
const auto pushToMuteIconFilePath
|
||||
= verifyIconFilePath( pushToMuteIconFilepath );
|
||||
= paths::verifyIconFilePath( pushToMuteIconFilepath );
|
||||
|
||||
if ( !pushToTalkIconFilePath.has_value()
|
||||
|| !pushToMuteIconFilePath.has_value() )
|
||||
|
||||
@@ -17,6 +17,60 @@ void RotationTabController::initStage1()
|
||||
|
||||
void RotationTabController::initStage2( OverlayController* var_parent )
|
||||
{
|
||||
const auto autoturnOverlayKey
|
||||
= std::string( application_strings::applicationKey )
|
||||
+ ".autoturnnotification";
|
||||
|
||||
const auto overlayError
|
||||
= vr::VROverlay()->CreateOverlay( autoturnOverlayKey.c_str(),
|
||||
autoturnOverlayKey.c_str(),
|
||||
&m_autoturnValues.overlayHandle );
|
||||
if ( overlayError != vr::VROverlayError_None )
|
||||
{
|
||||
LOG( ERROR ) << "Could not create autoturn notification overlay: "
|
||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||
overlayError );
|
||||
|
||||
emit defaultProfileDisplay();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr auto autoturnIconFilepath = "/res/img/rotation/autoturn.png";
|
||||
constexpr auto noautoturnIconFilepath = "/res/img/rotation/noautoturn.png";
|
||||
|
||||
const auto autoturnIconFilePath
|
||||
= paths::verifyIconFilePath( autoturnIconFilepath );
|
||||
const auto noautoturnIconFilePath
|
||||
= paths::verifyIconFilePath( noautoturnIconFilepath );
|
||||
|
||||
if ( !autoturnIconFilePath.has_value()
|
||||
|| !noautoturnIconFilePath.has_value() )
|
||||
{
|
||||
emit defaultProfileDisplay();
|
||||
return;
|
||||
}
|
||||
|
||||
m_autoturnValues.autoturnPath = *autoturnIconFilePath;
|
||||
m_autoturnValues.noautoturnPath = *noautoturnIconFilePath;
|
||||
|
||||
auto pushToPath = m_autoturnValues.autoturnPath.c_str();
|
||||
|
||||
vr::VROverlay()->SetOverlayFromFile( m_autoturnValues.overlayHandle,
|
||||
pushToPath );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_autoturnValues.overlayHandle,
|
||||
0.02f );
|
||||
vr::HmdMatrix34_t notificationTransform
|
||||
= { { { 1.0f, 0.0f, 0.0f, 0.12f },
|
||||
{ 0.0f, 1.0f, 0.0f, 0.08f },
|
||||
{ 0.0f, 0.0f, 1.0f, -0.3f } } };
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
m_autoturnValues.overlayHandle,
|
||||
vr::k_unTrackedDeviceIndex_Hmd,
|
||||
¬ificationTransform );
|
||||
|
||||
emit defaultProfileDisplay();
|
||||
|
||||
this->parent = var_parent;
|
||||
}
|
||||
|
||||
@@ -65,6 +119,29 @@ void RotationTabController::eventLoopTick(
|
||||
m_autoTurnChaperoneDistancesLast = std::move( chaperoneDistances );
|
||||
}
|
||||
}
|
||||
if ( m_autoTurnNotificationTimestamp )
|
||||
{
|
||||
auto count = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now()
|
||||
- *m_autoTurnNotificationTimestamp )
|
||||
.count();
|
||||
if ( count > 1500 )
|
||||
{
|
||||
m_autoTurnNotificationTimestamp.reset();
|
||||
if ( getNotificationOverlayHandle()
|
||||
!= vr::k_ulOverlayHandleInvalid )
|
||||
{
|
||||
vr::VROverlay()->HideOverlay( getNotificationOverlayHandle() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float pct
|
||||
= std::min( 1.0f, 3.0f - static_cast<float>( count ) / 500.0f );
|
||||
vr::VROverlay()->SetOverlayAlpha( getNotificationOverlayHandle(),
|
||||
pct );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RotationTabController::doVestibularMotion(
|
||||
@@ -453,6 +530,12 @@ bool RotationTabController::autoTurnUseCornerAngle() const
|
||||
settings::BoolSetting::ROTATION_autoturnUseCornerAngle );
|
||||
}
|
||||
|
||||
bool RotationTabController::autoTurnShowNotification() const
|
||||
{
|
||||
return settings::getSetting(
|
||||
settings::BoolSetting::ROTATION_autoturnShowNotification );
|
||||
}
|
||||
|
||||
double RotationTabController::cordDetangleAngle() const
|
||||
{
|
||||
return settings::getSetting(
|
||||
@@ -505,6 +588,39 @@ void RotationTabController::setAutoTurnEnabled( bool value, bool notify )
|
||||
{
|
||||
emit autoTurnEnabledChanged( value );
|
||||
}
|
||||
|
||||
if ( !value )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_autoturnValues.overlayHandle,
|
||||
m_autoturnValues.noautoturnPath.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_autoturnValues.overlayHandle,
|
||||
m_autoturnValues.autoturnPath.c_str() );
|
||||
}
|
||||
|
||||
if ( autoTurnShowNotification()
|
||||
&& getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayAlpha( getNotificationOverlayHandle(),
|
||||
1.0f );
|
||||
vr::VROverlay()->ShowOverlay( getNotificationOverlayHandle() );
|
||||
m_autoTurnNotificationTimestamp.emplace(
|
||||
std::chrono::steady_clock::now() );
|
||||
}
|
||||
}
|
||||
void RotationTabController::setAutoTurnShowNotification( bool value,
|
||||
bool notify )
|
||||
{
|
||||
settings::setSetting(
|
||||
settings::BoolSetting::ROTATION_autoturnShowNotification, value );
|
||||
if ( notify )
|
||||
{
|
||||
emit autoTurnShowNotificationChanged( value );
|
||||
}
|
||||
}
|
||||
void RotationTabController::setAutoTurnActivationDistance( float value,
|
||||
bool notify )
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <thread>
|
||||
#include <openvr.h>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
#include "../utils/FrameRateUtils.h"
|
||||
#include "../utils/ChaperoneUtils.h"
|
||||
#include "../settings/settings_object.h"
|
||||
@@ -82,10 +83,25 @@ class RotationTabController : public QObject
|
||||
Q_PROPERTY(
|
||||
double vestibularMotionRadius READ vestibularMotionRadius WRITE
|
||||
setVestibularMotionRadius NOTIFY vestibularMotionRadiusChanged )
|
||||
Q_PROPERTY(
|
||||
bool autoTurnShowNotification READ autoTurnShowNotification WRITE
|
||||
setAutoTurnShowNotification NOTIFY autoTurnShowNotificationChanged )
|
||||
|
||||
private:
|
||||
OverlayController* parent;
|
||||
|
||||
struct
|
||||
{
|
||||
vr::VROverlayHandle_t overlayHandle = vr::k_ulOverlayHandleInvalid;
|
||||
std::string autoturnPath;
|
||||
std::string noautoturnPath;
|
||||
} m_autoturnValues;
|
||||
|
||||
virtual vr::VROverlayHandle_t getNotificationOverlayHandle()
|
||||
{
|
||||
return m_autoturnValues.overlayHandle;
|
||||
}
|
||||
|
||||
// Variables
|
||||
int m_autoTurnLinearSmoothTurnRemaining = 0;
|
||||
std::chrono::steady_clock::time_point m_autoTurnLastUpdate;
|
||||
@@ -95,6 +111,9 @@ private:
|
||||
double m_autoTurnRoundingError = 0.0;
|
||||
std::chrono::steady_clock::time_point::duration m_estimatedFrameRate;
|
||||
|
||||
std::optional<std::chrono::steady_clock::time_point>
|
||||
m_autoTurnNotificationTimestamp;
|
||||
|
||||
bool m_isHMDActive = false;
|
||||
|
||||
void doAutoTurn(
|
||||
@@ -116,6 +135,7 @@ public:
|
||||
float autoTurnActivationDistance() const;
|
||||
float autoTurnDeactivationDistance() const;
|
||||
bool autoTurnUseCornerAngle() const;
|
||||
bool autoTurnShowNotification() const;
|
||||
double cordDetangleAngle() const;
|
||||
double minCordTangle() const;
|
||||
int autoTurnSpeed() const;
|
||||
@@ -126,6 +146,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void setAutoTurnEnabled( bool value, bool notify = true );
|
||||
void setAutoTurnShowNotification( bool value, bool notify = true );
|
||||
void setAutoTurnActivationDistance( float value, bool notify = true );
|
||||
void setAutoTurnDeactivationDistance( float value, bool notify = true );
|
||||
void setAutoTurnUseCornerAngle( bool value, bool notify = true );
|
||||
@@ -138,7 +159,9 @@ public slots:
|
||||
|
||||
signals:
|
||||
|
||||
void defaultProfileDisplay();
|
||||
void autoTurnEnabledChanged( bool value );
|
||||
void autoTurnShowNotificationChanged( bool value );
|
||||
void autoTurnActivationDistanceChanged( float value );
|
||||
void autoTurnDeactivationDistanceChanged( float value );
|
||||
void autoTurnUseCornerAngleChanged( bool value );
|
||||
|
||||
Reference in New Issue
Block a user