save brightness OverlaySettings
This commit is contained in:
@@ -8,10 +8,9 @@ namespace advsettings
|
|||||||
{
|
{
|
||||||
void VideoTabController::initStage1()
|
void VideoTabController::initStage1()
|
||||||
{
|
{
|
||||||
//reloadVideoConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO args
|
|
||||||
void VideoTabController::initStage2(OverlayController* var_parent,
|
void VideoTabController::initStage2(OverlayController* var_parent,
|
||||||
QQuickWindow* var_widget)
|
QQuickWindow* var_widget)
|
||||||
{
|
{
|
||||||
@@ -25,21 +24,18 @@ namespace advsettings
|
|||||||
notifKey.c_str(), notifKey.c_str(), &m_brightnessNotificationOverlayHandle);
|
notifKey.c_str(), notifKey.c_str(), &m_brightnessNotificationOverlayHandle);
|
||||||
if (overlayError == vr::VROverlayError_None)
|
if (overlayError == vr::VROverlayError_None)
|
||||||
{
|
{
|
||||||
constexpr auto notificationIconFilename
|
|
||||||
= "/res/img/video/dimmer.png";
|
|
||||||
const auto notifIconPath
|
const auto notifIconPath
|
||||||
= paths::binaryDirectoryFindFile(notificationIconFilename);
|
= paths::binaryDirectoryFindFile(video_keys::k_brightnessOverlayFilename);
|
||||||
if (notifIconPath.has_value())
|
if (notifIconPath.has_value())
|
||||||
{
|
{
|
||||||
vr::VROverlay()->SetOverlayFromFile(m_brightnessNotificationOverlayHandle,
|
vr::VROverlay()->SetOverlayFromFile(m_brightnessNotificationOverlayHandle,
|
||||||
notifIconPath->c_str());
|
notifIconPath->c_str());
|
||||||
vr::VROverlay()->SetOverlayWidthInMeters(
|
vr::VROverlay()->SetOverlayWidthInMeters(
|
||||||
m_brightnessNotificationOverlayHandle, 1.0f);
|
m_brightnessNotificationOverlayHandle, k_overlayWidth);
|
||||||
//Places the "overlay just past eye sight 1mx1m
|
|
||||||
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.00f },
|
{ 0.0f, 1.0f, 0.0f, 0.00f },
|
||||||
{ 0.0f, 0.0f, 1.0f, -0.15f } } };
|
{ 0.0f, 0.0f, 1.0f, k_hmdDistance } } };
|
||||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||||
m_brightnessNotificationOverlayHandle,
|
m_brightnessNotificationOverlayHandle,
|
||||||
vr::k_unTrackedDeviceIndex_Hmd,
|
vr::k_unTrackedDeviceIndex_Hmd,
|
||||||
@@ -48,7 +44,7 @@ namespace advsettings
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "Could not find notification icon \""
|
LOG(ERROR) << "Could not find notification icon \""
|
||||||
<< notificationIconFilename << "\"";
|
<< video_keys::k_brightnessOverlayFilename << "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -57,7 +53,8 @@ namespace advsettings
|
|||||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
overlayError);
|
overlayError);
|
||||||
}
|
}
|
||||||
//emit defaultProfileDisplay();
|
|
||||||
|
reloadVideoConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoTabController::eventLoopTick()
|
void VideoTabController::eventLoopTick()
|
||||||
@@ -65,35 +62,35 @@ namespace advsettings
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void VideoTabController::reloadVideoConfig() {
|
void VideoTabController::reloadVideoConfig() {
|
||||||
//Others Use Mutex needed?
|
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup(getSettingsName());
|
settings->beginGroup(getSettingsName());
|
||||||
|
setBrightnessEnabled(settings->value("brightnessEnabled", false).toBool(), true);
|
||||||
//TODO might need emit params
|
m_opacityValue = settings->value("opacityValue", 0.0f).toFloat();
|
||||||
setBrightnessEnabled(settings->value("brightnessEnabled", false).toBool());
|
setBrightnessValue(settings->value("brightnessValue", 1.0f).toFloat(), true);
|
||||||
setBrightnessLevel(settings->value("brightnessValue", 100).toFloat());
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
void VideoTabController::saveVideoConfig() {
|
void VideoTabController::saveVideoConfig() {
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup(getSettingsName());
|
settings->beginGroup(getSettingsName());
|
||||||
|
|
||||||
settings->setValue("brightnessEnabled", brightnessEnabled());
|
settings->setValue("brightnessEnabled", brightnessEnabled());
|
||||||
|
settings->setValue("opacityValue", opacityValue());
|
||||||
settings->setValue("brightnessValue", brightnessValue());
|
settings->setValue("brightnessValue", brightnessValue());
|
||||||
}
|
settings->endGroup();
|
||||||
void VideoTabController::saveVideoConfig() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
float VideoTabController::opacityValue() const {
|
||||||
|
return m_opacityValue;
|
||||||
|
}
|
||||||
|
|
||||||
float VideoTabController::brightnessValue() const
|
float VideoTabController::brightnessValue() const
|
||||||
{
|
{
|
||||||
return (1.0f - m_opacityValue);
|
return m_brightnessValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoTabController::brightnessEnabled() const
|
bool VideoTabController::brightnessEnabled() const
|
||||||
@@ -111,15 +108,17 @@ namespace advsettings
|
|||||||
if(getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid)
|
if(getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid)
|
||||||
{
|
{
|
||||||
vr::VROverlay()->ShowOverlay(getBrightnessOverlayHandle());
|
vr::VROverlay()->ShowOverlay(getBrightnessOverlayHandle());
|
||||||
LOG(INFO) << "overlay is on";
|
LOG(INFO) << "Brightness Overlay toggled on";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid)
|
if (getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid)
|
||||||
{
|
{
|
||||||
vr::VROverlay()->HideOverlay(getBrightnessOverlayHandle());
|
vr::VROverlay()->HideOverlay(getBrightnessOverlayHandle());
|
||||||
|
LOG(INFO) << "Brightness Overlay toggled off";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
saveVideoConfig();
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
{
|
||||||
emit brightnessEnabledChanged(value);
|
emit brightnessEnabledChanged(value);
|
||||||
@@ -135,14 +134,17 @@ namespace advsettings
|
|||||||
|
|
||||||
if (realvalue != m_opacityValue)
|
if (realvalue != m_opacityValue)
|
||||||
{
|
{
|
||||||
m_opacityValue = realvalue;
|
m_brightnessValue = percvalue;
|
||||||
if (realvalue <= 1.0f && realvalue >= 0.0f) {
|
if (realvalue <= 1.0f && realvalue >= 0.0f) {
|
||||||
|
m_opacityValue = realvalue;
|
||||||
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, realvalue);
|
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, realvalue);
|
||||||
if (overlayError != vr::VROverlayError_None) {
|
if (overlayError != vr::VROverlayError_None) {
|
||||||
LOG(ERROR) << "Could not set alpha: "
|
LOG(ERROR) << "Could not set alpha: "
|
||||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
overlayError);
|
overlayError);
|
||||||
}
|
}
|
||||||
|
//only saves if opacity Value is valid. [1-0]
|
||||||
|
saveVideoConfig();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(WARNING) << "alpha value is invalid setting to 1.0";
|
LOG(WARNING) << "alpha value is invalid setting to 1.0";
|
||||||
|
|||||||
@@ -5,11 +5,16 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <openvr.h>
|
#include <openvr.h>
|
||||||
//#include "../overlaycontroller.h"
|
|
||||||
|
|
||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
|
|
||||||
|
namespace video_keys {
|
||||||
|
|
||||||
|
constexpr auto k_brightnessOverlayFilename = "/res/img/video/dimmer.png";
|
||||||
|
|
||||||
|
}//namespace video_keys
|
||||||
|
|
||||||
namespace advsettings {
|
namespace advsettings {
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
@@ -23,18 +28,23 @@ namespace advsettings {
|
|||||||
setBrightnessValue NOTIFY brightnessValueChanged)
|
setBrightnessValue NOTIFY brightnessValueChanged)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//TODO
|
|
||||||
//constexpr auto notificationBrightnessFilename
|
// how far away the overlay is, any OVERLAY closer will not be dimmed.
|
||||||
|
const float k_hmdDistance = -0.15f;
|
||||||
|
// how wide overlay is, Increase this value if edges of view are not dimmed.
|
||||||
|
const float k_overlayWidth = 1.0f;
|
||||||
OverlayController * parent;
|
OverlayController * parent;
|
||||||
QQuickWindow* widget;
|
QQuickWindow* widget;
|
||||||
|
|
||||||
vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle
|
vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle
|
||||||
= vr::k_ulOverlayHandleInvalid;
|
= vr::k_ulOverlayHandleInvalid;
|
||||||
float m_opacityValue = 0.0f;
|
float m_opacityValue = 0.0f;
|
||||||
|
float m_brightnessValue = 1.0f;
|
||||||
bool m_brightnessEnabled = false;
|
bool m_brightnessEnabled = false;
|
||||||
|
|
||||||
//void reloadVideoConfig();
|
|
||||||
//void saveVideoConfig();
|
void reloadVideoConfig();
|
||||||
|
void saveVideoConfig();
|
||||||
|
|
||||||
|
|
||||||
QString getSettingsName(){
|
QString getSettingsName(){
|
||||||
@@ -48,6 +58,10 @@ namespace advsettings {
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
float opacityValue() const;
|
||||||
|
//inverse of brightnessValue
|
||||||
float brightnessValue() const;
|
float brightnessValue() const;
|
||||||
bool brightnessEnabled() const;
|
bool brightnessEnabled() const;
|
||||||
|
|
||||||
@@ -66,4 +80,4 @@ namespace advsettings {
|
|||||||
void brightnessValueChanged(float value);
|
void brightnessValueChanged(float value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}// namespace
|
}// namespace advsettings
|
||||||
Reference in New Issue
Block a user