From ddd413fa13cb4c900fec16eb4cfd5aaaa4096a94 Mon Sep 17 00:00:00 2001 From: ykeara Date: Tue, 2 Apr 2019 21:31:03 -0500 Subject: [PATCH] dimmer in-prog --- src/res/img/video/dimmer.png | Bin 0 -> 12392 bytes src/tabcontrollers/VideoTabController.cpp | 89 ++++++++++++++++++++++ src/tabcontrollers/VideoTabController.h | 41 ++++++++++ 3 files changed, 130 insertions(+) create mode 100644 src/res/img/video/dimmer.png create mode 100644 src/tabcontrollers/VideoTabController.cpp create mode 100644 src/tabcontrollers/VideoTabController.h diff --git a/src/res/img/video/dimmer.png b/src/res/img/video/dimmer.png new file mode 100644 index 0000000000000000000000000000000000000000..7c2f6a12d9d1397a2715b06ae78a9c8df3df6439 GIT binary patch literal 12392 zcmeI&F-ikL6vpvyjF3$vrbrV6aZlg@1R<9tL}M z%N;egPNbQVTShmxWn0XqVY8Nfo6e}5t9-q0+tPf}-b|~9-EMr4+M`rGj(5|z_)fU=; literal 0 HcmV?d00001 diff --git a/src/tabcontrollers/VideoTabController.cpp b/src/tabcontrollers/VideoTabController.cpp new file mode 100644 index 0000000..b833ef6 --- /dev/null +++ b/src/tabcontrollers/VideoTabController.cpp @@ -0,0 +1,89 @@ +#include "VideoTabController.h" +#include +#include +#include "../overlaycontroller.h" + +namespace advsettings +{ + void VideoTabController::initStage1() + { + reloadVideoConfig(); + } + +//TODO args + void VideoTabController::initStage2(OverlayController* var_parent, + QQuickWindow* var_widget) + { + this->parent = var_parent; + this->widget = var_widget; + + std::string notifKey = std::string(application_strings::applicationKey) + + ".dimnotification"; + + vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay( + notifKey.c_str(), notifKey.c_str(), &m_brightnessNotificationOverlayHandle); + if (overlayError == vr::VROverlayError_None) + { + constexpr auto notificationIconFilename + = "/res/img/video/dimmer.png"; + const auto notifIconPath + = paths::binaryDirectoryFindFile(notificationIconFilename); + if (notifIconPath.has_value()) + { + vr::VROverlay()->SetOverlayFromFile(m_brightnessNotificationOverlayHandle, + notifIconPath->c_str()); + vr::VROverlay()->SetOverlayWidthInMeters( + m_ulNotificationOverlayHandle, 1.0f); + vr::HmdMatrix34_t notificationTransform + = { { { 1.0f, 0.0f, 0.0f, 0.00f }, + { 0.0f, 1.0f, 0.0f, 0.00f }, + { 0.0f, 0.0f, 1.0f, -0.3f } } }; + vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative( + m_brightnessNotificationOverlayHandle, + vr::k_unTrackedDeviceIndex_Hmd, + ¬ificationTransform); + } + else + { + LOG(ERROR) << "Could not find notification icon \"" + << notificationIconFilename << "\""; + } + } + else + { + LOG(ERROR) << "Could not create ptt notification overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError); + } + emit defaultProfileDisplay(); + */ + } + + void VideoTabController::eventLoopTick() + { + + } + + void VideoTabController::reloadVideoConfig() { + //Others Use Mutex needed? + auto settings = OverlayController::appSettings(); + settings->beginGroup(getSettingsName()); + + //TODO might need emit params + setBrightnessEnabled(settings->value("brightnessEnabled", false).toBool()); + setBrightnessLevel(settings->value("brightnessValue", 100).toFloat()); + settings->endGroup(); + + } + + void VideoTabController::saveVideoConfig() { + auto settings = OverlayController::appSettings(); + settings->beginGroup(getSettingsName()); + + settings->setValue("brightnessEnabled", brightnessEnabled()); + settings->setValue("brightnessValue", brightnessValue()); + } + void VideoTabController::saveVideoConfig() { + + } +} \ No newline at end of file diff --git a/src/tabcontrollers/VideoTabController.h b/src/tabcontrollers/VideoTabController.h new file mode 100644 index 0000000..46cc99e --- /dev/null +++ b/src/tabcontrollers/VideoTabController.h @@ -0,0 +1,41 @@ +#pragma once + +namespace advsettings { + + Q_OBJECT + Q_PROPERTY(int playbackDeviceIndex READ playbackDeviceIndex WRITE + setPlaybackDeviceIndex NOTIFY playbackDeviceIndexChanged) + Q_PROPERTY(int mirrorDeviceIndex READ mirrorDeviceIndex WRITE + setMirrorDeviceIndex NOTIFY mirrorDeviceIndexChanged) + +private: + //TODO + constexpr auto notificationBrightnessFilename + = "todo"; + vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle + = vr::k_ulOverlayHandleInvalid; + float m_brightnessValue = 1.0; + bool m_brightnessEnabled = false; + + void reloadVideoConfig(); + void saveVideoConfig(); + + + QString getSettingsName() override + { + return "videoSettings"; + } + + vr::VROverlayHandle_t getBrightnessOverlayHandle() + { + return m_brightnessNotificationOverlayHandle; + } + + +public: + + void initStage1(); + //TODO ?? on args + void initStage2(OverlayController* var_parent, QQuickWindow* var_widget); + +} \ No newline at end of file