mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:49:27 +02:00
Add support for querying the desired output audio device for OpenVR
This commit is contained in:
parent
cbff1910e2
commit
c3f664502a
5 changed files with 53 additions and 2 deletions
|
@ -10,10 +10,10 @@ if (WIN32)
|
||||||
# we're using static GLEW, so define GLEW_STATIC
|
# we're using static GLEW, so define GLEW_STATIC
|
||||||
add_definitions(-DGLEW_STATIC)
|
add_definitions(-DGLEW_STATIC)
|
||||||
set(TARGET_NAME openvr)
|
set(TARGET_NAME openvr)
|
||||||
setup_hifi_plugin(OpenGL Script Qml Widgets)
|
setup_hifi_plugin(OpenGL Script Qml Widgets Multimedia)
|
||||||
link_hifi_libraries(shared gl networking controllers ui
|
link_hifi_libraries(shared gl networking controllers ui
|
||||||
plugins display-plugins ui-plugins input-plugins script-engine
|
plugins display-plugins ui-plugins input-plugins script-engine
|
||||||
render-utils model gpu gpu-gl render model-networking fbx ktx image procedural)
|
audio-client render-utils model gpu gpu-gl render model-networking fbx ktx image procedural)
|
||||||
|
|
||||||
include_hifi_library_headers(octree)
|
include_hifi_library_headers(octree)
|
||||||
|
|
||||||
|
@ -21,4 +21,5 @@ if (WIN32)
|
||||||
find_package(OpenVR REQUIRED)
|
find_package(OpenVR REQUIRED)
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${OPENVR_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} PRIVATE ${OPENVR_INCLUDE_DIRS})
|
||||||
target_link_libraries(${TARGET_NAME} ${OPENVR_LIBRARIES})
|
target_link_libraries(${TARGET_NAME} ${OPENVR_LIBRARIES})
|
||||||
|
target_link_libraries(${TARGET_NAME} Winmm.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
//
|
//
|
||||||
#include "OpenVrDisplayPlugin.h"
|
#include "OpenVrDisplayPlugin.h"
|
||||||
|
|
||||||
|
// Odd ordering of header is required to avoid 'macro redinition warnings'
|
||||||
|
#include <AudioClient.h>
|
||||||
|
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
#include <QtCore/QLoggingCategory>
|
#include <QtCore/QLoggingCategory>
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
@ -713,3 +716,30 @@ bool OpenVrDisplayPlugin::isKeyboardVisible() {
|
||||||
int OpenVrDisplayPlugin::getRequiredThreadCount() const {
|
int OpenVrDisplayPlugin::getRequiredThreadCount() const {
|
||||||
return Parent::getRequiredThreadCount() + (_threadedSubmit ? 1 : 0);
|
return Parent::getRequiredThreadCount() + (_threadedSubmit ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString OpenVrDisplayPlugin::getPreferredAudioInDevice() const {
|
||||||
|
QString device = getVrSettingString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackDevice_String);
|
||||||
|
if (!device.isEmpty()) {
|
||||||
|
static const WCHAR INIT = 0;
|
||||||
|
size_t size = device.size() + 1;
|
||||||
|
std::vector<WCHAR> deviceW;
|
||||||
|
deviceW.assign(size, INIT);
|
||||||
|
device.toWCharArray(deviceW.data());
|
||||||
|
device = AudioClient::friendlyNameForAudioDevice(deviceW.data());
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OpenVrDisplayPlugin::getPreferredAudioOutDevice() const {
|
||||||
|
QString device = getVrSettingString(vr::k_pch_audio_Section, vr::k_pch_audio_OnRecordDevice_String);
|
||||||
|
if (!device.isEmpty()) {
|
||||||
|
static const WCHAR INIT = 0;
|
||||||
|
size_t size = device.size() + 1;
|
||||||
|
std::vector<WCHAR> deviceW;
|
||||||
|
deviceW.assign(size, INIT);
|
||||||
|
device.toWCharArray(deviceW.data());
|
||||||
|
device = AudioClient::friendlyNameForAudioDevice(deviceW.data());
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@ public:
|
||||||
// Possibly needs an additional thread for VR submission
|
// Possibly needs an additional thread for VR submission
|
||||||
int getRequiredThreadCount() const override;
|
int getRequiredThreadCount() const override;
|
||||||
|
|
||||||
|
QString getPreferredAudioInDevice() const override;
|
||||||
|
QString getPreferredAudioOutDevice() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool internalActivate() override;
|
bool internalActivate() override;
|
||||||
void internalDeactivate() override;
|
void internalDeactivate() override;
|
||||||
|
|
|
@ -72,6 +72,21 @@ bool openVrSupported() {
|
||||||
return (enableDebugOpenVR || !isOculusPresent()) && vr::VR_IsHmdPresent();
|
return (enableDebugOpenVR || !isOculusPresent()) && vr::VR_IsHmdPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString getVrSettingString(const char* section, const char* setting) {
|
||||||
|
QString result;
|
||||||
|
static const uint32_t BUFFER_SIZE = 1024;
|
||||||
|
static char BUFFER[BUFFER_SIZE];
|
||||||
|
vr::IVRSettings * vrSettings = vr::VRSettings();
|
||||||
|
if (vrSettings) {
|
||||||
|
vr::EVRSettingsError error = vr::VRSettingsError_None;
|
||||||
|
vrSettings->GetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackDevice_String, BUFFER, BUFFER_SIZE, &error);
|
||||||
|
if (error == vr::VRSettingsError_None) {
|
||||||
|
result = BUFFER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
vr::IVRSystem* acquireOpenVrSystem() {
|
vr::IVRSystem* acquireOpenVrSystem() {
|
||||||
bool hmdPresent = vr::VR_IsHmdPresent();
|
bool hmdPresent = vr::VR_IsHmdPresent();
|
||||||
if (hmdPresent) {
|
if (hmdPresent) {
|
||||||
|
@ -82,6 +97,7 @@ vr::IVRSystem* acquireOpenVrSystem() {
|
||||||
#endif
|
#endif
|
||||||
vr::EVRInitError eError = vr::VRInitError_None;
|
vr::EVRInitError eError = vr::VRInitError_None;
|
||||||
activeHmd = vr::VR_Init(&eError, vr::VRApplication_Scene);
|
activeHmd = vr::VR_Init(&eError, vr::VRApplication_Scene);
|
||||||
|
|
||||||
#if DEV_BUILD
|
#if DEV_BUILD
|
||||||
qCDebug(displayplugins) << "OpenVR display: HMD is " << activeHmd << " error is " << eError;
|
qCDebug(displayplugins) << "OpenVR display: HMD is " << activeHmd << " error is " << eError;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,6 +25,7 @@ bool openVrQuitRequested();
|
||||||
void enableOpenVrKeyboard(PluginContainer* container);
|
void enableOpenVrKeyboard(PluginContainer* container);
|
||||||
void disableOpenVrKeyboard();
|
void disableOpenVrKeyboard();
|
||||||
bool isOpenVrKeyboardShown();
|
bool isOpenVrKeyboardShown();
|
||||||
|
QString getVrSettingString(const char* section, const char* setting);
|
||||||
|
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
|
|
Loading…
Reference in a new issue