mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01: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
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
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
|
||||
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)
|
||||
|
||||
|
@ -21,4 +21,5 @@ if (WIN32)
|
|||
find_package(OpenVR REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${OPENVR_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_NAME} ${OPENVR_LIBRARIES})
|
||||
target_link_libraries(${TARGET_NAME} Winmm.lib)
|
||||
endif()
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
//
|
||||
#include "OpenVrDisplayPlugin.h"
|
||||
|
||||
// Odd ordering of header is required to avoid 'macro redinition warnings'
|
||||
#include <AudioClient.h>
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QLoggingCategory>
|
||||
#include <QtCore/QFileInfo>
|
||||
|
@ -713,3 +716,30 @@ bool OpenVrDisplayPlugin::isKeyboardVisible() {
|
|||
int OpenVrDisplayPlugin::getRequiredThreadCount() const {
|
||||
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
|
||||
int getRequiredThreadCount() const override;
|
||||
|
||||
QString getPreferredAudioInDevice() const override;
|
||||
QString getPreferredAudioOutDevice() const override;
|
||||
|
||||
protected:
|
||||
bool internalActivate() override;
|
||||
void internalDeactivate() override;
|
||||
|
|
|
@ -72,6 +72,21 @@ bool openVrSupported() {
|
|||
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() {
|
||||
bool hmdPresent = vr::VR_IsHmdPresent();
|
||||
if (hmdPresent) {
|
||||
|
@ -82,6 +97,7 @@ vr::IVRSystem* acquireOpenVrSystem() {
|
|||
#endif
|
||||
vr::EVRInitError eError = vr::VRInitError_None;
|
||||
activeHmd = vr::VR_Init(&eError, vr::VRApplication_Scene);
|
||||
|
||||
#if DEV_BUILD
|
||||
qCDebug(displayplugins) << "OpenVR display: HMD is " << activeHmd << " error is " << eError;
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,7 @@ bool openVrQuitRequested();
|
|||
void enableOpenVrKeyboard(PluginContainer* container);
|
||||
void disableOpenVrKeyboard();
|
||||
bool isOpenVrKeyboardShown();
|
||||
QString getVrSettingString(const char* section, const char* setting);
|
||||
|
||||
|
||||
template<typename F>
|
||||
|
|
Loading…
Reference in a new issue