Format every single file using .clang-format
This commit is contained in:
+233
-99
@@ -12,99 +12,174 @@
|
|||||||
|
|
||||||
INITIALIZE_EASYLOGGINGPP
|
INITIALIZE_EASYLOGGINGPP
|
||||||
|
|
||||||
void myQtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
void myQtMessageHandler( QtMsgType type,
|
||||||
|
const QMessageLogContext& context,
|
||||||
|
const QString& msg )
|
||||||
|
{
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
switch (type) {
|
switch ( type )
|
||||||
|
{
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
LOG(DEBUG) << localMsg.constData() << " (" << context.file << ":" << context.line << ")";
|
LOG( DEBUG ) << localMsg.constData() << " (" << context.file << ":"
|
||||||
|
<< context.line << ")";
|
||||||
break;
|
break;
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
LOG(INFO) << localMsg.constData() << " (" << context.file << ":" << context.line << ")";
|
LOG( INFO ) << localMsg.constData() << " (" << context.file << ":"
|
||||||
|
<< context.line << ")";
|
||||||
break;
|
break;
|
||||||
case QtWarningMsg:
|
case QtWarningMsg:
|
||||||
LOG(WARNING) << localMsg.constData() << " (" << context.file << ":" << context.line << ")";
|
LOG( WARNING ) << localMsg.constData() << " (" << context.file << ":"
|
||||||
|
<< context.line << ")";
|
||||||
break;
|
break;
|
||||||
case QtCriticalMsg:
|
case QtCriticalMsg:
|
||||||
LOG(ERROR) << localMsg.constData() << " (" << context.file << ":" << context.line << ")";
|
LOG( ERROR ) << localMsg.constData() << " (" << context.file << ":"
|
||||||
|
<< context.line << ")";
|
||||||
break;
|
break;
|
||||||
case QtFatalMsg:
|
case QtFatalMsg:
|
||||||
LOG(FATAL) << localMsg.constData() << " (" << context.file << ":" << context.line << ")";
|
LOG( FATAL ) << localMsg.constData() << " (" << context.file << ":"
|
||||||
|
<< context.line << ")";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void installManifest(bool cleaninstall = false) {
|
void installManifest( bool cleaninstall = false )
|
||||||
auto manifestQPath = QDir::cleanPath(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("manifest.vrmanifest"));
|
{
|
||||||
if (QFile::exists(manifestQPath)) {
|
auto manifestQPath
|
||||||
|
= QDir::cleanPath( QDir( QCoreApplication::applicationDirPath() )
|
||||||
|
.absoluteFilePath( "manifest.vrmanifest" ) );
|
||||||
|
if ( QFile::exists( manifestQPath ) )
|
||||||
|
{
|
||||||
bool alreadyInstalled = false;
|
bool alreadyInstalled = false;
|
||||||
if (vr::VRApplications()->IsApplicationInstalled(advsettings::OverlayController::applicationKey)) {
|
if ( vr::VRApplications()->IsApplicationInstalled(
|
||||||
if (cleaninstall) {
|
advsettings::OverlayController::applicationKey ) )
|
||||||
|
{
|
||||||
|
if ( cleaninstall )
|
||||||
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
auto appError = vr::VRApplicationError_None;
|
auto appError = vr::VRApplicationError_None;
|
||||||
vr::VRApplications()->GetApplicationPropertyString(advsettings::OverlayController::applicationKey, vr::VRApplicationProperty_WorkingDirectory_String, buffer, 1024, &appError);
|
vr::VRApplications()->GetApplicationPropertyString(
|
||||||
if (appError == vr::VRApplicationError_None) {
|
advsettings::OverlayController::applicationKey,
|
||||||
auto oldManifestQPath = QDir::cleanPath(QDir(buffer).absoluteFilePath("manifest.vrmanifest"));
|
vr::VRApplicationProperty_WorkingDirectory_String,
|
||||||
if (oldManifestQPath.compare(manifestQPath, Qt::CaseInsensitive) != 0) {
|
buffer,
|
||||||
vr::VRApplications()->RemoveApplicationManifest(QDir::toNativeSeparators(oldManifestQPath).toStdString().c_str());
|
1024,
|
||||||
} else {
|
&appError );
|
||||||
|
if ( appError == vr::VRApplicationError_None )
|
||||||
|
{
|
||||||
|
auto oldManifestQPath
|
||||||
|
= QDir::cleanPath( QDir( buffer ).absoluteFilePath(
|
||||||
|
"manifest.vrmanifest" ) );
|
||||||
|
if ( oldManifestQPath.compare( manifestQPath,
|
||||||
|
Qt::CaseInsensitive )
|
||||||
|
!= 0 )
|
||||||
|
{
|
||||||
|
vr::VRApplications()->RemoveApplicationManifest(
|
||||||
|
QDir::toNativeSeparators( oldManifestQPath )
|
||||||
|
.toStdString()
|
||||||
|
.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
alreadyInstalled = true;
|
alreadyInstalled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
alreadyInstalled = true;
|
alreadyInstalled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto apperror = vr::VRApplications()->AddApplicationManifest(QDir::toNativeSeparators(manifestQPath).toStdString().c_str());
|
auto apperror = vr::VRApplications()->AddApplicationManifest(
|
||||||
if (apperror != vr::VRApplicationError_None) {
|
QDir::toNativeSeparators( manifestQPath ).toStdString().c_str() );
|
||||||
throw std::runtime_error(std::string("Could not add application manifest: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror)));
|
if ( apperror != vr::VRApplicationError_None )
|
||||||
} else if (!alreadyInstalled || cleaninstall) {
|
{
|
||||||
auto app_error = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true);
|
throw std::runtime_error(
|
||||||
if (app_error != vr::VRApplicationError_None) {
|
std::string( "Could not add application manifest: " )
|
||||||
throw std::runtime_error(std::string("Could not set auto start: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror)));
|
+ std::string(
|
||||||
|
vr::VRApplications()->GetApplicationsErrorNameFromEnum(
|
||||||
|
apperror ) ) );
|
||||||
|
}
|
||||||
|
else if ( !alreadyInstalled || cleaninstall )
|
||||||
|
{
|
||||||
|
auto app_error = vr::VRApplications()->SetApplicationAutoLaunch(
|
||||||
|
advsettings::OverlayController::applicationKey, true );
|
||||||
|
if ( app_error != vr::VRApplicationError_None )
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
std::string( "Could not set auto start: " )
|
||||||
|
+ std::string( vr::VRApplications()
|
||||||
|
->GetApplicationsErrorNameFromEnum(
|
||||||
|
apperror ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
throw std::runtime_error(std::string("Could not find application manifest: ") + manifestQPath.toStdString());
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
std::string( "Could not find application manifest: " )
|
||||||
|
+ manifestQPath.toStdString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeManifest() {
|
void removeManifest()
|
||||||
auto manifestQPath = QDir::cleanPath(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("manifest.vrmanifest"));
|
{
|
||||||
if (QFile::exists(manifestQPath)) {
|
auto manifestQPath
|
||||||
if (vr::VRApplications()->IsApplicationInstalled(advsettings::OverlayController::applicationKey)) {
|
= QDir::cleanPath( QDir( QCoreApplication::applicationDirPath() )
|
||||||
vr::VRApplications()->RemoveApplicationManifest(QDir::toNativeSeparators(manifestQPath).toStdString().c_str());
|
.absoluteFilePath( "manifest.vrmanifest" ) );
|
||||||
|
if ( QFile::exists( manifestQPath ) )
|
||||||
|
{
|
||||||
|
if ( vr::VRApplications()->IsApplicationInstalled(
|
||||||
|
advsettings::OverlayController::applicationKey ) )
|
||||||
|
{
|
||||||
|
vr::VRApplications()->RemoveApplicationManifest(
|
||||||
|
QDir::toNativeSeparators( manifestQPath )
|
||||||
|
.toStdString()
|
||||||
|
.c_str() );
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
throw std::runtime_error(std::string("Could not find application manifest: ") + manifestQPath.toStdString());
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
std::string( "Could not find application manifest: " )
|
||||||
|
+ manifestQPath.toStdString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MyQApplication : public QApplication
|
||||||
class MyQApplication : public QApplication {
|
{
|
||||||
public:
|
public:
|
||||||
using QApplication::QApplication;
|
using QApplication::QApplication;
|
||||||
|
|
||||||
virtual bool notify(QObject * receiver, QEvent * event) override {
|
virtual bool notify( QObject* receiver, QEvent* event ) override
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
return QApplication::notify( receiver, event );
|
return QApplication::notify( receiver, event );
|
||||||
} catch (std::exception& e) {
|
}
|
||||||
LOG(ERROR) << "Exception thrown from an event handler: " << e.what();
|
catch ( std::exception& e )
|
||||||
|
{
|
||||||
|
LOG( ERROR ) << "Exception thrown from an event handler: "
|
||||||
|
<< e.what();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace argument
|
||||||
|
{
|
||||||
namespace argument {
|
|
||||||
// Checks whether a specific string was passed as a launch argument.
|
// Checks whether a specific string was passed as a launch argument.
|
||||||
bool CheckCommandLineArgument(int argc, char *argv[], const std::string parameter) {
|
bool CheckCommandLineArgument( int argc,
|
||||||
|
char* argv[],
|
||||||
|
const std::string parameter )
|
||||||
|
{
|
||||||
// The old way was one giant loop that tested every single parameter.
|
// The old way was one giant loop that tested every single parameter.
|
||||||
// Having an individual loop for all args most likely has a very small performance
|
// Having an individual loop for all args most likely has a very small
|
||||||
// penalty compared to the original solution,
|
// performance penalty compared to the original solution, but the gains in
|
||||||
// but the gains in readability and ease of extension of not having a hundred line+ for loop are worth it.
|
// readability and ease of extension of not having a hundred line+ for loop
|
||||||
for (int i = 0; i < argc; i++) {
|
// are worth it.
|
||||||
if (std::string(argv[i]) == parameter) {
|
for ( int i = 0; i < argc; i++ )
|
||||||
|
{
|
||||||
|
if ( std::string( argv[i] ) == parameter )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,20 +191,21 @@ namespace argument {
|
|||||||
constexpr auto NO_MANIFEST = "-nomanifest";
|
constexpr auto NO_MANIFEST = "-nomanifest";
|
||||||
constexpr auto INSTALL_MANIFEST = "-installmanifest";
|
constexpr auto INSTALL_MANIFEST = "-installmanifest";
|
||||||
constexpr auto REMOVE_MANIFEST = "-removemanifest";
|
constexpr auto REMOVE_MANIFEST = "-removemanifest";
|
||||||
}
|
} // namespace argument
|
||||||
|
|
||||||
enum ReturnErrorCode {
|
enum ReturnErrorCode
|
||||||
|
{
|
||||||
SUCCESS = 0,
|
SUCCESS = 0,
|
||||||
GENERAL_FAILURE = -1,
|
GENERAL_FAILURE = -1,
|
||||||
OPENVR_INIT_ERROR = -2,
|
OPENVR_INIT_ERROR = -2,
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main( int argc, char* argv[] )
|
||||||
|
{
|
||||||
const char* logConfigFileName = "logging.conf";
|
const char* logConfigFileName = "logging.conf";
|
||||||
|
|
||||||
const char* logConfigDefault =
|
const char* logConfigDefault
|
||||||
"* GLOBAL:\n"
|
= "* GLOBAL:\n"
|
||||||
" FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n"
|
" FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n"
|
||||||
" FILENAME = \"AdvancedSettings.log\"\n"
|
" FILENAME = \"AdvancedSettings.log\"\n"
|
||||||
" ENABLED = true\n"
|
" ENABLED = true\n"
|
||||||
@@ -141,118 +217,176 @@ int main(int argc, char *argv[]) {
|
|||||||
"* DEBUG:\n"
|
"* DEBUG:\n"
|
||||||
" ENABLED = false\n";
|
" ENABLED = false\n";
|
||||||
|
|
||||||
const bool desktop_mode = argument::CheckCommandLineArgument(argc, argv, argument::DESKTOP_MODE);
|
const bool desktop_mode = argument::CheckCommandLineArgument(
|
||||||
const bool no_sound = argument::CheckCommandLineArgument(argc, argv, argument::NO_SOUND);
|
argc, argv, argument::DESKTOP_MODE );
|
||||||
const bool no_manifest = argument::CheckCommandLineArgument(argc, argv, argument::NO_MANIFEST);
|
const bool no_sound
|
||||||
const bool install_manifest = argument::CheckCommandLineArgument(argc, argv, argument::INSTALL_MANIFEST);
|
= argument::CheckCommandLineArgument( argc, argv, argument::NO_SOUND );
|
||||||
const bool remove_manifest = argument::CheckCommandLineArgument(argc, argv, argument::REMOVE_MANIFEST);
|
const bool no_manifest = argument::CheckCommandLineArgument(
|
||||||
|
argc, argv, argument::NO_MANIFEST );
|
||||||
|
const bool install_manifest = argument::CheckCommandLineArgument(
|
||||||
|
argc, argv, argument::INSTALL_MANIFEST );
|
||||||
|
const bool remove_manifest = argument::CheckCommandLineArgument(
|
||||||
|
argc, argv, argument::REMOVE_MANIFEST );
|
||||||
|
|
||||||
if (install_manifest || remove_manifest) {
|
if ( install_manifest || remove_manifest )
|
||||||
|
{
|
||||||
int exit_code = ReturnErrorCode::SUCCESS;
|
int exit_code = ReturnErrorCode::SUCCESS;
|
||||||
QCoreApplication coreApp( argc, argv );
|
QCoreApplication coreApp( argc, argv );
|
||||||
auto openvr_init_status = vr::VRInitError_None;
|
auto openvr_init_status = vr::VRInitError_None;
|
||||||
vr::VR_Init( &openvr_init_status, vr::VRApplication_Utility );
|
vr::VR_Init( &openvr_init_status, vr::VRApplication_Utility );
|
||||||
|
|
||||||
if (openvr_init_status == vr::VRInitError_None) {
|
if ( openvr_init_status == vr::VRInitError_None )
|
||||||
try {
|
{
|
||||||
if (install_manifest) {
|
try
|
||||||
|
{
|
||||||
|
if ( install_manifest )
|
||||||
|
{
|
||||||
installManifest( true );
|
installManifest( true );
|
||||||
}
|
}
|
||||||
else if (remove_manifest) {
|
else if ( remove_manifest )
|
||||||
|
{
|
||||||
removeManifest();
|
removeManifest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch ( std::exception& e )
|
||||||
|
{
|
||||||
exit_code = ReturnErrorCode::GENERAL_FAILURE;
|
exit_code = ReturnErrorCode::GENERAL_FAILURE;
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
exit_code = ReturnErrorCode::OPENVR_INIT_ERROR;
|
exit_code = ReturnErrorCode::OPENVR_INIT_ERROR;
|
||||||
std::cerr << std::string("Failed to initialize OpenVR: " + std::string(vr::VR_GetVRInitErrorAsEnglishDescription(openvr_init_status))) << std::endl;
|
std::cerr << std::string(
|
||||||
|
"Failed to initialize OpenVR: "
|
||||||
|
+ std::string(
|
||||||
|
vr::VR_GetVRInitErrorAsEnglishDescription(
|
||||||
|
openvr_init_status ) ) )
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VR_Shutdown();
|
vr::VR_Shutdown();
|
||||||
exit( exit_code );
|
exit( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
MyQApplication a( argc, argv );
|
MyQApplication a( argc, argv );
|
||||||
a.setOrganizationName( "matzman666" );
|
a.setOrganizationName( "matzman666" );
|
||||||
a.setApplicationName( "OpenVRAdvancedSettings" );
|
a.setApplicationName( "OpenVRAdvancedSettings" );
|
||||||
a.setApplicationDisplayName(advsettings::OverlayController::applicationName);
|
a.setApplicationDisplayName(
|
||||||
a.setApplicationVersion(advsettings::OverlayController::applicationVersionString);
|
advsettings::OverlayController::applicationName );
|
||||||
|
a.setApplicationVersion(
|
||||||
|
advsettings::OverlayController::applicationVersionString );
|
||||||
|
|
||||||
qInstallMessageHandler( myQtMessageHandler );
|
qInstallMessageHandler( myQtMessageHandler );
|
||||||
|
|
||||||
// Configure logger
|
// Configure logger
|
||||||
QString logFilePath;
|
QString logFilePath;
|
||||||
START_EASYLOGGINGPP( argc, argv );
|
START_EASYLOGGINGPP( argc, argv );
|
||||||
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
|
el::Loggers::addFlag(
|
||||||
|
el::LoggingFlag::DisableApplicationAbortOnFatalLog );
|
||||||
auto logconfigfile = QFileInfo( logConfigFileName ).absoluteFilePath();
|
auto logconfigfile = QFileInfo( logConfigFileName ).absoluteFilePath();
|
||||||
el::Configurations conf;
|
el::Configurations conf;
|
||||||
if (QFile::exists(logconfigfile)) {
|
if ( QFile::exists( logconfigfile ) )
|
||||||
|
{
|
||||||
conf.parseFromFile( logconfigfile.toStdString() );
|
conf.parseFromFile( logconfigfile.toStdString() );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
conf.parseFromText( logConfigDefault );
|
conf.parseFromText( logConfigDefault );
|
||||||
}
|
}
|
||||||
if (!conf.get(el::Level::Global, el::ConfigurationType::Filename)) {
|
if ( !conf.get( el::Level::Global, el::ConfigurationType::Filename ) )
|
||||||
logFilePath = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).absoluteFilePath("AdvancedSettings.log");
|
{
|
||||||
conf.set(el::Level::Global, el::ConfigurationType::Filename, QDir::toNativeSeparators(logFilePath).toStdString());
|
logFilePath = QDir( QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::AppDataLocation ) )
|
||||||
|
.absoluteFilePath( "AdvancedSettings.log" );
|
||||||
|
conf.set( el::Level::Global,
|
||||||
|
el::ConfigurationType::Filename,
|
||||||
|
QDir::toNativeSeparators( logFilePath ).toStdString() );
|
||||||
}
|
}
|
||||||
conf.setRemainingToDefault();
|
conf.setRemainingToDefault();
|
||||||
el::Loggers::reconfigureAllLoggers( conf );
|
el::Loggers::reconfigureAllLoggers( conf );
|
||||||
LOG(INFO) << "Application started (Version " << advsettings::OverlayController::applicationVersionString << ")";
|
LOG( INFO ) << "Application started (Version "
|
||||||
LOG(INFO) << "Log Config: " << QDir::toNativeSeparators(logconfigfile).toStdString();
|
<< advsettings::OverlayController::applicationVersionString
|
||||||
if (!logFilePath.isEmpty()) {
|
<< ")";
|
||||||
|
LOG( INFO ) << "Log Config: "
|
||||||
|
<< QDir::toNativeSeparators( logconfigfile ).toStdString();
|
||||||
|
if ( !logFilePath.isEmpty() )
|
||||||
|
{
|
||||||
LOG( INFO ) << "Log File: " << logFilePath;
|
LOG( INFO ) << "Log File: " << logFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desktop_mode) {
|
if ( desktop_mode )
|
||||||
|
{
|
||||||
LOG( INFO ) << "Desktop mode enabled.";
|
LOG( INFO ) << "Desktop mode enabled.";
|
||||||
}
|
}
|
||||||
if (no_sound) {
|
if ( no_sound )
|
||||||
|
{
|
||||||
LOG( INFO ) << "Sound effects disabled.";
|
LOG( INFO ) << "Sound effects disabled.";
|
||||||
}
|
}
|
||||||
if (no_manifest) {
|
if ( no_manifest )
|
||||||
|
{
|
||||||
LOG( INFO ) << "vrmanifest disabled.";
|
LOG( INFO ) << "vrmanifest disabled.";
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings appSettings(QSettings::IniFormat, QSettings::UserScope, a.organizationName(), a.applicationName());
|
QSettings appSettings( QSettings::IniFormat,
|
||||||
|
QSettings::UserScope,
|
||||||
|
a.organizationName(),
|
||||||
|
a.applicationName() );
|
||||||
advsettings::OverlayController::setAppSettings( &appSettings );
|
advsettings::OverlayController::setAppSettings( &appSettings );
|
||||||
LOG(INFO) << "Settings File: " << appSettings.fileName().toStdString();
|
LOG( INFO ) << "Settings File: "
|
||||||
|
<< appSettings.fileName().toStdString();
|
||||||
|
|
||||||
QQmlEngine qmlEngine;
|
QQmlEngine qmlEngine;
|
||||||
|
|
||||||
advsettings::OverlayController* controller = advsettings::OverlayController::createInstance(desktop_mode, no_sound);
|
advsettings::OverlayController* controller
|
||||||
|
= advsettings::OverlayController::createInstance( desktop_mode,
|
||||||
|
no_sound );
|
||||||
controller->Init( &qmlEngine );
|
controller->Init( &qmlEngine );
|
||||||
|
|
||||||
QQmlComponent component(&qmlEngine, QUrl::fromLocalFile("res/qml/mainwidget.qml"));
|
QQmlComponent component(
|
||||||
|
&qmlEngine, QUrl::fromLocalFile( "res/qml/mainwidget.qml" ) );
|
||||||
auto errors = component.errors();
|
auto errors = component.errors();
|
||||||
for (auto& e : errors) {
|
for ( auto& e : errors )
|
||||||
LOG(ERROR) << "QML Error: " << e.toString().toStdString() << std::endl;
|
{
|
||||||
|
LOG( ERROR ) << "QML Error: " << e.toString().toStdString()
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
auto quickObj = component.create();
|
auto quickObj = component.create();
|
||||||
controller->SetWidget(qobject_cast<QQuickItem*>(quickObj), advsettings::OverlayController::applicationName, advsettings::OverlayController::applicationKey);
|
controller->SetWidget( qobject_cast<QQuickItem*>( quickObj ),
|
||||||
|
advsettings::OverlayController::applicationName,
|
||||||
|
advsettings::OverlayController::applicationKey );
|
||||||
|
|
||||||
if (!desktop_mode && !no_manifest) {
|
if ( !desktop_mode && !no_manifest )
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
installManifest();
|
installManifest();
|
||||||
} catch (std::exception& e) {
|
}
|
||||||
|
catch ( std::exception& e )
|
||||||
|
{
|
||||||
LOG( ERROR ) << e.what();
|
LOG( ERROR ) << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desktop_mode) {
|
if ( desktop_mode )
|
||||||
|
{
|
||||||
auto m_pWindow = new QQuickWindow();
|
auto m_pWindow = new QQuickWindow();
|
||||||
qobject_cast<QQuickItem*>(quickObj)->setParentItem(m_pWindow->contentItem());
|
qobject_cast<QQuickItem*>( quickObj )
|
||||||
m_pWindow->setGeometry(0, 0, qobject_cast<QQuickItem*>(quickObj)->width(), qobject_cast<QQuickItem*>(quickObj)->height());
|
->setParentItem( m_pWindow->contentItem() );
|
||||||
|
m_pWindow->setGeometry(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
qobject_cast<QQuickItem*>( quickObj )->width(),
|
||||||
|
qobject_cast<QQuickItem*>( quickObj )->height() );
|
||||||
m_pWindow->show();
|
m_pWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
}
|
||||||
} catch (const std::exception& e) {
|
catch ( const std::exception& e )
|
||||||
|
{
|
||||||
LOG( FATAL ) << e.what();
|
LOG( FATAL ) << e.what();
|
||||||
return ReturnErrorCode::GENERAL_FAILURE;
|
return ReturnErrorCode::GENERAL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
+644
-256
File diff suppressed because it is too large
Load Diff
+61
-24
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <openvr.h>
|
#include <openvr.h>
|
||||||
#include <QtCore/QtCore>
|
#include <QtCore/QtCore>
|
||||||
// because of incompatibilities with QtOpenGL and GLEW we need to cherry pick includes
|
// because of incompatibilities with QtOpenGL and GLEW we need to cherry pick
|
||||||
|
// includes
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QMatrix4x4>
|
#include <QMatrix4x4>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@@ -35,12 +36,11 @@
|
|||||||
#include "tabcontrollers/UtilitiesTabController.h"
|
#include "tabcontrollers/UtilitiesTabController.h"
|
||||||
#include "tabcontrollers/AccessibilityTabController.h"
|
#include "tabcontrollers/AccessibilityTabController.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class OverlayController : public QObject {
|
class OverlayController : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( bool desktopMode READ isDesktopMode )
|
Q_PROPERTY( bool desktopMode READ isDesktopMode )
|
||||||
|
|
||||||
@@ -51,7 +51,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid;
|
vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid;
|
||||||
vr::VROverlayHandle_t m_ulOverlayThumbnailHandle = vr::k_ulOverlayHandleInvalid;
|
vr::VROverlayHandle_t m_ulOverlayThumbnailHandle
|
||||||
|
= vr::k_ulOverlayHandleInvalid;
|
||||||
|
|
||||||
std::unique_ptr<QQuickRenderControl> m_pRenderControl;
|
std::unique_ptr<QQuickRenderControl> m_pRenderControl;
|
||||||
std::unique_ptr<QQuickWindow> m_pWindow;
|
std::unique_ptr<QQuickWindow> m_pWindow;
|
||||||
@@ -77,7 +78,8 @@ private:
|
|||||||
QSoundEffect focusChangedSoundEffect;
|
QSoundEffect focusChangedSoundEffect;
|
||||||
QSoundEffect alarm01SoundEffect;
|
QSoundEffect alarm01SoundEffect;
|
||||||
|
|
||||||
public: // I know it's an ugly hack to make them public to enable external access, but I am too lazy to implement getters.
|
public: // I know it's an ugly hack to make them public to enable external
|
||||||
|
// access, but I am too lazy to implement getters.
|
||||||
SteamVRTabController steamVRTabController;
|
SteamVRTabController steamVRTabController;
|
||||||
ChaperoneTabController chaperoneTabController;
|
ChaperoneTabController chaperoneTabController;
|
||||||
MoveCenterTabController moveCenterTabController;
|
MoveCenterTabController moveCenterTabController;
|
||||||
@@ -90,7 +92,10 @@ public: // I know it's an ugly hack to make them public to enable external acces
|
|||||||
AccessibilityTabController accessibilityTabController;
|
AccessibilityTabController accessibilityTabController;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController(bool desktopMode, bool noSound) : QObject(), desktopMode(desktopMode), noSound(noSound) {}
|
OverlayController( bool desktopMode, bool noSound )
|
||||||
|
: QObject(), desktopMode( desktopMode ), noSound( noSound )
|
||||||
|
{
|
||||||
|
}
|
||||||
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
|
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -99,22 +104,44 @@ public:
|
|||||||
void Init( QQmlEngine* qmlEngine );
|
void Init( QQmlEngine* qmlEngine );
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
bool isDashboardVisible() {
|
bool isDashboardVisible()
|
||||||
|
{
|
||||||
return dashboardVisible;
|
return dashboardVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetWidget(QQuickItem* quickItem, const std::string& name, const std::string& key = "");
|
void SetWidget( QQuickItem* quickItem,
|
||||||
|
const std::string& name,
|
||||||
|
const std::string& key = "" );
|
||||||
|
|
||||||
void AddOffsetToUniverseCenter(vr::ETrackingUniverseOrigin universe, unsigned axisId, float offset, bool adjustBounds = true, bool commit = true);
|
void AddOffsetToUniverseCenter( vr::ETrackingUniverseOrigin universe,
|
||||||
void AddOffsetToUniverseCenter(vr::ETrackingUniverseOrigin universe, float offset[3], bool adjustBounds = true, bool commit = true);
|
unsigned axisId,
|
||||||
void RotateUniverseCenter(vr::ETrackingUniverseOrigin universe, float yAngle, bool adjustBounds = true, bool commit = true); // around y axis
|
float offset,
|
||||||
void AddOffsetToCollisionBounds(unsigned axisId, float offset, bool commit = true);
|
bool adjustBounds = true,
|
||||||
|
bool commit = true );
|
||||||
|
void AddOffsetToUniverseCenter( vr::ETrackingUniverseOrigin universe,
|
||||||
|
float offset[3],
|
||||||
|
bool adjustBounds = true,
|
||||||
|
bool commit = true );
|
||||||
|
void RotateUniverseCenter( vr::ETrackingUniverseOrigin universe,
|
||||||
|
float yAngle,
|
||||||
|
bool adjustBounds = true,
|
||||||
|
bool commit = true ); // around y axis
|
||||||
|
void AddOffsetToCollisionBounds( unsigned axisId,
|
||||||
|
float offset,
|
||||||
|
bool commit = true );
|
||||||
void AddOffsetToCollisionBounds( float offset[3], bool commit = true );
|
void AddOffsetToCollisionBounds( float offset[3], bool commit = true );
|
||||||
void RotateCollisionBounds(float angle, bool commit = true); // around y axis
|
void RotateCollisionBounds( float angle,
|
||||||
|
bool commit = true ); // around y axis
|
||||||
|
|
||||||
bool isDesktopMode() { return desktopMode; };
|
bool isDesktopMode()
|
||||||
|
{
|
||||||
|
return desktopMode;
|
||||||
|
};
|
||||||
|
|
||||||
utils::ChaperoneUtils& chaperoneUtils() noexcept { return m_chaperoneUtils; }
|
utils::ChaperoneUtils& chaperoneUtils() noexcept
|
||||||
|
{
|
||||||
|
return m_chaperoneUtils;
|
||||||
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString getVersionString();
|
Q_INVOKABLE QString getVersionString();
|
||||||
Q_INVOKABLE QUrl getVRRuntimePathUrl();
|
Q_INVOKABLE QUrl getVRRuntimePathUrl();
|
||||||
@@ -124,7 +151,8 @@ public:
|
|||||||
const vr::VROverlayHandle_t& overlayHandle();
|
const vr::VROverlayHandle_t& overlayHandle();
|
||||||
const vr::VROverlayHandle_t& overlayThumbnailHandle();
|
const vr::VROverlayHandle_t& overlayThumbnailHandle();
|
||||||
|
|
||||||
bool pollNextEvent(vr::VROverlayHandle_t ulOverlayHandle, vr::VREvent_t* pEvent);
|
bool pollNextEvent( vr::VROverlayHandle_t ulOverlayHandle,
|
||||||
|
vr::VREvent_t* pEvent );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void renderOverlay();
|
void renderOverlay();
|
||||||
@@ -147,18 +175,27 @@ private:
|
|||||||
static std::unique_ptr<OverlayController> singleton;
|
static std::unique_ptr<OverlayController> singleton;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static OverlayController* getInstance() {
|
static OverlayController* getInstance()
|
||||||
|
{
|
||||||
return singleton.get();
|
return singleton.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static OverlayController* createInstance(bool desktopMode, bool noSound) {
|
static OverlayController* createInstance( bool desktopMode, bool noSound )
|
||||||
singleton.reset(new advsettings::OverlayController(desktopMode, noSound));
|
{
|
||||||
|
singleton.reset(
|
||||||
|
new advsettings::OverlayController( desktopMode, noSound ) );
|
||||||
return singleton.get();
|
return singleton.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QSettings* appSettings() { return _appSettings; }
|
static QSettings* appSettings()
|
||||||
|
{
|
||||||
|
return _appSettings;
|
||||||
|
}
|
||||||
|
|
||||||
static void setAppSettings(QSettings* settings) { _appSettings = settings; }
|
static void setAppSettings( QSettings* settings )
|
||||||
|
{
|
||||||
|
_appSettings = settings;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace advsettings
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -3,15 +3,17 @@
|
|||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
void AccessibilityTabController::initStage1() {
|
void AccessibilityTabController::initStage1()
|
||||||
|
{
|
||||||
setTrackingUniverse( vr::VRCompositor()->GetTrackingSpace() );
|
setTrackingUniverse( vr::VRCompositor()->GetTrackingSpace() );
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( getSettingsName() );
|
settings->beginGroup( getSettingsName() );
|
||||||
auto value = settings->value( "heightOffset", m_heightOffset );
|
auto value = settings->value( "heightOffset", m_heightOffset );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_heightOffset = value.toFloat();
|
m_heightOffset = value.toFloat();
|
||||||
emit heightOffsetChanged( m_heightOffset );
|
emit heightOffsetChanged( m_heightOffset );
|
||||||
}
|
}
|
||||||
@@ -19,79 +21,112 @@ void AccessibilityTabController::initStage1() {
|
|||||||
reloadPttConfig();
|
reloadPttConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
void AccessibilityTabController::initStage2( OverlayController* var_parent,
|
||||||
|
QQuickWindow* var_widget )
|
||||||
|
{
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::setTrackingUniverse(int value) {
|
void AccessibilityTabController::setTrackingUniverse( int value )
|
||||||
if (m_trackingUniverse != value) {
|
{
|
||||||
|
if ( m_trackingUniverse != value )
|
||||||
|
{
|
||||||
reset();
|
reset();
|
||||||
m_trackingUniverse = value;
|
m_trackingUniverse = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float AccessibilityTabController::heightOffset() const {
|
float AccessibilityTabController::heightOffset() const
|
||||||
|
{
|
||||||
return m_heightOffset;
|
return m_heightOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::setHeightOffset(float value, bool notify) {
|
void AccessibilityTabController::setHeightOffset( float value, bool notify )
|
||||||
if (std::abs(m_heightOffset - value) > 0.001) {
|
{
|
||||||
|
if ( std::abs( m_heightOffset - value ) > 0.001 )
|
||||||
|
{
|
||||||
modHeightOffset( value - m_heightOffset, notify );
|
modHeightOffset( value - m_heightOffset, notify );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::modHeightOffset(float value, bool notify) {
|
void AccessibilityTabController::modHeightOffset( float value, bool notify )
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, 1, -value, false);
|
{
|
||||||
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse, 1, -value, false );
|
||||||
m_heightOffset += value;
|
m_heightOffset += value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( getSettingsName() );
|
settings->beginGroup( getSettingsName() );
|
||||||
settings->setValue( "heightOffset", m_heightOffset );
|
settings->setValue( "heightOffset", m_heightOffset );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit heightOffsetChanged( m_heightOffset );
|
emit heightOffsetChanged( m_heightOffset );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccessibilityTabController::onPttStart()
|
||||||
void AccessibilityTabController::onPttStart() {
|
{
|
||||||
m_toggleHeightOffset = m_heightOffset;
|
m_toggleHeightOffset = m_heightOffset;
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, 1, m_toggleHeightOffset, false);
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
1,
|
||||||
|
m_toggleHeightOffset,
|
||||||
|
false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::onPttStop() {
|
void AccessibilityTabController::onPttStop()
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, 1, -m_toggleHeightOffset, false);
|
{
|
||||||
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
1,
|
||||||
|
-m_toggleHeightOffset,
|
||||||
|
false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::onPttDisabled() {
|
void AccessibilityTabController::onPttDisabled()
|
||||||
if (pttActive()) {
|
{
|
||||||
|
if ( pttActive() )
|
||||||
|
{
|
||||||
stopPtt();
|
stopPtt();
|
||||||
}
|
}
|
||||||
m_toggleHeightOffset = 0;
|
m_toggleHeightOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::reset() {
|
void AccessibilityTabController::reset()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
|
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
|
||||||
vr::VRChaperoneSetup()->RevertWorkingCopy();
|
vr::VRChaperoneSetup()->RevertWorkingCopy();
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, 1, m_heightOffset, false, false);
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
1,
|
||||||
|
m_heightOffset,
|
||||||
|
false,
|
||||||
|
false );
|
||||||
vr::VRChaperoneSetup()->CommitWorkingCopy( vr::EChaperoneConfigFile_Live );
|
vr::VRChaperoneSetup()->CommitWorkingCopy( vr::EChaperoneConfigFile_Live );
|
||||||
m_heightOffset = 0.0f;
|
m_heightOffset = 0.0f;
|
||||||
emit heightOffsetChanged( m_heightOffset );
|
emit heightOffsetChanged( m_heightOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessibilityTabController::eventLoopTick(vr::ETrackingUniverseOrigin universe) {
|
void AccessibilityTabController::eventLoopTick(
|
||||||
if (!eventLoopMutex.try_lock()) {
|
vr::ETrackingUniverseOrigin universe )
|
||||||
|
{
|
||||||
|
if ( !eventLoopMutex.try_lock() )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settingsUpdateCounter >= 50) {
|
if ( settingsUpdateCounter >= 50 )
|
||||||
|
{
|
||||||
setTrackingUniverse( ( int ) universe );
|
setTrackingUniverse( ( int ) universe );
|
||||||
settingsUpdateCounter = 0;
|
settingsUpdateCounter = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
settingsUpdateCounter++;
|
settingsUpdateCounter++;
|
||||||
}
|
}
|
||||||
checkPttStatus();
|
checkPttStatus();
|
||||||
eventLoopMutex.unlock();
|
eventLoopMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advconfig
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -5,15 +5,16 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
class AccessibilityTabController : public PttController
|
||||||
class AccessibilityTabController : public PttController {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float heightOffset READ heightOffset WRITE setHeightOffset NOTIFY heightOffsetChanged)
|
Q_PROPERTY( float heightOffset READ heightOffset WRITE setHeightOffset
|
||||||
|
NOTIFY heightOffsetChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -25,7 +26,10 @@ private:
|
|||||||
|
|
||||||
unsigned settingsUpdateCounter = 0;
|
unsigned settingsUpdateCounter = 0;
|
||||||
|
|
||||||
QString getSettingsName() override { return "accessibilitySettings"; }
|
QString getSettingsName() override
|
||||||
|
{
|
||||||
|
return "accessibilitySettings";
|
||||||
|
}
|
||||||
void onPttStart() override;
|
void onPttStart() override;
|
||||||
void onPttStop() override;
|
void onPttStop() override;
|
||||||
void onPttDisabled() override;
|
void onPttDisabled() override;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class AudioTabController;
|
class AudioTabController;
|
||||||
|
|
||||||
class AudioManager
|
class AudioManager
|
||||||
@@ -15,11 +15,13 @@ public:
|
|||||||
|
|
||||||
virtual void init( AudioTabController* controller ) = 0;
|
virtual void init( AudioTabController* controller ) = 0;
|
||||||
|
|
||||||
virtual void setPlaybackDevice(const std::string& id, bool notify = true) = 0;
|
virtual void setPlaybackDevice( const std::string& id, bool notify = true )
|
||||||
|
= 0;
|
||||||
virtual std::string getPlaybackDevName() = 0;
|
virtual std::string getPlaybackDevName() = 0;
|
||||||
virtual std::string getPlaybackDevId() = 0;
|
virtual std::string getPlaybackDevId() = 0;
|
||||||
|
|
||||||
virtual void setMirrorDevice(const std::string& id, bool notify = true) = 0;
|
virtual void setMirrorDevice( const std::string& id, bool notify = true )
|
||||||
|
= 0;
|
||||||
virtual bool isMirrorValid() = 0;
|
virtual bool isMirrorValid() = 0;
|
||||||
virtual std::string getMirrorDevName() = 0;
|
virtual std::string getMirrorDevName() = 0;
|
||||||
virtual std::string getMirrorDevId() = 0;
|
virtual std::string getMirrorDevId() = 0;
|
||||||
@@ -37,9 +39,10 @@ public:
|
|||||||
virtual bool getMicMuted() = 0;
|
virtual bool getMicMuted() = 0;
|
||||||
virtual bool setMicMuted( bool value ) = 0;
|
virtual bool setMicMuted( bool value ) = 0;
|
||||||
|
|
||||||
virtual std::vector<std::pair<std::string, std::string>> getRecordingDevices() = 0;
|
virtual std::vector<std::pair<std::string, std::string>>
|
||||||
virtual std::vector<std::pair<std::string, std::string>> getPlaybackDevices() = 0;
|
getRecordingDevices() = 0;
|
||||||
|
virtual std::vector<std::pair<std::string, std::string>>
|
||||||
|
getPlaybackDevices() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -8,12 +8,13 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
struct AudioProfile {
|
struct AudioProfile
|
||||||
|
{
|
||||||
std::string profileName;
|
std::string profileName;
|
||||||
std::string playbackName;
|
std::string playbackName;
|
||||||
std::string mirrorName;
|
std::string mirrorName;
|
||||||
@@ -24,28 +25,40 @@ namespace advsettings {
|
|||||||
bool mirrorMute = false;
|
bool mirrorMute = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AudioTabController : public PttController
|
||||||
class AudioTabController : public PttController {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int playbackDeviceIndex READ playbackDeviceIndex WRITE setPlaybackDeviceIndex NOTIFY playbackDeviceIndexChanged)
|
Q_PROPERTY( int playbackDeviceIndex READ playbackDeviceIndex WRITE
|
||||||
Q_PROPERTY(int mirrorDeviceIndex READ mirrorDeviceIndex WRITE setMirrorDeviceIndex NOTIFY mirrorDeviceIndexChanged)
|
setPlaybackDeviceIndex NOTIFY playbackDeviceIndexChanged )
|
||||||
//Q_PROPERTY(bool mirrorPresent READ mirrorPresent NOTIFY mirrorPresentChanged)
|
Q_PROPERTY( int mirrorDeviceIndex READ mirrorDeviceIndex WRITE
|
||||||
//Q_PROPERTY(QString mirrorDevName READ mirrorDevName NOTIFY mirrorDevNameChanged)
|
setMirrorDeviceIndex NOTIFY mirrorDeviceIndexChanged )
|
||||||
Q_PROPERTY(float mirrorVolume READ mirrorVolume WRITE setMirrorVolume NOTIFY mirrorVolumeChanged)
|
// Q_PROPERTY(bool mirrorPresent READ mirrorPresent NOTIFY
|
||||||
Q_PROPERTY(bool mirrorMuted READ mirrorMuted WRITE setMirrorMuted NOTIFY mirrorMutedChanged)
|
// mirrorPresentChanged) Q_PROPERTY(QString mirrorDevName READ mirrorDevName
|
||||||
Q_PROPERTY(int micDeviceIndex READ micDeviceIndex WRITE setMicDeviceIndex NOTIFY micDeviceIndexChanged)
|
// NOTIFY mirrorDevNameChanged)
|
||||||
|
Q_PROPERTY( float mirrorVolume READ mirrorVolume WRITE setMirrorVolume
|
||||||
|
NOTIFY mirrorVolumeChanged )
|
||||||
|
Q_PROPERTY( bool mirrorMuted READ mirrorMuted WRITE setMirrorMuted NOTIFY
|
||||||
|
mirrorMutedChanged )
|
||||||
|
Q_PROPERTY( int micDeviceIndex READ micDeviceIndex WRITE setMicDeviceIndex
|
||||||
|
NOTIFY micDeviceIndexChanged )
|
||||||
// Q_PROPERTY(bool micPresent READ micPresent NOTIFY micPresentChanged)
|
// Q_PROPERTY(bool micPresent READ micPresent NOTIFY micPresentChanged)
|
||||||
// Q_PROPERTY(QString micDevName READ micDevName NOTIFY micDevNameChanged)
|
// Q_PROPERTY(QString micDevName READ micDevName NOTIFY micDevNameChanged)
|
||||||
Q_PROPERTY(float micVolume READ micVolume WRITE setMicVolume NOTIFY micVolumeChanged)
|
Q_PROPERTY( float micVolume READ micVolume WRITE setMicVolume NOTIFY
|
||||||
Q_PROPERTY(bool micMuted READ micMuted WRITE setMicMuted NOTIFY micMutedChanged)
|
micVolumeChanged )
|
||||||
Q_PROPERTY(bool micProximitySensorCanMute READ micProximitySensorCanMute WRITE setMicProximitySensorCanMute NOTIFY micProximitySensorCanMuteChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(bool micReversePtt READ micReversePtt WRITE setMicReversePtt NOTIFY micReversePttChanged)
|
bool micMuted READ micMuted WRITE setMicMuted NOTIFY micMutedChanged )
|
||||||
|
Q_PROPERTY( bool micProximitySensorCanMute READ micProximitySensorCanMute
|
||||||
|
WRITE setMicProximitySensorCanMute NOTIFY
|
||||||
|
micProximitySensorCanMuteChanged )
|
||||||
|
Q_PROPERTY( bool micReversePtt READ micReversePtt WRITE setMicReversePtt
|
||||||
|
NOTIFY micReversePttChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
QQuickWindow* widget;
|
QQuickWindow* widget;
|
||||||
|
|
||||||
vr::VROverlayHandle_t m_ulNotificationOverlayHandle = vr::k_ulOverlayHandleInvalid;
|
vr::VROverlayHandle_t m_ulNotificationOverlayHandle
|
||||||
|
= vr::k_ulOverlayHandleInvalid;
|
||||||
|
|
||||||
int m_playbackDeviceIndex = -1;
|
int m_playbackDeviceIndex = -1;
|
||||||
|
|
||||||
@@ -66,14 +79,20 @@ namespace advsettings {
|
|||||||
std::vector<std::pair<std::string, std::string>> m_playbackDevices;
|
std::vector<std::pair<std::string, std::string>> m_playbackDevices;
|
||||||
std::string lastMirrorDevId;
|
std::string lastMirrorDevId;
|
||||||
|
|
||||||
QString getSettingsName() override { return "audioSettings"; }
|
QString getSettingsName() override
|
||||||
|
{
|
||||||
|
return "audioSettings";
|
||||||
|
}
|
||||||
// QString getSettingsNameAudio() override { return "audioSettingsTest"; }
|
// QString getSettingsNameAudio() override { return "audioSettingsTest"; }
|
||||||
void onPttStart() override;
|
void onPttStart() override;
|
||||||
void onPttStop() override;
|
void onPttStop() override;
|
||||||
void onPttEnabled() override;
|
void onPttEnabled() override;
|
||||||
void onPttDisabled() override;
|
void onPttDisabled() override;
|
||||||
bool pttChangeValid() override;
|
bool pttChangeValid() override;
|
||||||
virtual vr::VROverlayHandle_t getNotificationOverlayHandle() override { return m_ulNotificationOverlayHandle; }
|
virtual vr::VROverlayHandle_t getNotificationOverlayHandle() override
|
||||||
|
{
|
||||||
|
return m_ulNotificationOverlayHandle;
|
||||||
|
}
|
||||||
|
|
||||||
void findPlaybackDeviceIndex( std::string id, bool notify = true );
|
void findPlaybackDeviceIndex( std::string id, bool notify = true );
|
||||||
void findMirrorDeviceIndex( std::string id, bool notify = true );
|
void findMirrorDeviceIndex( std::string id, bool notify = true );
|
||||||
@@ -88,8 +107,6 @@ namespace advsettings {
|
|||||||
// std::recursive_mutex eventLoopMutexAudio;
|
// std::recursive_mutex eventLoopMutexAudio;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,13 +9,13 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
struct ChaperoneProfile
|
||||||
struct ChaperoneProfile {
|
{
|
||||||
std::string profileName;
|
std::string profileName;
|
||||||
|
|
||||||
bool includesChaperoneGeometry = false;
|
bool includesChaperoneGeometry = false;
|
||||||
@@ -64,32 +64,72 @@ struct ChaperoneProfile {
|
|||||||
float chaperoneVelocityModifier = 0.0f;
|
float chaperoneVelocityModifier = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ChaperoneTabController : public QObject
|
||||||
class ChaperoneTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float boundsVisibility READ boundsVisibility WRITE setBoundsVisibility NOTIFY boundsVisibilityChanged)
|
Q_PROPERTY( float boundsVisibility READ boundsVisibility WRITE
|
||||||
Q_PROPERTY(float fadeDistance READ fadeDistance WRITE setFadeDistance NOTIFY fadeDistanceChanged)
|
setBoundsVisibility NOTIFY boundsVisibilityChanged )
|
||||||
|
Q_PROPERTY( float fadeDistance READ fadeDistance WRITE setFadeDistance
|
||||||
|
NOTIFY fadeDistanceChanged )
|
||||||
Q_PROPERTY( float height READ height WRITE setHeight NOTIFY heightChanged )
|
Q_PROPERTY( float height READ height WRITE setHeight NOTIFY heightChanged )
|
||||||
Q_PROPERTY(bool centerMarker READ centerMarker WRITE setCenterMarker NOTIFY centerMarkerChanged)
|
Q_PROPERTY( bool centerMarker READ centerMarker WRITE setCenterMarker NOTIFY
|
||||||
Q_PROPERTY(bool playSpaceMarker READ playSpaceMarker WRITE setPlaySpaceMarker NOTIFY playSpaceMarkerChanged)
|
centerMarkerChanged )
|
||||||
Q_PROPERTY(bool forceBounds READ forceBounds WRITE setForceBounds NOTIFY forceBoundsChanged)
|
Q_PROPERTY( bool playSpaceMarker READ playSpaceMarker WRITE
|
||||||
|
setPlaySpaceMarker NOTIFY playSpaceMarkerChanged )
|
||||||
|
Q_PROPERTY( bool forceBounds READ forceBounds WRITE setForceBounds NOTIFY
|
||||||
|
forceBoundsChanged )
|
||||||
|
|
||||||
Q_PROPERTY(bool chaperoneSwitchToBeginnerEnabled READ isChaperoneSwitchToBeginnerEnabled WRITE setChaperoneSwitchToBeginnerEnabled NOTIFY chaperoneSwitchToBeginnerEnabledChanged)
|
Q_PROPERTY( bool chaperoneSwitchToBeginnerEnabled READ
|
||||||
Q_PROPERTY(float chaperoneSwitchToBeginnerDistance READ chaperoneSwitchToBeginnerDistance WRITE setChaperoneSwitchToBeginnerDistance NOTIFY chaperoneSwitchToBeginnerDistanceChanged)
|
isChaperoneSwitchToBeginnerEnabled WRITE
|
||||||
|
setChaperoneSwitchToBeginnerEnabled NOTIFY
|
||||||
|
chaperoneSwitchToBeginnerEnabledChanged )
|
||||||
|
Q_PROPERTY( float chaperoneSwitchToBeginnerDistance READ
|
||||||
|
chaperoneSwitchToBeginnerDistance WRITE
|
||||||
|
setChaperoneSwitchToBeginnerDistance NOTIFY
|
||||||
|
chaperoneSwitchToBeginnerDistanceChanged )
|
||||||
|
|
||||||
Q_PROPERTY(bool chaperoneHapticFeedbackEnabled READ isChaperoneHapticFeedbackEnabled WRITE setChaperoneHapticFeedbackEnabled NOTIFY chaperoneHapticFeedbackEnabledChanged)
|
Q_PROPERTY( bool chaperoneHapticFeedbackEnabled READ
|
||||||
Q_PROPERTY(float chaperoneHapticFeedbackDistance READ chaperoneHapticFeedbackDistance WRITE setChaperoneHapticFeedbackDistance NOTIFY chaperoneHapticFeedbackDistanceChanged)
|
isChaperoneHapticFeedbackEnabled WRITE
|
||||||
|
setChaperoneHapticFeedbackEnabled NOTIFY
|
||||||
|
chaperoneHapticFeedbackEnabledChanged )
|
||||||
|
Q_PROPERTY( float chaperoneHapticFeedbackDistance READ
|
||||||
|
chaperoneHapticFeedbackDistance WRITE
|
||||||
|
setChaperoneHapticFeedbackDistance NOTIFY
|
||||||
|
chaperoneHapticFeedbackDistanceChanged )
|
||||||
|
|
||||||
Q_PROPERTY(bool chaperoneAlarmSoundEnabled READ isChaperoneAlarmSoundEnabled WRITE setChaperoneAlarmSoundEnabled NOTIFY chaperoneAlarmSoundEnabledChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(bool chaperoneAlarmSoundLooping READ isChaperoneAlarmSoundLooping WRITE setChaperoneAlarmSoundLooping NOTIFY chaperoneAlarmSoundLoopingChanged)
|
bool chaperoneAlarmSoundEnabled READ isChaperoneAlarmSoundEnabled WRITE
|
||||||
Q_PROPERTY(bool chaperoneAlarmSoundAdjustVolume READ isChaperoneAlarmSoundAdjustVolume WRITE setChaperoneAlarmSoundAdjustVolume NOTIFY chaperoneAlarmSoundAdjustVolumeChanged)
|
setChaperoneAlarmSoundEnabled NOTIFY
|
||||||
Q_PROPERTY(float chaperoneAlarmSoundDistance READ chaperoneAlarmSoundDistance WRITE setChaperoneAlarmSoundDistance NOTIFY chaperoneAlarmSoundDistanceChanged)
|
chaperoneAlarmSoundEnabledChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
bool chaperoneAlarmSoundLooping READ isChaperoneAlarmSoundLooping WRITE
|
||||||
|
setChaperoneAlarmSoundLooping NOTIFY
|
||||||
|
chaperoneAlarmSoundLoopingChanged )
|
||||||
|
Q_PROPERTY( bool chaperoneAlarmSoundAdjustVolume READ
|
||||||
|
isChaperoneAlarmSoundAdjustVolume WRITE
|
||||||
|
setChaperoneAlarmSoundAdjustVolume NOTIFY
|
||||||
|
chaperoneAlarmSoundAdjustVolumeChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
float chaperoneAlarmSoundDistance READ chaperoneAlarmSoundDistance WRITE
|
||||||
|
setChaperoneAlarmSoundDistance NOTIFY
|
||||||
|
chaperoneAlarmSoundDistanceChanged )
|
||||||
|
|
||||||
Q_PROPERTY(bool chaperoneShowDashboardEnabled READ isChaperoneShowDashboardEnabled WRITE setChaperoneShowDashboardEnabled NOTIFY chaperoneShowDashboardEnabledChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(float chaperoneShowDashboardDistance READ chaperoneShowDashboardDistance WRITE setChaperoneShowDashboardDistance NOTIFY chaperoneShowDashboardDistanceChanged)
|
bool chaperoneShowDashboardEnabled READ isChaperoneShowDashboardEnabled
|
||||||
|
WRITE setChaperoneShowDashboardEnabled NOTIFY
|
||||||
|
chaperoneShowDashboardEnabledChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
float chaperoneShowDashboardDistance READ chaperoneShowDashboardDistance
|
||||||
|
WRITE setChaperoneShowDashboardDistance NOTIFY
|
||||||
|
chaperoneShowDashboardDistanceChanged )
|
||||||
|
|
||||||
Q_PROPERTY(bool chaperoneVelocityModifierEnabled READ isChaperoneVelocityModifierEnabled WRITE setChaperoneVelocityModifierEnabled NOTIFY chaperoneVelocityModifierEnabledChanged)
|
Q_PROPERTY( bool chaperoneVelocityModifierEnabled READ
|
||||||
Q_PROPERTY(float chaperoneVelocityModifier READ chaperoneVelocityModifier WRITE setChaperoneVelocityModifier NOTIFY chaperoneVelocityModifierChanged)
|
isChaperoneVelocityModifierEnabled WRITE
|
||||||
|
setChaperoneVelocityModifierEnabled NOTIFY
|
||||||
|
chaperoneVelocityModifierEnabledChanged )
|
||||||
|
Q_PROPERTY( float chaperoneVelocityModifier READ chaperoneVelocityModifier
|
||||||
|
WRITE setChaperoneVelocityModifier NOTIFY
|
||||||
|
chaperoneVelocityModifierChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -137,7 +177,10 @@ public:
|
|||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
||||||
|
|
||||||
void eventLoopTick(vr::TrackedDevicePose_t* devicePoses, float leftSpeed, float rightSpeed, float hmdSpeed);
|
void eventLoopTick( vr::TrackedDevicePose_t* devicePoses,
|
||||||
|
float leftSpeed,
|
||||||
|
float rightSpeed,
|
||||||
|
float hmdSpeed );
|
||||||
void handleChaperoneWarnings( float distance );
|
void handleChaperoneWarnings( float distance );
|
||||||
|
|
||||||
float boundsVisibility() const;
|
float boundsVisibility() const;
|
||||||
@@ -182,7 +225,8 @@ public slots:
|
|||||||
void setForceBounds( bool value, bool notify = true );
|
void setForceBounds( bool value, bool notify = true );
|
||||||
|
|
||||||
void setChaperoneSwitchToBeginnerEnabled( bool value, bool notify = true );
|
void setChaperoneSwitchToBeginnerEnabled( bool value, bool notify = true );
|
||||||
void setChaperoneSwitchToBeginnerDistance(float value, bool notify = true);
|
void setChaperoneSwitchToBeginnerDistance( float value,
|
||||||
|
bool notify = true );
|
||||||
|
|
||||||
void setChaperoneHapticFeedbackEnabled( bool value, bool notify = true );
|
void setChaperoneHapticFeedbackEnabled( bool value, bool notify = true );
|
||||||
void setChaperoneHapticFeedbackDistance( float value, bool notify = true );
|
void setChaperoneHapticFeedbackDistance( float value, bool notify = true );
|
||||||
@@ -201,8 +245,16 @@ public slots:
|
|||||||
void flipOrientation();
|
void flipOrientation();
|
||||||
void reloadFromDisk();
|
void reloadFromDisk();
|
||||||
|
|
||||||
void addChaperoneProfile(QString name, bool includeGeometry, bool includeVisbility, bool includeFadeDistance, bool includeCenterMarker,
|
void addChaperoneProfile( QString name,
|
||||||
bool includePlaySpaceMarker, bool includeFloorBounds, bool includeBoundsColor, bool includeChaperoneStyle, bool includeForceBounds,
|
bool includeGeometry,
|
||||||
|
bool includeVisbility,
|
||||||
|
bool includeFadeDistance,
|
||||||
|
bool includeCenterMarker,
|
||||||
|
bool includePlaySpaceMarker,
|
||||||
|
bool includeFloorBounds,
|
||||||
|
bool includeBoundsColor,
|
||||||
|
bool includeChaperoneStyle,
|
||||||
|
bool includeForceBounds,
|
||||||
bool includesProximityWarningSettings );
|
bool includesProximityWarningSettings );
|
||||||
void applyChaperoneProfile( unsigned index );
|
void applyChaperoneProfile( unsigned index );
|
||||||
void deleteChaperoneProfile( unsigned index );
|
void deleteChaperoneProfile( unsigned index );
|
||||||
|
|||||||
@@ -3,23 +3,30 @@
|
|||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
|
void FixFloorTabController::initStage1() {}
|
||||||
|
|
||||||
|
void FixFloorTabController::initStage2( OverlayController* var_parent,
|
||||||
void FixFloorTabController::initStage1() {
|
QQuickWindow* var_widget )
|
||||||
}
|
{
|
||||||
|
|
||||||
void FixFloorTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses) {
|
void FixFloorTabController::eventLoopTick(
|
||||||
if (state > 0) {
|
vr::TrackedDevicePose_t* devicePoses )
|
||||||
if (measurementCount == 0) {
|
{
|
||||||
|
if ( state > 0 )
|
||||||
|
{
|
||||||
|
if ( measurementCount == 0 )
|
||||||
|
{
|
||||||
// Get Controller ids for left/right hand
|
// Get Controller ids for left/right hand
|
||||||
auto leftId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_LeftHand);
|
auto leftId
|
||||||
if (leftId == vr::k_unTrackedDeviceIndexInvalid) {
|
= vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
|
||||||
|
vr::TrackedControllerRole_LeftHand );
|
||||||
|
if ( leftId == vr::k_unTrackedDeviceIndexInvalid )
|
||||||
|
{
|
||||||
statusMessage = "No left controller found.";
|
statusMessage = "No left controller found.";
|
||||||
statusMessageTimeout = 2.0;
|
statusMessageTimeout = 2.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
@@ -27,8 +34,11 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses)
|
|||||||
state = 0;
|
state = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto rightId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_RightHand);
|
auto rightId
|
||||||
if (rightId == vr::k_unTrackedDeviceIndexInvalid) {
|
= vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
|
||||||
|
vr::TrackedControllerRole_RightHand );
|
||||||
|
if ( rightId == vr::k_unTrackedDeviceIndexInvalid )
|
||||||
|
{
|
||||||
statusMessage = "No right controller found.";
|
statusMessage = "No right controller found.";
|
||||||
statusMessageTimeout = 2.0;
|
statusMessageTimeout = 2.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
@@ -39,29 +49,43 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses)
|
|||||||
// Get poses
|
// Get poses
|
||||||
vr::TrackedDevicePose_t* leftPose = devicePoses + leftId;
|
vr::TrackedDevicePose_t* leftPose = devicePoses + leftId;
|
||||||
vr::TrackedDevicePose_t* rightPose = devicePoses + rightId;
|
vr::TrackedDevicePose_t* rightPose = devicePoses + rightId;
|
||||||
if (!leftPose->bPoseIsValid || !leftPose->bDeviceIsConnected || leftPose->eTrackingResult != vr::TrackingResult_Running_OK) {
|
if ( !leftPose->bPoseIsValid || !leftPose->bDeviceIsConnected
|
||||||
|
|| leftPose->eTrackingResult != vr::TrackingResult_Running_OK )
|
||||||
|
{
|
||||||
statusMessage = "Left controller tracking problems.";
|
statusMessage = "Left controller tracking problems.";
|
||||||
statusMessageTimeout = 2.0;
|
statusMessageTimeout = 2.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
emit measureEndSignal();
|
emit measureEndSignal();
|
||||||
state = 0;
|
state = 0;
|
||||||
return;
|
return;
|
||||||
} else if (!rightPose->bPoseIsValid || !rightPose->bDeviceIsConnected || rightPose->eTrackingResult != vr::TrackingResult_Running_OK) {
|
}
|
||||||
|
else if ( !rightPose->bPoseIsValid || !rightPose->bDeviceIsConnected
|
||||||
|
|| rightPose->eTrackingResult
|
||||||
|
!= vr::TrackingResult_Running_OK )
|
||||||
|
{
|
||||||
statusMessage = "Right controller tracking problems.";
|
statusMessage = "Right controller tracking problems.";
|
||||||
statusMessageTimeout = 2.0;
|
statusMessageTimeout = 2.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
emit measureEndSignal();
|
emit measureEndSignal();
|
||||||
state = 0;
|
state = 0;
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
// The controller with the lowest y-pos is the floor fix reference
|
else
|
||||||
if (leftPose->mDeviceToAbsoluteTracking.m[1][3] < rightPose->mDeviceToAbsoluteTracking.m[1][3]) {
|
{
|
||||||
|
// The controller with the lowest y-pos is the floor fix
|
||||||
|
// reference
|
||||||
|
if ( leftPose->mDeviceToAbsoluteTracking.m[1][3]
|
||||||
|
< rightPose->mDeviceToAbsoluteTracking.m[1][3] )
|
||||||
|
{
|
||||||
referenceController = leftId;
|
referenceController = leftId;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
referenceController = rightId;
|
referenceController = rightId;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& m = devicePoses[referenceController].mDeviceToAbsoluteTracking.m;
|
auto& m = devicePoses[referenceController]
|
||||||
|
.mDeviceToAbsoluteTracking.m;
|
||||||
tempOffsetX = ( double ) m[0][3];
|
tempOffsetX = ( double ) m[0][3];
|
||||||
tempOffsetY = ( double ) m[1][3];
|
tempOffsetY = ( double ) m[1][3];
|
||||||
tempOffsetZ = ( double ) m[2][3];
|
tempOffsetZ = ( double ) m[2][3];
|
||||||
@@ -78,43 +102,63 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses)
|
|||||||
tempRoll = std::atan2( ( double ) m[1][0], ( double ) m[1][1] );
|
tempRoll = std::atan2( ( double ) m[1][0], ( double ) m[1][1] );
|
||||||
measurementCount = 1;
|
measurementCount = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
measurementCount++;
|
measurementCount++;
|
||||||
auto& m = devicePoses[referenceController].mDeviceToAbsoluteTracking.m;
|
auto& m
|
||||||
|
= devicePoses[referenceController].mDeviceToAbsoluteTracking.m;
|
||||||
|
|
||||||
double rollDiff = std::atan2((double)m[1][0], (double)m[1][1]) - tempRoll;
|
double rollDiff
|
||||||
if (rollDiff > M_PI) {
|
= std::atan2( ( double ) m[1][0], ( double ) m[1][1] )
|
||||||
|
- tempRoll;
|
||||||
|
if ( rollDiff > M_PI )
|
||||||
|
{
|
||||||
rollDiff -= 2.0 * M_PI;
|
rollDiff -= 2.0 * M_PI;
|
||||||
} else if (rollDiff < -M_PI) {
|
}
|
||||||
|
else if ( rollDiff < -M_PI )
|
||||||
|
{
|
||||||
rollDiff += 2.0 * M_PI;
|
rollDiff += 2.0 * M_PI;
|
||||||
}
|
}
|
||||||
tempRoll += rollDiff / ( double ) measurementCount;
|
tempRoll += rollDiff / ( double ) measurementCount;
|
||||||
if (tempRoll > M_PI) {
|
if ( tempRoll > M_PI )
|
||||||
|
{
|
||||||
tempRoll -= 2.0 * M_PI;
|
tempRoll -= 2.0 * M_PI;
|
||||||
} else if (tempRoll < -M_PI) {
|
}
|
||||||
|
else if ( tempRoll < -M_PI )
|
||||||
|
{
|
||||||
tempRoll += 2.0 * M_PI;
|
tempRoll += 2.0 * M_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (measurementCount >= 25) {
|
if ( measurementCount >= 25 )
|
||||||
if (std::abs(tempRoll) <= M_PI_2) {
|
{
|
||||||
|
if ( std::abs( tempRoll ) <= M_PI_2 )
|
||||||
|
{
|
||||||
floorOffsetY = tempOffsetY - controllerUpOffsetCorrection;
|
floorOffsetY = tempOffsetY - controllerUpOffsetCorrection;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
floorOffsetY = tempOffsetY - controllerDownOffsetCorrection;
|
floorOffsetY = tempOffsetY - controllerDownOffsetCorrection;
|
||||||
}
|
}
|
||||||
|
|
||||||
floorOffsetX = tempOffsetX;
|
floorOffsetX = tempOffsetX;
|
||||||
floorOffsetZ = tempOffsetZ;
|
floorOffsetZ = tempOffsetZ;
|
||||||
|
|
||||||
LOG(INFO) << "Fix Floor and adjust playspace center: Floor Offset = [" << floorOffsetX << ", " << floorOffsetY << ", " << floorOffsetZ << "]";
|
LOG( INFO )
|
||||||
|
<< "Fix Floor and adjust playspace center: Floor Offset = ["
|
||||||
|
<< floorOffsetX << ", " << floorOffsetY << ", "
|
||||||
|
<< floorOffsetZ << "]";
|
||||||
float offset[3] = { 0, 0, 0 };
|
float offset[3] = { 0, 0, 0 };
|
||||||
offset[1] = floorOffsetY;
|
offset[1] = floorOffsetY;
|
||||||
if (state == 2) {
|
if ( state == 2 )
|
||||||
|
{
|
||||||
offset[0] = floorOffsetX;
|
offset[0] = floorOffsetX;
|
||||||
offset[2] = floorOffsetZ;
|
offset[2] = floorOffsetZ;
|
||||||
}
|
}
|
||||||
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, offset, true);
|
parent->AddOffsetToUniverseCenter(
|
||||||
statusMessage = (state == 2) ? "Recentering ... Ok" : "Fixing ... OK";
|
vr::TrackingUniverseStanding, offset, true );
|
||||||
|
statusMessage
|
||||||
|
= ( state == 2 ) ? "Recentering ... Ok" : "Fixing ... OK";
|
||||||
statusMessageTimeout = 1.0;
|
statusMessageTimeout = 1.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
emit measureEndSignal();
|
emit measureEndSignal();
|
||||||
@@ -125,28 +169,35 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FixFloorTabController::currentStatusMessage() {
|
QString FixFloorTabController::currentStatusMessage()
|
||||||
|
{
|
||||||
return statusMessage;
|
return statusMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
float FixFloorTabController::currentStatusMessageTimeout() {
|
float FixFloorTabController::currentStatusMessageTimeout()
|
||||||
|
{
|
||||||
return statusMessageTimeout;
|
return statusMessageTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FixFloorTabController::canUndo() const {
|
bool FixFloorTabController::canUndo() const
|
||||||
|
{
|
||||||
return m_canUndo;
|
return m_canUndo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixFloorTabController::setCanUndo(bool value, bool notify) {
|
void FixFloorTabController::setCanUndo( bool value, bool notify )
|
||||||
if (m_canUndo != value) {
|
{
|
||||||
|
if ( m_canUndo != value )
|
||||||
|
{
|
||||||
m_canUndo = value;
|
m_canUndo = value;
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit canUndoChanged( m_canUndo );
|
emit canUndoChanged( m_canUndo );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixFloorTabController::fixFloorClicked() {
|
void FixFloorTabController::fixFloorClicked()
|
||||||
|
{
|
||||||
statusMessage = "Fixing ...";
|
statusMessage = "Fixing ...";
|
||||||
statusMessageTimeout = 1.0;
|
statusMessageTimeout = 1.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
@@ -155,7 +206,8 @@ void FixFloorTabController::fixFloorClicked() {
|
|||||||
state = 1;
|
state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixFloorTabController::recenterClicked() {
|
void FixFloorTabController::recenterClicked()
|
||||||
|
{
|
||||||
statusMessage = "Fixing ...";
|
statusMessage = "Fixing ...";
|
||||||
statusMessageTimeout = 1.0;
|
statusMessageTimeout = 1.0;
|
||||||
emit statusMessageSignal();
|
emit statusMessageSignal();
|
||||||
@@ -164,11 +216,16 @@ void FixFloorTabController::recenterClicked() {
|
|||||||
state = 2;
|
state = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixFloorTabController::undoFixFloorClicked() {
|
void FixFloorTabController::undoFixFloorClicked()
|
||||||
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 0, -floorOffsetX, false);
|
{
|
||||||
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 1, -floorOffsetY, false);
|
parent->AddOffsetToUniverseCenter(
|
||||||
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 2, -floorOffsetZ, false);
|
vr::TrackingUniverseStanding, 0, -floorOffsetX, false );
|
||||||
LOG(INFO) << "Fix Floor: Undo Floor Offset = [" << -floorOffsetX << ", " << -floorOffsetY << ", " << -floorOffsetZ << "]";
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
vr::TrackingUniverseStanding, 1, -floorOffsetY, false );
|
||||||
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
vr::TrackingUniverseStanding, 2, -floorOffsetZ, false );
|
||||||
|
LOG( INFO ) << "Fix Floor: Undo Floor Offset = [" << -floorOffsetX << ", "
|
||||||
|
<< -floorOffsetY << ", " << -floorOffsetZ << "]";
|
||||||
floorOffsetY = 0.0f;
|
floorOffsetY = 0.0f;
|
||||||
statusMessage = "Undo ... OK";
|
statusMessage = "Undo ... OK";
|
||||||
statusMessageTimeout = 1.0;
|
statusMessageTimeout = 1.0;
|
||||||
@@ -176,4 +233,4 @@ void FixFloorTabController::undoFixFloorClicked() {
|
|||||||
setCanUndo( false );
|
setCanUndo( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advconfig
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -6,24 +6,30 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
class FixFloorTabController : public QObject {
|
class FixFloorTabController : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool canUndo READ canUndo WRITE setCanUndo NOTIFY canUndoChanged)
|
Q_PROPERTY(
|
||||||
|
bool canUndo READ canUndo WRITE setCanUndo NOTIFY canUndoChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
QQuickWindow* widget;
|
QQuickWindow* widget;
|
||||||
|
|
||||||
float controllerUpOffsetCorrection = 0.062f; // Controller touchpad facing upwards
|
float controllerUpOffsetCorrection
|
||||||
float controllerDownOffsetCorrection = 0.006f; // Controller touchpad facing downwards
|
= 0.062f; // Controller touchpad facing upwards
|
||||||
|
float controllerDownOffsetCorrection
|
||||||
|
= 0.006f; // Controller touchpad facing downwards
|
||||||
|
|
||||||
int state = 0; // 0 .. idle, 1 .. floor fix in progress, 2 .. recenter in progress
|
int state
|
||||||
vr::TrackedDeviceIndex_t referenceController = vr::k_unTrackedDeviceIndexInvalid;
|
= 0; // 0 .. idle, 1 .. floor fix in progress, 2 .. recenter in progress
|
||||||
|
vr::TrackedDeviceIndex_t referenceController
|
||||||
|
= vr::k_unTrackedDeviceIndexInvalid;
|
||||||
unsigned measurementCount = 0;
|
unsigned measurementCount = 0;
|
||||||
double tempOffsetX = 0.0;
|
double tempOffsetX = 0.0;
|
||||||
double tempOffsetY = 0.0;
|
double tempOffsetY = 0.0;
|
||||||
@@ -36,7 +42,6 @@ private:
|
|||||||
float statusMessageTimeout = 0.0f;
|
float statusMessageTimeout = 0.0f;
|
||||||
bool m_canUndo = false;
|
bool m_canUndo = false;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class AudioTabController;
|
class AudioTabController;
|
||||||
|
|
||||||
class KeyboardInput
|
class KeyboardInput
|
||||||
@@ -19,5 +19,4 @@ public:
|
|||||||
virtual void sendKeyboardAltTab() = 0;
|
virtual void sendKeyboardAltTab() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
|
||||||
void rotateCoordinates(float coordinates[3], float angle) {
|
void rotateCoordinates( float coordinates[3], float angle )
|
||||||
if (angle == 0) {
|
{
|
||||||
|
if ( angle == 0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float s = sin( angle );
|
float s = sin( angle );
|
||||||
@@ -15,136 +17,170 @@ void rotateCoordinates(float coordinates[3], float angle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
using std::chrono::duration_cast;
|
using std::chrono::duration_cast;
|
||||||
using std::chrono::milliseconds;
|
using std::chrono::milliseconds;
|
||||||
typedef std::chrono::system_clock clock;
|
typedef std::chrono::system_clock clock;
|
||||||
|
|
||||||
void MoveCenterTabController::initStage1() {
|
void MoveCenterTabController::initStage1()
|
||||||
|
{
|
||||||
setTrackingUniverse( vr::VRCompositor()->GetTrackingSpace() );
|
setTrackingUniverse( vr::VRCompositor()->GetTrackingSpace() );
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
auto value = settings->value( "adjustChaperone", m_adjustChaperone );
|
auto value = settings->value( "adjustChaperone", m_adjustChaperone );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_adjustChaperone = value.toBool();
|
m_adjustChaperone = value.toBool();
|
||||||
}
|
}
|
||||||
value = settings->value( "moveShortcutRight", m_moveShortcutRightEnabled );
|
value = settings->value( "moveShortcutRight", m_moveShortcutRightEnabled );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_moveShortcutRightEnabled = value.toBool();
|
m_moveShortcutRightEnabled = value.toBool();
|
||||||
}
|
}
|
||||||
value = settings->value( "moveShortcutLeft", m_moveShortcutLeftEnabled );
|
value = settings->value( "moveShortcutLeft", m_moveShortcutLeftEnabled );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_moveShortcutLeftEnabled = value.toBool();
|
m_moveShortcutLeftEnabled = value.toBool();
|
||||||
}
|
}
|
||||||
value = settings->value( "requireDoubleClick", m_requireDoubleClick );
|
value = settings->value( "requireDoubleClick", m_requireDoubleClick );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_requireDoubleClick = value.toBool();
|
m_requireDoubleClick = value.toBool();
|
||||||
}
|
}
|
||||||
value = settings->value( "lockXToggle", m_lockXToggle );
|
value = settings->value( "lockXToggle", m_lockXToggle );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_lockXToggle = value.toBool();
|
m_lockXToggle = value.toBool();
|
||||||
}
|
}
|
||||||
value = settings->value( "lockYToggle", m_lockYToggle );
|
value = settings->value( "lockYToggle", m_lockYToggle );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_lockYToggle = value.toBool();
|
m_lockYToggle = value.toBool();
|
||||||
}
|
}
|
||||||
value = settings->value( "lockZToggle", m_lockZToggle );
|
value = settings->value( "lockZToggle", m_lockZToggle );
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_lockZToggle = value.toBool();
|
m_lockZToggle = value.toBool();
|
||||||
}
|
}
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
lastMoveButtonClick[0] = lastMoveButtonClick[1] = clock::now();
|
lastMoveButtonClick[0] = lastMoveButtonClick[1] = clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
void MoveCenterTabController::initStage2( OverlayController* var_parent,
|
||||||
|
QQuickWindow* var_widget )
|
||||||
|
{
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MoveCenterTabController::trackingUniverse() const
|
||||||
int MoveCenterTabController::trackingUniverse() const {
|
{
|
||||||
return ( int ) m_trackingUniverse;
|
return ( int ) m_trackingUniverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setTrackingUniverse(int value, bool notify) {
|
void MoveCenterTabController::setTrackingUniverse( int value, bool notify )
|
||||||
if (m_trackingUniverse != value) {
|
{
|
||||||
|
if ( m_trackingUniverse != value )
|
||||||
|
{
|
||||||
reset();
|
reset();
|
||||||
m_trackingUniverse = value;
|
m_trackingUniverse = value;
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit trackingUniverseChanged( m_trackingUniverse );
|
emit trackingUniverseChanged( m_trackingUniverse );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float MoveCenterTabController::offsetX() const {
|
float MoveCenterTabController::offsetX() const
|
||||||
|
{
|
||||||
return m_offsetX;
|
return m_offsetX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setOffsetX(float value, bool notify) {
|
void MoveCenterTabController::setOffsetX( float value, bool notify )
|
||||||
if (m_offsetX != value) {
|
{
|
||||||
|
if ( m_offsetX != value )
|
||||||
|
{
|
||||||
modOffsetX( value - m_offsetX, notify );
|
modOffsetX( value - m_offsetX, notify );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float MoveCenterTabController::offsetY() const {
|
float MoveCenterTabController::offsetY() const
|
||||||
|
{
|
||||||
return m_offsetY;
|
return m_offsetY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setOffsetY(float value, bool notify) {
|
void MoveCenterTabController::setOffsetY( float value, bool notify )
|
||||||
if (m_offsetY != value) {
|
{
|
||||||
|
if ( m_offsetY != value )
|
||||||
|
{
|
||||||
modOffsetY( value - m_offsetY, notify );
|
modOffsetY( value - m_offsetY, notify );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float MoveCenterTabController::offsetZ() const {
|
float MoveCenterTabController::offsetZ() const
|
||||||
|
{
|
||||||
return m_offsetZ;
|
return m_offsetZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setOffsetZ(float value, bool notify) {
|
void MoveCenterTabController::setOffsetZ( float value, bool notify )
|
||||||
if (m_offsetZ != value) {
|
{
|
||||||
|
if ( m_offsetZ != value )
|
||||||
|
{
|
||||||
modOffsetZ( value - m_offsetZ, notify );
|
modOffsetZ( value - m_offsetZ, notify );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MoveCenterTabController::rotation() const {
|
int MoveCenterTabController::rotation() const
|
||||||
|
{
|
||||||
return m_rotation;
|
return m_rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setRotation(int value, bool notify) {
|
void MoveCenterTabController::setRotation( int value, bool notify )
|
||||||
if (m_rotation != value) {
|
{
|
||||||
|
if ( m_rotation != value )
|
||||||
|
{
|
||||||
// float angle = (value - m_rotation) * 2 * M_PI / 360.0;
|
// float angle = (value - m_rotation) * 2 * M_PI / 360.0;
|
||||||
//parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, angle, m_adjustChaperone);
|
// parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse,
|
||||||
|
// angle, m_adjustChaperone);
|
||||||
m_rotation = value;
|
m_rotation = value;
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit rotationChanged( m_rotation );
|
emit rotationChanged( m_rotation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::applyRotation() {
|
void MoveCenterTabController::applyRotation()
|
||||||
if (m_rotation != m_rotationOld) {
|
{
|
||||||
|
if ( m_rotation != m_rotationOld )
|
||||||
|
{
|
||||||
float angle = ( m_rotationOld - m_rotation ) * 2 * M_PI / 360.0;
|
float angle = ( m_rotationOld - m_rotation ) * 2 * M_PI / 360.0;
|
||||||
parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, angle, m_adjustChaperone);
|
parent->RotateUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
angle,
|
||||||
|
m_adjustChaperone );
|
||||||
m_rotationOld = m_rotation;
|
m_rotationOld = m_rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveCenterTabController::adjustChaperone() const {
|
bool MoveCenterTabController::adjustChaperone() const
|
||||||
|
{
|
||||||
return m_adjustChaperone;
|
return m_adjustChaperone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setAdjustChaperone(bool value, bool notify) {
|
void MoveCenterTabController::setAdjustChaperone( bool value, bool notify )
|
||||||
if (m_adjustChaperone != value) {
|
{
|
||||||
|
if ( m_adjustChaperone != value )
|
||||||
|
{
|
||||||
m_adjustChaperone = value;
|
m_adjustChaperone = value;
|
||||||
if (m_trackingUniverse == vr::TrackingUniverseStanding) {
|
if ( m_trackingUniverse == vr::TrackingUniverseStanding )
|
||||||
|
{
|
||||||
auto angle = m_rotation * 2 * M_PI / 360.0;
|
auto angle = m_rotation * 2 * M_PI / 360.0;
|
||||||
float offsetdir = m_adjustChaperone ? -1.0 : 1.0;
|
float offsetdir = m_adjustChaperone ? -1.0 : 1.0;
|
||||||
float offset[3] = {
|
float offset[3] = { offsetdir * m_offsetX,
|
||||||
offsetdir * m_offsetX,
|
|
||||||
offsetdir * m_offsetY,
|
offsetdir * m_offsetY,
|
||||||
offsetdir * m_offsetZ
|
offsetdir * m_offsetZ };
|
||||||
};
|
|
||||||
rotateCoordinates( offset, angle );
|
rotateCoordinates( offset, angle );
|
||||||
|
|
||||||
parent->AddOffsetToCollisionBounds( offset );
|
parent->AddOffsetToCollisionBounds( offset );
|
||||||
@@ -154,158 +190,197 @@ void MoveCenterTabController::setAdjustChaperone(bool value, bool notify) {
|
|||||||
settings->setValue( "adjustChaperone", m_adjustChaperone );
|
settings->setValue( "adjustChaperone", m_adjustChaperone );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit adjustChaperoneChanged( m_adjustChaperone );
|
emit adjustChaperoneChanged( m_adjustChaperone );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MoveCenterTabController::moveShortcutRight() const
|
||||||
bool MoveCenterTabController::moveShortcutRight() const {
|
{
|
||||||
return m_moveShortcutRightEnabled;
|
return m_moveShortcutRightEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setMoveShortcutRight(bool value, bool notify) {
|
void MoveCenterTabController::setMoveShortcutRight( bool value, bool notify )
|
||||||
|
{
|
||||||
m_moveShortcutRightEnabled = value;
|
m_moveShortcutRightEnabled = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
settings->setValue( "moveShortcutRight", m_moveShortcutRightEnabled );
|
settings->setValue( "moveShortcutRight", m_moveShortcutRightEnabled );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit moveShortcutRightChanged( m_moveShortcutRightEnabled );
|
emit moveShortcutRightChanged( m_moveShortcutRightEnabled );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveCenterTabController::moveShortcutLeft() const {
|
bool MoveCenterTabController::moveShortcutLeft() const
|
||||||
|
{
|
||||||
return m_moveShortcutLeftEnabled;
|
return m_moveShortcutLeftEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setMoveShortcutLeft(bool value, bool notify) {
|
void MoveCenterTabController::setMoveShortcutLeft( bool value, bool notify )
|
||||||
|
{
|
||||||
m_moveShortcutLeftEnabled = value;
|
m_moveShortcutLeftEnabled = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
settings->setValue( "moveShortcutLeft", m_moveShortcutLeftEnabled );
|
settings->setValue( "moveShortcutLeft", m_moveShortcutLeftEnabled );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit moveShortcutLeftChanged( m_moveShortcutLeftEnabled );
|
emit moveShortcutLeftChanged( m_moveShortcutLeftEnabled );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveCenterTabController::requireDoubleClick() const {
|
bool MoveCenterTabController::requireDoubleClick() const
|
||||||
|
{
|
||||||
return m_requireDoubleClick;
|
return m_requireDoubleClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setRequireDoubleClick(bool value, bool notify) {
|
void MoveCenterTabController::setRequireDoubleClick( bool value, bool notify )
|
||||||
|
{
|
||||||
m_requireDoubleClick = value;
|
m_requireDoubleClick = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
settings->setValue( "requireDoubleClick", m_requireDoubleClick );
|
settings->setValue( "requireDoubleClick", m_requireDoubleClick );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit requireDoubleClickChanged( m_requireDoubleClick );
|
emit requireDoubleClickChanged( m_requireDoubleClick );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveCenterTabController::lockXToggle() const {
|
bool MoveCenterTabController::lockXToggle() const
|
||||||
|
{
|
||||||
return m_lockXToggle;
|
return m_lockXToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setLockX(bool value, bool notify) {
|
void MoveCenterTabController::setLockX( bool value, bool notify )
|
||||||
|
{
|
||||||
m_lockXToggle = value;
|
m_lockXToggle = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
settings->setValue( "lockXToggle", m_lockXToggle );
|
settings->setValue( "lockXToggle", m_lockXToggle );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit requireLockXChanged( m_lockXToggle );
|
emit requireLockXChanged( m_lockXToggle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MoveCenterTabController::lockYToggle() const
|
||||||
bool MoveCenterTabController::lockYToggle() const {
|
{
|
||||||
return m_lockYToggle;
|
return m_lockYToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setLockY(bool value, bool notify) {
|
void MoveCenterTabController::setLockY( bool value, bool notify )
|
||||||
|
{
|
||||||
m_lockYToggle = value;
|
m_lockYToggle = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
settings->setValue( "lockYToggle", m_lockYToggle );
|
settings->setValue( "lockYToggle", m_lockYToggle );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit requireLockYChanged( m_lockYToggle );
|
emit requireLockYChanged( m_lockYToggle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveCenterTabController::lockZToggle() const {
|
bool MoveCenterTabController::lockZToggle() const
|
||||||
|
{
|
||||||
return m_lockZToggle;
|
return m_lockZToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::setLockZ(bool value, bool notify) {
|
void MoveCenterTabController::setLockZ( bool value, bool notify )
|
||||||
|
{
|
||||||
m_lockZToggle = value;
|
m_lockZToggle = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "playspaceSettings" );
|
settings->beginGroup( "playspaceSettings" );
|
||||||
settings->setValue( "lockZToggle", m_lockZToggle );
|
settings->setValue( "lockZToggle", m_lockZToggle );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit requireLockZChanged( m_lockZToggle );
|
emit requireLockZChanged( m_lockZToggle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoveCenterTabController::modOffsetX( float value, bool notify )
|
||||||
|
{
|
||||||
void MoveCenterTabController::modOffsetX(float value, bool notify) {
|
|
||||||
// TODO ? possible issue with locking position this way
|
// TODO ? possible issue with locking position this way
|
||||||
if (!m_lockXToggle) {
|
if ( !m_lockXToggle )
|
||||||
|
{
|
||||||
auto angle = m_rotation * 2 * M_PI / 360.0;
|
auto angle = m_rotation * 2 * M_PI / 360.0;
|
||||||
float offset[3] = { value, 0, 0 };
|
float offset[3] = { value, 0, 0 };
|
||||||
rotateCoordinates( offset, angle );
|
rotateCoordinates( offset, angle );
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, offset, m_adjustChaperone);
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
offset,
|
||||||
|
m_adjustChaperone );
|
||||||
m_offsetX += value;
|
m_offsetX += value;
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit offsetXChanged( m_offsetX );
|
emit offsetXChanged( m_offsetX );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::modOffsetY(float value, bool notify) {
|
void MoveCenterTabController::modOffsetY( float value, bool notify )
|
||||||
if (!m_lockYToggle) {
|
{
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, 1, value, m_adjustChaperone);
|
if ( !m_lockYToggle )
|
||||||
|
{
|
||||||
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
1,
|
||||||
|
value,
|
||||||
|
m_adjustChaperone );
|
||||||
m_offsetY += value;
|
m_offsetY += value;
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit offsetYChanged( m_offsetY );
|
emit offsetYChanged( m_offsetY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::modOffsetZ(float value, bool notify) {
|
void MoveCenterTabController::modOffsetZ( float value, bool notify )
|
||||||
if (!m_lockZToggle) {
|
{
|
||||||
|
if ( !m_lockZToggle )
|
||||||
|
{
|
||||||
auto angle = m_rotation * 2 * M_PI / 360.0;
|
auto angle = m_rotation * 2 * M_PI / 360.0;
|
||||||
float offset[3] = { 0, 0, value };
|
float offset[3] = { 0, 0, value };
|
||||||
rotateCoordinates( offset, angle );
|
rotateCoordinates( offset, angle );
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, offset, m_adjustChaperone);
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
offset,
|
||||||
|
m_adjustChaperone );
|
||||||
m_offsetZ += value;
|
m_offsetZ += value;
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit offsetZChanged( m_offsetZ );
|
emit offsetZChanged( m_offsetZ );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::reset() {
|
void MoveCenterTabController::reset()
|
||||||
|
{
|
||||||
vr::VRChaperoneSetup()->RevertWorkingCopy();
|
vr::VRChaperoneSetup()->RevertWorkingCopy();
|
||||||
parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, -m_rotation * 2 * M_PI / 360.0, m_adjustChaperone, false);
|
parent->RotateUniverseCenter(
|
||||||
float offset[3] = {
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
-m_offsetX,
|
-m_rotation * 2 * M_PI / 360.0,
|
||||||
-m_offsetY,
|
m_adjustChaperone,
|
||||||
-m_offsetZ
|
false );
|
||||||
};
|
float offset[3] = { -m_offsetX, -m_offsetY, -m_offsetZ };
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, offset, m_adjustChaperone, false);
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
offset,
|
||||||
|
m_adjustChaperone,
|
||||||
|
false );
|
||||||
vr::VRChaperoneSetup()->CommitWorkingCopy( vr::EChaperoneConfigFile_Live );
|
vr::VRChaperoneSetup()->CommitWorkingCopy( vr::EChaperoneConfigFile_Live );
|
||||||
m_offsetX = 0.0f;
|
m_offsetX = 0.0f;
|
||||||
m_offsetY = 0.0f;
|
m_offsetY = 0.0f;
|
||||||
@@ -317,55 +392,84 @@ void MoveCenterTabController::reset() {
|
|||||||
emit rotationChanged( m_rotation );
|
emit rotationChanged( m_rotation );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMoveShortCutPressed(vr::ETrackedControllerRole hand) {
|
bool isMoveShortCutPressed( vr::ETrackedControllerRole hand )
|
||||||
auto handId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(hand);
|
{
|
||||||
if (handId == vr::k_unTrackedDeviceIndexInvalid || handId >= vr::k_unMaxTrackedDeviceCount) {
|
auto handId
|
||||||
|
= vr::VRSystem()->GetTrackedDeviceIndexForControllerRole( hand );
|
||||||
|
if ( handId == vr::k_unTrackedDeviceIndexInvalid
|
||||||
|
|| handId >= vr::k_unMaxTrackedDeviceCount )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VRControllerState_t state;
|
vr::VRControllerState_t state;
|
||||||
if (vr::VRSystem()->GetControllerState(handId, &state, sizeof(vr::VRControllerState_t))) {
|
if ( vr::VRSystem()->GetControllerState(
|
||||||
return state.ulButtonPressed & vr::ButtonMaskFromId(vr::k_EButton_ApplicationMenu);
|
handId, &state, sizeof( vr::VRControllerState_t ) ) )
|
||||||
|
{
|
||||||
|
return state.ulButtonPressed
|
||||||
|
& vr::ButtonMaskFromId( vr::k_EButton_ApplicationMenu );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::ETrackedControllerRole MoveCenterTabController::getMoveShortcutHand() {
|
vr::ETrackedControllerRole MoveCenterTabController::getMoveShortcutHand()
|
||||||
|
{
|
||||||
auto activeHand = m_activeMoveController;
|
auto activeHand = m_activeMoveController;
|
||||||
|
|
||||||
bool rightPressed = m_moveShortcutRightEnabled && isMoveShortCutPressed(vr::TrackedControllerRole_RightHand);
|
bool rightPressed
|
||||||
bool leftPressed = m_moveShortcutLeftEnabled && isMoveShortCutPressed(vr::TrackedControllerRole_LeftHand);
|
= m_moveShortcutRightEnabled
|
||||||
bool checkDoubleClick = m_requireDoubleClick && activeHand == vr::TrackedControllerRole_Invalid;
|
&& isMoveShortCutPressed( vr::TrackedControllerRole_RightHand );
|
||||||
|
bool leftPressed
|
||||||
|
= m_moveShortcutLeftEnabled
|
||||||
|
&& isMoveShortCutPressed( vr::TrackedControllerRole_LeftHand );
|
||||||
|
bool checkDoubleClick = m_requireDoubleClick
|
||||||
|
&& activeHand == vr::TrackedControllerRole_Invalid;
|
||||||
|
|
||||||
auto now = clock::now();
|
auto now = clock::now();
|
||||||
// if we start pressing the shortcut on a controller we set the active one to it
|
// if we start pressing the shortcut on a controller we set the active one
|
||||||
if (rightPressed && !m_moveShortcutRightPressed) {
|
// to it
|
||||||
auto elapsed = duration_cast<milliseconds>(now - lastMoveButtonClick[0]).count();
|
if ( rightPressed && !m_moveShortcutRightPressed )
|
||||||
if (!checkDoubleClick || elapsed < 250) {
|
{
|
||||||
|
auto elapsed
|
||||||
|
= duration_cast<milliseconds>( now - lastMoveButtonClick[0] )
|
||||||
|
.count();
|
||||||
|
if ( !checkDoubleClick || elapsed < 250 )
|
||||||
|
{
|
||||||
activeHand = vr::TrackedControllerRole_RightHand;
|
activeHand = vr::TrackedControllerRole_RightHand;
|
||||||
}
|
}
|
||||||
lastMoveButtonClick[0] = now;
|
lastMoveButtonClick[0] = now;
|
||||||
}
|
}
|
||||||
if (leftPressed && !m_moveShortcutLeftPressed) {
|
if ( leftPressed && !m_moveShortcutLeftPressed )
|
||||||
auto elapsed = duration_cast<milliseconds>(now - lastMoveButtonClick[1]).count();
|
{
|
||||||
if (!checkDoubleClick || elapsed < 250) {
|
auto elapsed
|
||||||
|
= duration_cast<milliseconds>( now - lastMoveButtonClick[1] )
|
||||||
|
.count();
|
||||||
|
if ( !checkDoubleClick || elapsed < 250 )
|
||||||
|
{
|
||||||
activeHand = vr::TrackedControllerRole_LeftHand;
|
activeHand = vr::TrackedControllerRole_LeftHand;
|
||||||
}
|
}
|
||||||
lastMoveButtonClick[1] = now;
|
lastMoveButtonClick[1] = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we let down of a shortcut we set the active hand to any remaining pressed down hand
|
// if we let down of a shortcut we set the active hand to any remaining
|
||||||
if (!rightPressed && m_moveShortcutRightPressed) {
|
// pressed down hand
|
||||||
activeHand = leftPressed ? vr::TrackedControllerRole_LeftHand : vr::TrackedControllerRole_Invalid;
|
if ( !rightPressed && m_moveShortcutRightPressed )
|
||||||
|
{
|
||||||
|
activeHand = leftPressed ? vr::TrackedControllerRole_LeftHand
|
||||||
|
: vr::TrackedControllerRole_Invalid;
|
||||||
}
|
}
|
||||||
if (!leftPressed && m_moveShortcutLeftPressed) {
|
if ( !leftPressed && m_moveShortcutLeftPressed )
|
||||||
activeHand = rightPressed ? vr::TrackedControllerRole_RightHand : vr::TrackedControllerRole_Invalid;
|
{
|
||||||
|
activeHand = rightPressed ? vr::TrackedControllerRole_RightHand
|
||||||
|
: vr::TrackedControllerRole_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!leftPressed && !rightPressed) {
|
if ( !leftPressed && !rightPressed )
|
||||||
|
{
|
||||||
activeHand = vr::TrackedControllerRole_Invalid;
|
activeHand = vr::TrackedControllerRole_Invalid;
|
||||||
if (m_activeMoveController != vr::TrackedControllerRole_Invalid) {
|
if ( m_activeMoveController != vr::TrackedControllerRole_Invalid )
|
||||||
|
{
|
||||||
// grace period while switching hands
|
// grace period while switching hands
|
||||||
lastMoveButtonClick[0] = lastMoveButtonClick[1] = now;
|
lastMoveButtonClick[0] = lastMoveButtonClick[1] = now;
|
||||||
}
|
}
|
||||||
@@ -378,24 +482,35 @@ vr::ETrackedControllerRole MoveCenterTabController::getMoveShortcutHand() {
|
|||||||
return activeHand;
|
return activeHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoveCenterTabController::eventLoopTick(
|
||||||
void MoveCenterTabController::eventLoopTick(vr::ETrackingUniverseOrigin universe, vr::TrackedDevicePose_t* devicePoses) {
|
vr::ETrackingUniverseOrigin universe,
|
||||||
if (settingsUpdateCounter >= 50) {
|
vr::TrackedDevicePose_t* devicePoses )
|
||||||
|
{
|
||||||
|
if ( settingsUpdateCounter >= 50 )
|
||||||
|
{
|
||||||
setTrackingUniverse( ( int ) universe );
|
setTrackingUniverse( ( int ) universe );
|
||||||
settingsUpdateCounter = 0;
|
settingsUpdateCounter = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
settingsUpdateCounter++;
|
settingsUpdateCounter++;
|
||||||
auto oldMoveHand = m_activeMoveController;
|
auto oldMoveHand = m_activeMoveController;
|
||||||
auto newMoveHand = getMoveShortcutHand();
|
auto newMoveHand = getMoveShortcutHand();
|
||||||
if (newMoveHand == vr::TrackedControllerRole_Invalid) {
|
if ( newMoveHand == vr::TrackedControllerRole_Invalid )
|
||||||
|
{
|
||||||
emit offsetXChanged( m_offsetX );
|
emit offsetXChanged( m_offsetX );
|
||||||
emit offsetYChanged( m_offsetY );
|
emit offsetYChanged( m_offsetY );
|
||||||
emit offsetZChanged( m_offsetZ );
|
emit offsetZChanged( m_offsetZ );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto handId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(newMoveHand);
|
auto handId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
|
||||||
if (newMoveHand == vr::TrackedControllerRole_Invalid || handId == vr::k_unTrackedDeviceIndexInvalid || handId >= vr::k_unMaxTrackedDeviceCount) {
|
newMoveHand );
|
||||||
if (oldMoveHand != vr::TrackedControllerRole_Invalid) {
|
if ( newMoveHand == vr::TrackedControllerRole_Invalid
|
||||||
|
|| handId == vr::k_unTrackedDeviceIndexInvalid
|
||||||
|
|| handId >= vr::k_unMaxTrackedDeviceCount )
|
||||||
|
{
|
||||||
|
if ( oldMoveHand != vr::TrackedControllerRole_Invalid )
|
||||||
|
{
|
||||||
emit offsetXChanged( m_offsetX );
|
emit offsetXChanged( m_offsetX );
|
||||||
emit offsetYChanged( m_offsetY );
|
emit offsetYChanged( m_offsetY );
|
||||||
emit offsetZChanged( m_offsetZ );
|
emit offsetZChanged( m_offsetZ );
|
||||||
@@ -403,14 +518,15 @@ void MoveCenterTabController::eventLoopTick(vr::ETrackingUniverseOrigin universe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vr::TrackedDevicePose_t* pose = devicePoses + handId;
|
vr::TrackedDevicePose_t* pose = devicePoses + handId;
|
||||||
if (!pose->bPoseIsValid || !pose->bDeviceIsConnected || pose->eTrackingResult != vr::TrackingResult_Running_OK) {
|
if ( !pose->bPoseIsValid || !pose->bDeviceIsConnected
|
||||||
|
|| pose->eTrackingResult != vr::TrackingResult_Running_OK )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float relativeControllerPosition[] = {
|
float relativeControllerPosition[]
|
||||||
pose->mDeviceToAbsoluteTracking.m[0][3],
|
= { pose->mDeviceToAbsoluteTracking.m[0][3],
|
||||||
pose->mDeviceToAbsoluteTracking.m[1][3],
|
pose->mDeviceToAbsoluteTracking.m[1][3],
|
||||||
pose->mDeviceToAbsoluteTracking.m[2][3]
|
pose->mDeviceToAbsoluteTracking.m[2][3] };
|
||||||
};
|
|
||||||
|
|
||||||
auto angle = m_rotation * 2 * M_PI / 360.0;
|
auto angle = m_rotation * 2 * M_PI / 360.0;
|
||||||
rotateCoordinates( relativeControllerPosition, -angle );
|
rotateCoordinates( relativeControllerPosition, -angle );
|
||||||
@@ -420,8 +536,8 @@ void MoveCenterTabController::eventLoopTick(vr::ETrackingUniverseOrigin universe
|
|||||||
relativeControllerPosition[2] + m_offsetZ,
|
relativeControllerPosition[2] + m_offsetZ,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (oldMoveHand == newMoveHand) {
|
if ( oldMoveHand == newMoveHand )
|
||||||
|
{
|
||||||
float diff[3] = {
|
float diff[3] = {
|
||||||
absoluteControllerPosition[0] - m_lastControllerPosition[0],
|
absoluteControllerPosition[0] - m_lastControllerPosition[0],
|
||||||
absoluteControllerPosition[1] - m_lastControllerPosition[1],
|
absoluteControllerPosition[1] - m_lastControllerPosition[1],
|
||||||
@@ -431,31 +547,38 @@ void MoveCenterTabController::eventLoopTick(vr::ETrackingUniverseOrigin universe
|
|||||||
// offset is un-rotated coordinates
|
// offset is un-rotated coordinates
|
||||||
|
|
||||||
// prevents UI from updating if axis movement is locked
|
// prevents UI from updating if axis movement is locked
|
||||||
if (!m_lockXToggle) {
|
if ( !m_lockXToggle )
|
||||||
|
{
|
||||||
m_offsetX += diff[0];
|
m_offsetX += diff[0];
|
||||||
}
|
}
|
||||||
if (!m_lockYToggle) {
|
if ( !m_lockYToggle )
|
||||||
|
{
|
||||||
m_offsetY += diff[1];
|
m_offsetY += diff[1];
|
||||||
}
|
}
|
||||||
if (!m_lockZToggle) {
|
if ( !m_lockZToggle )
|
||||||
|
{
|
||||||
m_offsetZ += diff[2];
|
m_offsetZ += diff[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rotateCoordinates( diff, angle );
|
rotateCoordinates( diff, angle );
|
||||||
// If locked removes movement
|
// If locked removes movement
|
||||||
if (m_lockXToggle) {
|
if ( m_lockXToggle )
|
||||||
|
{
|
||||||
diff[0] = 0;
|
diff[0] = 0;
|
||||||
}
|
}
|
||||||
if (m_lockYToggle) {
|
if ( m_lockYToggle )
|
||||||
|
{
|
||||||
diff[1] = 0;
|
diff[1] = 0;
|
||||||
}
|
}
|
||||||
if (m_lockZToggle) {
|
if ( m_lockZToggle )
|
||||||
|
{
|
||||||
diff[2] = 0;
|
diff[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent->AddOffsetToUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, diff, m_adjustChaperone);
|
parent->AddOffsetToUniverseCenter(
|
||||||
|
( vr::TrackingUniverseOrigin ) m_trackingUniverse,
|
||||||
|
diff,
|
||||||
|
m_adjustChaperone );
|
||||||
}
|
}
|
||||||
m_lastControllerPosition[0] = absoluteControllerPosition[0];
|
m_lastControllerPosition[0] = absoluteControllerPosition[0];
|
||||||
m_lastControllerPosition[1] = absoluteControllerPosition[1];
|
m_lastControllerPosition[1] = absoluteControllerPosition[1];
|
||||||
@@ -463,4 +586,4 @@ void MoveCenterTabController::eventLoopTick(vr::ETrackingUniverseOrigin universe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advconfig
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -7,26 +7,38 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
class MoveCenterTabController : public QObject
|
||||||
class MoveCenterTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int trackingUniverse READ trackingUniverse WRITE setTrackingUniverse NOTIFY trackingUniverseChanged)
|
Q_PROPERTY( int trackingUniverse READ trackingUniverse WRITE
|
||||||
Q_PROPERTY(float offsetX READ offsetX WRITE setOffsetX NOTIFY offsetXChanged)
|
setTrackingUniverse NOTIFY trackingUniverseChanged )
|
||||||
Q_PROPERTY(float offsetY READ offsetY WRITE setOffsetY NOTIFY offsetYChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(float offsetZ READ offsetZ WRITE setOffsetZ NOTIFY offsetZChanged)
|
float offsetX READ offsetX WRITE setOffsetX NOTIFY offsetXChanged )
|
||||||
Q_PROPERTY(int rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(bool adjustChaperone READ adjustChaperone WRITE setAdjustChaperone NOTIFY adjustChaperoneChanged)
|
float offsetY READ offsetY WRITE setOffsetY NOTIFY offsetYChanged )
|
||||||
Q_PROPERTY(bool moveShortcutRight READ moveShortcutRight WRITE setMoveShortcutRight NOTIFY moveShortcutRightChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(bool moveShortcutLeft READ moveShortcutLeft WRITE setMoveShortcutLeft NOTIFY moveShortcutLeftChanged)
|
float offsetZ READ offsetZ WRITE setOffsetZ NOTIFY offsetZChanged )
|
||||||
Q_PROPERTY(bool requireDoubleClick READ requireDoubleClick WRITE setRequireDoubleClick NOTIFY requireDoubleClickChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(bool lockXToggle READ lockXToggle WRITE setLockX NOTIFY requireLockXChanged)
|
int rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
|
||||||
Q_PROPERTY(bool lockYToggle READ lockYToggle WRITE setLockY NOTIFY requireLockYChanged)
|
Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE
|
||||||
Q_PROPERTY(bool lockZToggle READ lockZToggle WRITE setLockZ NOTIFY requireLockZChanged)
|
setAdjustChaperone NOTIFY adjustChaperoneChanged )
|
||||||
|
Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE
|
||||||
|
setMoveShortcutRight NOTIFY moveShortcutRightChanged )
|
||||||
|
Q_PROPERTY( bool moveShortcutLeft READ moveShortcutLeft WRITE
|
||||||
|
setMoveShortcutLeft NOTIFY moveShortcutLeftChanged )
|
||||||
|
Q_PROPERTY( bool requireDoubleClick READ requireDoubleClick WRITE
|
||||||
|
setRequireDoubleClick NOTIFY requireDoubleClickChanged )
|
||||||
|
Q_PROPERTY( bool lockXToggle READ lockXToggle WRITE setLockX NOTIFY
|
||||||
|
requireLockXChanged )
|
||||||
|
Q_PROPERTY( bool lockYToggle READ lockYToggle WRITE setLockY NOTIFY
|
||||||
|
requireLockYChanged )
|
||||||
|
Q_PROPERTY( bool lockZToggle READ lockZToggle WRITE setLockZ NOTIFY
|
||||||
|
requireLockZChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -59,7 +71,8 @@ public:
|
|||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
||||||
|
|
||||||
void eventLoopTick(vr::ETrackingUniverseOrigin universe, vr::TrackedDevicePose_t* devicePoses);
|
void eventLoopTick( vr::ETrackingUniverseOrigin universe,
|
||||||
|
vr::TrackedDevicePose_t* devicePoses );
|
||||||
|
|
||||||
float offsetX() const;
|
float offsetX() const;
|
||||||
float offsetY() const;
|
float offsetY() const;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,27 +10,31 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
enum TouchPadArea {
|
enum TouchPadArea
|
||||||
|
{
|
||||||
PAD_AREA_LEFT = ( 1 << 0 ),
|
PAD_AREA_LEFT = ( 1 << 0 ),
|
||||||
PAD_AREA_TOP = ( 1 << 1 ),
|
PAD_AREA_TOP = ( 1 << 1 ),
|
||||||
PAD_AREA_RIGHT = ( 1 << 2 ),
|
PAD_AREA_RIGHT = ( 1 << 2 ),
|
||||||
PAD_AREA_BOTTOM = ( 1 << 3 ),
|
PAD_AREA_BOTTOM = ( 1 << 3 ),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PttControllerConfig {
|
struct PttControllerConfig
|
||||||
|
{
|
||||||
QVariantList digitalButtons;
|
QVariantList digitalButtons;
|
||||||
uint64_t digitalButtonMask = 0;
|
uint64_t digitalButtonMask = 0;
|
||||||
unsigned triggerMode = 0; // 0 .. disabled, 1 .. enabled
|
unsigned triggerMode = 0; // 0 .. disabled, 1 .. enabled
|
||||||
unsigned touchpadMode = 0; // 0 .. disabled, 1 .. only touch, 2 .. only press, 3 .. both
|
unsigned touchpadMode
|
||||||
|
= 0; // 0 .. disabled, 1 .. only touch, 2 .. only press, 3 .. both
|
||||||
unsigned touchpadAreas = 0;
|
unsigned touchpadAreas = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PttProfile {
|
struct PttProfile
|
||||||
|
{
|
||||||
std::string profileName;
|
std::string profileName;
|
||||||
|
|
||||||
bool showNotification = false;
|
bool showNotification = false;
|
||||||
@@ -39,14 +43,20 @@ namespace advsettings {
|
|||||||
PttControllerConfig controllerConfigs[2];
|
PttControllerConfig controllerConfigs[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PttController : public QObject
|
||||||
class PttController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool pttEnabled READ pttEnabled WRITE setPttEnabled NOTIFY pttEnabledChanged)
|
Q_PROPERTY( bool pttEnabled READ pttEnabled WRITE setPttEnabled NOTIFY
|
||||||
|
pttEnabledChanged )
|
||||||
Q_PROPERTY( bool pttActive READ pttActive NOTIFY pttActiveChanged )
|
Q_PROPERTY( bool pttActive READ pttActive NOTIFY pttActiveChanged )
|
||||||
Q_PROPERTY(bool pttShowNotification READ pttShowNotification WRITE setPttShowNotification NOTIFY pttShowNotificationChanged)
|
Q_PROPERTY( bool pttShowNotification READ pttShowNotification WRITE
|
||||||
Q_PROPERTY(bool pttLeftControllerEnabled READ pttLeftControllerEnabled WRITE setPttLeftControllerEnabled NOTIFY pttLeftControllerEnabledChanged)
|
setPttShowNotification NOTIFY pttShowNotificationChanged )
|
||||||
Q_PROPERTY(bool pttRightControllerEnabled READ pttRightControllerEnabled WRITE setPttRightControllerEnabled NOTIFY pttRightControllerEnabledChanged)
|
Q_PROPERTY(
|
||||||
|
bool pttLeftControllerEnabled READ pttLeftControllerEnabled WRITE
|
||||||
|
setPttLeftControllerEnabled NOTIFY pttLeftControllerEnabledChanged )
|
||||||
|
Q_PROPERTY( bool pttRightControllerEnabled READ pttRightControllerEnabled
|
||||||
|
WRITE setPttRightControllerEnabled NOTIFY
|
||||||
|
pttRightControllerEnabledChanged )
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_pttEnabled = false;
|
bool m_pttEnabled = false;
|
||||||
@@ -65,8 +75,14 @@ namespace advsettings {
|
|||||||
virtual void onPttStop(){};
|
virtual void onPttStop(){};
|
||||||
virtual void onPttEnabled(){};
|
virtual void onPttEnabled(){};
|
||||||
virtual void onPttDisabled(){};
|
virtual void onPttDisabled(){};
|
||||||
virtual bool pttChangeValid() { return true; }
|
virtual bool pttChangeValid()
|
||||||
virtual vr::VROverlayHandle_t getNotificationOverlayHandle() { return vr::k_ulOverlayHandleInvalid; }
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual vr::VROverlayHandle_t getNotificationOverlayHandle()
|
||||||
|
{
|
||||||
|
return vr::k_ulOverlayHandleInvalid;
|
||||||
|
}
|
||||||
std::recursive_mutex eventLoopMutex;
|
std::recursive_mutex eventLoopMutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -84,7 +100,6 @@ namespace advsettings {
|
|||||||
void savePttProfiles();
|
void savePttProfiles();
|
||||||
void savePttConfig();
|
void savePttConfig();
|
||||||
|
|
||||||
|
|
||||||
Q_INVOKABLE QVariantList pttDigitalButtons( unsigned controller );
|
Q_INVOKABLE QVariantList pttDigitalButtons( unsigned controller );
|
||||||
Q_INVOKABLE unsigned long pttDigitalButtonMask( unsigned controller );
|
Q_INVOKABLE unsigned long pttDigitalButtonMask( unsigned controller );
|
||||||
Q_INVOKABLE unsigned pttTouchpadMode( unsigned controller );
|
Q_INVOKABLE unsigned pttTouchpadMode( unsigned controller );
|
||||||
@@ -96,11 +111,21 @@ namespace advsettings {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPttEnabled( bool value, bool notify = true, bool save = true );
|
void setPttEnabled( bool value, bool notify = true, bool save = true );
|
||||||
void setPttShowNotification(bool value, bool notify = true, bool save = true);
|
void setPttShowNotification( bool value,
|
||||||
void setPttLeftControllerEnabled(bool value, bool notify = true, bool save = true);
|
bool notify = true,
|
||||||
void setPttRightControllerEnabled(bool value, bool notify = true, bool save = true);
|
bool save = true );
|
||||||
|
void setPttLeftControllerEnabled( bool value,
|
||||||
|
bool notify = true,
|
||||||
|
bool save = true );
|
||||||
|
void setPttRightControllerEnabled( bool value,
|
||||||
|
bool notify = true,
|
||||||
|
bool save = true );
|
||||||
|
|
||||||
void setPttControllerConfig(unsigned controller, QVariantList buttons, unsigned triggerMode, unsigned padMode, unsigned padAreas);
|
void setPttControllerConfig( unsigned controller,
|
||||||
|
QVariantList buttons,
|
||||||
|
unsigned triggerMode,
|
||||||
|
unsigned padMode,
|
||||||
|
unsigned padAreas );
|
||||||
|
|
||||||
void addPttProfile( QString name );
|
void addPttProfile( QString name );
|
||||||
void applyPttProfile( unsigned index );
|
void applyPttProfile( unsigned index );
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,13 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
struct ReviveControllerProfile
|
||||||
struct ReviveControllerProfile {
|
{
|
||||||
std::string profileName;
|
std::string profileName;
|
||||||
int gripButtonMode;
|
int gripButtonMode;
|
||||||
bool triggerAsGrip;
|
bool triggerAsGrip;
|
||||||
@@ -26,28 +25,48 @@ namespace advsettings {
|
|||||||
float touchZ;
|
float touchZ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ReviveTabController : public QObject
|
||||||
class ReviveTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int isOverlayInstalled READ isOverlayInstalled NOTIFY isOverlayInstalledChanged)
|
Q_PROPERTY( int isOverlayInstalled READ isOverlayInstalled NOTIFY
|
||||||
Q_PROPERTY(int gripButtonMode READ gripButtonMode WRITE setGripButtonMode NOTIFY gripButtonModeChanged)
|
isOverlayInstalledChanged )
|
||||||
Q_PROPERTY(int triggerAsGrip READ triggerAsGrip WRITE setTriggerAsGrip NOTIFY triggerAsGripChanged)
|
Q_PROPERTY( int gripButtonMode READ gripButtonMode WRITE setGripButtonMode
|
||||||
Q_PROPERTY(bool pixelsPerDisplayPixelOverrideEnabled READ isPixelsPerDisplayPixelOverrideEnabled WRITE setPixelsPerDisplayPixelOverrideEnabled NOTIFY pixelsPerDisplayPixelOverrideEnabledChanged)
|
NOTIFY gripButtonModeChanged )
|
||||||
Q_PROPERTY(float toggleDelay READ toggleDelay WRITE setToggleDelay NOTIFY toggleDelayChanged)
|
Q_PROPERTY( int triggerAsGrip READ triggerAsGrip WRITE setTriggerAsGrip
|
||||||
Q_PROPERTY(float pixelsPerDisplayPixelOverride READ pixelsPerDisplayPixelOverride WRITE setPixelsPerDisplayPixelOverride NOTIFY pixelsPerDisplayPixelOverrideChanged)
|
NOTIFY triggerAsGripChanged )
|
||||||
Q_PROPERTY(float thumbDeadzone READ thumbDeadzone WRITE setThumbDeadzone NOTIFY thumbDeadzoneChanged)
|
Q_PROPERTY( bool pixelsPerDisplayPixelOverrideEnabled READ
|
||||||
Q_PROPERTY(float thumbRange READ thumbRange WRITE setThumbRange NOTIFY thumbRangeChanged)
|
isPixelsPerDisplayPixelOverrideEnabled WRITE
|
||||||
Q_PROPERTY(float touchPitch READ touchPitch WRITE setTouchPitch NOTIFY touchPitchChanged)
|
setPixelsPerDisplayPixelOverrideEnabled NOTIFY
|
||||||
Q_PROPERTY(float touchYaw READ touchYaw WRITE setTouchYaw NOTIFY touchYawChanged)
|
pixelsPerDisplayPixelOverrideEnabledChanged )
|
||||||
Q_PROPERTY(float touchRoll READ touchRoll WRITE setTouchRoll NOTIFY touchRollChanged)
|
Q_PROPERTY( float toggleDelay READ toggleDelay WRITE setToggleDelay NOTIFY
|
||||||
|
toggleDelayChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
float pixelsPerDisplayPixelOverride READ pixelsPerDisplayPixelOverride
|
||||||
|
WRITE setPixelsPerDisplayPixelOverride NOTIFY
|
||||||
|
pixelsPerDisplayPixelOverrideChanged )
|
||||||
|
Q_PROPERTY( float thumbDeadzone READ thumbDeadzone WRITE setThumbDeadzone
|
||||||
|
NOTIFY thumbDeadzoneChanged )
|
||||||
|
Q_PROPERTY( float thumbRange READ thumbRange WRITE setThumbRange NOTIFY
|
||||||
|
thumbRangeChanged )
|
||||||
|
Q_PROPERTY( float touchPitch READ touchPitch WRITE setTouchPitch NOTIFY
|
||||||
|
touchPitchChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
float touchYaw READ touchYaw WRITE setTouchYaw NOTIFY touchYawChanged )
|
||||||
|
Q_PROPERTY( float touchRoll READ touchRoll WRITE setTouchRoll NOTIFY
|
||||||
|
touchRollChanged )
|
||||||
Q_PROPERTY( float touchX READ touchX WRITE setTouchX NOTIFY touchXChanged )
|
Q_PROPERTY( float touchX READ touchX WRITE setTouchX NOTIFY touchXChanged )
|
||||||
Q_PROPERTY( float touchY READ touchY WRITE setTouchY NOTIFY touchYChanged )
|
Q_PROPERTY( float touchY READ touchY WRITE setTouchY NOTIFY touchYChanged )
|
||||||
Q_PROPERTY( float touchZ READ touchZ WRITE setTouchZ NOTIFY touchZChanged )
|
Q_PROPERTY( float touchZ READ touchZ WRITE setTouchZ NOTIFY touchZChanged )
|
||||||
Q_PROPERTY(float piPlayerHeight READ piPlayerHeight WRITE setPiPlayerHeight NOTIFY piPlayerHeightChanged)
|
Q_PROPERTY( float piPlayerHeight READ piPlayerHeight WRITE setPiPlayerHeight
|
||||||
Q_PROPERTY(float piEyeHeight READ piEyeHeight WRITE setPiEyeHeight NOTIFY piEyeHeightChanged)
|
NOTIFY piPlayerHeightChanged )
|
||||||
Q_PROPERTY(QString piUsername READ piUsername WRITE setPiUsername NOTIFY piUsernameChanged)
|
Q_PROPERTY( float piEyeHeight READ piEyeHeight WRITE setPiEyeHeight NOTIFY
|
||||||
Q_PROPERTY(QString piName READ piName WRITE setPiName NOTIFY piNameChanged)
|
piEyeHeightChanged )
|
||||||
Q_PROPERTY(int piGender READ piGender WRITE setPiGender NOTIFY piGenderChanged)
|
Q_PROPERTY( QString piUsername READ piUsername WRITE setPiUsername NOTIFY
|
||||||
|
piUsernameChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
QString piName READ piName WRITE setPiName NOTIFY piNameChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
int piGender READ piGender WRITE setPiGender NOTIFY piGenderChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -121,7 +140,8 @@ namespace advsettings {
|
|||||||
void setTriggerAsGrip( bool value, bool notify = true );
|
void setTriggerAsGrip( bool value, bool notify = true );
|
||||||
void setToggleDelay( float value, bool notify = true );
|
void setToggleDelay( float value, bool notify = true );
|
||||||
|
|
||||||
void setPixelsPerDisplayPixelOverrideEnabled(bool value, bool notify = true);
|
void setPixelsPerDisplayPixelOverrideEnabled( bool value,
|
||||||
|
bool notify = true );
|
||||||
void setPixelsPerDisplayPixelOverride( float value, bool notify = true );
|
void setPixelsPerDisplayPixelOverride( float value, bool notify = true );
|
||||||
|
|
||||||
void setThumbDeadzone( float value, bool notify = true );
|
void setThumbDeadzone( float value, bool notify = true );
|
||||||
@@ -138,7 +158,9 @@ namespace advsettings {
|
|||||||
void setPiEyeHeight( float value, bool notify = true );
|
void setPiEyeHeight( float value, bool notify = true );
|
||||||
void setPiUsername( const QString& value, bool notify = true );
|
void setPiUsername( const QString& value, bool notify = true );
|
||||||
void setPiName( const QString& value, bool notify = true );
|
void setPiName( const QString& value, bool notify = true );
|
||||||
void setPiGender(int value, bool notify = true); // 0 .. Unknown, 1 .. Male, 2 .. Female
|
void setPiGender( int value,
|
||||||
|
bool notify
|
||||||
|
= true ); // 0 .. Unknown, 1 .. Male, 2 .. Female
|
||||||
|
|
||||||
void addControllerProfile( QString name );
|
void addControllerProfile( QString name );
|
||||||
void applyControllerProfile( unsigned index );
|
void applyControllerProfile( unsigned index );
|
||||||
|
|||||||
@@ -3,69 +3,88 @@
|
|||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
|
void SettingsTabController::initStage1()
|
||||||
void SettingsTabController::initStage1() {
|
{
|
||||||
m_autoStartEnabled = vr::VRApplications()->GetApplicationAutoLaunch(OverlayController::applicationKey);
|
m_autoStartEnabled = vr::VRApplications()->GetApplicationAutoLaunch(
|
||||||
|
OverlayController::applicationKey );
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "applicationSettings" );
|
settings->beginGroup( "applicationSettings" );
|
||||||
auto value = settings->value( "forceRevivePage", m_forceRevivePage );
|
auto value = settings->value( "forceRevivePage", m_forceRevivePage );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
if (value.isValid() && !value.isNull()) {
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
m_forceRevivePage = value.toBool();
|
m_forceRevivePage = value.toBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
void SettingsTabController::initStage2( OverlayController* var_parent,
|
||||||
|
QQuickWindow* var_widget )
|
||||||
|
{
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsTabController::eventLoopTick() {
|
void SettingsTabController::eventLoopTick()
|
||||||
if (settingsUpdateCounter >= 50) {
|
{
|
||||||
setAutoStartEnabled(vr::VRApplications()->GetApplicationAutoLaunch(OverlayController::applicationKey));
|
if ( settingsUpdateCounter >= 50 )
|
||||||
|
{
|
||||||
|
setAutoStartEnabled( vr::VRApplications()->GetApplicationAutoLaunch(
|
||||||
|
OverlayController::applicationKey ) );
|
||||||
settingsUpdateCounter = 0;
|
settingsUpdateCounter = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
settingsUpdateCounter++;
|
settingsUpdateCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsTabController::autoStartEnabled() const {
|
bool SettingsTabController::autoStartEnabled() const
|
||||||
|
{
|
||||||
return m_autoStartEnabled;
|
return m_autoStartEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsTabController::setAutoStartEnabled(bool value, bool notify) {
|
void SettingsTabController::setAutoStartEnabled( bool value, bool notify )
|
||||||
if (m_autoStartEnabled != value) {
|
{
|
||||||
|
if ( m_autoStartEnabled != value )
|
||||||
|
{
|
||||||
m_autoStartEnabled = value;
|
m_autoStartEnabled = value;
|
||||||
auto apperror = vr::VRApplications()->SetApplicationAutoLaunch(OverlayController::applicationKey, m_autoStartEnabled);
|
auto apperror = vr::VRApplications()->SetApplicationAutoLaunch(
|
||||||
if (apperror != vr::VRApplicationError_None) {
|
OverlayController::applicationKey, m_autoStartEnabled );
|
||||||
LOG(ERROR) << "Could not set auto start: " << vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror);
|
if ( apperror != vr::VRApplicationError_None )
|
||||||
|
{
|
||||||
|
LOG( ERROR ) << "Could not set auto start: "
|
||||||
|
<< vr::VRApplications()
|
||||||
|
->GetApplicationsErrorNameFromEnum( apperror );
|
||||||
}
|
}
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit autoStartEnabledChanged( m_autoStartEnabled );
|
emit autoStartEnabledChanged( m_autoStartEnabled );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsTabController::forceRevivePage() const
|
||||||
bool SettingsTabController::forceRevivePage() const {
|
{
|
||||||
return m_forceRevivePage;
|
return m_forceRevivePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsTabController::setForceRevivePage( bool value, bool notify )
|
||||||
void SettingsTabController::setForceRevivePage(bool value, bool notify) {
|
{
|
||||||
if (m_forceRevivePage != value) {
|
if ( m_forceRevivePage != value )
|
||||||
|
{
|
||||||
m_forceRevivePage = value;
|
m_forceRevivePage = value;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "applicationSettings" );
|
settings->beginGroup( "applicationSettings" );
|
||||||
settings->setValue( "forceRevivePage", m_forceRevivePage );
|
settings->setValue( "forceRevivePage", m_forceRevivePage );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit forceRevivePageChanged( m_forceRevivePage );
|
emit forceRevivePageChanged( m_forceRevivePage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advconfig
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -5,16 +5,18 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
class SettingsTabController : public QObject
|
||||||
class SettingsTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool autoStartEnabled READ autoStartEnabled WRITE setAutoStartEnabled NOTIFY autoStartEnabledChanged)
|
Q_PROPERTY( bool autoStartEnabled READ autoStartEnabled WRITE
|
||||||
Q_PROPERTY(bool forceRevivePage READ forceRevivePage WRITE setForceRevivePage NOTIFY forceRevivePageChanged)
|
setAutoStartEnabled NOTIFY autoStartEnabledChanged )
|
||||||
|
Q_PROPERTY( bool forceRevivePage READ forceRevivePage WRITE
|
||||||
|
setForceRevivePage NOTIFY forceRevivePageChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
|
|||||||
@@ -3,20 +3,27 @@
|
|||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
|
void StatisticsTabController::initStage1() {}
|
||||||
|
|
||||||
void StatisticsTabController::initStage1() {
|
void StatisticsTabController::initStage2( OverlayController* var_parent,
|
||||||
}
|
QQuickWindow* var_widget )
|
||||||
|
{
|
||||||
void StatisticsTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses, float leftSpeed, float rightSpeed) {
|
void StatisticsTabController::eventLoopTick(
|
||||||
|
vr::TrackedDevicePose_t* devicePoses,
|
||||||
|
float leftSpeed,
|
||||||
|
float rightSpeed )
|
||||||
|
{
|
||||||
vr::Compositor_CumulativeStats pStats;
|
vr::Compositor_CumulativeStats pStats;
|
||||||
vr::VRCompositor()->GetCumulativeStats(&pStats, sizeof(vr::Compositor_CumulativeStats));
|
vr::VRCompositor()->GetCumulativeStats(
|
||||||
if (pStats.m_nPid != m_cumStats.m_nPid) {
|
&pStats, sizeof( vr::Compositor_CumulativeStats ) );
|
||||||
|
if ( pStats.m_nPid != m_cumStats.m_nPid )
|
||||||
|
{
|
||||||
m_cumStats = pStats;
|
m_cumStats = pStats;
|
||||||
m_droppedFramesOffset = 0;
|
m_droppedFramesOffset = 0;
|
||||||
m_reprojectedFramesOffset = 0;
|
m_reprojectedFramesOffset = 0;
|
||||||
@@ -29,29 +36,44 @@ void StatisticsTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses
|
|||||||
auto& m = devicePoses->mDeviceToAbsoluteTracking.m;
|
auto& m = devicePoses->mDeviceToAbsoluteTracking.m;
|
||||||
|
|
||||||
// Hmd Distance //
|
// Hmd Distance //
|
||||||
if (lastPosTimer == 0) {
|
if ( lastPosTimer == 0 )
|
||||||
if (devicePoses[0].bPoseIsValid && devicePoses[0].eTrackingResult == vr::TrackingResult_Running_OK) {
|
{
|
||||||
if (!lastHmdPosValid) {
|
if ( devicePoses[0].bPoseIsValid
|
||||||
|
&& devicePoses[0].eTrackingResult
|
||||||
|
== vr::TrackingResult_Running_OK )
|
||||||
|
{
|
||||||
|
if ( !lastHmdPosValid )
|
||||||
|
{
|
||||||
lastHmdPosValid = true;
|
lastHmdPosValid = true;
|
||||||
} else {
|
}
|
||||||
auto delta = std::sqrt(std::pow(m[0][3] - lastHmdPos[0], 2) /*+ std::pow(m[1][3] - lastHmdPos[1], 2)*/ + std::pow(m[2][3] - lastHmdPos[2], 2));
|
else
|
||||||
if (delta >= 0.01f) {
|
{
|
||||||
|
auto delta = std::sqrt(
|
||||||
|
std::pow( m[0][3] - lastHmdPos[0],
|
||||||
|
2 ) /*+ std::pow(m[1][3] - lastHmdPos[1], 2)*/
|
||||||
|
+ std::pow( m[2][3] - lastHmdPos[2], 2 ) );
|
||||||
|
if ( delta >= 0.01f )
|
||||||
|
{
|
||||||
m_hmdDistanceMoved += delta;
|
m_hmdDistanceMoved += delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastHmdPos[0] = m[0][3];
|
lastHmdPos[0] = m[0][3];
|
||||||
lastHmdPos[1] = m[1][3];
|
lastHmdPos[1] = m[1][3];
|
||||||
lastHmdPos[2] = m[2][3];
|
lastHmdPos[2] = m[2][3];
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
lastHmdPosValid = false;
|
lastHmdPosValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controller speeds //
|
// Controller speeds //
|
||||||
if (leftSpeed > m_leftControllerMaxSpeed) {
|
if ( leftSpeed > m_leftControllerMaxSpeed )
|
||||||
|
{
|
||||||
m_leftControllerMaxSpeed = leftSpeed;
|
m_leftControllerMaxSpeed = leftSpeed;
|
||||||
}
|
}
|
||||||
if (rightSpeed > m_rightControllerMaxSpeed) {
|
if ( rightSpeed > m_rightControllerMaxSpeed )
|
||||||
|
{
|
||||||
m_rightControllerMaxSpeed = rightSpeed;
|
m_rightControllerMaxSpeed = rightSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,165 +92,230 @@ void StatisticsTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses
|
|||||||
double yawRaw = 0.0;
|
double yawRaw = 0.0;
|
||||||
double yaw = 0.0;
|
double yaw = 0.0;
|
||||||
bool rotationChanged = false;
|
bool rotationChanged = false;
|
||||||
if (devicePoses[0].bPoseIsValid && devicePoses[0].eTrackingResult == vr::TrackingResult_Running_OK) {
|
if ( devicePoses[0].bPoseIsValid
|
||||||
|
&& devicePoses[0].eTrackingResult == vr::TrackingResult_Running_OK )
|
||||||
|
{
|
||||||
yawRaw = std::atan2( m[0][2], m[2][2] );
|
yawRaw = std::atan2( m[0][2], m[2][2] );
|
||||||
if (yawRaw < 0.0f) {
|
if ( yawRaw < 0.0f )
|
||||||
|
{
|
||||||
yawRaw += 2 * M_PI; // map to [0, 2*pi], CCW
|
yawRaw += 2 * M_PI; // map to [0, 2*pi], CCW
|
||||||
}
|
}
|
||||||
yaw = yawRaw - rotationOffset;
|
yaw = yawRaw - rotationOffset;
|
||||||
if (yaw < 0.0) {
|
if ( yaw < 0.0 )
|
||||||
|
{
|
||||||
yaw = 2 * M_PI + yaw;
|
yaw = 2 * M_PI + yaw;
|
||||||
}
|
}
|
||||||
if (rotationResetFlag) {
|
if ( rotationResetFlag )
|
||||||
|
{
|
||||||
rotationDir = 0;
|
rotationDir = 0;
|
||||||
rotationCounter = 0;
|
rotationCounter = 0;
|
||||||
rotationOffset = yawRaw;
|
rotationOffset = yawRaw;
|
||||||
rotationResetFlag = false;
|
rotationResetFlag = false;
|
||||||
lastYaw = -1.0f;
|
lastYaw = -1.0f;
|
||||||
rotationChanged = true;
|
rotationChanged = true;
|
||||||
} else if (lastYaw < 0.0f && yaw > 0.0) {
|
}
|
||||||
|
else if ( lastYaw < 0.0f && yaw > 0.0 )
|
||||||
|
{
|
||||||
lastYaw = yaw;
|
lastYaw = yaw;
|
||||||
rotationChanged = true;
|
rotationChanged = true;
|
||||||
if (yaw <= M_PI) {
|
if ( yaw <= M_PI )
|
||||||
|
{
|
||||||
rotationDir = 1;
|
rotationDir = 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
rotationDir = -1;
|
rotationDir = -1;
|
||||||
}
|
}
|
||||||
} else if (std::abs(lastYaw - yaw) >= 0.01 && yaw > 0.0) {
|
}
|
||||||
|
else if ( std::abs( lastYaw - yaw ) >= 0.01 && yaw > 0.0 )
|
||||||
|
{
|
||||||
auto diff = yaw - lastYaw;
|
auto diff = yaw - lastYaw;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
if (std::abs(diff) > M_PI) {
|
if ( std::abs( diff ) > M_PI )
|
||||||
if (diff < -M_PI) { // CCW overflow
|
{
|
||||||
|
if ( diff < -M_PI )
|
||||||
|
{ // CCW overflow
|
||||||
mode = 1;
|
mode = 1;
|
||||||
} else if (diff > M_PI) { // CW overflow
|
|
||||||
mode = -1;
|
|
||||||
}
|
}
|
||||||
} else {
|
else if ( diff > M_PI )
|
||||||
if (lastYaw < 0.0 && yaw > 0.0) {
|
{ // CW overflow
|
||||||
mode = 1;
|
|
||||||
} else if (lastYaw > 0.0 && yaw < 0.0) {
|
|
||||||
mode = -1;
|
mode = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode > 0) {
|
else
|
||||||
if (rotationCounter == 0 && rotationDir <= 0) {
|
{
|
||||||
|
if ( lastYaw < 0.0 && yaw > 0.0 )
|
||||||
|
{
|
||||||
|
mode = 1;
|
||||||
|
}
|
||||||
|
else if ( lastYaw > 0.0 && yaw < 0.0 )
|
||||||
|
{
|
||||||
|
mode = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( mode > 0 )
|
||||||
|
{
|
||||||
|
if ( rotationCounter == 0 && rotationDir <= 0 )
|
||||||
|
{
|
||||||
rotationDir = 1;
|
rotationDir = 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
rotationCounter++;
|
rotationCounter++;
|
||||||
}
|
}
|
||||||
} else if (mode < 0) {
|
}
|
||||||
if (rotationCounter == 0 && rotationDir >= 0) {
|
else if ( mode < 0 )
|
||||||
|
{
|
||||||
|
if ( rotationCounter == 0 && rotationDir >= 0 )
|
||||||
|
{
|
||||||
rotationDir = -1;
|
rotationDir = -1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
rotationCounter--;
|
rotationCounter--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastYaw = yaw;
|
lastYaw = yaw;
|
||||||
rotationChanged = true;
|
rotationChanged = true;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
lastYaw = -1;
|
lastYaw = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotationChanged) {
|
if ( rotationChanged )
|
||||||
|
{
|
||||||
m_hmdRotation = ( float ) rotationCounter;
|
m_hmdRotation = ( float ) rotationCounter;
|
||||||
if (rotationDir > 0) {
|
if ( rotationDir > 0 )
|
||||||
|
{
|
||||||
m_hmdRotation += yaw / ( 2 * M_PI );
|
m_hmdRotation += yaw / ( 2 * M_PI );
|
||||||
} else if (rotationDir < 0) {
|
}
|
||||||
|
else if ( rotationDir < 0 )
|
||||||
|
{
|
||||||
m_hmdRotation += -1.0f + yaw / ( 2 * M_PI );
|
m_hmdRotation += -1.0f + yaw / ( 2 * M_PI );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lastPosTimer == 0) {
|
if ( lastPosTimer == 0 )
|
||||||
|
{
|
||||||
lastPosTimer = 10;
|
lastPosTimer = 10;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
lastPosTimer--;
|
lastPosTimer--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float StatisticsTabController::hmdDistanceMoved() const {
|
float StatisticsTabController::hmdDistanceMoved() const
|
||||||
|
{
|
||||||
return m_hmdDistanceMoved;
|
return m_hmdDistanceMoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
float StatisticsTabController::hmdRotations() const {
|
float StatisticsTabController::hmdRotations() const
|
||||||
|
{
|
||||||
return m_hmdRotation;
|
return m_hmdRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
float StatisticsTabController::rightControllerMaxSpeed() const {
|
float StatisticsTabController::rightControllerMaxSpeed() const
|
||||||
|
{
|
||||||
return m_rightControllerMaxSpeed;
|
return m_rightControllerMaxSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
float StatisticsTabController::leftControllerMaxSpeed() const {
|
float StatisticsTabController::leftControllerMaxSpeed() const
|
||||||
|
{
|
||||||
return m_leftControllerMaxSpeed;
|
return m_leftControllerMaxSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned StatisticsTabController::presentedFrames() const {
|
unsigned StatisticsTabController::presentedFrames() const
|
||||||
|
{
|
||||||
return m_cumStats.m_nNumFramePresents - m_presentedFramesOffset;
|
return m_cumStats.m_nNumFramePresents - m_presentedFramesOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned StatisticsTabController::droppedFrames() const {
|
unsigned StatisticsTabController::droppedFrames() const
|
||||||
|
{
|
||||||
return m_cumStats.m_nNumDroppedFrames - m_droppedFramesOffset;
|
return m_cumStats.m_nNumDroppedFrames - m_droppedFramesOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned StatisticsTabController::reprojectedFrames() const {
|
unsigned StatisticsTabController::reprojectedFrames() const
|
||||||
|
{
|
||||||
return m_cumStats.m_nNumReprojectedFrames - m_reprojectedFramesOffset;
|
return m_cumStats.m_nNumReprojectedFrames - m_reprojectedFramesOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned StatisticsTabController::timedOut() const {
|
unsigned StatisticsTabController::timedOut() const
|
||||||
|
{
|
||||||
return m_cumStats.m_nNumTimedOut - m_timedOutOffset;
|
return m_cumStats.m_nNumTimedOut - m_timedOutOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
float StatisticsTabController::totalReprojectedRatio() const {
|
float StatisticsTabController::totalReprojectedRatio() const
|
||||||
float totalFrames = (float)(m_cumStats.m_nNumFramePresents - m_totalRatioPresentedOffset);
|
{
|
||||||
float reprojectedFrames = (float)(m_cumStats.m_nNumReprojectedFrames - m_totalRatioReprojectedOffset);
|
float totalFrames = ( float ) ( m_cumStats.m_nNumFramePresents
|
||||||
if (totalFrames != 0.0f) {
|
- m_totalRatioPresentedOffset );
|
||||||
|
float reprojectedFrames = ( float ) ( m_cumStats.m_nNumReprojectedFrames
|
||||||
|
- m_totalRatioReprojectedOffset );
|
||||||
|
if ( totalFrames != 0.0f )
|
||||||
|
{
|
||||||
return reprojectedFrames / totalFrames;
|
return reprojectedFrames / totalFrames;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::statsDistanceResetClicked() {
|
void StatisticsTabController::statsDistanceResetClicked()
|
||||||
|
{
|
||||||
lastHmdPosValid = false;
|
lastHmdPosValid = false;
|
||||||
if (m_hmdDistanceMoved != 0.0) {
|
if ( m_hmdDistanceMoved != 0.0 )
|
||||||
|
{
|
||||||
m_hmdDistanceMoved = 0.0;
|
m_hmdDistanceMoved = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::statsRotationResetClicked() {
|
void StatisticsTabController::statsRotationResetClicked()
|
||||||
|
{
|
||||||
rotationResetFlag = true;
|
rotationResetFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::statsLeftControllerSpeedResetClicked() {
|
void StatisticsTabController::statsLeftControllerSpeedResetClicked()
|
||||||
if (m_leftControllerMaxSpeed != 0.0) {
|
{
|
||||||
|
if ( m_leftControllerMaxSpeed != 0.0 )
|
||||||
|
{
|
||||||
m_leftControllerMaxSpeed = 0.0;
|
m_leftControllerMaxSpeed = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::statsRightControllerSpeedResetClicked() {
|
void StatisticsTabController::statsRightControllerSpeedResetClicked()
|
||||||
if (m_rightControllerMaxSpeed != 0.0) {
|
{
|
||||||
|
if ( m_rightControllerMaxSpeed != 0.0 )
|
||||||
|
{
|
||||||
m_rightControllerMaxSpeed = 0.0;
|
m_rightControllerMaxSpeed = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::presentedFramesResetClicked() {
|
void StatisticsTabController::presentedFramesResetClicked()
|
||||||
|
{
|
||||||
m_presentedFramesOffset = m_cumStats.m_nNumFramePresents;
|
m_presentedFramesOffset = m_cumStats.m_nNumFramePresents;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::droppedFramesResetClicked() {
|
void StatisticsTabController::droppedFramesResetClicked()
|
||||||
|
{
|
||||||
m_droppedFramesOffset = m_cumStats.m_nNumDroppedFrames;
|
m_droppedFramesOffset = m_cumStats.m_nNumDroppedFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::reprojectedFramesResetClicked() {
|
void StatisticsTabController::reprojectedFramesResetClicked()
|
||||||
|
{
|
||||||
m_reprojectedFramesOffset = m_cumStats.m_nNumReprojectedFrames;
|
m_reprojectedFramesOffset = m_cumStats.m_nNumReprojectedFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::timedOutResetClicked() {
|
void StatisticsTabController::timedOutResetClicked()
|
||||||
|
{
|
||||||
m_timedOutOffset = m_cumStats.m_nNumTimedOut;
|
m_timedOutOffset = m_cumStats.m_nNumTimedOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsTabController::totalRatioResetClicked() {
|
void StatisticsTabController::totalRatioResetClicked()
|
||||||
|
{
|
||||||
m_totalRatioPresentedOffset = m_cumStats.m_nNumFramePresents;
|
m_totalRatioPresentedOffset = m_cumStats.m_nNumFramePresents;
|
||||||
m_totalRatioReprojectedOffset = m_cumStats.m_nNumReprojectedFrames;
|
m_totalRatioReprojectedOffset = m_cumStats.m_nNumReprojectedFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advconfig
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
class StatisticsTabController : public QObject
|
||||||
class StatisticsTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( float hmdDistanceMoved READ hmdDistanceMoved )
|
Q_PROPERTY( float hmdDistanceMoved READ hmdDistanceMoved )
|
||||||
Q_PROPERTY( float hmdRotations READ hmdRotations )
|
Q_PROPERTY( float hmdRotations READ hmdRotations )
|
||||||
@@ -55,7 +55,9 @@ public:
|
|||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
void initStage2( OverlayController* parent, QQuickWindow* widget );
|
||||||
|
|
||||||
void eventLoopTick(vr::TrackedDevicePose_t* devicePoses, float leftSpeed, float rightSpeed);
|
void eventLoopTick( vr::TrackedDevicePose_t* devicePoses,
|
||||||
|
float leftSpeed,
|
||||||
|
float rightSpeed );
|
||||||
|
|
||||||
float hmdDistanceMoved() const;
|
float hmdDistanceMoved() const;
|
||||||
float hmdRotations() const;
|
float hmdRotations() const;
|
||||||
@@ -80,5 +82,4 @@ public slots:
|
|||||||
void totalRatioResetClicked();
|
void totalRatioResetClicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace advsettings
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -2,346 +2,546 @@
|
|||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
|
||||||
namespace vr {
|
namespace vr
|
||||||
|
{
|
||||||
// this was removed from openvr_api.h in 1.0.8
|
// this was removed from openvr_api.h in 1.0.8
|
||||||
static const char* const k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier";
|
static const char* const k_pch_SteamVR_RenderTargetMultiplier_Float
|
||||||
}
|
= "renderTargetMultiplier";
|
||||||
|
} // namespace vr
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// openvr's github repo hasn't been updated yet to reflect changes in beta 1477423729.
|
// openvr's github repo hasn't been updated yet to reflect changes in beta
|
||||||
//static const char* vrsettings_steamvr_allowAsyncReprojection = "allowAsyncReprojection";
|
// 1477423729.
|
||||||
//static const char* vrsettings_steamvr_allowInterleavedReprojection = "allowInterleavedReprojection";
|
// static const char* vrsettings_steamvr_allowAsyncReprojection =
|
||||||
|
// "allowAsyncReprojection"; static const char*
|
||||||
|
// vrsettings_steamvr_allowInterleavedReprojection =
|
||||||
|
// "allowInterleavedReprojection";
|
||||||
|
|
||||||
static const char* vrsettings_steamvr_supersampleScale = "supersampleScale";
|
static const char* vrsettings_steamvr_supersampleScale = "supersampleScale";
|
||||||
static const char* vrsettings_steamvr_allowSupersampleFiltering = "allowSupersampleFiltering";
|
static const char* vrsettings_steamvr_allowSupersampleFiltering
|
||||||
|
= "allowSupersampleFiltering";
|
||||||
static const char* vrsettings_compositor_category = "compositor";
|
static const char* vrsettings_compositor_category = "compositor";
|
||||||
|
|
||||||
void SteamVRTabController::initStage1() {
|
void SteamVRTabController::initStage1()
|
||||||
|
{
|
||||||
eventLoopTick();
|
eventLoopTick();
|
||||||
reloadSteamVRProfiles();
|
reloadSteamVRProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::initStage2( OverlayController* var_parent,
|
||||||
void SteamVRTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
QQuickWindow* var_widget )
|
||||||
|
{
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::reloadSteamVRProfiles()
|
||||||
void SteamVRTabController::reloadSteamVRProfiles() {
|
{
|
||||||
steamvrProfiles.clear();
|
steamvrProfiles.clear();
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "steamVRSettings" );
|
settings->beginGroup( "steamVRSettings" );
|
||||||
auto profileCount = settings->beginReadArray( "steamVRProfiles" );
|
auto profileCount = settings->beginReadArray( "steamVRProfiles" );
|
||||||
for (int i = 0; i < profileCount; i++) {
|
for ( int i = 0; i < profileCount; i++ )
|
||||||
|
{
|
||||||
settings->setArrayIndex( i );
|
settings->setArrayIndex( i );
|
||||||
steamvrProfiles.emplace_back();
|
steamvrProfiles.emplace_back();
|
||||||
auto& entry = steamvrProfiles[i];
|
auto& entry = steamvrProfiles[i];
|
||||||
entry.profileName = settings->value("profileName").toString().toStdString();
|
entry.profileName
|
||||||
entry.includesSupersampling = settings->value("includesSupersampling", false).toBool();
|
= settings->value( "profileName" ).toString().toStdString();
|
||||||
if (entry.includesSupersampling) {
|
entry.includesSupersampling
|
||||||
entry.supersampling = settings->value("supersampling", 1.0f).toFloat();
|
= settings->value( "includesSupersampling", false ).toBool();
|
||||||
|
if ( entry.includesSupersampling )
|
||||||
|
{
|
||||||
|
entry.supersampling
|
||||||
|
= settings->value( "supersampling", 1.0f ).toFloat();
|
||||||
}
|
}
|
||||||
entry.includesSupersampleFiltering = settings->value("includesSupersampleFiltering", false).toBool();
|
entry.includesSupersampleFiltering
|
||||||
if (entry.includesSupersampleFiltering) {
|
= settings->value( "includesSupersampleFiltering", false ).toBool();
|
||||||
entry.supersampleFiltering = settings->value("supersampleFiltering", true).toBool();
|
if ( entry.includesSupersampleFiltering )
|
||||||
|
{
|
||||||
|
entry.supersampleFiltering
|
||||||
|
= settings->value( "supersampleFiltering", true ).toBool();
|
||||||
}
|
}
|
||||||
entry.includesReprojectionSettings = settings->value("includesReprojectionSettings", false).toBool();
|
entry.includesReprojectionSettings
|
||||||
if (entry.includesReprojectionSettings) {
|
= settings->value( "includesReprojectionSettings", false ).toBool();
|
||||||
entry.asynchronousReprojection = settings->value("asynchronousReprojection", true).toBool();
|
if ( entry.includesReprojectionSettings )
|
||||||
entry.interleavedReprojection = settings->value("interleavedReprojection", true).toBool();
|
{
|
||||||
entry.alwaysOnReprojection = settings->value("alwaysOnReprojection", true).toBool();
|
entry.asynchronousReprojection
|
||||||
|
= settings->value( "asynchronousReprojection", true ).toBool();
|
||||||
|
entry.interleavedReprojection
|
||||||
|
= settings->value( "interleavedReprojection", true ).toBool();
|
||||||
|
entry.alwaysOnReprojection
|
||||||
|
= settings->value( "alwaysOnReprojection", true ).toBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::saveSteamVRProfiles()
|
||||||
void SteamVRTabController::saveSteamVRProfiles() {
|
{
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "steamVRSettings" );
|
settings->beginGroup( "steamVRSettings" );
|
||||||
settings->beginWriteArray( "steamVRProfiles" );
|
settings->beginWriteArray( "steamVRProfiles" );
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (auto& p : steamvrProfiles) {
|
for ( auto& p : steamvrProfiles )
|
||||||
|
{
|
||||||
settings->setArrayIndex( i );
|
settings->setArrayIndex( i );
|
||||||
settings->setValue("profileName", QString::fromStdString(p.profileName));
|
settings->setValue( "profileName",
|
||||||
|
QString::fromStdString( p.profileName ) );
|
||||||
settings->setValue( "includesSupersampling", p.includesSupersampling );
|
settings->setValue( "includesSupersampling", p.includesSupersampling );
|
||||||
if (p.includesSupersampling) {
|
if ( p.includesSupersampling )
|
||||||
|
{
|
||||||
settings->setValue( "supersampling", p.supersampling );
|
settings->setValue( "supersampling", p.supersampling );
|
||||||
}
|
}
|
||||||
settings->setValue("includesSupersampleFiltering", p.includesSupersampleFiltering);
|
settings->setValue( "includesSupersampleFiltering",
|
||||||
if (p.includesSupersampleFiltering) {
|
p.includesSupersampleFiltering );
|
||||||
settings->setValue("supersampleFiltering", p.supersampleFiltering);
|
if ( p.includesSupersampleFiltering )
|
||||||
|
{
|
||||||
|
settings->setValue( "supersampleFiltering",
|
||||||
|
p.supersampleFiltering );
|
||||||
}
|
}
|
||||||
settings->setValue("includesReprojectionSettings", p.includesReprojectionSettings);
|
settings->setValue( "includesReprojectionSettings",
|
||||||
if (p.includesReprojectionSettings) {
|
p.includesReprojectionSettings );
|
||||||
settings->setValue("asynchronousReprojection", p.asynchronousReprojection);
|
if ( p.includesReprojectionSettings )
|
||||||
settings->setValue("interleavedReprojection", p.interleavedReprojection);
|
{
|
||||||
settings->setValue("alwaysOnReprojection", p.alwaysOnReprojection);
|
settings->setValue( "asynchronousReprojection",
|
||||||
|
p.asynchronousReprojection );
|
||||||
|
settings->setValue( "interleavedReprojection",
|
||||||
|
p.interleavedReprojection );
|
||||||
|
settings->setValue( "alwaysOnReprojection",
|
||||||
|
p.alwaysOnReprojection );
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE unsigned SteamVRTabController::getSteamVRProfileCount()
|
||||||
Q_INVOKABLE unsigned SteamVRTabController::getSteamVRProfileCount() {
|
{
|
||||||
return ( unsigned ) steamvrProfiles.size();
|
return ( unsigned ) steamvrProfiles.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString SteamVRTabController::getSteamVRProfileName(unsigned index) {
|
Q_INVOKABLE QString
|
||||||
if (index >= steamvrProfiles.size()) {
|
SteamVRTabController::getSteamVRProfileName( unsigned index )
|
||||||
|
{
|
||||||
|
if ( index >= steamvrProfiles.size() )
|
||||||
|
{
|
||||||
return QString();
|
return QString();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return QString::fromStdString( steamvrProfiles[index].profileName );
|
return QString::fromStdString( steamvrProfiles[index].profileName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::eventLoopTick()
|
||||||
void SteamVRTabController::eventLoopTick() {
|
{
|
||||||
if (settingsUpdateCounter >= 50) {
|
if ( settingsUpdateCounter >= 50 )
|
||||||
|
{
|
||||||
vr::EVRSettingsError vrSettingsError;
|
vr::EVRSettingsError vrSettingsError;
|
||||||
auto ss = vr::VRSettings()->GetFloat(vr::k_pch_SteamVR_Section, vrsettings_steamvr_supersampleScale, &vrSettingsError);
|
auto ss
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
= vr::VRSettings()->GetFloat( vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not read \"" << vrsettings_steamvr_supersampleScale << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vrsettings_steamvr_supersampleScale,
|
||||||
if (m_superSampling != 1.0) {
|
&vrSettingsError );
|
||||||
LOG(DEBUG) << "OpenVR returns an error and we have a custom supersampling value: " << m_superSampling;
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not read \""
|
||||||
|
<< vrsettings_steamvr_supersampleScale
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
|
if ( m_superSampling != 1.0 )
|
||||||
|
{
|
||||||
|
LOG( DEBUG ) << "OpenVR returns an error and we have a custom "
|
||||||
|
"supersampling value: "
|
||||||
|
<< m_superSampling;
|
||||||
setSuperSampling( 1.0 );
|
setSuperSampling( 1.0 );
|
||||||
}
|
}
|
||||||
} else if (m_superSampling != ss) {
|
}
|
||||||
LOG(DEBUG) << "OpenVR reports a changed supersampling value: " << m_superSampling << " => " << ss;
|
else if ( m_superSampling != ss )
|
||||||
|
{
|
||||||
|
LOG( DEBUG ) << "OpenVR reports a changed supersampling value: "
|
||||||
|
<< m_superSampling << " => " << ss;
|
||||||
setSuperSampling( ss );
|
setSuperSampling( ss );
|
||||||
}
|
}
|
||||||
auto css = vr::VRSettings()->GetFloat(vrsettings_compositor_category, vr::k_pch_SteamVR_RenderTargetMultiplier_Float, &vrSettingsError);
|
auto css = vr::VRSettings()->GetFloat(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vrsettings_compositor_category,
|
||||||
if (vrSettingsError != vr::VRSettingsError_UnsetSettingHasNoDefault) { // does not appear in the default settings file as of beta 1477423729
|
vr::k_pch_SteamVR_RenderTargetMultiplier_Float,
|
||||||
LOG(WARNING) << "Could not read \"compositor::" << vr::k_pch_SteamVR_RenderTargetMultiplier_Float << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
if ( vrSettingsError
|
||||||
|
!= vr::VRSettingsError_UnsetSettingHasNoDefault )
|
||||||
|
{ // does not appear in the default settings file as of beta
|
||||||
|
// 1477423729
|
||||||
|
LOG( WARNING )
|
||||||
|
<< "Could not read \"compositor::"
|
||||||
|
<< vr::k_pch_SteamVR_RenderTargetMultiplier_Float
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
if (m_compositorSuperSampling != 1.0) {
|
if ( m_compositorSuperSampling != 1.0 )
|
||||||
LOG(DEBUG) << "OpenVR returns an error and we have a custom compositor supersampling value: " << m_compositorSuperSampling;
|
{
|
||||||
|
LOG( DEBUG ) << "OpenVR returns an error and we have a custom "
|
||||||
|
"compositor supersampling value: "
|
||||||
|
<< m_compositorSuperSampling;
|
||||||
setCompositorSuperSampling( 1.0 );
|
setCompositorSuperSampling( 1.0 );
|
||||||
}
|
}
|
||||||
} else if (m_compositorSuperSampling != css) {
|
}
|
||||||
LOG(DEBUG) << "OpenVR reports a changed compositor supersampling value: " << m_compositorSuperSampling << " => " << css;
|
else if ( m_compositorSuperSampling != css )
|
||||||
|
{
|
||||||
|
LOG( DEBUG )
|
||||||
|
<< "OpenVR reports a changed compositor supersampling value: "
|
||||||
|
<< m_compositorSuperSampling << " => " << css;
|
||||||
setCompositorSuperSampling( css );
|
setCompositorSuperSampling( css );
|
||||||
}
|
}
|
||||||
auto air = vr::VRSettings()->GetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowReprojection_Bool, &vrSettingsError);
|
auto air = vr::VRSettings()->GetBool(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not read \"" << vr::k_pch_SteamVR_AllowReprojection_Bool << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_AllowReprojection_Bool,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not read \""
|
||||||
|
<< vr::k_pch_SteamVR_AllowReprojection_Bool
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
setAllowInterleavedReprojection( air );
|
setAllowInterleavedReprojection( air );
|
||||||
auto aar = vr::VRSettings()->GetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowAsyncReprojection_Bool, &vrSettingsError);
|
auto aar = vr::VRSettings()->GetBool(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not read \"" << vr::k_pch_SteamVR_AllowAsyncReprojection_Bool << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_AllowAsyncReprojection_Bool,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not read \""
|
||||||
|
<< vr::k_pch_SteamVR_AllowAsyncReprojection_Bool
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
setAllowAsyncReprojection( aar );
|
setAllowAsyncReprojection( aar );
|
||||||
auto fr = vr::VRSettings()->GetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_ForceReprojection_Bool, &vrSettingsError);
|
auto fr = vr::VRSettings()->GetBool(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not read \"" << vr::k_pch_SteamVR_ForceReprojection_Bool << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_ForceReprojection_Bool,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not read \""
|
||||||
|
<< vr::k_pch_SteamVR_ForceReprojection_Bool
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
setForceReprojection( fr );
|
setForceReprojection( fr );
|
||||||
auto sf = vr::VRSettings()->GetBool(vr::k_pch_SteamVR_Section, vrsettings_steamvr_allowSupersampleFiltering, &vrSettingsError);
|
auto sf = vr::VRSettings()->GetBool(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not read \"" << vrsettings_steamvr_allowSupersampleFiltering << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vrsettings_steamvr_allowSupersampleFiltering,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not read \""
|
||||||
|
<< vrsettings_steamvr_allowSupersampleFiltering
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
setAllowSupersampleFiltering( sf );
|
setAllowSupersampleFiltering( sf );
|
||||||
settingsUpdateCounter = 0;
|
settingsUpdateCounter = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
settingsUpdateCounter++;
|
settingsUpdateCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::setSuperSampling( float value, bool notify )
|
||||||
void SteamVRTabController::setSuperSampling(float value, bool notify) {
|
{
|
||||||
bool override = false;
|
bool override = false;
|
||||||
if (value <= 0.01f) {
|
if ( value <= 0.01f )
|
||||||
LOG(WARNING) << "Encountered a supersampling value <= 0.01, setting supersampling to 1.0";
|
{
|
||||||
|
LOG( WARNING ) << "Encountered a supersampling value <= 0.01, setting "
|
||||||
|
"supersampling to 1.0";
|
||||||
value = 1.0f;
|
value = 1.0f;
|
||||||
override = true;
|
override = true;
|
||||||
}
|
}
|
||||||
if (override || m_superSampling != value) {
|
if ( override || m_superSampling != value )
|
||||||
LOG(DEBUG) << "Supersampling value changed: " << m_superSampling << " => " << value;
|
{
|
||||||
|
LOG( DEBUG ) << "Supersampling value changed: " << m_superSampling
|
||||||
|
<< " => " << value;
|
||||||
m_superSampling = value;
|
m_superSampling = value;
|
||||||
vr::VRSettings()->SetFloat(vr::k_pch_SteamVR_Section, vrsettings_steamvr_supersampleScale, m_superSampling);
|
vr::VRSettings()->SetFloat( vr::k_pch_SteamVR_Section,
|
||||||
|
vrsettings_steamvr_supersampleScale,
|
||||||
|
m_superSampling );
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit superSamplingChanged( m_superSampling );
|
emit superSamplingChanged( m_superSampling );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::setCompositorSuperSampling( float value,
|
||||||
void SteamVRTabController::setCompositorSuperSampling(float value, bool notify) {
|
bool notify )
|
||||||
|
{
|
||||||
bool override = false;
|
bool override = false;
|
||||||
if (value <= 0.01f) {
|
if ( value <= 0.01f )
|
||||||
LOG(WARNING) << "Encountered a compositor supersampling value <= 0.01, setting supersampling to 1.0";
|
{
|
||||||
|
LOG( WARNING ) << "Encountered a compositor supersampling value <= "
|
||||||
|
"0.01, setting supersampling to 1.0";
|
||||||
value = 1.0f;
|
value = 1.0f;
|
||||||
override = true;
|
override = true;
|
||||||
}
|
}
|
||||||
if (override || m_compositorSuperSampling != value) {
|
if ( override || m_compositorSuperSampling != value )
|
||||||
LOG(DEBUG) << "Compositor supersampling value changed: " << m_compositorSuperSampling << " => " << value;
|
{
|
||||||
|
LOG( DEBUG ) << "Compositor supersampling value changed: "
|
||||||
|
<< m_compositorSuperSampling << " => " << value;
|
||||||
m_compositorSuperSampling = value;
|
m_compositorSuperSampling = value;
|
||||||
vr::VRSettings()->SetFloat(vrsettings_compositor_category, vr::k_pch_SteamVR_RenderTargetMultiplier_Float, m_compositorSuperSampling);
|
vr::VRSettings()->SetFloat(
|
||||||
|
vrsettings_compositor_category,
|
||||||
|
vr::k_pch_SteamVR_RenderTargetMultiplier_Float,
|
||||||
|
m_compositorSuperSampling );
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit compositorSuperSamplingChanged( m_compositorSuperSampling );
|
emit compositorSuperSamplingChanged( m_compositorSuperSampling );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SteamVRTabController::superSampling() const
|
||||||
float SteamVRTabController::superSampling() const {
|
{
|
||||||
return m_superSampling;
|
return m_superSampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SteamVRTabController::compositorSuperSampling() const
|
||||||
float SteamVRTabController::compositorSuperSampling() const {
|
{
|
||||||
return m_compositorSuperSampling;
|
return m_compositorSuperSampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SteamVRTabController::allowInterleavedReprojection() const
|
||||||
bool SteamVRTabController::allowInterleavedReprojection() const {
|
{
|
||||||
return m_allowInterleavedReprojection;
|
return m_allowInterleavedReprojection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SteamVRTabController::allowAsyncReprojection() const
|
||||||
bool SteamVRTabController::allowAsyncReprojection() const {
|
{
|
||||||
return m_allowAsyncReprojection;
|
return m_allowAsyncReprojection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::setAllowInterleavedReprojection( bool value,
|
||||||
void SteamVRTabController::setAllowInterleavedReprojection(bool value, bool notify) {
|
bool notify )
|
||||||
if (m_allowInterleavedReprojection != value) {
|
{
|
||||||
|
if ( m_allowInterleavedReprojection != value )
|
||||||
|
{
|
||||||
m_allowInterleavedReprojection = value;
|
m_allowInterleavedReprojection = value;
|
||||||
vr::VRSettings()->SetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowReprojection_Bool, m_allowInterleavedReprojection);
|
vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section,
|
||||||
|
vr::k_pch_SteamVR_AllowReprojection_Bool,
|
||||||
|
m_allowInterleavedReprojection );
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
emit allowInterleavedReprojectionChanged(m_allowInterleavedReprojection);
|
{
|
||||||
|
emit allowInterleavedReprojectionChanged(
|
||||||
|
m_allowInterleavedReprojection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::setAllowAsyncReprojection( bool value, bool notify )
|
||||||
void SteamVRTabController::setAllowAsyncReprojection(bool value, bool notify) {
|
{
|
||||||
if (m_allowAsyncReprojection != value) {
|
if ( m_allowAsyncReprojection != value )
|
||||||
|
{
|
||||||
m_allowAsyncReprojection = value;
|
m_allowAsyncReprojection = value;
|
||||||
vr::VRSettings()->SetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowAsyncReprojection_Bool, m_allowAsyncReprojection);
|
vr::VRSettings()->SetBool(
|
||||||
|
vr::k_pch_SteamVR_Section,
|
||||||
|
vr::k_pch_SteamVR_AllowAsyncReprojection_Bool,
|
||||||
|
m_allowAsyncReprojection );
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit allowAsyncReprojectionChanged( m_allowAsyncReprojection );
|
emit allowAsyncReprojectionChanged( m_allowAsyncReprojection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SteamVRTabController::forceReprojection() const {
|
bool SteamVRTabController::forceReprojection() const
|
||||||
|
{
|
||||||
return m_forceReprojection;
|
return m_forceReprojection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::setForceReprojection( bool value, bool notify )
|
||||||
void SteamVRTabController::setForceReprojection(bool value, bool notify) {
|
{
|
||||||
if (m_forceReprojection != value) {
|
if ( m_forceReprojection != value )
|
||||||
|
{
|
||||||
m_forceReprojection = value;
|
m_forceReprojection = value;
|
||||||
vr::VRSettings()->SetBool(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_ForceReprojection_Bool, m_forceReprojection);
|
vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section,
|
||||||
|
vr::k_pch_SteamVR_ForceReprojection_Bool,
|
||||||
|
m_forceReprojection );
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit forceReprojectionChanged( m_forceReprojection );
|
emit forceReprojectionChanged( m_forceReprojection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SteamVRTabController::allowSupersampleFiltering() const
|
||||||
bool SteamVRTabController::allowSupersampleFiltering() const {
|
{
|
||||||
return m_allowSupersampleFiltering;
|
return m_allowSupersampleFiltering;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::setAllowSupersampleFiltering( bool value,
|
||||||
void SteamVRTabController::setAllowSupersampleFiltering(bool value, bool notify) {
|
bool notify )
|
||||||
if (m_allowSupersampleFiltering != value) {
|
{
|
||||||
|
if ( m_allowSupersampleFiltering != value )
|
||||||
|
{
|
||||||
m_allowSupersampleFiltering = value;
|
m_allowSupersampleFiltering = value;
|
||||||
vr::VRSettings()->SetBool(vr::k_pch_SteamVR_Section, vrsettings_steamvr_allowSupersampleFiltering, m_allowSupersampleFiltering);
|
vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section,
|
||||||
|
vrsettings_steamvr_allowSupersampleFiltering,
|
||||||
|
m_allowSupersampleFiltering );
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
emit allowSupersampleFilteringChanged(m_allowSupersampleFiltering);
|
{
|
||||||
|
emit allowSupersampleFilteringChanged(
|
||||||
|
m_allowSupersampleFiltering );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::reset()
|
||||||
void SteamVRTabController::reset() {
|
{
|
||||||
vr::EVRSettingsError vrSettingsError;
|
vr::EVRSettingsError vrSettingsError;
|
||||||
|
|
||||||
vr::VRSettings()->RemoveKeyInSection(vr::k_pch_SteamVR_Section, vrsettings_steamvr_supersampleScale, &vrSettingsError);
|
vr::VRSettings()->RemoveKeyInSection( vr::k_pch_SteamVR_Section,
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vrsettings_steamvr_supersampleScale,
|
||||||
LOG(WARNING) << "Could not remove \"" << vrsettings_steamvr_supersampleScale << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not remove \""
|
||||||
|
<< vrsettings_steamvr_supersampleScale << "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
|
|
||||||
setCompositorSuperSampling( 1.0f ); // Is not in default.vrsettings yet
|
setCompositorSuperSampling( 1.0f ); // Is not in default.vrsettings yet
|
||||||
vr::VRSettings()->RemoveKeyInSection(vrsettings_compositor_category, vr::k_pch_SteamVR_RenderTargetMultiplier_Float, &vrSettingsError);
|
vr::VRSettings()->RemoveKeyInSection(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vrsettings_compositor_category,
|
||||||
LOG(WARNING) << "Could not remove \"" << vrsettings_compositor_category << "::" << vr::k_pch_SteamVR_RenderTargetMultiplier_Float << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_RenderTargetMultiplier_Float,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not remove \""
|
||||||
|
<< vrsettings_compositor_category
|
||||||
|
<< "::" << vr::k_pch_SteamVR_RenderTargetMultiplier_Float
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VRSettings()->RemoveKeyInSection(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowReprojection_Bool, &vrSettingsError);
|
vr::VRSettings()->RemoveKeyInSection(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not remove \"" << vr::k_pch_SteamVR_AllowReprojection_Bool << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_AllowReprojection_Bool,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not remove \""
|
||||||
|
<< vr::k_pch_SteamVR_AllowReprojection_Bool
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VRSettings()->RemoveKeyInSection(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowAsyncReprojection_Bool, &vrSettingsError);
|
vr::VRSettings()->RemoveKeyInSection(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not remove \"" << vr::k_pch_SteamVR_AllowAsyncReprojection_Bool << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_AllowAsyncReprojection_Bool,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not remove \""
|
||||||
|
<< vr::k_pch_SteamVR_AllowAsyncReprojection_Bool
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VRSettings()->RemoveKeyInSection(vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_ForceReprojection_Bool, &vrSettingsError);
|
vr::VRSettings()->RemoveKeyInSection(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not remove \"" << vr::k_pch_SteamVR_ForceReprojection_Bool << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vr::k_pch_SteamVR_ForceReprojection_Bool,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not remove \""
|
||||||
|
<< vr::k_pch_SteamVR_ForceReprojection_Bool
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VRSettings()->RemoveKeyInSection(vr::k_pch_SteamVR_Section, vrsettings_steamvr_allowSupersampleFiltering, &vrSettingsError);
|
vr::VRSettings()->RemoveKeyInSection(
|
||||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
vr::k_pch_SteamVR_Section,
|
||||||
LOG(WARNING) << "Could not remove \"" << vrsettings_steamvr_allowSupersampleFiltering << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
vrsettings_steamvr_allowSupersampleFiltering,
|
||||||
|
&vrSettingsError );
|
||||||
|
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||||
|
{
|
||||||
|
LOG( WARNING ) << "Could not remove \""
|
||||||
|
<< vrsettings_steamvr_allowSupersampleFiltering
|
||||||
|
<< "\" setting: "
|
||||||
|
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||||
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VRSettings()->Sync();
|
vr::VRSettings()->Sync();
|
||||||
settingsUpdateCounter = 999; // Easiest way to get default values
|
settingsUpdateCounter = 999; // Easiest way to get default values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::restartSteamVR()
|
||||||
void SteamVRTabController::restartSteamVR() {
|
{
|
||||||
QString cmd = QString("cmd.exe /C restartvrserver.bat \"") + parent->getVRRuntimePathUrl().toLocalFile() + QString("\"");
|
QString cmd = QString( "cmd.exe /C restartvrserver.bat \"" )
|
||||||
|
+ parent->getVRRuntimePathUrl().toLocalFile()
|
||||||
|
+ QString( "\"" );
|
||||||
LOG( INFO ) << "SteamVR Restart Command: " << cmd;
|
LOG( INFO ) << "SteamVR Restart Command: " << cmd;
|
||||||
QProcess::startDetached( cmd );
|
QProcess::startDetached( cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::addSteamVRProfile( QString name,
|
||||||
void SteamVRTabController::addSteamVRProfile(QString name, bool includeSupersampling, bool includeSupersampleFiltering, bool includeReprojectionSettings) {
|
bool includeSupersampling,
|
||||||
|
bool includeSupersampleFiltering,
|
||||||
|
bool includeReprojectionSettings )
|
||||||
|
{
|
||||||
SteamVRProfile* profile = nullptr;
|
SteamVRProfile* profile = nullptr;
|
||||||
for (auto& p : steamvrProfiles) {
|
for ( auto& p : steamvrProfiles )
|
||||||
if (p.profileName.compare(name.toStdString()) == 0) {
|
{
|
||||||
|
if ( p.profileName.compare( name.toStdString() ) == 0 )
|
||||||
|
{
|
||||||
profile = &p;
|
profile = &p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!profile) {
|
if ( !profile )
|
||||||
|
{
|
||||||
auto i = steamvrProfiles.size();
|
auto i = steamvrProfiles.size();
|
||||||
steamvrProfiles.emplace_back();
|
steamvrProfiles.emplace_back();
|
||||||
profile = &steamvrProfiles[i];
|
profile = &steamvrProfiles[i];
|
||||||
}
|
}
|
||||||
profile->profileName = name.toStdString();
|
profile->profileName = name.toStdString();
|
||||||
profile->includesSupersampling = includeSupersampling;
|
profile->includesSupersampling = includeSupersampling;
|
||||||
if (includeSupersampling) {
|
if ( includeSupersampling )
|
||||||
|
{
|
||||||
profile->supersampling = m_superSampling;
|
profile->supersampling = m_superSampling;
|
||||||
}
|
}
|
||||||
profile->includesSupersampleFiltering = includeSupersampleFiltering;
|
profile->includesSupersampleFiltering = includeSupersampleFiltering;
|
||||||
if (includeSupersampleFiltering) {
|
if ( includeSupersampleFiltering )
|
||||||
|
{
|
||||||
profile->supersampleFiltering = m_allowSupersampleFiltering;
|
profile->supersampleFiltering = m_allowSupersampleFiltering;
|
||||||
}
|
}
|
||||||
profile->includesReprojectionSettings = includeReprojectionSettings;
|
profile->includesReprojectionSettings = includeReprojectionSettings;
|
||||||
if (includeReprojectionSettings) {
|
if ( includeReprojectionSettings )
|
||||||
|
{
|
||||||
profile->asynchronousReprojection = m_allowAsyncReprojection;
|
profile->asynchronousReprojection = m_allowAsyncReprojection;
|
||||||
profile->interleavedReprojection = m_allowInterleavedReprojection;
|
profile->interleavedReprojection = m_allowInterleavedReprojection;
|
||||||
profile->alwaysOnReprojection = m_forceReprojection;
|
profile->alwaysOnReprojection = m_forceReprojection;
|
||||||
@@ -351,17 +551,21 @@ void SteamVRTabController::addSteamVRProfile(QString name, bool includeSupersamp
|
|||||||
emit steamVRProfilesUpdated();
|
emit steamVRProfilesUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::applySteamVRProfile( unsigned index )
|
||||||
void SteamVRTabController::applySteamVRProfile(unsigned index) {
|
{
|
||||||
if (index < steamvrProfiles.size()) {
|
if ( index < steamvrProfiles.size() )
|
||||||
|
{
|
||||||
auto& profile = steamvrProfiles[index];
|
auto& profile = steamvrProfiles[index];
|
||||||
if (profile.includesSupersampling) {
|
if ( profile.includesSupersampling )
|
||||||
|
{
|
||||||
setSuperSampling( profile.supersampling );
|
setSuperSampling( profile.supersampling );
|
||||||
}
|
}
|
||||||
if (profile.includesSupersampleFiltering) {
|
if ( profile.includesSupersampleFiltering )
|
||||||
|
{
|
||||||
setAllowSupersampleFiltering( profile.supersampleFiltering );
|
setAllowSupersampleFiltering( profile.supersampleFiltering );
|
||||||
}
|
}
|
||||||
if (profile.includesReprojectionSettings) {
|
if ( profile.includesReprojectionSettings )
|
||||||
|
{
|
||||||
setAllowAsyncReprojection( profile.asynchronousReprojection );
|
setAllowAsyncReprojection( profile.asynchronousReprojection );
|
||||||
setAllowInterleavedReprojection( profile.interleavedReprojection );
|
setAllowInterleavedReprojection( profile.interleavedReprojection );
|
||||||
setForceReprojection( profile.alwaysOnReprojection );
|
setForceReprojection( profile.alwaysOnReprojection );
|
||||||
@@ -370,9 +574,10 @@ void SteamVRTabController::applySteamVRProfile(unsigned index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SteamVRTabController::deleteSteamVRProfile( unsigned index )
|
||||||
void SteamVRTabController::deleteSteamVRProfile(unsigned index) {
|
{
|
||||||
if (index < steamvrProfiles.size()) {
|
if ( index < steamvrProfiles.size() )
|
||||||
|
{
|
||||||
auto pos = steamvrProfiles.begin() + index;
|
auto pos = steamvrProfiles.begin() + index;
|
||||||
steamvrProfiles.erase( pos );
|
steamvrProfiles.erase( pos );
|
||||||
saveSteamVRProfiles();
|
saveSteamVRProfiles();
|
||||||
@@ -381,7 +586,4 @@ void SteamVRTabController::deleteSteamVRProfile(unsigned index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace advsettings
|
||||||
|
|
||||||
} // namespace advconfig
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,15 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
struct SteamVRProfile
|
||||||
struct SteamVRProfile {
|
{
|
||||||
std::string profileName;
|
std::string profileName;
|
||||||
|
|
||||||
bool includesSupersampling = false;
|
bool includesSupersampling = false;
|
||||||
@@ -28,15 +26,26 @@ struct SteamVRProfile {
|
|||||||
bool alwaysOnReprojection = true;
|
bool alwaysOnReprojection = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SteamVRTabController : public QObject
|
||||||
class SteamVRTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float superSampling READ superSampling WRITE setSuperSampling NOTIFY superSamplingChanged)
|
Q_PROPERTY( float superSampling READ superSampling WRITE setSuperSampling
|
||||||
Q_PROPERTY(float compositorSuperSampling READ compositorSuperSampling WRITE setCompositorSuperSampling NOTIFY compositorSuperSamplingChanged)
|
NOTIFY superSamplingChanged )
|
||||||
Q_PROPERTY(bool allowInterleavedReprojection READ allowInterleavedReprojection WRITE setAllowInterleavedReprojection NOTIFY allowInterleavedReprojectionChanged)
|
Q_PROPERTY(
|
||||||
Q_PROPERTY(bool allowAsyncReprojection READ allowAsyncReprojection WRITE setAllowAsyncReprojection NOTIFY allowAsyncReprojectionChanged)
|
float compositorSuperSampling READ compositorSuperSampling WRITE
|
||||||
Q_PROPERTY(bool forceReprojection READ forceReprojection WRITE setForceReprojection NOTIFY forceReprojectionChanged)
|
setCompositorSuperSampling NOTIFY compositorSuperSamplingChanged )
|
||||||
Q_PROPERTY(bool allowSupersampleFiltering READ allowSupersampleFiltering WRITE setAllowSupersampleFiltering NOTIFY allowSupersampleFilteringChanged)
|
Q_PROPERTY(
|
||||||
|
bool allowInterleavedReprojection READ allowInterleavedReprojection
|
||||||
|
WRITE setAllowInterleavedReprojection NOTIFY
|
||||||
|
allowInterleavedReprojectionChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
bool allowAsyncReprojection READ allowAsyncReprojection WRITE
|
||||||
|
setAllowAsyncReprojection NOTIFY allowAsyncReprojectionChanged )
|
||||||
|
Q_PROPERTY( bool forceReprojection READ forceReprojection WRITE
|
||||||
|
setForceReprojection NOTIFY forceReprojectionChanged )
|
||||||
|
Q_PROPERTY( bool allowSupersampleFiltering READ allowSupersampleFiltering
|
||||||
|
WRITE setAllowSupersampleFiltering NOTIFY
|
||||||
|
allowSupersampleFilteringChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -80,7 +89,10 @@ public slots:
|
|||||||
void setForceReprojection( bool value, bool notify = true );
|
void setForceReprojection( bool value, bool notify = true );
|
||||||
void setAllowSupersampleFiltering( bool value, bool notify = true );
|
void setAllowSupersampleFiltering( bool value, bool notify = true );
|
||||||
|
|
||||||
void addSteamVRProfile(QString name, bool includeSupersampling, bool includeSupersampleFiltering, bool includeReprojectionSettings);
|
void addSteamVRProfile( QString name,
|
||||||
|
bool includeSupersampling,
|
||||||
|
bool includeSupersampleFiltering,
|
||||||
|
bool includeReprojectionSettings );
|
||||||
void applySteamVRProfile( unsigned index );
|
void applySteamVRProfile( unsigned index );
|
||||||
void deleteSteamVRProfile( unsigned index );
|
void deleteSteamVRProfile( unsigned index );
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
const char* steamDesktopOverlaykey = "valve.steam.desktop";
|
const char* steamDesktopOverlaykey = "valve.steam.desktop";
|
||||||
|
|
||||||
void UtilitiesTabController::initStage1() {
|
void UtilitiesTabController::initStage1()
|
||||||
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
keyboardInput.reset( new KeyboardInputWindows() );
|
keyboardInput.reset( new KeyboardInputWindows() );
|
||||||
#else
|
#else
|
||||||
@@ -31,63 +32,86 @@ namespace advsettings {
|
|||||||
m_alarmIsModal = qAlarmIsModal.toBool();
|
m_alarmIsModal = qAlarmIsModal.toBool();
|
||||||
m_alarmTime = QTime( qAlarmHour.toInt(), qAlarmMinute.toInt() );
|
m_alarmTime = QTime( qAlarmHour.toInt(), qAlarmMinute.toInt() );
|
||||||
vr::VROverlayHandle_t pOverlayHandle;
|
vr::VROverlayHandle_t pOverlayHandle;
|
||||||
auto error = vr::VROverlay()->FindOverlay(steamDesktopOverlaykey, &pOverlayHandle);
|
auto error = vr::VROverlay()->FindOverlay( steamDesktopOverlaykey,
|
||||||
if (error != vr::VROverlayError_None) {
|
&pOverlayHandle );
|
||||||
|
if ( error != vr::VROverlayError_None )
|
||||||
|
{
|
||||||
m_steamDesktopOverlayAvailable = false;
|
m_steamDesktopOverlayAvailable = false;
|
||||||
LOG(INFO) << "Could not find overlay \"" << steamDesktopOverlaykey << "\": " << vr::VROverlay()->GetOverlayErrorNameFromEnum(error);
|
LOG( INFO ) << "Could not find overlay \"" << steamDesktopOverlaykey
|
||||||
} else {
|
<< "\": "
|
||||||
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum( error );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_steamDesktopOverlayAvailable = true;
|
m_steamDesktopOverlayAvailable = true;
|
||||||
float width;
|
float width;
|
||||||
error = vr::VROverlay()->GetOverlayWidthInMeters(pOverlayHandle, &width);
|
error = vr::VROverlay()->GetOverlayWidthInMeters( pOverlayHandle,
|
||||||
if (error != vr::VROverlayError_None) {
|
&width );
|
||||||
LOG(ERROR) << "Could not read overlay width of \"" << steamDesktopOverlaykey << "\": " << vr::VROverlay()->GetOverlayErrorNameFromEnum(error);
|
if ( error != vr::VROverlayError_None )
|
||||||
} else {
|
{
|
||||||
|
LOG( ERROR ) << "Could not read overlay width of \""
|
||||||
|
<< steamDesktopOverlaykey << "\": "
|
||||||
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
|
error );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_steamDesktopOverlayWidth = width;
|
m_steamDesktopOverlayWidth = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::initStage2(OverlayController * var_parent, QQuickWindow * var_widget) {
|
void UtilitiesTabController::initStage2( OverlayController* var_parent,
|
||||||
|
QQuickWindow* var_widget )
|
||||||
|
{
|
||||||
this->parent = var_parent;
|
this->parent = var_parent;
|
||||||
this->widget = var_widget;
|
this->widget = var_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardInput(QString input) {
|
void UtilitiesTabController::sendKeyboardInput( QString input )
|
||||||
|
{
|
||||||
keyboardInput->sendKeyboardInput( input );
|
keyboardInput->sendKeyboardInput( input );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardEnter() {
|
void UtilitiesTabController::sendKeyboardEnter()
|
||||||
|
{
|
||||||
keyboardInput->sendKeyboardEnter();
|
keyboardInput->sendKeyboardEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardAltTab() {
|
void UtilitiesTabController::sendKeyboardAltTab()
|
||||||
|
{
|
||||||
keyboardInput->sendKeyboardAltTab();
|
keyboardInput->sendKeyboardAltTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardBackspace(int count) {
|
void UtilitiesTabController::sendKeyboardBackspace( int count )
|
||||||
|
{
|
||||||
keyboardInput->sendKeyboardBackspace( count );
|
keyboardInput->sendKeyboardBackspace( count );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UtilitiesTabController::alarmEnabled() const
|
||||||
bool UtilitiesTabController::alarmEnabled() const {
|
{
|
||||||
return m_alarmEnabled;
|
return m_alarmEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UtilitiesTabController::alarmIsModal() const {
|
bool UtilitiesTabController::alarmIsModal() const
|
||||||
|
{
|
||||||
return m_alarmIsModal;
|
return m_alarmIsModal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UtilitiesTabController::alarmTimeHour() const {
|
int UtilitiesTabController::alarmTimeHour() const
|
||||||
|
{
|
||||||
return m_alarmTime.hour();
|
return m_alarmTime.hour();
|
||||||
}
|
}
|
||||||
|
|
||||||
int UtilitiesTabController::alarmTimeMinute() const {
|
int UtilitiesTabController::alarmTimeMinute() const
|
||||||
|
{
|
||||||
return m_alarmTime.minute();
|
return m_alarmTime.minute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setAlarmEnabled(bool enabled, bool notify) {
|
void UtilitiesTabController::setAlarmEnabled( bool enabled, bool notify )
|
||||||
if (m_alarmEnabled != enabled) {
|
{
|
||||||
|
if ( m_alarmEnabled != enabled )
|
||||||
|
{
|
||||||
m_alarmEnabled = enabled;
|
m_alarmEnabled = enabled;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "utilitiesSettings" );
|
settings->beginGroup( "utilitiesSettings" );
|
||||||
@@ -95,31 +119,40 @@ namespace advsettings {
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
m_alarmLastCheckTime = QTime();
|
m_alarmLastCheckTime = QTime();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit alarmEnabledChanged( m_alarmEnabled );
|
emit alarmEnabledChanged( m_alarmEnabled );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setAlarmIsModal(bool modal, bool notify) {
|
void UtilitiesTabController::setAlarmIsModal( bool modal, bool notify )
|
||||||
if (m_alarmIsModal != modal) {
|
{
|
||||||
|
if ( m_alarmIsModal != modal )
|
||||||
|
{
|
||||||
m_alarmIsModal = modal;
|
m_alarmIsModal = modal;
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "utilitiesSettings" );
|
settings->beginGroup( "utilitiesSettings" );
|
||||||
settings->setValue( "alarmIsModal", m_alarmIsModal );
|
settings->setValue( "alarmIsModal", m_alarmIsModal );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit alarmIsModalChanged( m_alarmIsModal );
|
emit alarmIsModalChanged( m_alarmIsModal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setAlarmTimeHour(int hour, bool notify) {
|
void UtilitiesTabController::setAlarmTimeHour( int hour, bool notify )
|
||||||
if (m_alarmTime.hour() != hour) {
|
{
|
||||||
if (m_alarmTime.isValid()) {
|
if ( m_alarmTime.hour() != hour )
|
||||||
|
{
|
||||||
|
if ( m_alarmTime.isValid() )
|
||||||
|
{
|
||||||
m_alarmTime = QTime( hour, m_alarmTime.minute() );
|
m_alarmTime = QTime( hour, m_alarmTime.minute() );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_alarmTime = QTime( hour, 0 );
|
m_alarmTime = QTime( hour, 0 );
|
||||||
}
|
}
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
@@ -129,17 +162,23 @@ namespace advsettings {
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
m_alarmLastCheckTime = QTime();
|
m_alarmLastCheckTime = QTime();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit alarmTimeHourChanged( hour );
|
emit alarmTimeHourChanged( hour );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setAlarmTimeMinute(int min, bool notify) {
|
void UtilitiesTabController::setAlarmTimeMinute( int min, bool notify )
|
||||||
if (m_alarmTime.minute() != min) {
|
{
|
||||||
if (m_alarmTime.isValid()) {
|
if ( m_alarmTime.minute() != min )
|
||||||
|
{
|
||||||
|
if ( m_alarmTime.isValid() )
|
||||||
|
{
|
||||||
m_alarmTime = QTime( m_alarmTime.hour(), min );
|
m_alarmTime = QTime( m_alarmTime.hour(), min );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_alarmTime = QTime( 0, min );
|
m_alarmTime = QTime( 0, min );
|
||||||
}
|
}
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
@@ -149,19 +188,22 @@ namespace advsettings {
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
m_alarmLastCheckTime = QTime();
|
m_alarmLastCheckTime = QTime();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit alarmTimeMinuteChanged( min );
|
emit alarmTimeMinuteChanged( min );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setAlarmTimeToCurrentTime() {
|
void UtilitiesTabController::setAlarmTimeToCurrentTime()
|
||||||
|
{
|
||||||
auto now = QTime::currentTime();
|
auto now = QTime::currentTime();
|
||||||
setAlarmTimeHour( now.hour() );
|
setAlarmTimeHour( now.hour() );
|
||||||
setAlarmTimeMinute( now.minute() );
|
setAlarmTimeMinute( now.minute() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::modAlarmTimeHour(int value, bool notify) {
|
void UtilitiesTabController::modAlarmTimeHour( int value, bool notify )
|
||||||
|
{
|
||||||
auto h = m_alarmTime.hour();
|
auto h = m_alarmTime.hour();
|
||||||
m_alarmTime = m_alarmTime.addSecs( value * 60 * 60 );
|
m_alarmTime = m_alarmTime.addSecs( value * 60 * 60 );
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
@@ -170,15 +212,18 @@ namespace advsettings {
|
|||||||
settings->setValue( "alarmMinute", m_alarmTime.minute() );
|
settings->setValue( "alarmMinute", m_alarmTime.minute() );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (h != m_alarmTime.hour()) {
|
if ( h != m_alarmTime.hour() )
|
||||||
|
{
|
||||||
m_alarmLastCheckTime = QTime();
|
m_alarmLastCheckTime = QTime();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit alarmTimeHourChanged( m_alarmTime.hour() );
|
emit alarmTimeHourChanged( m_alarmTime.hour() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::modAlarmTimeMinute(int value, bool notify) {
|
void UtilitiesTabController::modAlarmTimeMinute( int value, bool notify )
|
||||||
|
{
|
||||||
auto h = m_alarmTime.hour();
|
auto h = m_alarmTime.hour();
|
||||||
auto m = m_alarmTime.minute();
|
auto m = m_alarmTime.minute();
|
||||||
m_alarmTime = m_alarmTime.addSecs( value * 60 );
|
m_alarmTime = m_alarmTime.addSecs( value * 60 );
|
||||||
@@ -188,131 +233,224 @@ namespace advsettings {
|
|||||||
settings->setValue( "alarmMinute", m_alarmTime.minute() );
|
settings->setValue( "alarmMinute", m_alarmTime.minute() );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
if (m != m_alarmTime.minute() || h != m_alarmTime.hour()) {
|
if ( m != m_alarmTime.minute() || h != m_alarmTime.hour() )
|
||||||
|
{
|
||||||
m_alarmLastCheckTime = QTime();
|
m_alarmLastCheckTime = QTime();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
if (h != m_alarmTime.hour()) {
|
{
|
||||||
|
if ( h != m_alarmTime.hour() )
|
||||||
|
{
|
||||||
emit alarmTimeHourChanged( m_alarmTime.hour() );
|
emit alarmTimeHourChanged( m_alarmTime.hour() );
|
||||||
}
|
}
|
||||||
if (m != m_alarmTime.minute()) {
|
if ( m != m_alarmTime.minute() )
|
||||||
|
{
|
||||||
emit alarmTimeMinuteChanged( m_alarmTime.minute() );
|
emit alarmTimeMinuteChanged( m_alarmTime.minute() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vr::VROverlayHandle_t createBatteryOverlay(vr::TrackedDeviceIndex_t index) {
|
vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index )
|
||||||
|
{
|
||||||
vr::VROverlayHandle_t handle = vr::k_ulOverlayHandleInvalid;
|
vr::VROverlayHandle_t handle = vr::k_ulOverlayHandleInvalid;
|
||||||
std::string batteryKey = std::string(OverlayController::applicationKey) + ".battery." + std::to_string(index);
|
std::string batteryKey = std::string( OverlayController::applicationKey )
|
||||||
vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay(batteryKey.c_str(), batteryKey.c_str(), &handle);
|
+ ".battery." + std::to_string( index );
|
||||||
if (overlayError == vr::VROverlayError_None) {
|
vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay(
|
||||||
std::string batteryIconPath = QApplication::applicationDirPath().toStdString() + "/res/battery_0.png";
|
batteryKey.c_str(), batteryKey.c_str(), &handle );
|
||||||
if (QFile::exists(QString::fromStdString(batteryIconPath))) {
|
if ( overlayError == vr::VROverlayError_None )
|
||||||
vr::VROverlay()->SetOverlayFromFile(handle, batteryIconPath.c_str());
|
{
|
||||||
|
std::string batteryIconPath
|
||||||
|
= QApplication::applicationDirPath().toStdString()
|
||||||
|
+ "/res/battery_0.png";
|
||||||
|
if ( QFile::exists( QString::fromStdString( batteryIconPath ) ) )
|
||||||
|
{
|
||||||
|
vr::VROverlay()->SetOverlayFromFile( handle,
|
||||||
|
batteryIconPath.c_str() );
|
||||||
vr::VROverlay()->SetOverlayWidthInMeters( handle, 0.05f );
|
vr::VROverlay()->SetOverlayWidthInMeters( handle, 0.05f );
|
||||||
vr::HmdMatrix34_t notificationTransform = {{
|
vr::HmdMatrix34_t notificationTransform
|
||||||
{1.0f, 0.0f, 0.0f, 0.00f},
|
= { { { 1.0f, 0.0f, 0.0f, 0.00f },
|
||||||
{ 0.0f, -1.0f, 0.0f, 0.01f },
|
{ 0.0f, -1.0f, 0.0f, 0.01f },
|
||||||
{0.0f, 0.0f, -1.0f, -0.013f}
|
{ 0.0f, 0.0f, -1.0f, -0.013f } } };
|
||||||
}};
|
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(handle, index, ¬ificationTransform);
|
handle, index, ¬ificationTransform );
|
||||||
LOG( INFO ) << "Created battery overlay for device " << index;
|
LOG( INFO ) << "Created battery overlay for device " << index;
|
||||||
} else {
|
|
||||||
LOG(ERROR) << "Could not find battery icon \"" << batteryIconPath << "\"";
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
LOG(ERROR) << "Could not create ptt notification overlay: " << vr::VROverlay()->GetOverlayErrorNameFromEnum(overlayError);
|
{
|
||||||
|
LOG( ERROR ) << "Could not find battery icon \"" << batteryIconPath
|
||||||
|
<< "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG( ERROR ) << "Could not create ptt notification overlay: "
|
||||||
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
|
overlayError );
|
||||||
}
|
}
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UtilitiesTabController::eventLoopTick()
|
||||||
void UtilitiesTabController::eventLoopTick() {
|
{
|
||||||
if (settingsUpdateCounter >= 10) {
|
if ( settingsUpdateCounter >= 10 )
|
||||||
|
{
|
||||||
vr::VROverlayHandle_t pOverlayHandle;
|
vr::VROverlayHandle_t pOverlayHandle;
|
||||||
auto error = vr::VROverlay()->FindOverlay(steamDesktopOverlaykey, &pOverlayHandle);
|
auto error = vr::VROverlay()->FindOverlay( steamDesktopOverlaykey,
|
||||||
if (error == vr::VROverlayError_None) {
|
&pOverlayHandle );
|
||||||
if (!m_steamDesktopOverlayAvailable) {
|
if ( error == vr::VROverlayError_None )
|
||||||
|
{
|
||||||
|
if ( !m_steamDesktopOverlayAvailable )
|
||||||
|
{
|
||||||
m_steamDesktopOverlayAvailable = true;
|
m_steamDesktopOverlayAvailable = true;
|
||||||
emit steamDesktopOverlayAvailableChanged(m_steamDesktopOverlayAvailable);
|
emit steamDesktopOverlayAvailableChanged(
|
||||||
|
m_steamDesktopOverlayAvailable );
|
||||||
}
|
}
|
||||||
float width;
|
float width;
|
||||||
error = vr::VROverlay()->GetOverlayWidthInMeters(pOverlayHandle, &width);
|
error = vr::VROverlay()->GetOverlayWidthInMeters( pOverlayHandle,
|
||||||
if (error != vr::VROverlayError_None) {
|
&width );
|
||||||
LOG(ERROR) << "Could not read overlay width of \"" << steamDesktopOverlaykey << "\": " << vr::VROverlay()->GetOverlayErrorNameFromEnum(error);
|
if ( error != vr::VROverlayError_None )
|
||||||
} else {
|
{
|
||||||
|
LOG( ERROR )
|
||||||
|
<< "Could not read overlay width of \""
|
||||||
|
<< steamDesktopOverlaykey << "\": "
|
||||||
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum( error );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
setSteamDesktopOverlayWidth( width, true, false );
|
setSteamDesktopOverlayWidth( width, true, false );
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (m_steamDesktopOverlayAvailable) {
|
else
|
||||||
|
{
|
||||||
|
if ( m_steamDesktopOverlayAvailable )
|
||||||
|
{
|
||||||
m_steamDesktopOverlayAvailable = false;
|
m_steamDesktopOverlayAvailable = false;
|
||||||
emit steamDesktopOverlayAvailableChanged(m_steamDesktopOverlayAvailable);
|
emit steamDesktopOverlayAvailableChanged(
|
||||||
|
m_steamDesktopOverlayAvailable );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_alarmEnabled && m_alarmTime.isValid()) {
|
if ( m_alarmEnabled && m_alarmTime.isValid() )
|
||||||
|
{
|
||||||
auto now = QTime::currentTime();
|
auto now = QTime::currentTime();
|
||||||
if (m_alarmLastCheckTime.isValid() && m_alarmLastCheckTime <= m_alarmTime && m_alarmTime <= now) {
|
if ( m_alarmLastCheckTime.isValid()
|
||||||
|
&& m_alarmLastCheckTime <= m_alarmTime && m_alarmTime <= now )
|
||||||
|
{
|
||||||
setAlarmEnabled( false );
|
setAlarmEnabled( false );
|
||||||
char alarmMessageBuffer[1024];
|
char alarmMessageBuffer[1024];
|
||||||
std::snprintf(alarmMessageBuffer, 1024, "The alarm at %02i:%02i went off.", alarmTimeHour(), alarmTimeMinute());
|
std::snprintf( alarmMessageBuffer,
|
||||||
if (m_alarmIsModal) {
|
1024,
|
||||||
std::thread messageThread([](UtilitiesTabController* parent, std::string message) {
|
"The alarm at %02i:%02i went off.",
|
||||||
auto res = vr::VROverlay()->ShowMessageOverlay(message.c_str(), "Alarm Clock", "Ok", "+15 min");
|
alarmTimeHour(),
|
||||||
if (res == vr::VRMessageOverlayResponse_ButtonPress_1) {
|
alarmTimeMinute() );
|
||||||
|
if ( m_alarmIsModal )
|
||||||
|
{
|
||||||
|
std::thread messageThread(
|
||||||
|
[]( UtilitiesTabController* parent,
|
||||||
|
std::string message ) {
|
||||||
|
auto res = vr::VROverlay()->ShowMessageOverlay(
|
||||||
|
message.c_str(),
|
||||||
|
"Alarm Clock",
|
||||||
|
"Ok",
|
||||||
|
"+15 min" );
|
||||||
|
if ( res
|
||||||
|
== vr::VRMessageOverlayResponse_ButtonPress_1 )
|
||||||
|
{
|
||||||
parent->setAlarmTimeToCurrentTime();
|
parent->setAlarmTimeToCurrentTime();
|
||||||
parent->modAlarmTimeMinute( 15 );
|
parent->modAlarmTimeMinute( 15 );
|
||||||
parent->setAlarmEnabled( true );
|
parent->setAlarmEnabled( true );
|
||||||
} else if (res >= vr::VRMessageOverlayResponse_CouldntFindSystemOverlay) {
|
}
|
||||||
static const char* errorMessages[] = { "CouldntFindSystemOverlay", "CouldntFindOrCreateClientOverlay", "ApplicationQuit" };
|
else if (
|
||||||
int errorCode = res - vr::VRMessageOverlayResponse_CouldntFindSystemOverlay;
|
res
|
||||||
if (res < 3) {
|
>= vr::VRMessageOverlayResponse_CouldntFindSystemOverlay )
|
||||||
LOG(ERROR) << "Could not create Alarm Overlay: " << errorMessages[errorCode];
|
{
|
||||||
} else {
|
static const char* errorMessages[]
|
||||||
LOG(ERROR) << "Could not create Alarm Overlay: Unknown Error";
|
= { "CouldntFindSystemOverlay",
|
||||||
|
"CouldntFindOrCreateClientOverlay",
|
||||||
|
"ApplicationQuit" };
|
||||||
|
int errorCode
|
||||||
|
= res
|
||||||
|
- vr::VRMessageOverlayResponse_CouldntFindSystemOverlay;
|
||||||
|
if ( res < 3 )
|
||||||
|
{
|
||||||
|
LOG( ERROR )
|
||||||
|
<< "Could not create Alarm Overlay: "
|
||||||
|
<< errorMessages[errorCode];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG( ERROR ) << "Could not create Alarm "
|
||||||
|
"Overlay: Unknown Error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, this, std::string(alarmMessageBuffer));
|
},
|
||||||
|
this,
|
||||||
|
std::string( alarmMessageBuffer ) );
|
||||||
messageThread.detach();
|
messageThread.detach();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vr::VRNotificationId notificationId;
|
vr::VRNotificationId notificationId;
|
||||||
vr::EVRInitError eError;
|
vr::EVRInitError eError;
|
||||||
vr::IVRNotifications* vrnotification = (vr::IVRNotifications*)vr::VR_GetGenericInterface(vr::IVRNotifications_Version, &eError);
|
vr::IVRNotifications* vrnotification
|
||||||
if (eError != vr::VRInitError_None) {
|
= ( vr::IVRNotifications* ) vr::VR_GetGenericInterface(
|
||||||
LOG(ERROR) << "Error while getting IVRNotifications interface" << vr::VR_GetVRInitErrorAsEnglishDescription(eError);
|
vr::IVRNotifications_Version, &eError );
|
||||||
|
if ( eError != vr::VRInitError_None )
|
||||||
|
{
|
||||||
|
LOG( ERROR )
|
||||||
|
<< "Error while getting IVRNotifications interface"
|
||||||
|
<< vr::VR_GetVRInitErrorAsEnglishDescription(
|
||||||
|
eError );
|
||||||
vrnotification = nullptr;
|
vrnotification = nullptr;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vr::NotificationBitmap_t* messageIconPtr = nullptr;
|
vr::NotificationBitmap_t* messageIconPtr = nullptr;
|
||||||
/*
|
/*
|
||||||
// Can i even create this object on the stack, who takes ownership?
|
// Can i even create this object on the stack, who takes
|
||||||
vr::NotificationBitmap_t messageIcon;
|
ownership? vr::NotificationBitmap_t messageIcon;
|
||||||
|
|
||||||
// First get image width and height
|
// First get image width and height
|
||||||
vr::VROverlay()->GetOverlayImageData(parent->overlayThumbnailHandle(), nullptr, 0, (uint32_t*)&messageIcon.m_nWidth, (uint32_t*)&messageIcon.m_nHeight);
|
vr::VROverlay()->GetOverlayImageData(parent->overlayThumbnailHandle(),
|
||||||
|
nullptr, 0, (uint32_t*)&messageIcon.m_nWidth,
|
||||||
|
(uint32_t*)&messageIcon.m_nHeight);
|
||||||
|
|
||||||
messageIcon.m_nBytesPerPixel = 4;
|
messageIcon.m_nBytesPerPixel = 4;
|
||||||
unsigned bufferSize = messageIcon.m_nWidth*messageIcon.m_nHeight*messageIcon.m_nBytesPerPixel;
|
unsigned bufferSize =
|
||||||
|
messageIcon.m_nWidth*messageIcon.m_nHeight*messageIcon.m_nBytesPerPixel;
|
||||||
|
|
||||||
// Can I delete this buffer after this section? Who takes ownership?
|
// Can I delete this buffer after this section? Who
|
||||||
std::unique_ptr<char> imageBuffer;
|
takes ownership? std::unique_ptr<char> imageBuffer;
|
||||||
imageBuffer.reset(new char[bufferSize]);
|
imageBuffer.reset(new char[bufferSize]);
|
||||||
messageIcon.m_pImageData = imageBuffer.get();
|
messageIcon.m_pImageData = imageBuffer.get();
|
||||||
|
|
||||||
// Get image data
|
// Get image data
|
||||||
auto iconError = vr::VROverlay()->GetOverlayImageData(parent->overlayThumbnailHandle(), messageIcon.m_pImageData, bufferSize, (uint32_t*)&messageIcon.m_nWidth, (uint32_t*)&messageIcon.m_nHeight);
|
auto iconError =
|
||||||
if (iconError != vr::VROverlayError_None) {
|
vr::VROverlay()->GetOverlayImageData(parent->overlayThumbnailHandle(),
|
||||||
LOG(ERROR) << "Error while getting message overlay icon: " << vr::VROverlay()->GetOverlayErrorNameFromEnum(iconError);
|
messageIcon.m_pImageData, bufferSize,
|
||||||
|
(uint32_t*)&messageIcon.m_nWidth,
|
||||||
|
(uint32_t*)&messageIcon.m_nHeight); if (iconError !=
|
||||||
|
vr::VROverlayError_None) { LOG(ERROR) << "Error while
|
||||||
|
getting message overlay icon: " <<
|
||||||
|
vr::VROverlay()->GetOverlayErrorNameFromEnum(iconError);
|
||||||
} else {
|
} else {
|
||||||
messageIconPtr = &messageIcon;
|
messageIconPtr = &messageIcon;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
auto nError = vrnotification->CreateNotification(
|
auto nError = vrnotification->CreateNotification(
|
||||||
parent->overlayHandle(), 666, vr::EVRNotificationType_Transient, alarmMessageBuffer, vr::EVRNotificationStyle_Application, messageIconPtr, ¬ificationId
|
parent->overlayHandle(),
|
||||||
);
|
666,
|
||||||
if (nError != vr::VRNotificationError_OK) {
|
vr::EVRNotificationType_Transient,
|
||||||
LOG(ERROR) << "Error while creating notification: " << nError;
|
alarmMessageBuffer,
|
||||||
|
vr::EVRNotificationStyle_Application,
|
||||||
|
messageIconPtr,
|
||||||
|
¬ificationId );
|
||||||
|
if ( nError != vr::VRNotificationError_OK )
|
||||||
|
{
|
||||||
|
LOG( ERROR )
|
||||||
|
<< "Error while creating notification: "
|
||||||
|
<< nError;
|
||||||
vrnotification = nullptr;
|
vrnotification = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,12 +459,19 @@ namespace advsettings {
|
|||||||
m_alarmLastCheckTime = now;
|
m_alarmLastCheckTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attach battery overlay to all tracked devices that aren't a
|
||||||
// attach battery overlay to all tracked devices that aren't a controller or hmd
|
// controller or hmd
|
||||||
for(vr::TrackedDeviceIndex_t i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {
|
for ( vr::TrackedDeviceIndex_t i = 0; i < vr::k_unMaxTrackedDeviceCount;
|
||||||
vr::ETrackedDeviceClass deviceClass = vr::VRSystem()->GetTrackedDeviceClass(i);
|
i++ )
|
||||||
if (deviceClass == vr::ETrackedDeviceClass::TrackedDeviceClass_GenericTracker) {
|
{
|
||||||
if (m_batteryOverlayHandles[i] == vr::k_ulOverlayHandleInvalid) {
|
vr::ETrackedDeviceClass deviceClass
|
||||||
|
= vr::VRSystem()->GetTrackedDeviceClass( i );
|
||||||
|
if ( deviceClass
|
||||||
|
== vr::ETrackedDeviceClass::TrackedDeviceClass_GenericTracker )
|
||||||
|
{
|
||||||
|
if ( m_batteryOverlayHandles[i]
|
||||||
|
== vr::k_ulOverlayHandleInvalid )
|
||||||
|
{
|
||||||
LOG( INFO ) << "Creating battery overlay for device " << i;
|
LOG( INFO ) << "Creating battery overlay for device " << i;
|
||||||
m_batteryOverlayHandles[i] = createBatteryOverlay( i );
|
m_batteryOverlayHandles[i] = createBatteryOverlay( i );
|
||||||
m_batteryVisible[i] = true;
|
m_batteryVisible[i] = true;
|
||||||
@@ -334,27 +479,55 @@ namespace advsettings {
|
|||||||
|
|
||||||
bool shouldShow = vr::VROverlay()->IsDashboardVisible();
|
bool shouldShow = vr::VROverlay()->IsDashboardVisible();
|
||||||
|
|
||||||
if (shouldShow != m_batteryVisible[i]) {
|
if ( shouldShow != m_batteryVisible[i] )
|
||||||
if (shouldShow) {
|
{
|
||||||
vr::VROverlay()->ShowOverlay(m_batteryOverlayHandles[i]);
|
if ( shouldShow )
|
||||||
} else {
|
{
|
||||||
vr::VROverlay()->HideOverlay(m_batteryOverlayHandles[i]);
|
vr::VROverlay()->ShowOverlay(
|
||||||
|
m_batteryOverlayHandles[i] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vr::VROverlay()->HideOverlay(
|
||||||
|
m_batteryOverlayHandles[i] );
|
||||||
}
|
}
|
||||||
m_batteryVisible[i] = shouldShow;
|
m_batteryVisible[i] = shouldShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasBatteryStatus = vr::VRSystem()->GetBoolTrackedDeviceProperty(i, vr::ETrackedDeviceProperty::Prop_DeviceProvidesBatteryStatus_Bool);
|
bool hasBatteryStatus
|
||||||
if (hasBatteryStatus) {
|
= vr::VRSystem()->GetBoolTrackedDeviceProperty(
|
||||||
float battery = vr::VRSystem()->GetFloatTrackedDeviceProperty(i, vr::ETrackedDeviceProperty::Prop_DeviceBatteryPercentage_Float);
|
i,
|
||||||
|
vr::ETrackedDeviceProperty::
|
||||||
|
Prop_DeviceProvidesBatteryStatus_Bool );
|
||||||
|
if ( hasBatteryStatus )
|
||||||
|
{
|
||||||
|
float battery
|
||||||
|
= vr::VRSystem()->GetFloatTrackedDeviceProperty(
|
||||||
|
i,
|
||||||
|
vr::ETrackedDeviceProperty::
|
||||||
|
Prop_DeviceBatteryPercentage_Float );
|
||||||
int batteryState = ceil( battery * 5 );
|
int batteryState = ceil( battery * 5 );
|
||||||
|
|
||||||
if (batteryState != m_batteryState[i]) {
|
if ( batteryState != m_batteryState[i] )
|
||||||
LOG(INFO) << "Updating battery overlay for device " << i << " to " << batteryState << "(" << battery << "";
|
{
|
||||||
std::string batteryIconPath = QApplication::applicationDirPath().toStdString() + "/res/battery_" + std::to_string(batteryState) + ".png";
|
LOG( INFO )
|
||||||
if (QFile::exists(QString::fromStdString(batteryIconPath))) {
|
<< "Updating battery overlay for device " << i
|
||||||
vr::VROverlay()->SetOverlayFromFile(m_batteryOverlayHandles[i], batteryIconPath.c_str());
|
<< " to " << batteryState << "(" << battery << "";
|
||||||
} else {
|
std::string batteryIconPath
|
||||||
LOG(ERROR) << "Could not find battery icon \"" << batteryIconPath << "\"";
|
= QApplication::applicationDirPath().toStdString()
|
||||||
|
+ "/res/battery_" + std::to_string( batteryState )
|
||||||
|
+ ".png";
|
||||||
|
if ( QFile::exists(
|
||||||
|
QString::fromStdString( batteryIconPath ) ) )
|
||||||
|
{
|
||||||
|
vr::VROverlay()->SetOverlayFromFile(
|
||||||
|
m_batteryOverlayHandles[i],
|
||||||
|
batteryIconPath.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG( ERROR ) << "Could not find battery icon \""
|
||||||
|
<< batteryIconPath << "\"";
|
||||||
}
|
}
|
||||||
m_batteryState[i] = batteryState;
|
m_batteryState[i] = batteryState;
|
||||||
}
|
}
|
||||||
@@ -363,40 +536,61 @@ namespace advsettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
settingsUpdateCounter = 0;
|
settingsUpdateCounter = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
settingsUpdateCounter++;
|
settingsUpdateCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UtilitiesTabController::steamDesktopOverlayAvailable() const
|
||||||
bool UtilitiesTabController::steamDesktopOverlayAvailable() const {
|
{
|
||||||
return m_steamDesktopOverlayAvailable;
|
return m_steamDesktopOverlayAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
float UtilitiesTabController::steamDesktopOverlayWidth() const {
|
float UtilitiesTabController::steamDesktopOverlayWidth() const
|
||||||
|
{
|
||||||
return m_steamDesktopOverlayWidth;
|
return m_steamDesktopOverlayWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setSteamDesktopOverlayWidth(float width, bool notify, bool notifyOpenVr) {
|
void UtilitiesTabController::setSteamDesktopOverlayWidth( float width,
|
||||||
if (std::abs(m_steamDesktopOverlayWidth - width) > 0.01) {
|
bool notify,
|
||||||
|
bool notifyOpenVr )
|
||||||
|
{
|
||||||
|
if ( std::abs( m_steamDesktopOverlayWidth - width ) > 0.01 )
|
||||||
|
{
|
||||||
m_steamDesktopOverlayWidth = width;
|
m_steamDesktopOverlayWidth = width;
|
||||||
if (notifyOpenVr) {
|
if ( notifyOpenVr )
|
||||||
|
{
|
||||||
vr::VROverlayHandle_t pOverlayHandle;
|
vr::VROverlayHandle_t pOverlayHandle;
|
||||||
auto error = vr::VROverlay()->FindOverlay(steamDesktopOverlaykey, &pOverlayHandle);
|
auto error = vr::VROverlay()->FindOverlay( steamDesktopOverlaykey,
|
||||||
if (error != vr::VROverlayError_None) {
|
&pOverlayHandle );
|
||||||
LOG(ERROR) << "Could not find overlay \"" << steamDesktopOverlaykey << "\": " << vr::VROverlay()->GetOverlayErrorNameFromEnum(error);
|
if ( error != vr::VROverlayError_None )
|
||||||
} else {
|
{
|
||||||
error = vr::VROverlay()->SetOverlayWidthInMeters(pOverlayHandle, m_steamDesktopOverlayWidth);
|
LOG( ERROR )
|
||||||
if (error != vr::VROverlayError_None) {
|
<< "Could not find overlay \"" << steamDesktopOverlaykey
|
||||||
LOG(ERROR) << "Could not modify overlay width of \"" << steamDesktopOverlaykey << "\": " << vr::VROverlay()->GetOverlayErrorNameFromEnum(error);
|
<< "\": "
|
||||||
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum( error );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = vr::VROverlay()->SetOverlayWidthInMeters(
|
||||||
|
pOverlayHandle, m_steamDesktopOverlayWidth );
|
||||||
|
if ( error != vr::VROverlayError_None )
|
||||||
|
{
|
||||||
|
LOG( ERROR )
|
||||||
|
<< "Could not modify overlay width of \""
|
||||||
|
<< steamDesktopOverlaykey << "\": "
|
||||||
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
|
error );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
emit steamDesktopOverlayWidthChanged( m_steamDesktopOverlayWidth );
|
emit steamDesktopOverlayWidthChanged( m_steamDesktopOverlayWidth );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace advsettings
|
||||||
} // namespace advconfig
|
|
||||||
|
|||||||
@@ -9,20 +9,28 @@
|
|||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
|
class UtilitiesTabController : public QObject
|
||||||
class UtilitiesTabController : public QObject {
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled NOTIFY alarmEnabledChanged)
|
Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled NOTIFY
|
||||||
Q_PROPERTY(bool alarmIsModal READ alarmIsModal WRITE setAlarmIsModal NOTIFY alarmIsModalChanged)
|
alarmEnabledChanged )
|
||||||
Q_PROPERTY(int alarmTimeHour READ alarmTimeHour WRITE setAlarmTimeHour NOTIFY alarmTimeHourChanged)
|
Q_PROPERTY( bool alarmIsModal READ alarmIsModal WRITE setAlarmIsModal NOTIFY
|
||||||
Q_PROPERTY(int alarmTimeMinute READ alarmTimeMinute WRITE setAlarmTimeMinute NOTIFY alarmTimeMinuteChanged)
|
alarmIsModalChanged )
|
||||||
Q_PROPERTY(bool steamDesktopOverlayAvailable READ steamDesktopOverlayAvailable NOTIFY steamDesktopOverlayAvailableChanged)
|
Q_PROPERTY( int alarmTimeHour READ alarmTimeHour WRITE setAlarmTimeHour
|
||||||
Q_PROPERTY(float steamDesktopOverlayWidth READ steamDesktopOverlayWidth WRITE setSteamDesktopOverlayWidth NOTIFY steamDesktopOverlayWidthChanged)
|
NOTIFY alarmTimeHourChanged )
|
||||||
|
Q_PROPERTY( int alarmTimeMinute READ alarmTimeMinute WRITE
|
||||||
|
setAlarmTimeMinute NOTIFY alarmTimeMinuteChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
bool steamDesktopOverlayAvailable READ steamDesktopOverlayAvailable
|
||||||
|
NOTIFY steamDesktopOverlayAvailableChanged )
|
||||||
|
Q_PROPERTY(
|
||||||
|
float steamDesktopOverlayWidth READ steamDesktopOverlayWidth WRITE
|
||||||
|
setSteamDesktopOverlayWidth NOTIFY steamDesktopOverlayWidthChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController* parent;
|
OverlayController* parent;
|
||||||
@@ -36,7 +44,8 @@ namespace advsettings {
|
|||||||
QTime m_alarmLastCheckTime;
|
QTime m_alarmLastCheckTime;
|
||||||
bool m_steamDesktopOverlayAvailable = false;
|
bool m_steamDesktopOverlayAvailable = false;
|
||||||
float m_steamDesktopOverlayWidth = 4.0f;
|
float m_steamDesktopOverlayWidth = 4.0f;
|
||||||
vr::VROverlayHandle_t m_batteryOverlayHandles[vr::k_unMaxTrackedDeviceCount];
|
vr::VROverlayHandle_t
|
||||||
|
m_batteryOverlayHandles[vr::k_unMaxTrackedDeviceCount];
|
||||||
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
|
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
|
||||||
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
|
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
|
||||||
|
|
||||||
@@ -70,7 +79,9 @@ namespace advsettings {
|
|||||||
void modAlarmTimeHour( int value, bool notify = true );
|
void modAlarmTimeHour( int value, bool notify = true );
|
||||||
void modAlarmTimeMinute( int value, bool notify = true );
|
void modAlarmTimeMinute( int value, bool notify = true );
|
||||||
|
|
||||||
void setSteamDesktopOverlayWidth(float width, bool notify = true, bool notifyOpenVr = true);
|
void setSteamDesktopOverlayWidth( float width,
|
||||||
|
bool notify = true,
|
||||||
|
bool notifyOpenVr = true );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void alarmEnabledChanged( bool enabled );
|
void alarmEnabledChanged( bool enabled );
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "AudioManagerDummy.h"
|
#include "AudioManagerDummy.h"
|
||||||
|
|
||||||
// Used to get the compiler to shut up about C4100: unreferenced formal parameter.
|
// Used to get the compiler to shut up about C4100: unreferenced formal
|
||||||
// The cast is to get GCC to shut up about it.
|
// parameter. The cast is to get GCC to shut up about it.
|
||||||
#define UNREFERENCED_PARAMETER( P ) static_cast<void>( ( P ) )
|
#define UNREFERENCED_PARAMETER( P ) static_cast<void>( ( P ) )
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
void AudioManagerDummy::init( AudioTabController* controller )
|
void AudioManagerDummy::init( AudioTabController* controller )
|
||||||
{
|
{
|
||||||
// noop
|
// noop
|
||||||
@@ -118,16 +118,16 @@ bool AudioManagerDummy::setMicMuted(bool value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string> > AudioManagerDummy::getRecordingDevices()
|
std::vector<std::pair<std::string, std::string>>
|
||||||
|
AudioManagerDummy::getRecordingDevices()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string> > AudioManagerDummy::getPlaybackDevices()
|
std::vector<std::pair<std::string, std::string>>
|
||||||
|
AudioManagerDummy::getPlaybackDevices()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace advsettings
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,19 +4,20 @@
|
|||||||
#include "../AudioManager.h"
|
#include "../AudioManager.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class AudioManagerDummy : public AudioManager
|
class AudioManagerDummy : public AudioManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void init( AudioTabController* controller ) override;
|
virtual void init( AudioTabController* controller ) override;
|
||||||
|
|
||||||
virtual void setPlaybackDevice(const std::string& id, bool notify = true) override;
|
virtual void setPlaybackDevice( const std::string& id,
|
||||||
|
bool notify = true ) override;
|
||||||
virtual std::string getPlaybackDevName() override;
|
virtual std::string getPlaybackDevName() override;
|
||||||
virtual std::string getPlaybackDevId() override;
|
virtual std::string getPlaybackDevId() override;
|
||||||
|
|
||||||
virtual void setMirrorDevice(const std::string& id, bool notify = true) override;
|
virtual void setMirrorDevice( const std::string& id,
|
||||||
|
bool notify = true ) override;
|
||||||
virtual bool isMirrorValid() override;
|
virtual bool isMirrorValid() override;
|
||||||
virtual std::string getMirrorDevName() override;
|
virtual std::string getMirrorDevName() override;
|
||||||
virtual std::string getMirrorDevId() override;
|
virtual std::string getMirrorDevId() override;
|
||||||
@@ -26,7 +27,8 @@ public:
|
|||||||
virtual bool setMirrorMuted( bool value ) override;
|
virtual bool setMirrorMuted( bool value ) override;
|
||||||
|
|
||||||
virtual bool isMicValid() override;
|
virtual bool isMicValid() override;
|
||||||
virtual void setMicDevice(const std::string& id, bool notify = true) override;
|
virtual void setMicDevice( const std::string& id,
|
||||||
|
bool notify = true ) override;
|
||||||
virtual std::string getMicDevName() override;
|
virtual std::string getMicDevName() override;
|
||||||
virtual std::string getMicDevId() override;
|
virtual std::string getMicDevId() override;
|
||||||
virtual float getMicVolume() override;
|
virtual float getMicVolume() override;
|
||||||
@@ -34,9 +36,11 @@ public:
|
|||||||
virtual bool getMicMuted() override;
|
virtual bool getMicMuted() override;
|
||||||
virtual bool setMicMuted( bool value ) override;
|
virtual bool setMicMuted( bool value ) override;
|
||||||
|
|
||||||
virtual std::vector<std::pair<std::string, std::string>> getRecordingDevices() override;
|
virtual std::vector<std::pair<std::string, std::string>>
|
||||||
virtual std::vector<std::pair<std::string, std::string>> getPlaybackDevices() override;
|
getRecordingDevices() override;
|
||||||
|
virtual std::vector<std::pair<std::string, std::string>>
|
||||||
|
getPlaybackDevices() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
#endif // AUDIOMANAGERLINUX_H
|
#endif // AUDIOMANAGERLINUX_H
|
||||||
|
|||||||
@@ -6,336 +6,486 @@
|
|||||||
#include <locale>
|
#include <locale>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
AudioManagerWindows::~AudioManagerWindows() {
|
AudioManagerWindows::~AudioManagerWindows()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
audioDeviceEnumerator->UnregisterEndpointNotificationCallback((IMMNotificationClient*)this);
|
audioDeviceEnumerator->UnregisterEndpointNotificationCallback(
|
||||||
if (mirrorAudioEndpointVolume) {
|
( IMMNotificationClient* ) this );
|
||||||
|
if ( mirrorAudioEndpointVolume )
|
||||||
|
{
|
||||||
mirrorAudioEndpointVolume->Release();
|
mirrorAudioEndpointVolume->Release();
|
||||||
}
|
}
|
||||||
if (micAudioEndpointVolume) {
|
if ( micAudioEndpointVolume )
|
||||||
|
{
|
||||||
micAudioEndpointVolume->Release();
|
micAudioEndpointVolume->Release();
|
||||||
}
|
}
|
||||||
if (mirrorAudioDevice) {
|
if ( mirrorAudioDevice )
|
||||||
|
{
|
||||||
mirrorAudioDevice->Release();
|
mirrorAudioDevice->Release();
|
||||||
}
|
}
|
||||||
if (micAudioDevice) {
|
if ( micAudioDevice )
|
||||||
|
{
|
||||||
micAudioDevice->Release();
|
micAudioDevice->Release();
|
||||||
}
|
}
|
||||||
if (playbackAudioDevice) {
|
if ( playbackAudioDevice )
|
||||||
|
{
|
||||||
playbackAudioDevice->Release();
|
playbackAudioDevice->Release();
|
||||||
}
|
}
|
||||||
audioDeviceEnumerator->Release();
|
audioDeviceEnumerator->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManagerWindows::init(AudioTabController* var_controller) {
|
void AudioManagerWindows::init( AudioTabController* var_controller )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
audioDeviceEnumerator = getAudioDeviceEnumerator();
|
audioDeviceEnumerator = getAudioDeviceEnumerator();
|
||||||
if (!audioDeviceEnumerator) {
|
if ( !audioDeviceEnumerator )
|
||||||
|
{
|
||||||
throw std::exception( "Could not create audio device enumerator" );
|
throw std::exception( "Could not create audio device enumerator" );
|
||||||
}
|
}
|
||||||
playbackAudioDevice = getDefaultPlaybackDevice( audioDeviceEnumerator );
|
playbackAudioDevice = getDefaultPlaybackDevice( audioDeviceEnumerator );
|
||||||
if (!playbackAudioDevice) {
|
if ( !playbackAudioDevice )
|
||||||
|
{
|
||||||
LOG( WARNING ) << "Could not find a default recording device.";
|
LOG( WARNING ) << "Could not find a default recording device.";
|
||||||
}
|
}
|
||||||
micAudioDevice = getDefaultRecordingDevice( audioDeviceEnumerator );
|
micAudioDevice = getDefaultRecordingDevice( audioDeviceEnumerator );
|
||||||
if (micAudioDevice) {
|
if ( micAudioDevice )
|
||||||
|
{
|
||||||
micAudioEndpointVolume = getAudioEndpointVolume( micAudioDevice );
|
micAudioEndpointVolume = getAudioEndpointVolume( micAudioDevice );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG( WARNING ) << "Could not find a default recording device.";
|
LOG( WARNING ) << "Could not find a default recording device.";
|
||||||
}
|
}
|
||||||
this->controller = var_controller;
|
this->controller = var_controller;
|
||||||
audioDeviceEnumerator->RegisterEndpointNotificationCallback((IMMNotificationClient*)this);
|
audioDeviceEnumerator->RegisterEndpointNotificationCallback(
|
||||||
|
( IMMNotificationClient* ) this );
|
||||||
policyConfig = getPolicyConfig();
|
policyConfig = getPolicyConfig();
|
||||||
if (!policyConfig) {
|
if ( !policyConfig )
|
||||||
|
{
|
||||||
LOG( ERROR ) << "Could not find PolicyConfig interface";
|
LOG( ERROR ) << "Could not find PolicyConfig interface";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManagerWindows::setPlaybackDevice(const std::string & id, bool notify) {
|
void AudioManagerWindows::setPlaybackDevice( const std::string& id,
|
||||||
|
bool notify )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (!id.empty()) {
|
if ( !id.empty() )
|
||||||
|
{
|
||||||
auto dev = getDevice( audioDeviceEnumerator, id );
|
auto dev = getDevice( audioDeviceEnumerator, id );
|
||||||
if (!dev) {
|
if ( !dev )
|
||||||
LOG(WARNING) << "Could not find playback device \"" << id << "\".";
|
{
|
||||||
} else {
|
LOG( WARNING ) << "Could not find playback device \"" << id
|
||||||
|
<< "\".";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
playbackAudioDevice = dev;
|
playbackAudioDevice = dev;
|
||||||
if (policyConfig) {
|
if ( policyConfig )
|
||||||
|
{
|
||||||
LPWSTR devId;
|
LPWSTR devId;
|
||||||
if (dev->GetId(&devId) >= 0) {
|
if ( dev->GetId( &devId ) >= 0 )
|
||||||
|
{
|
||||||
policyConfig->SetDefaultEndpoint( devId, eConsole );
|
policyConfig->SetDefaultEndpoint( devId, eConsole );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
controller->onNewPlaybackDevice();
|
controller->onNewPlaybackDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getPlaybackDevName() {
|
std::string AudioManagerWindows::getPlaybackDevName()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (playbackAudioDevice) {
|
if ( playbackAudioDevice )
|
||||||
|
{
|
||||||
return getDeviceName( playbackAudioDevice );
|
return getDeviceName( playbackAudioDevice );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getPlaybackDevId() {
|
std::string AudioManagerWindows::getPlaybackDevId()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (playbackAudioDevice) {
|
if ( playbackAudioDevice )
|
||||||
|
{
|
||||||
return getDeviceId( playbackAudioDevice );
|
return getDeviceId( playbackAudioDevice );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioManagerWindows::setMirrorDevice( const std::string& id, bool notify )
|
||||||
void AudioManagerWindows::setMirrorDevice(const std::string& id, bool notify) {
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (id.empty()) {
|
if ( id.empty() )
|
||||||
|
{
|
||||||
deleteMirrorDevice();
|
deleteMirrorDevice();
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
controller->onNewMirrorDevice();
|
controller->onNewMirrorDevice();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
auto dev = getDevice( audioDeviceEnumerator, id );
|
auto dev = getDevice( audioDeviceEnumerator, id );
|
||||||
if (dev) {
|
if ( dev )
|
||||||
|
{
|
||||||
mirrorAudioDevice = dev;
|
mirrorAudioDevice = dev;
|
||||||
mirrorAudioEndpointVolume = getAudioEndpointVolume(mirrorAudioDevice);
|
mirrorAudioEndpointVolume
|
||||||
} else {
|
= getAudioEndpointVolume( mirrorAudioDevice );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG( WARNING ) << "Could not find mirror device \"" << id << "\".";
|
LOG( WARNING ) << "Could not find mirror device \"" << id << "\".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
controller->onNewMirrorDevice();
|
controller->onNewMirrorDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManagerWindows::deleteMirrorDevice() {
|
void AudioManagerWindows::deleteMirrorDevice()
|
||||||
if (mirrorAudioEndpointVolume) {
|
{
|
||||||
|
if ( mirrorAudioEndpointVolume )
|
||||||
|
{
|
||||||
mirrorAudioEndpointVolume->Release();
|
mirrorAudioEndpointVolume->Release();
|
||||||
mirrorAudioEndpointVolume = nullptr;
|
mirrorAudioEndpointVolume = nullptr;
|
||||||
}
|
}
|
||||||
if (mirrorAudioDevice) {
|
if ( mirrorAudioDevice )
|
||||||
|
{
|
||||||
mirrorAudioDevice->Release();
|
mirrorAudioDevice->Release();
|
||||||
mirrorAudioDevice = nullptr;
|
mirrorAudioDevice = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::isMirrorValid() {
|
bool AudioManagerWindows::isMirrorValid()
|
||||||
|
{
|
||||||
return mirrorAudioEndpointVolume != nullptr;
|
return mirrorAudioEndpointVolume != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getMirrorDevName() {
|
std::string AudioManagerWindows::getMirrorDevName()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (mirrorAudioDevice) {
|
if ( mirrorAudioDevice )
|
||||||
|
{
|
||||||
return getDeviceName( mirrorAudioDevice );
|
return getDeviceName( mirrorAudioDevice );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getMirrorDevId() {
|
std::string AudioManagerWindows::getMirrorDevId()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (mirrorAudioDevice) {
|
if ( mirrorAudioDevice )
|
||||||
|
{
|
||||||
return getDeviceId( mirrorAudioDevice );
|
return getDeviceId( mirrorAudioDevice );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioManagerWindows::getMirrorVolume() {
|
float AudioManagerWindows::getMirrorVolume()
|
||||||
|
{
|
||||||
float value;
|
float value;
|
||||||
if (mirrorAudioEndpointVolume && mirrorAudioEndpointVolume->GetMasterVolumeLevelScalar(&value) >= 0) {
|
if ( mirrorAudioEndpointVolume
|
||||||
|
&& mirrorAudioEndpointVolume->GetMasterVolumeLevelScalar( &value )
|
||||||
|
>= 0 )
|
||||||
|
{
|
||||||
return value;
|
return value;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::setMirrorVolume(float value) {
|
bool AudioManagerWindows::setMirrorVolume( float value )
|
||||||
if (mirrorAudioEndpointVolume) {
|
{
|
||||||
if (mirrorAudioEndpointVolume->SetMasterVolumeLevelScalar(value, nullptr) >= 0) {
|
if ( mirrorAudioEndpointVolume )
|
||||||
|
{
|
||||||
|
if ( mirrorAudioEndpointVolume->SetMasterVolumeLevelScalar( value,
|
||||||
|
nullptr )
|
||||||
|
>= 0 )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::getMirrorMuted() {
|
bool AudioManagerWindows::getMirrorMuted()
|
||||||
|
{
|
||||||
BOOL value;
|
BOOL value;
|
||||||
if (mirrorAudioEndpointVolume && mirrorAudioEndpointVolume->GetMute(&value) >= 0) {
|
if ( mirrorAudioEndpointVolume
|
||||||
|
&& mirrorAudioEndpointVolume->GetMute( &value ) >= 0 )
|
||||||
|
{
|
||||||
return value;
|
return value;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::setMirrorMuted(bool value) {
|
bool AudioManagerWindows::setMirrorMuted( bool value )
|
||||||
if (mirrorAudioEndpointVolume) {
|
{
|
||||||
if (mirrorAudioEndpointVolume->SetMute(value, nullptr) >= 0) {
|
if ( mirrorAudioEndpointVolume )
|
||||||
|
{
|
||||||
|
if ( mirrorAudioEndpointVolume->SetMute( value, nullptr ) >= 0 )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioManagerWindows::isMicValid()
|
||||||
bool AudioManagerWindows::isMicValid() {
|
{
|
||||||
return micAudioEndpointVolume != nullptr;
|
return micAudioEndpointVolume != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManagerWindows::setMicDevice(const std::string & id, bool notify) {
|
void AudioManagerWindows::setMicDevice( const std::string& id, bool notify )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (!id.empty()) {
|
if ( !id.empty() )
|
||||||
|
{
|
||||||
auto dev = getDevice( audioDeviceEnumerator, id );
|
auto dev = getDevice( audioDeviceEnumerator, id );
|
||||||
if (!dev) {
|
if ( !dev )
|
||||||
LOG(WARNING) << "Could not find recording device \"" << id << "\".";
|
{
|
||||||
} else {
|
LOG( WARNING ) << "Could not find recording device \"" << id
|
||||||
|
<< "\".";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
micAudioDevice = dev;
|
micAudioDevice = dev;
|
||||||
if (policyConfig) {
|
if ( policyConfig )
|
||||||
|
{
|
||||||
LPWSTR devId;
|
LPWSTR devId;
|
||||||
if (dev->GetId(&devId) >= 0) {
|
if ( dev->GetId( &devId ) >= 0 )
|
||||||
|
{
|
||||||
policyConfig->SetDefaultEndpoint( devId, eConsole );
|
policyConfig->SetDefaultEndpoint( devId, eConsole );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notify) {
|
if ( notify )
|
||||||
|
{
|
||||||
controller->onNewRecordingDevice();
|
controller->onNewRecordingDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getMicDevName() {
|
std::string AudioManagerWindows::getMicDevName()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (micAudioDevice) {
|
if ( micAudioDevice )
|
||||||
|
{
|
||||||
return getDeviceName( micAudioDevice );
|
return getDeviceName( micAudioDevice );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getMicDevId() {
|
std::string AudioManagerWindows::getMicDevId()
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (micAudioDevice) {
|
if ( micAudioDevice )
|
||||||
|
{
|
||||||
return getDeviceId( micAudioDevice );
|
return getDeviceId( micAudioDevice );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioManagerWindows::getMicVolume() {
|
float AudioManagerWindows::getMicVolume()
|
||||||
|
{
|
||||||
float value;
|
float value;
|
||||||
if (micAudioEndpointVolume && micAudioEndpointVolume->GetMasterVolumeLevelScalar(&value) >= 0) {
|
if ( micAudioEndpointVolume
|
||||||
|
&& micAudioEndpointVolume->GetMasterVolumeLevelScalar( &value ) >= 0 )
|
||||||
|
{
|
||||||
return value;
|
return value;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::setMicVolume(float value) {
|
bool AudioManagerWindows::setMicVolume( float value )
|
||||||
if (micAudioEndpointVolume) {
|
{
|
||||||
if (micAudioEndpointVolume->SetMasterVolumeLevelScalar(value, nullptr) >= 0) {
|
if ( micAudioEndpointVolume )
|
||||||
|
{
|
||||||
|
if ( micAudioEndpointVolume->SetMasterVolumeLevelScalar( value,
|
||||||
|
nullptr )
|
||||||
|
>= 0 )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::getMicMuted() {
|
bool AudioManagerWindows::getMicMuted()
|
||||||
|
{
|
||||||
BOOL value;
|
BOOL value;
|
||||||
if (micAudioEndpointVolume && micAudioEndpointVolume->GetMute(&value) >= 0) {
|
if ( micAudioEndpointVolume
|
||||||
|
&& micAudioEndpointVolume->GetMute( &value ) >= 0 )
|
||||||
|
{
|
||||||
return value;
|
return value;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioManagerWindows::setMicMuted(bool value) {
|
bool AudioManagerWindows::setMicMuted( bool value )
|
||||||
if (micAudioEndpointVolume) {
|
{
|
||||||
if (micAudioEndpointVolume->SetMute(value, nullptr) >= 0) {
|
if ( micAudioEndpointVolume )
|
||||||
|
{
|
||||||
|
if ( micAudioEndpointVolume->SetMute( value, nullptr ) >= 0 )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> AudioManagerWindows::getRecordingDevices() {
|
std::vector<std::pair<std::string, std::string>>
|
||||||
|
AudioManagerWindows::getRecordingDevices()
|
||||||
|
{
|
||||||
return getDevices( audioDeviceEnumerator, eCapture );
|
return getDevices( audioDeviceEnumerator, eCapture );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> AudioManagerWindows::getPlaybackDevices() {
|
std::vector<std::pair<std::string, std::string>>
|
||||||
|
AudioManagerWindows::getPlaybackDevices()
|
||||||
|
{
|
||||||
return getDevices( audioDeviceEnumerator, eRender );
|
return getDevices( audioDeviceEnumerator, eRender );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMMDeviceEnumerator* AudioManagerWindows::getAudioDeviceEnumerator()
|
||||||
IMMDeviceEnumerator* AudioManagerWindows::getAudioDeviceEnumerator() {
|
{
|
||||||
IMMDeviceEnumerator* pEnumerator;
|
IMMDeviceEnumerator* pEnumerator;
|
||||||
if (CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator) < 0) {
|
if ( CoCreateInstance( __uuidof( MMDeviceEnumerator ),
|
||||||
|
NULL,
|
||||||
|
CLSCTX_ALL,
|
||||||
|
__uuidof( IMMDeviceEnumerator ),
|
||||||
|
( void** ) &pEnumerator )
|
||||||
|
< 0 )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pEnumerator;
|
return pEnumerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPolicyConfig * AudioManagerWindows::getPolicyConfig() {
|
IPolicyConfig* AudioManagerWindows::getPolicyConfig()
|
||||||
|
{
|
||||||
IPolicyConfig* var_policyConfig = nullptr;
|
IPolicyConfig* var_policyConfig = nullptr;
|
||||||
// for Win 10
|
// for Win 10
|
||||||
auto hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig2, (LPVOID *)&var_policyConfig);
|
auto hr = CoCreateInstance( __uuidof( CPolicyConfigClient ),
|
||||||
if (hr != S_OK) {
|
NULL,
|
||||||
hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig1, (LPVOID *)&var_policyConfig);
|
CLSCTX_INPROC,
|
||||||
|
IID_IPolicyConfig2,
|
||||||
|
( LPVOID* ) &var_policyConfig );
|
||||||
|
if ( hr != S_OK )
|
||||||
|
{
|
||||||
|
hr = CoCreateInstance( __uuidof( CPolicyConfigClient ),
|
||||||
|
NULL,
|
||||||
|
CLSCTX_INPROC,
|
||||||
|
IID_IPolicyConfig1,
|
||||||
|
( LPVOID* ) &var_policyConfig );
|
||||||
}
|
}
|
||||||
// for Win Vista, 7, 8, 8.1
|
// for Win Vista, 7, 8, 8.1
|
||||||
if (hr != S_OK) {
|
if ( hr != S_OK )
|
||||||
hr = CoCreateInstance(__uuidof(CPolicyConfigClient), NULL, CLSCTX_INPROC, IID_IPolicyConfig0, (LPVOID *)&var_policyConfig);
|
{
|
||||||
|
hr = CoCreateInstance( __uuidof( CPolicyConfigClient ),
|
||||||
|
NULL,
|
||||||
|
CLSCTX_INPROC,
|
||||||
|
IID_IPolicyConfig0,
|
||||||
|
( LPVOID* ) &var_policyConfig );
|
||||||
}
|
}
|
||||||
if (hr != S_OK) {
|
if ( hr != S_OK )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return var_policyConfig;
|
return var_policyConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMMDevice* AudioManagerWindows::getDefaultRecordingDevice(IMMDeviceEnumerator* deviceEnumerator) {
|
IMMDevice* AudioManagerWindows::getDefaultRecordingDevice(
|
||||||
|
IMMDeviceEnumerator* deviceEnumerator )
|
||||||
|
{
|
||||||
IMMDevice* pDevice;
|
IMMDevice* pDevice;
|
||||||
if (deviceEnumerator->GetDefaultAudioEndpoint(eCapture, eConsole, &pDevice) < 0) {
|
if ( deviceEnumerator->GetDefaultAudioEndpoint(
|
||||||
|
eCapture, eConsole, &pDevice )
|
||||||
|
< 0 )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pDevice;
|
return pDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMMDevice * AudioManagerWindows::getDefaultPlaybackDevice(IMMDeviceEnumerator * deviceEnumerator) {
|
IMMDevice* AudioManagerWindows::getDefaultPlaybackDevice(
|
||||||
|
IMMDeviceEnumerator* deviceEnumerator )
|
||||||
|
{
|
||||||
IMMDevice* pDevice;
|
IMMDevice* pDevice;
|
||||||
if (deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice) < 0) {
|
if ( deviceEnumerator->GetDefaultAudioEndpoint(
|
||||||
|
eRender, eConsole, &pDevice )
|
||||||
|
< 0 )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pDevice;
|
return pDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMMDevice* AudioManagerWindows::getDevice(IMMDeviceEnumerator* deviceEnumerator, const std::string& id) {
|
IMMDevice*
|
||||||
|
AudioManagerWindows::getDevice( IMMDeviceEnumerator* deviceEnumerator,
|
||||||
|
const std::string& id )
|
||||||
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
std::wstring wid = converter.from_bytes( id );
|
std::wstring wid = converter.from_bytes( id );
|
||||||
return getDevice( deviceEnumerator, wid.c_str() );
|
return getDevice( deviceEnumerator, wid.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
IMMDevice * AudioManagerWindows::getDevice(IMMDeviceEnumerator * deviceEnumerator, LPCWSTR id) {
|
IMMDevice*
|
||||||
|
AudioManagerWindows::getDevice( IMMDeviceEnumerator* deviceEnumerator,
|
||||||
|
LPCWSTR id )
|
||||||
|
{
|
||||||
IMMDevice* pDevice;
|
IMMDevice* pDevice;
|
||||||
if (deviceEnumerator->GetDevice(id, &pDevice) < 0) {
|
if ( deviceEnumerator->GetDevice( id, &pDevice ) < 0 )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pDevice;
|
return pDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioEndpointVolume * AudioManagerWindows::getAudioEndpointVolume(IMMDevice* device) {
|
IAudioEndpointVolume*
|
||||||
|
AudioManagerWindows::getAudioEndpointVolume( IMMDevice* device )
|
||||||
|
{
|
||||||
IAudioEndpointVolume* pEndpointVolume;
|
IAudioEndpointVolume* pEndpointVolume;
|
||||||
if (device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (void**)&pEndpointVolume) < 0) {
|
if ( device->Activate( __uuidof( IAudioEndpointVolume ),
|
||||||
|
CLSCTX_INPROC_SERVER,
|
||||||
|
NULL,
|
||||||
|
( void** ) &pEndpointVolume )
|
||||||
|
< 0 )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pEndpointVolume;
|
return pEndpointVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getDeviceName(IMMDevice* device) {
|
std::string AudioManagerWindows::getDeviceName( IMMDevice* device )
|
||||||
|
{
|
||||||
IPropertyStore* pProps = nullptr;
|
IPropertyStore* pProps = nullptr;
|
||||||
PROPVARIANT varString;
|
PROPVARIANT varString;
|
||||||
if (device->OpenPropertyStore(STGM_READ, &pProps) >= 0 && pProps->GetValue(PKEY_Device_FriendlyName, &varString) >= 0) {
|
if ( device->OpenPropertyStore( STGM_READ, &pProps ) >= 0
|
||||||
|
&& pProps->GetValue( PKEY_Device_FriendlyName, &varString ) >= 0 )
|
||||||
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
std::string name = converter.to_bytes( varString.pwszVal );
|
std::string name = converter.to_bytes( varString.pwszVal );
|
||||||
return name;
|
return name;
|
||||||
@@ -343,26 +493,37 @@ std::string AudioManagerWindows::getDeviceName(IMMDevice* device) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AudioManagerWindows::getDeviceId(IMMDevice* device) {
|
std::string AudioManagerWindows::getDeviceId( IMMDevice* device )
|
||||||
|
{
|
||||||
LPWSTR ppstrId;
|
LPWSTR ppstrId;
|
||||||
if (device->GetId(&ppstrId) >= 0) {
|
if ( device->GetId( &ppstrId ) >= 0 )
|
||||||
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
return converter.to_bytes( ppstrId );
|
return converter.to_bytes( ppstrId );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> AudioManagerWindows::getDevices(IMMDeviceEnumerator * deviceEnumerator, EDataFlow dataFlow) {
|
std::vector<std::pair<std::string, std::string>>
|
||||||
|
AudioManagerWindows::getDevices( IMMDeviceEnumerator* deviceEnumerator,
|
||||||
|
EDataFlow dataFlow )
|
||||||
|
{
|
||||||
std::vector<std::pair<std::string, std::string>> retval;
|
std::vector<std::pair<std::string, std::string>> retval;
|
||||||
IMMDeviceCollection* ppDevices = nullptr;
|
IMMDeviceCollection* ppDevices = nullptr;
|
||||||
if (deviceEnumerator->EnumAudioEndpoints(dataFlow, DEVICE_STATE_ACTIVE, &ppDevices) >= 0) {
|
if ( deviceEnumerator->EnumAudioEndpoints(
|
||||||
|
dataFlow, DEVICE_STATE_ACTIVE, &ppDevices )
|
||||||
|
>= 0 )
|
||||||
|
{
|
||||||
UINT count;
|
UINT count;
|
||||||
ppDevices->GetCount( &count );
|
ppDevices->GetCount( &count );
|
||||||
for (UINT i = 0; i < count; ++i) {
|
for ( UINT i = 0; i < count; ++i )
|
||||||
|
{
|
||||||
IMMDevice* device = nullptr;
|
IMMDevice* device = nullptr;
|
||||||
ppDevices->Item( i, &device );
|
ppDevices->Item( i, &device );
|
||||||
if (device) {
|
if ( device )
|
||||||
retval.emplace_back(getDeviceId(device), getDeviceName(device));
|
{
|
||||||
|
retval.emplace_back( getDeviceId( device ),
|
||||||
|
getDeviceName( device ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ppDevices->Release();
|
ppDevices->Release();
|
||||||
@@ -370,79 +531,115 @@ std::vector<std::pair<std::string, std::string>> AudioManagerWindows::getDevices
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT AudioManagerWindows::QueryInterface( REFIID riid, void** ppvObject )
|
||||||
HRESULT AudioManagerWindows::QueryInterface(REFIID riid, void ** ppvObject) {
|
{
|
||||||
if (IID_IUnknown == riid) {
|
if ( IID_IUnknown == riid )
|
||||||
|
{
|
||||||
AddRef();
|
AddRef();
|
||||||
*ppvObject = ( IUnknown* ) this;
|
*ppvObject = ( IUnknown* ) this;
|
||||||
} else if (__uuidof(IMMNotificationClient) == riid) {
|
}
|
||||||
|
else if ( __uuidof( IMMNotificationClient ) == riid )
|
||||||
|
{
|
||||||
AddRef();
|
AddRef();
|
||||||
*ppvObject = ( IMMNotificationClient* ) this;
|
*ppvObject = ( IMMNotificationClient* ) this;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*ppvObject = NULL;
|
*ppvObject = NULL;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG AudioManagerWindows::AddRef(void) {
|
ULONG AudioManagerWindows::AddRef( void )
|
||||||
|
{
|
||||||
return 1; // We don't need reference counting
|
return 1; // We don't need reference counting
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG AudioManagerWindows::Release(void) {
|
ULONG AudioManagerWindows::Release( void )
|
||||||
|
{
|
||||||
return 1; // We don't need reference counting
|
return 1; // We don't need reference counting
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT AudioManagerWindows::OnDeviceStateChanged(LPCWSTR, DWORD) {
|
HRESULT AudioManagerWindows::OnDeviceStateChanged( LPCWSTR, DWORD )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
controller->onDeviceStateChanged();
|
controller->onDeviceStateChanged();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT AudioManagerWindows::OnDeviceAdded(LPCWSTR) {
|
HRESULT AudioManagerWindows::OnDeviceAdded( LPCWSTR )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
controller->onDeviceStateChanged();
|
controller->onDeviceStateChanged();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT AudioManagerWindows::OnDeviceRemoved(LPCWSTR) {
|
HRESULT AudioManagerWindows::OnDeviceRemoved( LPCWSTR )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
controller->onDeviceStateChanged();
|
controller->onDeviceStateChanged();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT AudioManagerWindows::OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId) {
|
HRESULT
|
||||||
|
AudioManagerWindows::OnDefaultDeviceChanged( EDataFlow flow,
|
||||||
|
ERole role,
|
||||||
|
LPCWSTR pwstrDefaultDeviceId )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
if (flow == eCapture && role == eMultimedia) {
|
if ( flow == eCapture && role == eMultimedia )
|
||||||
if (audioDeviceEnumerator) {
|
{
|
||||||
auto device = getDevice(audioDeviceEnumerator, pwstrDefaultDeviceId);
|
if ( audioDeviceEnumerator )
|
||||||
if (device != micAudioDevice) {
|
{
|
||||||
if (micAudioDevice) {
|
auto device
|
||||||
|
= getDevice( audioDeviceEnumerator, pwstrDefaultDeviceId );
|
||||||
|
if ( device != micAudioDevice )
|
||||||
|
{
|
||||||
|
if ( micAudioDevice )
|
||||||
|
{
|
||||||
micAudioDevice->Release();
|
micAudioDevice->Release();
|
||||||
}
|
}
|
||||||
micAudioDevice = device;
|
micAudioDevice = device;
|
||||||
if (micAudioDevice) {
|
if ( micAudioDevice )
|
||||||
micAudioEndpointVolume = getAudioEndpointVolume(micAudioDevice);
|
{
|
||||||
} else {
|
micAudioEndpointVolume
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
= getAudioEndpointVolume( micAudioDevice );
|
||||||
std::string name = converter.to_bytes(pwstrDefaultDeviceId);
|
}
|
||||||
LOG(WARNING) << "Could not find recording device \"" << name << "\".";
|
else
|
||||||
|
{
|
||||||
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>
|
||||||
|
converter;
|
||||||
|
std::string name
|
||||||
|
= converter.to_bytes( pwstrDefaultDeviceId );
|
||||||
|
LOG( WARNING ) << "Could not find recording device \""
|
||||||
|
<< name << "\".";
|
||||||
}
|
}
|
||||||
controller->onNewRecordingDevice();
|
controller->onNewRecordingDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (flow == eRender && role == eMultimedia) {
|
}
|
||||||
if (audioDeviceEnumerator) {
|
else if ( flow == eRender && role == eMultimedia )
|
||||||
auto device = getDevice(audioDeviceEnumerator, pwstrDefaultDeviceId);
|
{
|
||||||
if (device != playbackAudioDevice) {
|
if ( audioDeviceEnumerator )
|
||||||
if (playbackAudioDevice) {
|
{
|
||||||
|
auto device
|
||||||
|
= getDevice( audioDeviceEnumerator, pwstrDefaultDeviceId );
|
||||||
|
if ( device != playbackAudioDevice )
|
||||||
|
{
|
||||||
|
if ( playbackAudioDevice )
|
||||||
|
{
|
||||||
playbackAudioDevice->Release();
|
playbackAudioDevice->Release();
|
||||||
}
|
}
|
||||||
playbackAudioDevice = device;
|
playbackAudioDevice = device;
|
||||||
if (!playbackAudioDevice) {
|
if ( !playbackAudioDevice )
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
{
|
||||||
std::string name = converter.to_bytes(pwstrDefaultDeviceId);
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>
|
||||||
LOG(WARNING) << "Could not find playback device \"" << name << "\".";
|
converter;
|
||||||
|
std::string name
|
||||||
|
= converter.to_bytes( pwstrDefaultDeviceId );
|
||||||
|
LOG( WARNING )
|
||||||
|
<< "Could not find playback device \"" << name << "\".";
|
||||||
}
|
}
|
||||||
controller->onNewPlaybackDevice();
|
controller->onNewPlaybackDevice();
|
||||||
}
|
}
|
||||||
@@ -474,13 +671,15 @@ HRESULT AudioManagerWindows::OnDefaultDeviceChanged(EDataFlow flow, ERole role,
|
|||||||
|
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
std::string name = converter.to_bytes(pwstrDefaultDeviceId);
|
std::string name = converter.to_bytes(pwstrDefaultDeviceId);
|
||||||
printf(" %s -->New default device: flow = %s, role = %s\n", name.c_str(), pszFlow, pszRole);
|
printf(" %s -->New default device: flow = %s, role = %s\n", name.c_str(),
|
||||||
fflush(stdout);*/
|
pszFlow, pszRole); fflush(stdout);*/
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT AudioManagerWindows::OnPropertyValueChanged(LPCWSTR, const PROPERTYKEY) {
|
HRESULT AudioManagerWindows::OnPropertyValueChanged( LPCWSTR,
|
||||||
|
const PROPERTYKEY )
|
||||||
|
{
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -8,12 +8,13 @@
|
|||||||
#include "IPolicyConfig.h"
|
#include "IPolicyConfig.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class AudioManagerWindows : public AudioManager, IMMNotificationClient {
|
class AudioManagerWindows : public AudioManager, IMMNotificationClient
|
||||||
|
{
|
||||||
friend class AudioNotificationClient;
|
friend class AudioNotificationClient;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::recursive_mutex _mutex;
|
std::recursive_mutex _mutex;
|
||||||
AudioTabController* controller = nullptr;
|
AudioTabController* controller = nullptr;
|
||||||
@@ -30,11 +31,13 @@ public:
|
|||||||
|
|
||||||
virtual void init( AudioTabController* controller ) override;
|
virtual void init( AudioTabController* controller ) override;
|
||||||
|
|
||||||
virtual void setPlaybackDevice(const std::string& id, bool notify = true) override;
|
virtual void setPlaybackDevice( const std::string& id,
|
||||||
|
bool notify = true ) override;
|
||||||
virtual std::string getPlaybackDevName() override;
|
virtual std::string getPlaybackDevName() override;
|
||||||
virtual std::string getPlaybackDevId() override;
|
virtual std::string getPlaybackDevId() override;
|
||||||
|
|
||||||
virtual void setMirrorDevice(const std::string& id, bool notify = true) override;
|
virtual void setMirrorDevice( const std::string& id,
|
||||||
|
bool notify = true ) override;
|
||||||
virtual bool isMirrorValid() override;
|
virtual bool isMirrorValid() override;
|
||||||
virtual std::string getMirrorDevName() override;
|
virtual std::string getMirrorDevName() override;
|
||||||
virtual std::string getMirrorDevId() override;
|
virtual std::string getMirrorDevId() override;
|
||||||
@@ -44,7 +47,8 @@ public:
|
|||||||
virtual bool setMirrorMuted( bool value ) override;
|
virtual bool setMirrorMuted( bool value ) override;
|
||||||
|
|
||||||
virtual bool isMicValid() override;
|
virtual bool isMicValid() override;
|
||||||
virtual void setMicDevice(const std::string& id, bool notify = true) override;
|
virtual void setMicDevice( const std::string& id,
|
||||||
|
bool notify = true ) override;
|
||||||
virtual std::string getMicDevName() override;
|
virtual std::string getMicDevName() override;
|
||||||
virtual std::string getMicDevId() override;
|
virtual std::string getMicDevId() override;
|
||||||
virtual float getMicVolume() override;
|
virtual float getMicVolume() override;
|
||||||
@@ -52,8 +56,10 @@ public:
|
|||||||
virtual bool getMicMuted() override;
|
virtual bool getMicMuted() override;
|
||||||
virtual bool setMicMuted( bool value ) override;
|
virtual bool setMicMuted( bool value ) override;
|
||||||
|
|
||||||
virtual std::vector<std::pair<std::string, std::string>> getRecordingDevices() override;
|
virtual std::vector<std::pair<std::string, std::string>>
|
||||||
virtual std::vector<std::pair<std::string, std::string>> getPlaybackDevices() override;
|
getRecordingDevices() override;
|
||||||
|
virtual std::vector<std::pair<std::string, std::string>>
|
||||||
|
getPlaybackDevices() override;
|
||||||
|
|
||||||
void deleteMirrorDevice();
|
void deleteMirrorDevice();
|
||||||
|
|
||||||
@@ -61,24 +67,32 @@ public:
|
|||||||
virtual HRESULT QueryInterface( REFIID riid, void** ppvObject ) override;
|
virtual HRESULT QueryInterface( REFIID riid, void** ppvObject ) override;
|
||||||
virtual ULONG AddRef( void ) override;
|
virtual ULONG AddRef( void ) override;
|
||||||
virtual ULONG Release( void ) override;
|
virtual ULONG Release( void ) override;
|
||||||
virtual HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) override;
|
virtual HRESULT OnDeviceStateChanged( LPCWSTR pwstrDeviceId,
|
||||||
|
DWORD dwNewState ) override;
|
||||||
virtual HRESULT OnDeviceAdded( LPCWSTR pwstrDeviceId ) override;
|
virtual HRESULT OnDeviceAdded( LPCWSTR pwstrDeviceId ) override;
|
||||||
virtual HRESULT OnDeviceRemoved( LPCWSTR pwstrDeviceId ) override;
|
virtual HRESULT OnDeviceRemoved( LPCWSTR pwstrDeviceId ) override;
|
||||||
virtual HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId) override;
|
virtual HRESULT
|
||||||
virtual HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) override;
|
OnDefaultDeviceChanged( EDataFlow flow,
|
||||||
|
ERole role,
|
||||||
|
LPCWSTR pwstrDefaultDeviceId ) override;
|
||||||
|
virtual HRESULT OnPropertyValueChanged( LPCWSTR pwstrDeviceId,
|
||||||
|
const PROPERTYKEY key ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IMMDeviceEnumerator* getAudioDeviceEnumerator();
|
IMMDeviceEnumerator* getAudioDeviceEnumerator();
|
||||||
IPolicyConfig* getPolicyConfig();
|
IPolicyConfig* getPolicyConfig();
|
||||||
IMMDevice* getDefaultRecordingDevice(IMMDeviceEnumerator* deviceEnumerator);
|
IMMDevice*
|
||||||
IMMDevice* getDefaultPlaybackDevice(IMMDeviceEnumerator* deviceEnumerator);
|
getDefaultRecordingDevice( IMMDeviceEnumerator* deviceEnumerator );
|
||||||
IMMDevice* getDevice(IMMDeviceEnumerator* deviceEnumerator, const std::string& id);
|
IMMDevice*
|
||||||
|
getDefaultPlaybackDevice( IMMDeviceEnumerator* deviceEnumerator );
|
||||||
|
IMMDevice* getDevice( IMMDeviceEnumerator* deviceEnumerator,
|
||||||
|
const std::string& id );
|
||||||
IMMDevice* getDevice( IMMDeviceEnumerator* deviceEnumerator, LPCWSTR id );
|
IMMDevice* getDevice( IMMDeviceEnumerator* deviceEnumerator, LPCWSTR id );
|
||||||
IAudioEndpointVolume* getAudioEndpointVolume( IMMDevice* device );
|
IAudioEndpointVolume* getAudioEndpointVolume( IMMDevice* device );
|
||||||
std::string getDeviceName( IMMDevice* device );
|
std::string getDeviceName( IMMDevice* device );
|
||||||
std::string getDeviceId( IMMDevice* device );
|
std::string getDeviceId( IMMDevice* device );
|
||||||
std::vector<std::pair<std::string, std::string>> getDevices(IMMDeviceEnumerator* deviceEnumerator, EDataFlow dataFlow);
|
std::vector<std::pair<std::string, std::string>>
|
||||||
|
getDevices( IMMDeviceEnumerator* deviceEnumerator, EDataFlow dataFlow );
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|
||||||
|
|||||||
@@ -5,90 +5,66 @@
|
|||||||
// @author EreTIk
|
// @author EreTIk
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ca286fc3-91fd-42c3-8e9b-caafa66242e3
|
// ca286fc3-91fd-42c3-8e9b-caafa66242e3
|
||||||
static const GUID IID_IPolicyConfig2 = { 0xCA286FC3, 0x91FD, 0x42C3, { 0x8E, 0x9B, 0xCA, 0xAF, 0xA6, 0x62, 0x42, 0xE3 } };
|
static const GUID IID_IPolicyConfig2
|
||||||
|
= { 0xCA286FC3,
|
||||||
|
0x91FD,
|
||||||
|
0x42C3,
|
||||||
|
{ 0x8E, 0x9B, 0xCA, 0xAF, 0xA6, 0x62, 0x42, 0xE3 } };
|
||||||
|
|
||||||
// 6be54be8-a068-4875-a49d-0c2966473b11
|
// 6be54be8-a068-4875-a49d-0c2966473b11
|
||||||
static const GUID IID_IPolicyConfig1 = { 0x6BE54BE8, 0xA068, 0x4875, { 0xA4, 0x9D, 0x0C, 0x29, 0x66, 0x47, 0x3B, 0x11 } };
|
static const GUID IID_IPolicyConfig1
|
||||||
|
= { 0x6BE54BE8,
|
||||||
|
0xA068,
|
||||||
|
0x4875,
|
||||||
|
{ 0xA4, 0x9D, 0x0C, 0x29, 0x66, 0x47, 0x3B, 0x11 } };
|
||||||
|
|
||||||
// f8679f50-850a-41cf-9c72-430f290290c8
|
// f8679f50-850a-41cf-9c72-430f290290c8
|
||||||
static const GUID IID_IPolicyConfig0 = { 0xF8679F50, 0x850A, 0x41CF, { 0x9C, 0x72, 0x43, 0x0F, 0x29, 0x02, 0x90, 0xC8 } };
|
static const GUID IID_IPolicyConfig0
|
||||||
|
= { 0xF8679F50,
|
||||||
|
0x850A,
|
||||||
|
0x41CF,
|
||||||
|
{ 0x9C, 0x72, 0x43, 0x0F, 0x29, 0x02, 0x90, 0xC8 } };
|
||||||
|
|
||||||
class DECLSPEC_UUID("870af99c-171d-4f9e-af0d-e63df40c2bc9") CPolicyConfigClient;
|
class DECLSPEC_UUID( "870af99c-171d-4f9e-af0d-e63df40c2bc9" )
|
||||||
|
CPolicyConfigClient;
|
||||||
|
|
||||||
interface IPolicyConfig : public IUnknown
|
interface IPolicyConfig : public IUnknown
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual HRESULT GetMixFormat( PCWSTR, WAVEFORMATEX** );
|
||||||
virtual HRESULT GetMixFormat(
|
|
||||||
PCWSTR,
|
|
||||||
WAVEFORMATEX **
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetDeviceFormat(
|
virtual HRESULT STDMETHODCALLTYPE GetDeviceFormat(
|
||||||
PCWSTR,
|
PCWSTR, INT, WAVEFORMATEX** );
|
||||||
INT,
|
|
||||||
WAVEFORMATEX **
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE ResetDeviceFormat(
|
virtual HRESULT STDMETHODCALLTYPE ResetDeviceFormat( PCWSTR );
|
||||||
PCWSTR
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetDeviceFormat(
|
virtual HRESULT STDMETHODCALLTYPE SetDeviceFormat(
|
||||||
PCWSTR,
|
PCWSTR, WAVEFORMATEX*, WAVEFORMATEX* );
|
||||||
WAVEFORMATEX *,
|
|
||||||
WAVEFORMATEX *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetProcessingPeriod(
|
virtual HRESULT STDMETHODCALLTYPE GetProcessingPeriod(
|
||||||
PCWSTR,
|
PCWSTR, INT, PINT64, PINT64 );
|
||||||
INT,
|
|
||||||
PINT64,
|
|
||||||
PINT64
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetProcessingPeriod(
|
virtual HRESULT STDMETHODCALLTYPE SetProcessingPeriod( PCWSTR, PINT64 );
|
||||||
PCWSTR,
|
|
||||||
PINT64
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetShareMode(
|
virtual HRESULT STDMETHODCALLTYPE GetShareMode( PCWSTR,
|
||||||
PCWSTR,
|
struct DeviceShareMode* );
|
||||||
struct DeviceShareMode *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetShareMode(
|
virtual HRESULT STDMETHODCALLTYPE SetShareMode( PCWSTR,
|
||||||
PCWSTR,
|
struct DeviceShareMode* );
|
||||||
struct DeviceShareMode *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetPropertyValue(
|
virtual HRESULT STDMETHODCALLTYPE GetPropertyValue(
|
||||||
PCWSTR,
|
PCWSTR, int, const PROPERTYKEY&, const PROPVARIANT* );
|
||||||
int,
|
|
||||||
const PROPERTYKEY &,
|
|
||||||
const PROPVARIANT *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetPropertyValue(
|
virtual HRESULT STDMETHODCALLTYPE SetPropertyValue(
|
||||||
PCWSTR,
|
PCWSTR, int, const PROPERTYKEY&, const PROPVARIANT* );
|
||||||
int,
|
|
||||||
const PROPERTYKEY &,
|
|
||||||
const PROPVARIANT *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetDefaultEndpoint(
|
virtual HRESULT STDMETHODCALLTYPE SetDefaultEndpoint(
|
||||||
__in PCWSTR wszDeviceId,
|
__in PCWSTR wszDeviceId, __in ERole eRole );
|
||||||
__in ERole eRole
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetEndpointVisibility(
|
virtual HRESULT STDMETHODCALLTYPE SetEndpointVisibility( PCWSTR, INT );
|
||||||
PCWSTR,
|
|
||||||
INT
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
interface DECLSPEC_UUID( "568b9108-44bf-40b4-9006-86afe5b5a620" )
|
interface DECLSPEC_UUID( "568b9108-44bf-40b4-9006-86afe5b5a620" )
|
||||||
@@ -111,67 +87,47 @@ CPolicyConfigVistaClient;
|
|||||||
interface IPolicyConfigVista : public IUnknown
|
interface IPolicyConfigVista : public IUnknown
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual HRESULT GetMixFormat(
|
virtual HRESULT GetMixFormat(
|
||||||
PCWSTR,
|
PCWSTR,
|
||||||
WAVEFORMATEX **
|
WAVEFORMATEX** ); // not available on Windows 7, use method from
|
||||||
); // not available on Windows 7, use method from IPolicyConfig
|
// IPolicyConfig
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetDeviceFormat(
|
virtual HRESULT STDMETHODCALLTYPE GetDeviceFormat(
|
||||||
PCWSTR,
|
PCWSTR, INT, WAVEFORMATEX** );
|
||||||
INT,
|
|
||||||
WAVEFORMATEX **
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetDeviceFormat(
|
virtual HRESULT STDMETHODCALLTYPE SetDeviceFormat(
|
||||||
PCWSTR,
|
PCWSTR, WAVEFORMATEX*, WAVEFORMATEX* );
|
||||||
WAVEFORMATEX *,
|
|
||||||
WAVEFORMATEX *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetProcessingPeriod(
|
virtual HRESULT STDMETHODCALLTYPE GetProcessingPeriod(
|
||||||
PCWSTR,
|
PCWSTR,
|
||||||
INT,
|
INT,
|
||||||
PINT64,
|
PINT64,
|
||||||
PINT64
|
PINT64 ); // not available on Windows 7, use method from IPolicyConfig
|
||||||
); // not available on Windows 7, use method from IPolicyConfig
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetProcessingPeriod(
|
virtual HRESULT STDMETHODCALLTYPE SetProcessingPeriod(
|
||||||
PCWSTR,
|
PCWSTR,
|
||||||
PINT64
|
PINT64 ); // not available on Windows 7, use method from IPolicyConfig
|
||||||
); // not available on Windows 7, use method from IPolicyConfig
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetShareMode(
|
virtual HRESULT STDMETHODCALLTYPE GetShareMode(
|
||||||
PCWSTR,
|
PCWSTR,
|
||||||
struct DeviceShareMode *
|
struct DeviceShareMode* ); // not available on Windows 7, use method
|
||||||
); // not available on Windows 7, use method from IPolicyConfig
|
// from IPolicyConfig
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetShareMode(
|
virtual HRESULT STDMETHODCALLTYPE SetShareMode(
|
||||||
PCWSTR,
|
PCWSTR,
|
||||||
struct DeviceShareMode *
|
struct DeviceShareMode* ); // not available on Windows 7, use method
|
||||||
); // not available on Windows 7, use method from IPolicyConfig
|
// from IPolicyConfig
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE GetPropertyValue(
|
virtual HRESULT STDMETHODCALLTYPE GetPropertyValue(
|
||||||
PCWSTR,
|
PCWSTR, int, const PROPERTYKEY&, const PROPVARIANT* );
|
||||||
int,
|
|
||||||
const PROPERTYKEY &,
|
|
||||||
const PROPVARIANT *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetPropertyValue(
|
virtual HRESULT STDMETHODCALLTYPE SetPropertyValue(
|
||||||
PCWSTR,
|
PCWSTR, int, const PROPERTYKEY&, const PROPVARIANT* );
|
||||||
int,
|
|
||||||
const PROPERTYKEY &,
|
|
||||||
const PROPVARIANT *
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetDefaultEndpoint(
|
virtual HRESULT STDMETHODCALLTYPE SetDefaultEndpoint(
|
||||||
__in PCWSTR wszDeviceId,
|
__in PCWSTR wszDeviceId, __in ERole eRole );
|
||||||
__in ERole eRole
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE SetEndpointVisibility(
|
virtual HRESULT STDMETHODCALLTYPE SetEndpointVisibility(
|
||||||
PCWSTR,
|
PCWSTR,
|
||||||
INT
|
INT ); // not available on Windows 7, use method from IPolicyConfig
|
||||||
); // not available on Windows 7, use method from IPolicyConfig
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "KeyboardInputDummy.h"
|
#include "KeyboardInputDummy.h"
|
||||||
|
|
||||||
// Used to get the compiler to shut up about C4100: unreferenced formal parameter.
|
// Used to get the compiler to shut up about C4100: unreferenced formal
|
||||||
// The cast is to get GCC to shut up about it.
|
// parameter. The cast is to get GCC to shut up about it.
|
||||||
#define UNREFERENCED_PARAMETER( P ) static_cast<void>( ( P ) )
|
#define UNREFERENCED_PARAMETER( P ) static_cast<void>( ( P ) )
|
||||||
|
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
void KeyboardInputDummy::sendKeyboardInput( QString input )
|
void KeyboardInputDummy::sendKeyboardInput( QString input )
|
||||||
{
|
{
|
||||||
// noop
|
// noop
|
||||||
@@ -28,4 +28,4 @@ void KeyboardInputDummy::sendKeyboardAltTab()
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include "../KeyboardInput.h"
|
#include "../KeyboardInput.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class KeyboardInputDummy : public KeyboardInput
|
class KeyboardInputDummy : public KeyboardInput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -15,6 +15,6 @@ public:
|
|||||||
virtual void sendKeyboardAltTab() override;
|
virtual void sendKeyboardAltTab() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|
||||||
#endif // KEYBOARDINPUTDUMMY_H
|
#endif // KEYBOARDINPUTDUMMY_H
|
||||||
|
|||||||
@@ -2,14 +2,18 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "../../logging.h"
|
#include "../../logging.h"
|
||||||
|
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) {
|
void fillKiStruct( INPUT& ip, WORD scanCode, bool keyup )
|
||||||
|
{
|
||||||
ip.type = INPUT_KEYBOARD;
|
ip.type = INPUT_KEYBOARD;
|
||||||
ip.ki.wVk = scanCode;
|
ip.ki.wVk = scanCode;
|
||||||
if (keyup) {
|
if ( keyup )
|
||||||
|
{
|
||||||
ip.ki.dwFlags = KEYEVENTF_KEYUP;
|
ip.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ip.ki.dwFlags = 0;
|
ip.ki.dwFlags = 0;
|
||||||
}
|
}
|
||||||
ip.ki.wScan = 0;
|
ip.ki.wScan = 0;
|
||||||
@@ -17,19 +21,30 @@ void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) {
|
|||||||
ip.ki.time = 0;
|
ip.ki.time = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void sendKeyboardInputRaw(int inputCount, LPINPUT input) {
|
void sendKeyboardInputRaw( int inputCount, LPINPUT input )
|
||||||
if ((inputCount > 0) && !SendInput(static_cast<UINT>(inputCount), input, sizeof(INPUT))) {
|
{
|
||||||
|
if ( ( inputCount > 0 )
|
||||||
|
&& !SendInput(
|
||||||
|
static_cast<UINT>( inputCount ), input, sizeof( INPUT ) ) )
|
||||||
|
{
|
||||||
char* err;
|
char* err;
|
||||||
auto errCode = GetLastError();
|
auto errCode = GetLastError();
|
||||||
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
if ( !FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
|
| FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
nullptr,
|
nullptr,
|
||||||
errCode,
|
errCode,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
MAKELANGID( LANG_NEUTRAL,
|
||||||
|
SUBLANG_DEFAULT ), // default language
|
||||||
reinterpret_cast<LPTSTR>( &err ),
|
reinterpret_cast<LPTSTR>( &err ),
|
||||||
0,
|
0,
|
||||||
nullptr)){
|
nullptr ) )
|
||||||
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
{
|
||||||
} else {
|
LOG( ERROR )
|
||||||
|
<< "Error calling SendInput(): Could not get error message ("
|
||||||
|
<< errCode << ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG( ERROR ) << "Error calling SendInput(): " << err;
|
LOG( ERROR ) << "Error calling SendInput(): " << err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,52 +53,66 @@ void sendKeyboardInputRaw(int inputCount, LPINPUT input) {
|
|||||||
void KeyboardInputWindows::sendKeyboardInput( QString input )
|
void KeyboardInputWindows::sendKeyboardInput( QString input )
|
||||||
{
|
{
|
||||||
int len = input.length();
|
int len = input.length();
|
||||||
if (len > 0) {
|
if ( len > 0 )
|
||||||
|
{
|
||||||
LPINPUT ips = new INPUT[static_cast<unsigned int>( len ) * 5 + 3];
|
LPINPUT ips = new INPUT[static_cast<unsigned int>( len ) * 5 + 3];
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
bool shiftPressed = false;
|
bool shiftPressed = false;
|
||||||
bool ctrlPressed = false;
|
bool ctrlPressed = false;
|
||||||
bool altPressed = false;
|
bool altPressed = false;
|
||||||
for (int i = 0; i < len; i++) {
|
for ( int i = 0; i < len; i++ )
|
||||||
|
{
|
||||||
short tmp = VkKeyScan( input.at( i ).toLatin1() );
|
short tmp = VkKeyScan( input.at( i ).toLatin1() );
|
||||||
WORD c = tmp & 0xFF;
|
WORD c = tmp & 0xFF;
|
||||||
short shiftState = tmp >> 8;
|
short shiftState = tmp >> 8;
|
||||||
bool isShift = shiftState & 1;
|
bool isShift = shiftState & 1;
|
||||||
bool isCtrl = shiftState & 2;
|
bool isCtrl = shiftState & 2;
|
||||||
bool isAlt = shiftState & 4;
|
bool isAlt = shiftState & 4;
|
||||||
if (isShift && !shiftPressed) {
|
if ( isShift && !shiftPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_SHIFT, false );
|
fillKiStruct( ips[ii++], VK_SHIFT, false );
|
||||||
shiftPressed = true;
|
shiftPressed = true;
|
||||||
} else if (!isShift && shiftPressed) {
|
}
|
||||||
|
else if ( !isShift && shiftPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_SHIFT, true );
|
fillKiStruct( ips[ii++], VK_SHIFT, true );
|
||||||
shiftPressed = false;
|
shiftPressed = false;
|
||||||
}
|
}
|
||||||
if (isCtrl && !ctrlPressed) {
|
if ( isCtrl && !ctrlPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_CONTROL, false );
|
fillKiStruct( ips[ii++], VK_CONTROL, false );
|
||||||
ctrlPressed = true;
|
ctrlPressed = true;
|
||||||
} else if (!isCtrl && ctrlPressed) {
|
}
|
||||||
|
else if ( !isCtrl && ctrlPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_CONTROL, true );
|
fillKiStruct( ips[ii++], VK_CONTROL, true );
|
||||||
ctrlPressed = false;
|
ctrlPressed = false;
|
||||||
}
|
}
|
||||||
if (isAlt && !altPressed) {
|
if ( isAlt && !altPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_MENU, false );
|
fillKiStruct( ips[ii++], VK_MENU, false );
|
||||||
altPressed = true;
|
altPressed = true;
|
||||||
} else if (!isAlt && altPressed) {
|
}
|
||||||
|
else if ( !isAlt && altPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_MENU, true );
|
fillKiStruct( ips[ii++], VK_MENU, true );
|
||||||
altPressed = false;
|
altPressed = false;
|
||||||
}
|
}
|
||||||
fillKiStruct( ips[ii++], c, false );
|
fillKiStruct( ips[ii++], c, false );
|
||||||
fillKiStruct( ips[ii++], c, true );
|
fillKiStruct( ips[ii++], c, true );
|
||||||
}
|
}
|
||||||
if (shiftPressed) {
|
if ( shiftPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_SHIFT, true );
|
fillKiStruct( ips[ii++], VK_SHIFT, true );
|
||||||
shiftPressed = false;
|
shiftPressed = false;
|
||||||
}
|
}
|
||||||
if (ctrlPressed) {
|
if ( ctrlPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_CONTROL, true );
|
fillKiStruct( ips[ii++], VK_CONTROL, true );
|
||||||
ctrlPressed = false;
|
ctrlPressed = false;
|
||||||
}
|
}
|
||||||
if (altPressed) {
|
if ( altPressed )
|
||||||
|
{
|
||||||
fillKiStruct( ips[ii++], VK_MENU, true );
|
fillKiStruct( ips[ii++], VK_MENU, true );
|
||||||
altPressed = false;
|
altPressed = false;
|
||||||
}
|
}
|
||||||
@@ -105,10 +134,12 @@ void KeyboardInputWindows::sendKeyboardEnter()
|
|||||||
|
|
||||||
void KeyboardInputWindows::sendKeyboardBackspace( int count )
|
void KeyboardInputWindows::sendKeyboardBackspace( int count )
|
||||||
{
|
{
|
||||||
if (count > 0) {
|
if ( count > 0 )
|
||||||
|
{
|
||||||
// We ensure that count is nonnegative, therefore safe cast.
|
// We ensure that count is nonnegative, therefore safe cast.
|
||||||
LPINPUT ips = new INPUT[static_cast<unsigned int>( count ) * 2];
|
LPINPUT ips = new INPUT[static_cast<unsigned int>( count ) * 2];
|
||||||
for (int i = 0; i < count; i++) {
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
fillKiStruct( ips[2 * i], VK_BACK, false );
|
fillKiStruct( ips[2 * i], VK_BACK, false );
|
||||||
fillKiStruct( ips[2 * i + 1], VK_BACK, true );
|
fillKiStruct( ips[2 * i + 1], VK_BACK, true );
|
||||||
}
|
}
|
||||||
@@ -131,4 +162,4 @@ void KeyboardInputWindows::sendKeyboardAltTab()
|
|||||||
delete[] ips;
|
delete[] ips;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include "../KeyboardInput.h"
|
#include "../KeyboardInput.h"
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
class KeyboardInputWindows : public KeyboardInput
|
class KeyboardInputWindows : public KeyboardInput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -15,6 +15,6 @@ public:
|
|||||||
virtual void sendKeyboardAltTab() override;
|
virtual void sendKeyboardAltTab() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace advsettings
|
||||||
|
|
||||||
#endif // KEYBOARDINPUTWINDOWS_H
|
#endif // KEYBOARDINPUTWINDOWS_H
|
||||||
|
|||||||
@@ -2,49 +2,63 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace utils {
|
namespace utils
|
||||||
|
{
|
||||||
|
float ChaperoneUtils::_getDistanceToChaperone(
|
||||||
float ChaperoneUtils::_getDistanceToChaperone(const vr::HmdVector3_t & x, vr::HmdVector3_t * projectedPoint) {
|
const vr::HmdVector3_t& x,
|
||||||
|
vr::HmdVector3_t* projectedPoint )
|
||||||
|
{
|
||||||
float distance = NAN;
|
float distance = NAN;
|
||||||
vr::HmdVector3_t* _cornersPtr = _corners.get();
|
vr::HmdVector3_t* _cornersPtr = _corners.get();
|
||||||
for (uint32_t i = 0; i < _quadsCount; i++) {
|
for ( uint32_t i = 0; i < _quadsCount; i++ )
|
||||||
|
{
|
||||||
uint32_t i2 = ( i + 1 ) % _quadsCount;
|
uint32_t i2 = ( i + 1 ) % _quadsCount;
|
||||||
vr::HmdVector3_t& r0 = _cornersPtr[i];
|
vr::HmdVector3_t& r0 = _cornersPtr[i];
|
||||||
vr::HmdVector3_t& r1 = _cornersPtr[i2];
|
vr::HmdVector3_t& r1 = _cornersPtr[i2];
|
||||||
float u_x = r1.v[0] - r0.v[0];
|
float u_x = r1.v[0] - r0.v[0];
|
||||||
float u_z = r1.v[2] - r0.v[2];
|
float u_z = r1.v[2] - r0.v[2];
|
||||||
float r = ((x.v[0] - r0.v[0]) * u_x + (x.v[2] - r0.v[2]) * u_z) / (u_x*u_x + u_z*u_z);
|
float r = ( ( x.v[0] - r0.v[0] ) * u_x + ( x.v[2] - r0.v[2] ) * u_z )
|
||||||
//int mode = 0; // 0 .. projected point on segment, 1 .. projected point outside of segment (r0 closer than r1), 2 .. projected point outside of segment (r1 closer than r0)
|
/ ( u_x * u_x + u_z * u_z );
|
||||||
|
// int mode = 0; // 0 .. projected point on segment, 1 .. projected
|
||||||
|
// point outside of segment (r0 closer than r1), 2 .. projected point
|
||||||
|
// outside of segment (r1 closer than r0)
|
||||||
float d;
|
float d;
|
||||||
float x1_x;
|
float x1_x;
|
||||||
float x1_z;
|
float x1_z;
|
||||||
if (r < 0.0f || r > 1.0f) { // projected point outside of segment
|
if ( r < 0.0f || r > 1.0f )
|
||||||
|
{ // projected point outside of segment
|
||||||
float d_x = r0.v[0] - x.v[0];
|
float d_x = r0.v[0] - x.v[0];
|
||||||
float d_z = r0.v[2] - x.v[2];
|
float d_z = r0.v[2] - x.v[2];
|
||||||
float d1 = sqrt( d_x * d_x + d_z * d_z );
|
float d1 = sqrt( d_x * d_x + d_z * d_z );
|
||||||
d_x = r1.v[0] - x.v[0];
|
d_x = r1.v[0] - x.v[0];
|
||||||
d_z = r1.v[2] - x.v[2];
|
d_z = r1.v[2] - x.v[2];
|
||||||
float d2 = sqrt( d_x * d_x + d_z * d_z );
|
float d2 = sqrt( d_x * d_x + d_z * d_z );
|
||||||
if (d1 < d2) {
|
if ( d1 < d2 )
|
||||||
|
{
|
||||||
d = d1;
|
d = d1;
|
||||||
x1_x = r0.v[0];
|
x1_x = r0.v[0];
|
||||||
x1_z = r0.v[2];
|
x1_z = r0.v[2];
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
d = d2;
|
d = d2;
|
||||||
x1_x = r1.v[0];
|
x1_x = r1.v[0];
|
||||||
x1_z = r1.v[2];
|
x1_z = r1.v[2];
|
||||||
}
|
}
|
||||||
} else { // projected point on segment
|
}
|
||||||
|
else
|
||||||
|
{ // projected point on segment
|
||||||
x1_x = r0.v[0] + r * u_x;
|
x1_x = r0.v[0] + r * u_x;
|
||||||
x1_z = r0.v[2] + r * u_z;
|
x1_z = r0.v[2] + r * u_z;
|
||||||
float d_x = x1_x - x.v[0];
|
float d_x = x1_x - x.v[0];
|
||||||
float d_z = x1_z - x.v[2];
|
float d_z = x1_z - x.v[2];
|
||||||
d = sqrt( d_x * d_x + d_z * d_z );
|
d = sqrt( d_x * d_x + d_z * d_z );
|
||||||
}
|
}
|
||||||
if (std::isnan(distance) || d < distance) {
|
if ( std::isnan( distance ) || d < distance )
|
||||||
|
{
|
||||||
distance = d;
|
distance = d;
|
||||||
if (projectedPoint) {
|
if ( projectedPoint )
|
||||||
|
{
|
||||||
projectedPoint->v[0] = x1_x;
|
projectedPoint->v[0] = x1_x;
|
||||||
projectedPoint->v[1] = x.v[1];
|
projectedPoint->v[1] = x.v[1];
|
||||||
projectedPoint->v[2] = x1_z;
|
projectedPoint->v[2] = x1_z;
|
||||||
@@ -54,28 +68,35 @@ float ChaperoneUtils::_getDistanceToChaperone(const vr::HmdVector3_t & x, vr::Hm
|
|||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChaperoneUtils::loadChaperoneData()
|
||||||
void ChaperoneUtils::loadChaperoneData() {
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo( nullptr, &_quadsCount );
|
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo( nullptr, &_quadsCount );
|
||||||
if (_quadsCount > 0) {
|
if ( _quadsCount > 0 )
|
||||||
std::unique_ptr<vr::HmdQuad_t> quadsBuffer(new vr::HmdQuad_t[_quadsCount]);
|
{
|
||||||
|
std::unique_ptr<vr::HmdQuad_t> quadsBuffer(
|
||||||
|
new vr::HmdQuad_t[_quadsCount] );
|
||||||
vr::HmdQuad_t* quadsBufferPtr = quadsBuffer.get();
|
vr::HmdQuad_t* quadsBufferPtr = quadsBuffer.get();
|
||||||
_corners.reset( ( vr::HmdVector3_t* ) new vr::HmdQuad_t[_quadsCount] );
|
_corners.reset( ( vr::HmdVector3_t* ) new vr::HmdQuad_t[_quadsCount] );
|
||||||
vr::HmdVector3_t* _cornersPtr = _corners.get();
|
vr::HmdVector3_t* _cornersPtr = _corners.get();
|
||||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo(quadsBufferPtr, &_quadsCount);
|
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo( quadsBufferPtr,
|
||||||
for (uint32_t i = 0; i < _quadsCount; i++) {
|
&_quadsCount );
|
||||||
|
for ( uint32_t i = 0; i < _quadsCount; i++ )
|
||||||
|
{
|
||||||
_cornersPtr[i] = quadsBufferPtr[i].vCorners[0];
|
_cornersPtr[i] = quadsBufferPtr[i].vCorners[0];
|
||||||
uint32_t i2 = ( i + 1 ) % _quadsCount;
|
uint32_t i2 = ( i + 1 ) % _quadsCount;
|
||||||
if (quadsBufferPtr[i].vCorners[3].v[0] != quadsBufferPtr[i2].vCorners[0].v[0]
|
if ( quadsBufferPtr[i].vCorners[3].v[0]
|
||||||
|| quadsBufferPtr[i].vCorners[3].v[1] != quadsBufferPtr[i2].vCorners[0].v[1]
|
!= quadsBufferPtr[i2].vCorners[0].v[0]
|
||||||
|| quadsBufferPtr[i].vCorners[3].v[2] != quadsBufferPtr[i2].vCorners[0].v[2]
|
|| quadsBufferPtr[i].vCorners[3].v[1]
|
||||||
|| quadsBufferPtr[i].vCorners[0].v[1] != 0.0f) {
|
!= quadsBufferPtr[i2].vCorners[0].v[1]
|
||||||
|
|| quadsBufferPtr[i].vCorners[3].v[2]
|
||||||
|
!= quadsBufferPtr[i2].vCorners[0].v[2]
|
||||||
|
|| quadsBufferPtr[i].vCorners[0].v[1] != 0.0f )
|
||||||
|
{
|
||||||
_chaperoneWellFormed = false;
|
_chaperoneWellFormed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end namespace utils
|
} // end namespace utils
|
||||||
|
|||||||
+27
-12
@@ -4,35 +4,50 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <openvr.h>
|
#include <openvr.h>
|
||||||
|
|
||||||
namespace utils {
|
namespace utils
|
||||||
|
{
|
||||||
class ChaperoneUtils {
|
class ChaperoneUtils
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
std::recursive_mutex _mutex;
|
std::recursive_mutex _mutex;
|
||||||
uint32_t _quadsCount = 0;
|
uint32_t _quadsCount = 0;
|
||||||
std::unique_ptr<vr::HmdVector3_t> _corners;
|
std::unique_ptr<vr::HmdVector3_t> _corners;
|
||||||
bool _chaperoneWellFormed = true;
|
bool _chaperoneWellFormed = true;
|
||||||
|
|
||||||
float _getDistanceToChaperone(const vr::HmdVector3_t& point, vr::HmdVector3_t* projectedPoint);
|
float _getDistanceToChaperone( const vr::HmdVector3_t& point,
|
||||||
|
vr::HmdVector3_t* projectedPoint );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t quadsCount() const noexcept { return _quadsCount; }
|
uint32_t quadsCount() const noexcept
|
||||||
bool isChaperoneWellFormed() const noexcept { return _chaperoneWellFormed; }
|
{
|
||||||
|
return _quadsCount;
|
||||||
|
}
|
||||||
|
bool isChaperoneWellFormed() const noexcept
|
||||||
|
{
|
||||||
|
return _chaperoneWellFormed;
|
||||||
|
}
|
||||||
|
|
||||||
std::recursive_mutex& mutex() noexcept { return _mutex; }
|
std::recursive_mutex& mutex() noexcept
|
||||||
|
{
|
||||||
|
return _mutex;
|
||||||
|
}
|
||||||
|
|
||||||
void loadChaperoneData();
|
void loadChaperoneData();
|
||||||
|
|
||||||
float getDistanceToChaperone(const vr::HmdVector3_t& point, vr::HmdVector3_t* projectedPoint = nullptr, bool doLock = false) {
|
float getDistanceToChaperone( const vr::HmdVector3_t& point,
|
||||||
if (doLock) {
|
vr::HmdVector3_t* projectedPoint = nullptr,
|
||||||
|
bool doLock = false )
|
||||||
|
{
|
||||||
|
if ( doLock )
|
||||||
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||||
return _getDistanceToChaperone( point, projectedPoint );
|
return _getDistanceToChaperone( point, projectedPoint );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return _getDistanceToChaperone( point, projectedPoint );
|
return _getDistanceToChaperone( point, projectedPoint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // end namespace utils
|
} // end namespace utils
|
||||||
|
|
||||||
|
|||||||
+34
-21
@@ -3,11 +3,14 @@
|
|||||||
#include <openvr.h>
|
#include <openvr.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace utils
|
||||||
namespace utils {
|
{
|
||||||
|
inline vr::HmdMatrix34_t& initRotationMatrix( vr::HmdMatrix34_t& matrix,
|
||||||
inline vr::HmdMatrix34_t& initRotationMatrix(vr::HmdMatrix34_t& matrix, unsigned axisId, float angle) {
|
unsigned axisId,
|
||||||
switch (axisId) {
|
float angle )
|
||||||
|
{
|
||||||
|
switch ( axisId )
|
||||||
|
{
|
||||||
case 0: // x-axis
|
case 0: // x-axis
|
||||||
matrix.m[0][0] = 1.0f;
|
matrix.m[0][0] = 1.0f;
|
||||||
matrix.m[0][1] = 0.0f;
|
matrix.m[0][1] = 0.0f;
|
||||||
@@ -56,12 +59,17 @@ inline vr::HmdMatrix34_t& initRotationMatrix(vr::HmdMatrix34_t& matrix, unsigned
|
|||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline vr::HmdMatrix34_t& matMul33( vr::HmdMatrix34_t& result,
|
||||||
inline vr::HmdMatrix34_t& matMul33(vr::HmdMatrix34_t& result, const vr::HmdMatrix34_t& a, const vr::HmdMatrix34_t& b) {
|
const vr::HmdMatrix34_t& a,
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
const vr::HmdMatrix34_t& b )
|
||||||
for (unsigned j = 0; j < 3; j++) {
|
{
|
||||||
|
for ( unsigned i = 0; i < 3; i++ )
|
||||||
|
{
|
||||||
|
for ( unsigned j = 0; j < 3; j++ )
|
||||||
|
{
|
||||||
result.m[i][j] = 0.0f;
|
result.m[i][j] = 0.0f;
|
||||||
for (unsigned k = 0; k < 3; k++) {
|
for ( unsigned k = 0; k < 3; k++ )
|
||||||
|
{
|
||||||
result.m[i][j] += a.m[i][k] * b.m[k][j];
|
result.m[i][j] += a.m[i][k] * b.m[k][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,29 +77,34 @@ inline vr::HmdMatrix34_t& matMul33(vr::HmdMatrix34_t& result, const vr::HmdMatri
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline vr::HmdVector3_t& matMul33( vr::HmdVector3_t& result,
|
||||||
inline vr::HmdVector3_t& matMul33(vr::HmdVector3_t& result, const vr::HmdMatrix34_t& a, const vr::HmdVector3_t& b) {
|
const vr::HmdMatrix34_t& a,
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
const vr::HmdVector3_t& b )
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < 3; i++ )
|
||||||
|
{
|
||||||
result.v[i] = 0.0f;
|
result.v[i] = 0.0f;
|
||||||
for (unsigned k = 0; k < 3; k++) {
|
for ( unsigned k = 0; k < 3; k++ )
|
||||||
|
{
|
||||||
result.v[i] += a.m[i][k] * b.v[k];
|
result.v[i] += a.m[i][k] * b.v[k];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline vr::HmdVector3_t& matMul33( vr::HmdVector3_t& result,
|
||||||
inline vr::HmdVector3_t& matMul33(vr::HmdVector3_t& result, const vr::HmdVector3_t& a, const vr::HmdMatrix34_t& b) {
|
const vr::HmdVector3_t& a,
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
const vr::HmdMatrix34_t& b )
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < 3; i++ )
|
||||||
|
{
|
||||||
result.v[i] = 0.0f;
|
result.v[i] = 0.0f;
|
||||||
for (unsigned k = 0; k < 3; k++) {
|
for ( unsigned k = 0; k < 3; k++ )
|
||||||
|
{
|
||||||
result.v[i] += a.v[k] * b.m[k][i];
|
result.v[i] += a.v[k] * b.m[k][i];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace utils
|
} // end namespace utils
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user