Skip to content

Commit

Permalink
Hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaer Kazmer committed May 21, 2019
1 parent 46f70ca commit f6bdcd9
Show file tree
Hide file tree
Showing 22 changed files with 404 additions and 296 deletions.
184 changes: 93 additions & 91 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ project(OpenComposite)

include(scripts/pch.cmake)

set(CMAKE_CXX_STANDARD 17)

# === Runtime Switcher ===
include_external_msproject(
RuntimeSwitcher ${CMAKE_SOURCE_DIR}/RuntimeSwitcher/RuntimeSwitcher.csproj
Expand All @@ -33,14 +35,14 @@ endif()
# === LibOVR ===
if(WIN32)

set(OVRDIR libs/libovr/OculusSDK/LibOVR)
add_library(ovr STATIC
${OVRDIR}/Shim/OVR_CAPI_Prototypes.h
${OVRDIR}/Shim/OVR_CAPI_Util.cpp
${OVRDIR}/Shim/OVR_CAPIShim.c
${OVRDIR}/Shim/OVR_StereoProjection.cpp
)
target_include_directories(ovr PUBLIC ${OVRDIR}/Include)
#set(OVRDIR libs/libovr/OculusSDK/LibOVR)
#add_library(ovr STATIC
# ${OVRDIR}/Shim/OVR_CAPI_Prototypes.h
# ${OVRDIR}/Shim/OVR_CAPI_Util.cpp
# ${OVRDIR}/Shim/OVR_CAPIShim.c
# ${OVRDIR}/Shim/OVR_StereoProjection.cpp
#)
#target_include_directories(ovr PUBLIC ${OVRDIR}/Include ${OVRDIR}/../Logging)

# Resource Processor
set(OVR_SHADER_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen_shaders")
Expand All @@ -65,85 +67,85 @@ endfunction()
file(MAKE_DIRECTORY ${OVR_SHADER_DIR}/Shaders)

# === LibOVRKernel ===
set(OVRKDIR libs/libovr/OculusSDK/LibOVRKernel)
set(OVRKSDIR ${OVRKDIR}/Src/Util/Shaders)
add_library(ovrkernel STATIC
${OVRKDIR}/../Logging/src/internal/Logging_Tools.cpp
${OVRKDIR}/../Logging/src/Logging_Library.cpp
${OVRKDIR}/../Logging/src/Logging_OutputPlugins.cpp
${OVRKDIR}/Src/GL/CAPI_GLE.cpp
${OVRKDIR}/Src/Kernel/OVR_Alg.cpp
${OVRKDIR}/Src/Kernel/OVR_Allocator.cpp
${OVRKDIR}/Src/Kernel/OVR_Atomic.cpp
${OVRKDIR}/Src/Kernel/OVR_Callbacks.cpp
${OVRKDIR}/Src/Kernel/OVR_CRC32.cpp
${OVRKDIR}/Src/Kernel/OVR_DebugHelp.cpp
${OVRKDIR}/Src/Kernel/OVR_Error.cpp
${OVRKDIR}/Src/Kernel/OVR_File.cpp
${OVRKDIR}/Src/Kernel/OVR_FileFILE.cpp
${OVRKDIR}/Src/Kernel/OVR_JSON.cpp
${OVRKDIR}/Src/Kernel/OVR_Log.cpp
${OVRKDIR}/Src/Kernel/OVR_mach_exc_OSX.c
${OVRKDIR}/Src/Kernel/OVR_Rand.cpp
${OVRKDIR}/Src/Kernel/OVR_RefCount.cpp
${OVRKDIR}/Src/Kernel/OVR_SharedMemory.cpp
${OVRKDIR}/Src/Kernel/OVR_Std.cpp
${OVRKDIR}/Src/Kernel/OVR_String.cpp
${OVRKDIR}/Src/Kernel/OVR_String_FormatUtil.cpp
${OVRKDIR}/Src/Kernel/OVR_String_PathUtil.cpp
${OVRKDIR}/Src/Kernel/OVR_SysFile.cpp
${OVRKDIR}/Src/Kernel/OVR_System.cpp
${OVRKDIR}/Src/Kernel/OVR_ThreadsPthread.cpp
${OVRKDIR}/Src/Kernel/OVR_ThreadsWinAPI.cpp
${OVRKDIR}/Src/Kernel/OVR_Timer.cpp
${OVRKDIR}/Src/Kernel/OVR_UTF8Util.cpp
${OVRKDIR}/Src/Util/Util_D3D11_Blitter.cpp
${OVRKDIR}/Src/Util/Util_Direct3D.cpp
${OVRKDIR}/Src/Util/Util_GL_Blitter.cpp
${OVRKDIR}/Src/Util/Util_ImageWindow.cpp
${OVRKDIR}/Src/Util/Util_LongPollThread.cpp
${OVRKDIR}/Src/Util/Util_SystemGUI.cpp
${OVRKDIR}/Src/Util/Util_SystemInfo.cpp
${OVRKDIR}/Src/Util/Util_Watchdog.cpp
)
target_include_directories(ovrkernel PUBLIC ${OVRKDIR}/Src)
target_include_directories(ovrkernel PRIVATE ${OVRKDIR}/../Logging/include)
target_link_libraries(ovrkernel ovr)
#set(OVRKDIR libs/libovr/OculusSDK/LibOVRKernel)
#set(OVRKSDIR ${OVRKDIR}/Src/Util/Shaders)
#add_library(ovrkernel STATIC
# ${OVRKDIR}/../Logging/src/internal/Logging_Tools.cpp
# ${OVRKDIR}/../Logging/src/Logging_Library.cpp
# ${OVRKDIR}/../Logging/src/Logging_OutputPlugins.cpp
# ${OVRKDIR}/Src/GL/CAPI_GLE.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Alg.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Allocator.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Atomic.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Callbacks.cpp
# ${OVRKDIR}/Src/Kernel/OVR_CRC32.cpp
# ${OVRKDIR}/Src/Kernel/OVR_DebugHelp.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Error.cpp
# ${OVRKDIR}/Src/Kernel/OVR_File.cpp
# ${OVRKDIR}/Src/Kernel/OVR_FileFILE.cpp
# ${OVRKDIR}/Src/Kernel/OVR_JSON.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Log.cpp
# ${OVRKDIR}/Src/Kernel/OVR_mach_exc_OSX.c
# ${OVRKDIR}/Src/Kernel/OVR_Rand.cpp
# ${OVRKDIR}/Src/Kernel/OVR_RefCount.cpp
# ${OVRKDIR}/Src/Kernel/OVR_SharedMemory.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Std.cpp
# ${OVRKDIR}/Src/Kernel/OVR_String.cpp
# ${OVRKDIR}/Src/Kernel/OVR_String_FormatUtil.cpp
# ${OVRKDIR}/Src/Kernel/OVR_String_PathUtil.cpp
# ${OVRKDIR}/Src/Kernel/OVR_SysFile.cpp
# ${OVRKDIR}/Src/Kernel/OVR_System.cpp
# ${OVRKDIR}/Src/Kernel/OVR_ThreadsPthread.cpp
# ${OVRKDIR}/Src/Kernel/OVR_ThreadsWinAPI.cpp
# ${OVRKDIR}/Src/Kernel/OVR_Timer.cpp
# ${OVRKDIR}/Src/Kernel/OVR_UTF8Util.cpp
# ${OVRKDIR}/Src/Util/Util_D3D11_Blitter.cpp
# ${OVRKDIR}/Src/Util/Util_Direct3D.cpp
# ${OVRKDIR}/Src/Util/Util_GL_Blitter.cpp
# ${OVRKDIR}/Src/Util/Util_ImageWindow.cpp
# ${OVRKDIR}/Src/Util/Util_LongPollThread.cpp
# ${OVRKDIR}/Src/Util/Util_SystemGUI.cpp
# ${OVRKDIR}/Src/Util/Util_SystemInfo.cpp
# ${OVRKDIR}/Src/Util/Util_Watchdog.cpp
#)
#target_include_directories(ovrkernel PUBLIC ${OVRKDIR}/Src)
#target_include_directories(ovrkernel PRIVATE ${OVRKDIR}/../Logging/include)
#target_link_libraries(ovrkernel ovr)

# Shader configuration
target_include_directories(ovrkernel PRIVATE ${OVR_SHADER_DIR})
# target_include_directories(ovrkernel PRIVATE ${OVR_SHADER_DIR})

set(OVRK_BLITTER ${OVRKDIR}/Src/Util/Util_D3D11_Blitter.cpp)
build_fx(${OVRKSDIR}/Blt_ps.hlsl ps_4_0 ${OVRK_BLITTER})
build_fx(${OVRKSDIR}/Blt_ps_ms2.hlsl ps_5_0 ${OVRK_BLITTER})
build_fx(${OVRKSDIR}/Blt_vs.hlsl vs_5_0 ${OVRK_BLITTER})

# === DrvOculus ===
add_library(DrvOculus STATIC
DrvOculus/DrvOculus.cpp
#add_library(DrvOculus STATIC
# DrvOculus/DrvOculus.cpp

DrvOculus/DrvOculusCommon.h
# DrvOculus/DrvOculusCommon.h

DrvOculus/OculusBackend.cpp
DrvOculus/OculusBackend.h
# DrvOculus/OculusBackend.cpp
# DrvOculus/OculusBackend.h

DrvOculus/OculusBackendSubmit.cpp
DrvOculus/OculusBackendMirror.cpp
DrvOculus/OculusBackendGuardian.cpp
# DrvOculus/OculusBackendSubmit.cpp
# DrvOculus/OculusBackendMirror.cpp
# DrvOculus/OculusBackendGuardian.cpp

DrvOculus/pub/DrvOculus.h
# DrvOculus/pub/DrvOculus.h

# Devices
DrvOculus/OculusDevice.cpp
DrvOculus/OculusDevice.h
# DrvOculus/OculusDevice.cpp
# DrvOculus/OculusDevice.h

DrvOculus/OculusHMD.cpp
DrvOculus/OculusHMD.h
)
target_include_directories(DrvOculus PUBLIC DrvOculus/pub)
target_include_directories(DrvOculus PRIVATE DrvOculus)
target_link_libraries(DrvOculus OpenVR ovr ovrkernel)
source_group(Public REGULAR_EXPRESSION DrvOculus/pub/*)
# DrvOculus/OculusHMD.cpp
# DrvOculus/OculusHMD.h
#)
#target_include_directories(DrvOculus PUBLIC DrvOculus/pub)
#target_include_directories(DrvOculus PRIVATE DrvOculus)
#target_link_libraries(DrvOculus OpenVR ovr ovrkernel)
#source_group(Public REGULAR_EXPRESSION DrvOculus/pub/*)

endif (WIN32)

Expand All @@ -163,22 +165,22 @@ add_library(OCCore STATIC
OpenOVR/stdafx.cpp

OpenOVR/API/OCBaseSystem.cpp
OpenOVR/Compositor/compositor.cpp
OpenOVR/Compositor/dx11compositor.cpp
OpenOVR/Compositor/dx10compositor.cpp
OpenOVR/Compositor/dx12compositor.cpp
OpenOVR/Compositor/glcompositor.cpp
OpenOVR/Compositor/vkcompositor.cpp
OpenOVR/convert.cpp
OpenOVR/libovr_wrapper.cpp
#OpenOVR/Compositor/compositor.cpp
#OpenOVR/Compositor/dx11compositor.cpp
#OpenOVR/Compositor/dx10compositor.cpp
#OpenOVR/Compositor/dx12compositor.cpp
#OpenOVR/Compositor/glcompositor.cpp
#OpenOVR/Compositor/vkcompositor.cpp
#OpenOVR/convert.cpp
#OpenOVR/libovr_wrapper.cpp
OpenOVR/logging.cpp
OpenOVR/Misc/audio_override.cpp
OpenOVR/Misc/Config.cpp
OpenOVR/Misc/debug_helper.cpp
OpenOVR/Misc/Haptics.cpp
OpenOVR/Misc/Keyboard/KeyboardLayout.cpp
OpenOVR/Misc/Keyboard/SudoFontMeta.cpp
OpenOVR/Misc/Keyboard/VRKeyboard.cpp
#OpenOVR/Misc/Haptics.cpp
#OpenOVR/Misc/Keyboard/KeyboardLayout.cpp
#OpenOVR/Misc/Keyboard/SudoFontMeta.cpp
#OpenOVR/Misc/Keyboard/VRKeyboard.cpp
OpenOVR/OpenOVR.cpp
OpenOVR/Reimpl/BaseApplications.cpp
OpenOVR/Reimpl/BaseChaperone.cpp
Expand Down Expand Up @@ -224,20 +226,20 @@ add_library(OCCore STATIC
OpenOVR/API/OCBaseSystem.h
OpenOVR/BaseCommon.h
OpenOVR/Compositor/compositor.h
OpenOVR/convert.h
#OpenOVR/convert.h
OpenOVR/custom_types.h
OpenOVR/libovr_wrapper.h
#OpenOVR/libovr_wrapper.h
OpenOVR/logging.h
OpenOVR/Misc/audio_override.h
OpenOVR/Misc/Config.h
OpenOVR/Misc/debug_helper.h
OpenOVR/Misc/Haptics.h
#OpenOVR/Misc/Haptics.h
OpenOVR/Misc/ini.h
OpenOVR/Misc/json/json-forwards.h
OpenOVR/Misc/json/json.h
OpenOVR/Misc/Keyboard/KeyboardLayout.h
OpenOVR/Misc/Keyboard/SudoFontMeta.h
OpenOVR/Misc/Keyboard/VRKeyboard.h
#OpenOVR/Misc/Keyboard/KeyboardLayout.h
#OpenOVR/Misc/Keyboard/SudoFontMeta.h
#OpenOVR/Misc/Keyboard/VRKeyboard.h
OpenOVR/Misc/lodepng.h
OpenOVR/Misc/ScopeGuard.h
OpenOVR/Reimpl/BaseApplications.h
Expand Down Expand Up @@ -325,7 +327,7 @@ add_library(OCCore STATIC
target_include_directories(OCCore PUBLIC OpenOVR) # TODO make this private and put the public headers elsewhere
target_include_directories(OCCore PRIVATE BundledLibs)
target_compile_definitions(OCCore PRIVATE -DSUPPORT_DX -DSUPPORT_GL -DSUPPORT_VK)
target_link_libraries(OCCore OpenVR ovr ovrkernel Vulkan)
target_link_libraries(OCCore OpenVR ovr Vulkan)

# Set up precompiled headers for OCCore
if (WIN32)
Expand All @@ -347,4 +349,4 @@ add_library(OCOVR SHARED
# Resources don't get nicely included in a library file
${OVR_RESOURCES}
)
target_link_libraries(OCOVR OCCore DrvOculus)
target_link_libraries(OCOVR OCCore)
31 changes: 16 additions & 15 deletions OCOVR/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
#include "Reimpl/GVRClientCore.gen.h"

#include "steamvr_abi.h"
#include "libovr_wrapper.h"
// #include "libovr_wrapper.h"
#include "Misc/debug_helper.h"
#include "Misc/audio_override.h"
#include "Misc/Config.h"
#include <map>
#include <memory>

#include "OVR_CAPI_Audio.h"
// #include "OVR_CAPI_Audio.h"

// Specific to OCOVR
#include "Drivers/Backend.h"
#include "Drivers/DriverManager.h"
#include "DrvOculus.h"
// #include "DrvOculus.h"

using namespace std;

static void init_audio();
static void setup_audio();
// static void init_audio();
// static void setup_audio();

HMODULE openovr_module_id;
HMODULE chainedImplementation;
Expand All @@ -41,7 +41,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
#if defined(_DEBUG)
DbgSetModule(hModule);
#endif
init_audio();
// init_audio();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
Expand Down Expand Up @@ -206,25 +206,26 @@ VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2(EVRInitError * peError, EVRAp
if (running)
ERR("Cannot init VR: Already running!");

ovr::Setup();
running_ovr = true;
// ovr::Setup();
// running_ovr = true;

setup_audio();
// setup_audio();

success:
current_apptype = eApplicationType;
running = true;
*peError = VRInitError_None;

// TODO seperate this from the rest of dllmain
BackendManager::Create(DrvOculus::CreateOculusBackend());
// BackendManager::Create(DrvOculus::CreateOculusBackend());
// DriverManager::Instance().Register(DrvOculus::CreateOculusDriver());

return current_init_token;
}

VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent() {
return ovr::IsAvailable();
return true;
// return ovr::IsAvailable();
}

VR_INTERFACE bool VR_CALLTYPE VR_IsInterfaceVersionValid(const char * pchInterfaceVersion) {
Expand All @@ -247,8 +248,8 @@ VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal() {
interfaces.clear();

// Shut down LibOVR
if(running_ovr)
ovr::Shutdown();
/* if(running_ovr)
ovr::Shutdown(); */

running = false;
}
Expand Down Expand Up @@ -331,12 +332,12 @@ void init_audio() {
// This switches over to the audio device returned by LibOVR, which supports
// stuff like audio mirroring. This can only be called after LibOVR is initialised,
// and thus will work on some games and not on others.
void setup_audio() {
/* void setup_audio() {
if (!oovr_global_configuration.EnableAudio())
return;
WCHAR deviceOutStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE];
ovrResult r = ovr_GetAudioDeviceOutGuidStr(deviceOutStrBuffer);
if (r == ovrSuccess)
set_app_default_audio_device(deviceOutStrBuffer);
}
} */
9 changes: 5 additions & 4 deletions OpenOVR/API/OCBaseSystem.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include "stdafx.h"
#include "OCBaseSystem.h"

#include "libovr_wrapper.h"
#include "OVR_CAPI.h"
// #include "libovr_wrapper.h"
// #include "OVR_CAPI.h"

#include "ISystem_001.h"
using EVRExtendedButtonId = ocapi::IVROCSystem_001::EVRExtendedButtonId;

uint64_t OCBaseSystem::GetExtendedButtonStatus() {
uint64_t val = 0;
return 0;
/* uint64_t val = 0;
ovrInputState inputState;
ovrResult result = ovr_GetInputState(*ovr::session, ovrControllerType_Touch, &inputState);
Expand All @@ -23,5 +24,5 @@ uint64_t OCBaseSystem::GetExtendedButtonStatus() {
val |= vr::ButtonMaskFromId((vr::EVRButtonId) EVRExtendedButtonId::k_EButton_OVRMenu);
}
return val;
return val; */
}
2 changes: 2 additions & 0 deletions OpenOVR/BaseCommon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once
#include "OpenVR/interfaces/vrtypes.h"
#include <memory>
#include <iostream>

class CVRCommon {
public:
Expand Down
2 changes: 1 addition & 1 deletion OpenOVR/Compositor/compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <wrl/client.h>
#include <atlbase.h>

#include <Extras/OVR_Math.h>
// #include <Extras/OVR_Math.h>

#include <vector>
#include <memory>
Expand Down
Loading

0 comments on commit f6bdcd9

Please sign in to comment.