mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Add scripting to set the refresh rate
This commit is contained in:
parent
ec11d70801
commit
5db78ef2e1
5 changed files with 77 additions and 6 deletions
|
@ -193,6 +193,7 @@
|
||||||
#include "scripting/TTSScriptingInterface.h"
|
#include "scripting/TTSScriptingInterface.h"
|
||||||
#include "scripting/KeyboardScriptingInterface.h"
|
#include "scripting/KeyboardScriptingInterface.h"
|
||||||
#include "scripting/RefreshRateScriptingInterface.h"
|
#include "scripting/RefreshRateScriptingInterface.h"
|
||||||
|
#include "scripting/PerformanceScriptingInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3280,6 +3281,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
|
||||||
surfaceContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
surfaceContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("RefreshRate", new RefreshRateScriptingInterface());
|
surfaceContext->setContextProperty("RefreshRate", new RefreshRateScriptingInterface());
|
||||||
|
surfaceContext->setContextProperty("Performance", new PerformanceScriptingInterface());
|
||||||
_fileDownload = new FileScriptingInterface(engine);
|
_fileDownload = new FileScriptingInterface(engine);
|
||||||
surfaceContext->setContextProperty("File", _fileDownload);
|
surfaceContext->setContextProperty("File", _fileDownload);
|
||||||
connect(_fileDownload, &FileScriptingInterface::unzipResult, this, &Application::handleUnzip);
|
connect(_fileDownload, &FileScriptingInterface::unzipResult, this, &Application::handleUnzip);
|
||||||
|
@ -3430,6 +3432,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona
|
||||||
surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
|
surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
|
||||||
surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
|
surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
|
||||||
surfaceContext->setContextProperty("RefreshRate", new RefreshRateScriptingInterface());
|
surfaceContext->setContextProperty("RefreshRate", new RefreshRateScriptingInterface());
|
||||||
|
surfaceContext->setContextProperty("Performance", new PerformanceScriptingInterface());
|
||||||
|
|
||||||
surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
||||||
surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
||||||
|
@ -7413,7 +7416,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
||||||
scriptEngine->registerGlobalObject("LODManager", DependencyManager::get<LODManager>().data());
|
scriptEngine->registerGlobalObject("LODManager", DependencyManager::get<LODManager>().data());
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Keyboard", DependencyManager::get<KeyboardScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Keyboard", DependencyManager::get<KeyboardScriptingInterface>().data());
|
||||||
scriptEngine->registerGlobalObject("RefreshRate", new RefreshRateScriptingInterface);
|
scriptEngine->registerGlobalObject("RefreshRate", new RefreshRateScriptingInterface());
|
||||||
|
scriptEngine->registerGlobalObject("Performance", new PerformanceScriptingInterface());
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Paths", DependencyManager::get<PathUtils>().data());
|
scriptEngine->registerGlobalObject("Paths", DependencyManager::get<PathUtils>().data());
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,8 @@
|
||||||
#include "RefreshRateManager.h"
|
#include "RefreshRateManager.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
|
|
||||||
#include <display-plugins/hmd/HmdDisplayPlugin.h>
|
|
||||||
|
|
||||||
static const int VR_TARGET_RATE = 90;
|
static const int VR_TARGET_RATE = 90;
|
||||||
|
|
||||||
static const std::array<std::string, RefreshRateManager::RefreshRateProfile::PROFILE_NUM> REFRESH_RATE_PROFILE_TO_STRING =
|
static const std::array<std::string, RefreshRateManager::RefreshRateProfile::PROFILE_NUM> REFRESH_RATE_PROFILE_TO_STRING =
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
28
interface/src/scripting/PerformanceScriptingInterface.cpp
Normal file
28
interface/src/scripting/PerformanceScriptingInterface.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2019/05/14
|
||||||
|
// Copyright 2013-2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "PerformanceScriptingInterface.h"
|
||||||
|
|
||||||
|
#include "../Application.h"
|
||||||
|
|
||||||
|
std::once_flag PerformanceScriptingInterface::registry_flag;
|
||||||
|
|
||||||
|
PerformanceScriptingInterface::PerformanceScriptingInterface() {
|
||||||
|
std::call_once(registry_flag, [] {
|
||||||
|
qmlRegisterType<PerformanceScriptingInterface>("PerformanceEnums", 1, 0, "RefreshRate");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerformanceScriptingInterface::setRefreshRateProfile(RefreshRateProfile refreshRateProfile) {
|
||||||
|
qApp->getRefreshRateManager().setRefreshRateProfile((RefreshRateManager::RefreshRateProfile)refreshRateProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
PerformanceScriptingInterface::RefreshRateProfile PerformanceScriptingInterface::getRefreshRateProfile() const {
|
||||||
|
return (PerformanceScriptingInterface::RefreshRateProfile)qApp->getRefreshRateManager().getRefreshRateProfile();
|
||||||
|
}
|
43
interface/src/scripting/PerformanceScriptingInterface.h
Normal file
43
interface/src/scripting/PerformanceScriptingInterface.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2019/05/14
|
||||||
|
// Copyright 2013-2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef hifi_PerformanceScriptingInterface_h
|
||||||
|
#define hifi_PerformanceScriptingInterface_h
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "../RefreshRateManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
class PerformanceScriptingInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
// Must match RefreshRateManager enums
|
||||||
|
enum RefreshRateProfile {
|
||||||
|
ECO = RefreshRateManager::RefreshRateProfile::ECO,
|
||||||
|
INTERACTIVE = RefreshRateManager::RefreshRateProfile::INTERACTIVE,
|
||||||
|
REALTIME = RefreshRateManager::RefreshRateProfile::REALTIME,
|
||||||
|
};
|
||||||
|
Q_ENUM(RefreshRateProfile)
|
||||||
|
|
||||||
|
|
||||||
|
PerformanceScriptingInterface();
|
||||||
|
~PerformanceScriptingInterface() = default;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setRefreshRateProfile(RefreshRateProfile refreshRateProfile);
|
||||||
|
RefreshRateProfile getRefreshRateProfile() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::once_flag registry_flag;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // header guard
|
Loading…
Reference in a new issue