draft: upgrade codebase to qt6 and cmake (#657)
* update qt6 upgrade progress * add flawed addition for QRenderTarget and link needed libs * update to better logging format * move many assets and qml files into qrc * get rid of deprecation messages * remove additional deprecation notices * make Qt6 finally render on desktop with some progress on vr * initialize QRhi with QQuickRenderControl * use default values to stop SegFaults * fix compilation on windows * add windows files for aiding in running exe * fix formatting of testing qt.conf * first attempt on using textures instead of files in AudioTabController * Fix public/private access issue * use getter instead of directly accessing class members * use QImage as a base to set overlay textures * use native logging * add more QImage Overlays * implement faulty vulkan implementation --------- Co-authored-by: ykeara <ykeara1@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <QtLogging>
|
||||
#include <QtDebug>
|
||||
#include <QImage>
|
||||
|
||||
namespace alarm_clock
|
||||
{
|
||||
@@ -23,8 +24,10 @@ VrAlarm::VrAlarm()
|
||||
|
||||
ovr_overlay_wrapper::hideOverlay( m_alarmOverlayHandle );
|
||||
|
||||
const auto filename = "/res/img/alarm/alarm_activated.png";
|
||||
ovr_overlay_wrapper::setOverlayFromFile( m_alarmOverlayHandle, filename );
|
||||
// Only need to set it once, no need to keep it in memory
|
||||
QImage alarmIcon( QString( ":/alarm/alarm_activated.png" ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage( m_alarmOverlayHandle,
|
||||
alarmIcon );
|
||||
|
||||
ovr_overlay_wrapper::setOverlayWidthInMeters( m_alarmOverlayHandle, 0.3f );
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "ovr_overlay_wrapper.h"
|
||||
#include <QtLogging>
|
||||
#include <QtDebug>
|
||||
#include <QImage>
|
||||
|
||||
namespace ovr_overlay_wrapper
|
||||
{
|
||||
@@ -100,6 +101,24 @@ OverlayError setOverlayFromFile( vr::VROverlayHandle_t overlayHandle,
|
||||
}
|
||||
}
|
||||
|
||||
OverlayError setOverlayFromQImage( vr::VROverlayHandle_t overlayHandle,
|
||||
QImage& image,
|
||||
std::string customErrorMsg )
|
||||
{
|
||||
image.convertTo( QImage::Format_RGBA8888 );
|
||||
vr::VROverlayError oError = vr::VROverlay()->SetOverlayRaw(
|
||||
overlayHandle, image.bits(), image.width(), image.height(), 4 );
|
||||
if ( oError != vr::VROverlayError_None )
|
||||
{
|
||||
qCritical() << "Error setting Overlay from" << image << "For"
|
||||
<< getOverlayKey( overlayHandle ) << "with error:"
|
||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum( oError )
|
||||
<< customErrorMsg;
|
||||
return OverlayError::UndefinedError;
|
||||
}
|
||||
return OverlayError::NoError;
|
||||
}
|
||||
|
||||
OverlayError showOverlay( vr::VROverlayHandle_t overlayHandle,
|
||||
std::string customErrorMsg )
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <QImage>
|
||||
#include "../utils/paths.h"
|
||||
|
||||
/* Wrapper For OpenVR's IVR settings class, allows us to do our error logging
|
||||
@@ -42,6 +43,9 @@ OverlayError setOverlayWidthInMeters( vr::VROverlayHandle_t overlayHandle,
|
||||
OverlayError setOverlayFromFile( vr::VROverlayHandle_t overlayHandle,
|
||||
std::string fileName,
|
||||
std::string customErrorMsg = "" );
|
||||
OverlayError setOverlayFromQImage( vr::VROverlayHandle_t overlayHandle,
|
||||
QImage& image,
|
||||
std::string customErrorMsg = "" );
|
||||
OverlayError showOverlay( vr::VROverlayHandle_t overlayHandle,
|
||||
std::string customErrorMsg = "" );
|
||||
OverlayError hideOverlay( vr::VROverlayHandle_t overlayHandle,
|
||||
|
||||
+62
-51
@@ -11,6 +11,7 @@
|
||||
#include <QtWidgets/QGraphicsSceneMouseEvent>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QGraphicsEllipseItem>
|
||||
#include <QQuickGraphicsConfiguration>
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <QCursor>
|
||||
#include <QProcess>
|
||||
@@ -20,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <openvr.h>
|
||||
#include "openvr/ovr_overlay_wrapper.h"
|
||||
#include "utils/Matrix.h"
|
||||
#include "keyboard_input/input_sender.h"
|
||||
#include "settings/settings.h"
|
||||
@@ -387,18 +389,10 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
vr::VROverlayFlags_SendVRSmoothScrollEvents,
|
||||
true );
|
||||
|
||||
constexpr auto thumbiconFilename = "res/img/icons/thumbicon.png";
|
||||
const auto thumbIconPath
|
||||
= paths::binaryDirectoryFindFile( thumbiconFilename );
|
||||
if ( thumbIconPath.has_value() )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile( m_ulOverlayThumbnailHandle,
|
||||
thumbIconPath->c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Could not find thumbnail icon \""
|
||||
<< thumbiconFilename << "\"";
|
||||
QImage thumbiconImg( QString( ":/icons/thumbicon.png" ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_ulOverlayThumbnailHandle, thumbiconImg );
|
||||
}
|
||||
|
||||
// Too many render calls in too short time overwhelm Qt and an
|
||||
@@ -413,10 +407,25 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
this,
|
||||
SLOT( renderOverlay() ) );
|
||||
|
||||
#if QT_CONFIG( vulkan )
|
||||
if ( m_window.graphicsApi() == QSGRendererInterface::Vulkan )
|
||||
{
|
||||
m_vulkanInstance.reset( new QVulkanInstance );
|
||||
m_vulkanInstance->setExtensions(
|
||||
QQuickGraphicsConfiguration::preferredInstanceExtensions() );
|
||||
if ( !m_vulkanInstance->create() )
|
||||
throw std::runtime_error( "Cannot create vulkan instance" );
|
||||
|
||||
m_window.setVulkanInstance( m_vulkanInstance.get() );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !m_renderControl.initialize() )
|
||||
throw std::runtime_error( "could not initialize m_renderControl" );
|
||||
|
||||
QRhi* rhi = m_renderControl.rhi();
|
||||
QRhi* rhi = this->rhi();
|
||||
|
||||
qInfo() << "Started with" << rhi->backendName();
|
||||
|
||||
m_pFBTexture.reset( rhi->newTexture(
|
||||
QRhiTexture::RGBA8,
|
||||
@@ -444,7 +453,6 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
0,
|
||||
static_cast<int>( quickItem->width() ),
|
||||
static_cast<int>( quickItem->height() ) );
|
||||
m_renderControl.initialize();
|
||||
|
||||
vr::HmdVector2_t vecWindowSize
|
||||
= { static_cast<float>( quickItem->width() ),
|
||||
@@ -511,40 +519,49 @@ void OverlayController::OnRenderRequest()
|
||||
}
|
||||
}
|
||||
|
||||
vr::ETextureType OverlayController::vrTextureTypeFromRhiBackend()
|
||||
void OverlayController::SetOverlayFromQRhiTexture( QRhiTexture& tex )
|
||||
{
|
||||
if ( !m_cached_vr_texture_type.has_value() )
|
||||
vr::Texture_t vrTex = {};
|
||||
QRhi* rhi = this->rhi();
|
||||
|
||||
switch ( rhi->backend() )
|
||||
{
|
||||
QRhi* rhi = m_renderControl.rhi();
|
||||
switch ( rhi->backend() )
|
||||
{
|
||||
case QRhi::Vulkan:
|
||||
m_cached_vr_texture_type = vr::TextureType_Vulkan;
|
||||
break;
|
||||
case QRhi::D3D12:
|
||||
m_cached_vr_texture_type = vr::TextureType_DirectX12;
|
||||
break;
|
||||
case QRhi::D3D11:
|
||||
m_cached_vr_texture_type = vr::TextureType_DirectX;
|
||||
break;
|
||||
case QRhi::OpenGLES2:
|
||||
m_cached_vr_texture_type = vr::TextureType_OpenGL;
|
||||
break;
|
||||
case QRhi::Metal:
|
||||
m_cached_vr_texture_type = vr::TextureType_Metal;
|
||||
break;
|
||||
default:
|
||||
qFatal() << "unknown RHI backend encountered:" << rhi->backend();
|
||||
throw std::runtime_error( "unsupported RHI backend encountered" );
|
||||
}
|
||||
case QRhi::OpenGLES2:
|
||||
{
|
||||
vrTex.handle = reinterpret_cast<void*>( tex.nativeTexture().object );
|
||||
vrTex.eType = vr::TextureType_OpenGL;
|
||||
vrTex.eColorSpace = vr::ColorSpace_Auto;
|
||||
}
|
||||
return m_cached_vr_texture_type.value();
|
||||
}
|
||||
vr::Texture_t OverlayController::vrTextureFromRhiTexture( QRhiTexture& tex )
|
||||
{
|
||||
return { reinterpret_cast<void*>( tex.nativeTexture().object ),
|
||||
vrTextureTypeFromRhiBackend(),
|
||||
vr::ColorSpace_Auto };
|
||||
break;
|
||||
#if QT_CONFIG( vulkan )
|
||||
case QRhi::Vulkan:
|
||||
{
|
||||
const QRhiVulkanNativeHandles* vulkan_handles
|
||||
= reinterpret_cast<const QRhiVulkanNativeHandles*>(
|
||||
rhi->nativeHandles() );
|
||||
vr::VRVulkanTextureData_t vulkan = {
|
||||
.m_nImage = tex.nativeTexture().object,
|
||||
.m_pDevice = vulkan_handles->dev,
|
||||
.m_pPhysicalDevice = vulkan_handles->physDev,
|
||||
.m_pInstance = vulkan_handles->inst->vkInstance(),
|
||||
.m_pQueue = vulkan_handles->gfxQueue,
|
||||
.m_nQueueFamilyIndex = vulkan_handles->gfxQueueIdx,
|
||||
.m_nWidth = static_cast<uint32_t>( tex.pixelSize().width() ),
|
||||
.m_nHeight = static_cast<uint32_t>( tex.pixelSize().height() ),
|
||||
.m_nFormat = tex.format(),
|
||||
.m_nSampleCount = static_cast<uint32_t>( tex.sampleCount() ),
|
||||
};
|
||||
vrTex.handle = &vulkan;
|
||||
vrTex.eType = vr::TextureType_Vulkan;
|
||||
vrTex.eColorSpace = vr::ColorSpace_Auto;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
qFatal() << "unimplemented backend:" << rhi->backend();
|
||||
throw std::runtime_error( "unimplemented backend" );
|
||||
}
|
||||
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &vrTex );
|
||||
}
|
||||
|
||||
void OverlayController::renderOverlay()
|
||||
@@ -563,13 +580,7 @@ void OverlayController::renderOverlay()
|
||||
m_renderControl.render();
|
||||
m_renderControl.endFrame();
|
||||
|
||||
auto tex = vrTextureFromRhiTexture( *m_pFBTexture );
|
||||
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &tex );
|
||||
|
||||
/*
|
||||
m_openGLContext.functions()->glFlush(); // We need to flush otherwise
|
||||
// the texture may be empty.
|
||||
*/
|
||||
SetOverlayFromQRhiTexture( *m_pFBTexture );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-6
@@ -108,6 +108,12 @@ private:
|
||||
vr::VROverlayHandle_t m_ulOverlayThumbnailHandle
|
||||
= vr::k_ulOverlayHandleInvalid;
|
||||
|
||||
#if QT_CONFIG( vulkan )
|
||||
std::unique_ptr<QVulkanInstance> m_vulkanInstance = nullptr;
|
||||
#endif
|
||||
QQuickRenderControl m_renderControl;
|
||||
QQuickWindow m_window{ &m_renderControl };
|
||||
|
||||
std::optional<vr::ETextureType> m_cached_vr_texture_type;
|
||||
std::unique_ptr<QRhiTexture> m_pFBTexture;
|
||||
std::unique_ptr<QRhiTextureRenderTarget> m_render_target;
|
||||
@@ -163,11 +169,8 @@ private:
|
||||
QJsonObject m_remoteVersionJsonObject;
|
||||
|
||||
public:
|
||||
|
||||
QQuickRenderControl m_renderControl;
|
||||
QQuickWindow m_window{ &m_renderControl };
|
||||
// I know it's an ugly hack to make them public to enable external
|
||||
// access, but I am too lazy to implement getters.
|
||||
// access, but I am too lazy to implement getters.
|
||||
SteamVRTabController m_steamVRTabController;
|
||||
ChaperoneTabController m_chaperoneTabController;
|
||||
MoveCenterTabController m_moveCenterTabController;
|
||||
@@ -191,13 +194,17 @@ private:
|
||||
void processRotationBindings();
|
||||
void processExclusiveInputBinding();
|
||||
|
||||
inline QRhi* rhi()
|
||||
{
|
||||
return m_renderControl.rhi();
|
||||
}
|
||||
|
||||
bool m_exclusiveState = false;
|
||||
bool m_keyPressOneState = false;
|
||||
bool m_keyPressTwoState = false;
|
||||
|
||||
public:
|
||||
vr::ETextureType vrTextureTypeFromRhiBackend();
|
||||
vr::Texture_t vrTextureFromRhiTexture( QRhiTexture& tex );
|
||||
void SetOverlayFromQRhiTexture( QRhiTexture& tex );
|
||||
OverlayController( bool desktopMode, bool noSound, QQmlEngine& qmlEngine );
|
||||
virtual ~OverlayController();
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
<file alias="backarrow">img/common/backarrow.svg</file>
|
||||
<file alias="box_checkmark">img/common/check.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icons">
|
||||
<file alias="thumbicon.png">img/icons/thumbicon.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/microphone">
|
||||
<file alias="on">img/audio/microphone/mic_on.svg</file>
|
||||
<file alias="off">img/audio/microphone/mic_off.svg</file>
|
||||
@@ -65,4 +68,7 @@
|
||||
<file alias="noautoturn.png">img/rotation/noautoturn.png</file>
|
||||
<file alias="noautoturn.svg">img/rotation/noautoturn.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/alarm">
|
||||
<file alias="alarm_activated.png">img/alarm/alarm_activated.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../settings/settings.h"
|
||||
#include "../settings/settings_object.h"
|
||||
#include "../utils/update_rate.h"
|
||||
#include "openvr/ovr_overlay_wrapper.h"
|
||||
#ifdef _WIN32
|
||||
# include "audiomanager/AudioManagerWindows.h"
|
||||
#elif __linux__
|
||||
@@ -87,31 +88,19 @@ void AudioTabController::initStage2( OverlayController* var_parent )
|
||||
return;
|
||||
}
|
||||
|
||||
QImage pushToTalkIcon;
|
||||
Q_ASSERT( pushToTalkIcon.load(
|
||||
QString( "qrc:/res/img/audio/microphone/ptt_notification.png" ) ) );
|
||||
QImage pushToMuteIcon;
|
||||
Q_ASSERT( pushToMuteIcon.load(
|
||||
QString( "qrc:/res/img/audio/microphone/ptt_notification.png" ) ) );
|
||||
m_pushToTalkValues.pushToTalkImg.reset(
|
||||
new QImage( QString( ":/microphone/ptt_notification.png" ) ) );
|
||||
m_pushToTalkValues.pushToMuteImg.reset(
|
||||
new QImage( QString( ":/microphone/ptm_notification.png" ) ) );
|
||||
|
||||
emit defaultProfileDisplay();
|
||||
return;
|
||||
|
||||
auto* rhi = parent->m_renderControl.rhi();
|
||||
m_pushToTalkValues.pushToTalkTex.reset(
|
||||
rhi->newTexture( QRhiTexture::RGBA8, pushToTalkIcon.size(), 1 ) );
|
||||
m_pushToTalkValues.pushToMuteTex.reset(
|
||||
rhi->newTexture( QRhiTexture::RGBA8, pushToTalkIcon.size(), 1 ) );
|
||||
|
||||
auto* pushToTex = m_pushToTalkValues.pushToTalkTex.get();
|
||||
auto* pushToImg = m_pushToTalkValues.pushToTalkImg.get();
|
||||
if ( settings::getSetting( settings::BoolSetting::AUDIO_micReversePtt ) )
|
||||
{
|
||||
pushToTex = m_pushToTalkValues.pushToMuteTex.get();
|
||||
pushToImg = m_pushToTalkValues.pushToMuteImg.get();
|
||||
}
|
||||
|
||||
auto tex = parent->vrTextureFromRhiTexture( *pushToTex );
|
||||
vr::VROverlay()->SetOverlayTexture( m_pushToTalkValues.overlayHandle,
|
||||
&tex );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage( m_pushToTalkValues.overlayHandle,
|
||||
*pushToImg );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_pushToTalkValues.overlayHandle,
|
||||
0.02f );
|
||||
vr::HmdMatrix34_t notificationTransform
|
||||
@@ -356,6 +345,8 @@ void AudioTabController::setMicReversePtt( bool value, bool notify )
|
||||
|
||||
settings::setSetting( settings::BoolSetting::AUDIO_micReversePtt, value );
|
||||
|
||||
// TODO: if reenabled use `ovr_overlay_wrapper::setOverlayFromQImage`
|
||||
// instead
|
||||
if ( value )
|
||||
{
|
||||
// vr::VROverlay()->SetOverlayFromFile(m_ptt_overlayHandle,/*pt_mute*/);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "audiomanager/AudioManager.h"
|
||||
#include <memory>
|
||||
#include <rhi/qrhi.h>
|
||||
#include <QImage>
|
||||
#include "../utils/FrameRateUtils.h"
|
||||
#include "../settings/settings_object.h"
|
||||
|
||||
@@ -116,8 +116,8 @@ private:
|
||||
struct
|
||||
{
|
||||
vr::VROverlayHandle_t overlayHandle = vr::k_ulOverlayHandleInvalid;
|
||||
std::unique_ptr<QRhiTexture> pushToTalkTex;
|
||||
std::unique_ptr<QRhiTexture> pushToMuteTex;
|
||||
std::unique_ptr<QImage> pushToTalkImg;
|
||||
std::unique_ptr<QImage> pushToMuteImg;
|
||||
} m_pushToTalkValues;
|
||||
|
||||
int m_playbackDeviceIndex = -1;
|
||||
|
||||
@@ -1619,8 +1619,22 @@ void ChaperoneTabController::initCenterMarkerOverlay()
|
||||
"" );
|
||||
if ( overlayError == ovr_overlay_wrapper::OverlayError::NoError )
|
||||
{
|
||||
ovr_overlay_wrapper::setOverlayFromFile(
|
||||
m_chaperoneFloorOverlayHandle, m_floorMarkerFN, "" );
|
||||
m_floorMarkers[-3] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermarkl3.png" ) ) );
|
||||
m_floorMarkers[-2] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermarkl2.png" ) ) );
|
||||
m_floorMarkers[-1] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermarkl1.png" ) ) );
|
||||
m_floorMarkers[0] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermark.png" ) ) );
|
||||
m_floorMarkers[1] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermarkr1.png" ) ) );
|
||||
m_floorMarkers[2] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermarkr2.png" ) ) );
|
||||
m_floorMarkers[3] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/chaperone/centermarkr3.png" ) ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_chaperoneFloorOverlayHandle, *m_floorMarkers[0], "" );
|
||||
ovr_overlay_wrapper::setOverlayWidthInMeters(
|
||||
m_chaperoneFloorOverlayHandle, 0.5f );
|
||||
updateCenterMarkerOverlayColor();
|
||||
@@ -1662,57 +1676,25 @@ void ChaperoneTabController::checkCenterMarkerOverlayRotationCount()
|
||||
if ( rotation > 0 )
|
||||
{
|
||||
rotation = rotation + 0.5f;
|
||||
int fullRotation = static_cast<int>( rotation );
|
||||
switch ( fullRotation )
|
||||
{
|
||||
case 0:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermark.png";
|
||||
rotationNext = 0;
|
||||
break;
|
||||
case 1:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermarkr1.png";
|
||||
rotationNext = 1;
|
||||
break;
|
||||
case 2:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermarkr2.png";
|
||||
rotationNext = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermarkr3.png";
|
||||
rotationNext = static_cast<int>( rotation );
|
||||
if ( rotationNext > 3 )
|
||||
rotationNext = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation = rotation + 0.5f;
|
||||
int fullRotation = static_cast<int>( std::floor( rotation ) );
|
||||
switch ( fullRotation )
|
||||
{
|
||||
case 0:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermark.png";
|
||||
rotationNext = 0;
|
||||
break;
|
||||
case -1:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermarkl1.png";
|
||||
rotationNext = -1;
|
||||
break;
|
||||
case -2:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermarkl2.png";
|
||||
rotationNext = -2;
|
||||
break;
|
||||
default:
|
||||
m_floorMarkerFN = "/res/img/chaperone/centermarkl3.png";
|
||||
rotationNext = static_cast<int>( std::floor( rotation ) );
|
||||
if ( rotationNext < -3 )
|
||||
rotationNext = -3;
|
||||
}
|
||||
}
|
||||
|
||||
if ( rotationNext != m_rotationCurrent && m_centerMarkerOverlayIsInit )
|
||||
{
|
||||
m_rotationCurrent = rotationNext;
|
||||
ovr_overlay_wrapper::setOverlayFromFile(
|
||||
m_chaperoneFloorOverlayHandle, m_floorMarkerFN, "" );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_chaperoneFloorOverlayHandle,
|
||||
*m_floorMarkers[rotationNext],
|
||||
"" );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
@@ -379,7 +380,7 @@ private:
|
||||
|
||||
std::vector<ChaperoneProfile> chaperoneProfiles;
|
||||
|
||||
std::string m_floorMarkerFN = "/res/img/chaperone/centermark.png";
|
||||
std::map<int, std::unique_ptr<QImage>> m_floorMarkers;
|
||||
void initCenterMarkerOverlay();
|
||||
void updateCenterMarkerOverlayColor();
|
||||
void checkCenterMarkerOverlayRotationCount();
|
||||
|
||||
@@ -39,29 +39,14 @@ void RotationTabController::initStage2( OverlayController* var_parent )
|
||||
|
||||
return;
|
||||
}
|
||||
m_autoturnValues.autoturnImg.reset(
|
||||
new QImage( QString( ":/rotation/autoturn.png" ) ) );
|
||||
m_autoturnValues.noautoturnImg.reset(
|
||||
new QImage( QString( ":/rotation/noautoturn.png" ) ) );
|
||||
|
||||
constexpr auto autoturnIconFilepath = "/res/img/rotation/autoturn.png";
|
||||
constexpr auto noautoturnIconFilepath = "/res/img/rotation/noautoturn.png";
|
||||
ovr_overlay_wrapper::setOverlayFromQImage( m_autoturnValues.overlayHandle,
|
||||
*m_autoturnValues.autoturnImg );
|
||||
|
||||
const auto autoturnIconFilePath
|
||||
= paths::verifyIconFilePath( autoturnIconFilepath );
|
||||
const auto noautoturnIconFilePath
|
||||
= paths::verifyIconFilePath( noautoturnIconFilepath );
|
||||
|
||||
if ( !autoturnIconFilePath.has_value()
|
||||
|| !noautoturnIconFilePath.has_value() )
|
||||
{
|
||||
emit defaultProfileDisplay();
|
||||
return;
|
||||
}
|
||||
|
||||
m_autoturnValues.autoturnPath = *autoturnIconFilePath;
|
||||
m_autoturnValues.noautoturnPath = *noautoturnIconFilePath;
|
||||
|
||||
auto pushToPath = m_autoturnValues.autoturnPath.c_str();
|
||||
|
||||
vr::VROverlay()->SetOverlayFromFile( m_autoturnValues.overlayHandle,
|
||||
pushToPath );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_autoturnValues.overlayHandle,
|
||||
0.02f );
|
||||
vr::HmdMatrix34_t notificationTransform
|
||||
@@ -677,22 +662,21 @@ void RotationTabController::setAutoTurnEnabled( bool value, bool notify )
|
||||
emit autoTurnEnabledChanged( value );
|
||||
}
|
||||
|
||||
if ( !value )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_autoturnValues.overlayHandle,
|
||||
m_autoturnValues.noautoturnPath.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_autoturnValues.overlayHandle,
|
||||
m_autoturnValues.autoturnPath.c_str() );
|
||||
}
|
||||
|
||||
if ( autoTurnShowNotification()
|
||||
&& getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid )
|
||||
{
|
||||
if ( !value )
|
||||
{
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_autoturnValues.overlayHandle,
|
||||
*m_autoturnValues.noautoturnImg );
|
||||
}
|
||||
else
|
||||
{
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_autoturnValues.overlayHandle, *m_autoturnValues.autoturnImg );
|
||||
}
|
||||
|
||||
vr::VROverlay()->SetOverlayAlpha( getNotificationOverlayHandle(),
|
||||
1.0f );
|
||||
vr::VROverlay()->ShowOverlay( getNotificationOverlayHandle() );
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QImage>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
@@ -99,8 +100,8 @@ private:
|
||||
struct
|
||||
{
|
||||
vr::VROverlayHandle_t overlayHandle = vr::k_ulOverlayHandleInvalid;
|
||||
std::string autoturnPath;
|
||||
std::string noautoturnPath;
|
||||
std::unique_ptr<QImage> autoturnImg;
|
||||
std::unique_ptr<QImage> noautoturnImg;
|
||||
} m_autoturnValues;
|
||||
|
||||
virtual vr::VROverlayHandle_t getNotificationOverlayHandle()
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#include "../keyboard_input/input_sender.h"
|
||||
#include "../settings/settings.h"
|
||||
#include "../utils/update_rate.h"
|
||||
#include "openvr/ovr_overlay_wrapper.h"
|
||||
#include <chrono>
|
||||
#include <qimage.h>
|
||||
#include <thread>
|
||||
|
||||
// application namespace
|
||||
@@ -257,34 +259,36 @@ vr::VROverlayHandle_t UtilitiesTabController::createBatteryOverlay(
|
||||
batteryKey.c_str(), batteryKey.c_str(), &handle );
|
||||
if ( overlayError == vr::VROverlayError_None )
|
||||
{
|
||||
QString batteryIconPath = getBatteryIconPath( 0 );
|
||||
if ( QFile::exists( batteryIconPath ) )
|
||||
m_batteryImgs[0] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/battery/battery_0.png" ) ) );
|
||||
m_batteryImgs[1] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/battery/battery_1.png" ) ) );
|
||||
m_batteryImgs[2] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/battery/battery_2.png" ) ) );
|
||||
m_batteryImgs[3] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/battery/battery_3.png" ) ) );
|
||||
m_batteryImgs[4] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/battery/battery_4.png" ) ) );
|
||||
m_batteryImgs[5] = std::unique_ptr<QImage>(
|
||||
new QImage( QString( ":/battery/battery_5.png" ) ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage( handle, *m_batteryImgs[0] );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( handle, 0.045f );
|
||||
vr::HmdMatrix34_t notificationTransform;
|
||||
if ( style == 1 )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
handle, batteryIconPath.toStdString().c_str() );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( handle, 0.045f );
|
||||
vr::HmdMatrix34_t notificationTransform;
|
||||
if ( style == 1 )
|
||||
{
|
||||
notificationTransform = { { { 1.0f, 0.0f, 0.0f, 0.00f },
|
||||
{ 0.0f, -1.0f, 0.0f, 0.0081f },
|
||||
{ 0.0f, 0.0f, -1.0f, -0.028f } } };
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationTransform = { { { 1.0f, 0.0f, 0.0f, 0.00f },
|
||||
{ 0.0f, -1.0f, 0.0f, 0.0081f },
|
||||
{ 0.0f, 0.0f, -1.0f, -0.0178f } } };
|
||||
}
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
handle, index, ¬ificationTransform );
|
||||
qInfo() << "Created battery overlay for device " << index;
|
||||
notificationTransform = { { { 1.0f, 0.0f, 0.0f, 0.00f },
|
||||
{ 0.0f, -1.0f, 0.0f, 0.0081f },
|
||||
{ 0.0f, 0.0f, -1.0f, -0.028f } } };
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Could not find battery icon \"" << batteryIconPath
|
||||
<< "\"";
|
||||
notificationTransform = { { { 1.0f, 0.0f, 0.0f, 0.00f },
|
||||
{ 0.0f, -1.0f, 0.0f, 0.0081f },
|
||||
{ 0.0f, 0.0f, -1.0f, -0.0178f } } };
|
||||
}
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
handle, index, ¬ificationTransform );
|
||||
qInfo() << "Created battery overlay for device " << index;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -378,19 +382,9 @@ void UtilitiesTabController::handleTrackerBatOvl()
|
||||
qInfo() << "Updating battery overlay for device " << i
|
||||
<< " to " << batteryState << "(" << battery << ")"
|
||||
<< QString::number( m_batteryOverlayHandles[i] );
|
||||
QString batteryIconPath
|
||||
= getBatteryIconPath( batteryState );
|
||||
if ( QFile::exists( batteryIconPath ) )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_batteryOverlayHandles[i],
|
||||
batteryIconPath.toStdString().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Could not find battery icon \""
|
||||
<< batteryIconPath << "\"";
|
||||
}
|
||||
ovr_overlay_wrapper::setOverlayFromQImage(
|
||||
m_batteryOverlayHandles[i],
|
||||
*m_batteryImgs[batteryState] );
|
||||
m_batteryState[i] = batteryState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QTime>
|
||||
#include <QImage>
|
||||
#include <openvr.h>
|
||||
#include <memory>
|
||||
#include "src/keyboard_input/keyboard_input.h"
|
||||
@@ -29,6 +30,7 @@ private:
|
||||
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
|
||||
std::array<std::unique_ptr<QImage>, 6> m_batteryImgs;
|
||||
vr::VROverlayHandle_t m_batteryOverlayHandles[vr::k_unMaxTrackedDeviceCount]
|
||||
= { 0 };
|
||||
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
|
||||
|
||||
@@ -52,30 +52,21 @@ void VideoTabController::initBrightnessOverlay()
|
||||
notifKey.c_str(), notifKey.c_str(), &m_brightnessOverlayHandle );
|
||||
if ( overlayError == vr::VROverlayError_None )
|
||||
{
|
||||
const auto notifIconPath = paths::binaryDirectoryFindFile(
|
||||
video_keys::k_brightnessOverlayFilename );
|
||||
if ( notifIconPath.has_value() )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile( m_brightnessOverlayHandle,
|
||||
notifIconPath->c_str() );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_brightnessOverlayHandle,
|
||||
k_overlayWidth );
|
||||
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, k_hmdDistance } } };
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
m_brightnessOverlayHandle,
|
||||
vr::k_unTrackedDeviceIndex_Hmd,
|
||||
¬ificationTransform );
|
||||
vr::VROverlay()->SetOverlaySortOrder( m_brightnessOverlayHandle,
|
||||
sortMax );
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Could not find brightness overlay \""
|
||||
<< video_keys::k_brightnessOverlayFilename << "\"";
|
||||
}
|
||||
QImage notifIcon( QString( ":/video/dimmer.png" ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage( m_brightnessOverlayHandle,
|
||||
notifIcon );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_brightnessOverlayHandle,
|
||||
k_overlayWidth );
|
||||
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, k_hmdDistance } } };
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
m_brightnessOverlayHandle,
|
||||
vr::k_unTrackedDeviceIndex_Hmd,
|
||||
¬ificationTransform );
|
||||
vr::VROverlay()->SetOverlaySortOrder( m_brightnessOverlayHandle,
|
||||
sortMax );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -95,32 +86,23 @@ void VideoTabController::initColorOverlay()
|
||||
notifKey.c_str(), notifKey.c_str(), &m_colorOverlayHandle );
|
||||
if ( overlayError == vr::VROverlayError_None )
|
||||
{
|
||||
const auto notifIconPath = paths::binaryDirectoryFindFile(
|
||||
video_keys::k_colorOverlayFilename );
|
||||
if ( notifIconPath.has_value() )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile( m_colorOverlayHandle,
|
||||
notifIconPath->c_str() );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_colorOverlayHandle,
|
||||
k_overlayWidth );
|
||||
// position it just slightly further out so we don't have to worry
|
||||
// about render order.
|
||||
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, ( k_hmdDistance - 0.01f ) } } };
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
m_colorOverlayHandle,
|
||||
vr::k_unTrackedDeviceIndex_Hmd,
|
||||
¬ificationTransform );
|
||||
vr::VROverlay()->SetOverlaySortOrder( m_brightnessOverlayHandle,
|
||||
sortMax );
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Could not find Base color overlay: \""
|
||||
<< video_keys::k_colorOverlayFilename << "\"";
|
||||
}
|
||||
QImage notifIcon( QString( ":/video/color.png" ) );
|
||||
ovr_overlay_wrapper::setOverlayFromQImage( m_colorOverlayHandle,
|
||||
notifIcon );
|
||||
vr::VROverlay()->SetOverlayWidthInMeters( m_colorOverlayHandle,
|
||||
k_overlayWidth );
|
||||
// position it just slightly further out so we don't have to worry
|
||||
// about render order.
|
||||
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, ( k_hmdDistance - 0.01f ) } } };
|
||||
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
|
||||
m_colorOverlayHandle,
|
||||
vr::k_unTrackedDeviceIndex_Hmd,
|
||||
¬ificationTransform );
|
||||
vr::VROverlay()->SetOverlaySortOrder( m_brightnessOverlayHandle,
|
||||
sortMax );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user