brightness cleaned up

This commit is contained in:
ykeara
2019-04-11 23:20:05 -05:00
parent 9b49191f95
commit 95ddbcbe3f
3 changed files with 22 additions and 18 deletions
@@ -40,27 +40,28 @@ GroupBox {
} }
Item { Item {
Layout.preferredWidth: 150 Layout.preferredWidth: 150
} }
MyText { MyText {
text: "Value :" text: "Brightness:"
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
Layout.rightMargin: 10 Layout.rightMargin: 10
} }
MySlider { MySlider {
id: brightnessSlider id: brightnessSlider
from: 0.05 from: 0.01
to: 1.0 to: 1.0
stepSize: 0.01 stepSize: 0.01
value: 1.0 value: 1.0
Layout.fillWidth: true Layout.fillWidth: true
onPositionChanged: { onPositionChanged: {
var val = (this.position * 100)/2 var val = (this.position * 100)
brightnessValueText.text = Math.round(val) + "%" brightnessValueText.text = Math.round(val) + "%"
} }
onValueChanged: { onValueChanged: {
VideoTabController.setBrightnessValue(value.toFixed(2), false) VideoTabController.setBrightnessValue(value.toFixed(2), false)
} }
} }
@@ -68,6 +69,7 @@ GroupBox {
MyTextField { MyTextField {
id: brightnessValueText id: brightnessValueText
text: "100%" text: "100%"
keyBoardUID: 301
Layout.preferredWidth: 100 Layout.preferredWidth: 100
Layout.leftMargin: 10 Layout.leftMargin: 10
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
@@ -80,7 +82,7 @@ GroupBox {
val = 100.0 val = 100.0
} }
var v = (val/100).toFixed(2) var v = (val/100).toFixed(2)
brightnessSlider.value = v brightnessSlider.value = v
} }
text = Math.round(VideoTabController.boundsVisibility * 100) + "%" text = Math.round(VideoTabController.boundsVisibility * 100) + "%"
} }
+13 -11
View File
@@ -34,11 +34,11 @@ namespace advsettings
notifIconPath->c_str()); notifIconPath->c_str());
vr::VROverlay()->SetOverlayWidthInMeters( vr::VROverlay()->SetOverlayWidthInMeters(
m_brightnessNotificationOverlayHandle, 1.0f); m_brightnessNotificationOverlayHandle, 1.0f);
//Places the "overlay just past eye sight 1mx1m should more or less cover all headsets //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.01f } } }; { 0.0f, 0.0f, 1.0f, -0.15f } } };
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative( vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
m_brightnessNotificationOverlayHandle, m_brightnessNotificationOverlayHandle,
vr::k_unTrackedDeviceIndex_Hmd, vr::k_unTrackedDeviceIndex_Hmd,
@@ -92,7 +92,7 @@ namespace advsettings
float VideoTabController::brightnessValue() const float VideoTabController::brightnessValue() const
{ {
return m_brightnessValue; return (1.0f - m_opacityValue);
} }
bool VideoTabController::brightnessEnabled() const bool VideoTabController::brightnessEnabled() const
@@ -112,6 +112,7 @@ 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";
} }
} }
else { else {
@@ -127,16 +128,17 @@ namespace advsettings
} }
} }
void VideoTabController::setBrightnessValue(float value, bool notify) void VideoTabController::setBrightnessValue(float percvalue, bool notify)
{ {
//TODO mutex? //TODO mutex?
//std::lock_guard<std::recursive_mutex> lock(eventLoopMutex); //std::lock_guard<std::recursive_mutex> lock(eventLoopMutex);
if (value != m_brightnessValue) float realvalue = (1.0f - percvalue);
{
m_brightnessValue = value;
if (value <= 1.0f && value >= 0.0f) {
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, value);
if (realvalue != m_opacityValue)
{
m_opacityValue = realvalue;
if (realvalue <= 1.0f && realvalue >= 0.0f) {
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(
@@ -145,13 +147,13 @@ namespace advsettings
} }
else { else {
LOG(WARNING) << "alpha value is invalid setting to 1.0"; LOG(WARNING) << "alpha value is invalid setting to 1.0";
m_brightnessValue = 1.0f; m_opacityValue = 0.0f;
} }
if (notify) if (notify)
{ {
emit brightnessValueChanged(value); emit brightnessValueChanged(percvalue);
} }
} }
} }
+2 -2
View File
@@ -30,7 +30,7 @@ namespace advsettings {
vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle
= vr::k_ulOverlayHandleInvalid; = vr::k_ulOverlayHandleInvalid;
float m_brightnessValue = 1.0f; float m_opacityValue = 0.0f;
bool m_brightnessEnabled = false; bool m_brightnessEnabled = false;
//void reloadVideoConfig(); //void reloadVideoConfig();
@@ -58,7 +58,7 @@ namespace advsettings {
public slots: public slots:
void setBrightnessEnabled(bool value, bool notify = true); void setBrightnessEnabled(bool value, bool notify = true);
void setBrightnessValue(float value, bool notify = true); void setBrightnessValue(float percvalue, bool notify = true);
signals: signals: