A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
OpenVRExpansionPlugin.cpp
Go to the documentation of this file.
1// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2
5
6#define LOCTEXT_NAMESPACE "FVRExpansionPluginModule"
7
9{
10 // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
11 //LoadOpenVRModule();
12}
13
15{
16 // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
17 // we call this function before unloading the module.
18// UnloadOpenVRModule();
19}
20
21/*bool FOpenVRExpansionPluginModule::LoadOpenVRModule()
22{
23#if !STEAMVR_SUPPORTED_PLATFORM
24 return false;
25#else
26#if PLATFORM_WINDOWS
27#if PLATFORM_64BITS
28
29 FString RootOpenVRPath;
30 TCHAR VROverridePath[MAX_PATH];
31 FPlatformMisc::GetEnvironmentVariable(TEXT("VR_OVERRIDE"), VROverridePath, MAX_PATH);
32
33 if (FCString::Strlen(VROverridePath) > 0)
34 {
35 RootOpenVRPath = FString::Printf(TEXT("%s\\bin\\win64\\"), VROverridePath);
36 }
37 else
38 {
39 RootOpenVRPath = FPaths::EngineDir() / FString::Printf(TEXT("Binaries/ThirdParty/OpenVR/%s/Win64/"), OPENVR_SDK_VER);
40 }
41
42 FPlatformProcess::PushDllDirectory(*RootOpenVRPath);
43 OpenVRDLLHandle = FPlatformProcess::GetDllHandle(*(RootOpenVRPath + "openvr_api.dll"));
44 FPlatformProcess::PopDllDirectory(*RootOpenVRPath);
45#else
46 FString RootOpenVRPath = FPaths::EngineDir() / FString::Printf(TEXT("Binaries/ThirdParty/OpenVR/%s/Win32/"), OPENVR_SDK_VER);
47 FPlatformProcess::PushDllDirectory(*RootOpenVRPath);
48 OpenVRDLLHandle = FPlatformProcess::GetDllHandle(*(RootOpenVRPath + "openvr_api.dll"));
49 FPlatformProcess::PopDllDirectory(*RootOpenVRPath);
50#endif
51#elif PLATFORM_MAC
52 OpenVRDLLHandle = FPlatformProcess::GetDllHandle(TEXT("libopenvr_api.dylib"));
53
54#elif PLATFORM_LINUX
55 FString RootOpenVRPath = FPaths::EngineDir() / FString::Printf(TEXT("Binaries/ThirdParty/OpenVR/%s/linux64/"), OPENVR_SDK_VER);
56 OpenVRDLLHandle = FPlatformProcess::GetDllHandle(*(RootOpenVRPath + "libopenvr_api.so"));
57#else
58 #error "SteamVRHMD is not supported for this platform."
59#endif //PLATFORM_WINDOWS
60
61 if (!OpenVRDLLHandle)
62 {
63 //UE_LOG(OpenVRExpansionFunctionLibraryLog, Warning, TEXT("Failed to load OpenVR library."));
64 return false;
65 }
66
67 //@todo steamvr: Remove GetProcAddress() workaround once we update to Steamworks 1.33 or higher
68 //VRInitFn = (pVRInit)FPlatformProcess::GetDllExport(OpenVRDLLHandle, TEXT("VR_Init"));
69 //VRShutdownFn = (pVRShutdown)FPlatformProcess::GetDllExport(OpenVRDLLHandle, TEXT("VR_Shutdown"));
70 //VRIsHmdPresentFn = (pVRIsHmdPresent)FPlatformProcess::GetDllExport(OpenVRDLLHandle, TEXT("VR_IsHmdPresent"));
71 //VRGetStringForHmdErrorFn = (pVRGetStringForHmdError)FPlatformProcess::GetDllExport(OpenVRDLLHandle, TEXT("VR_GetStringForHmdError"));
72 UOpenVRExpansionFunctionLibrary::VRGetGenericInterfaceFn = (pVRGetGenericInterface)FPlatformProcess::GetDllExport(OpenVRDLLHandle, TEXT("VR_GetGenericInterface"));
73
74 if (!UOpenVRExpansionFunctionLibrary::VRGetGenericInterfaceFn)
75 {
76 //UE_LOG(OpenVRExpansionFunctionLibraryLog, Warning, TEXT("Failed to GetProcAddress() on openvr_api.dll"));
77 UnloadOpenVRModule();
78 return false;
79 }
80
81 return true;
82#endif
83}*/
84
85/*void FOpenVRExpansionPluginModule::UnloadOpenVRModule()
86{
87#if STEAMVR_SUPPORTED_PLATFORM
88 if (OpenVRDLLHandle != nullptr)
89 {
90 FPlatformProcess::FreeDllHandle(OpenVRDLLHandle);
91 OpenVRDLLHandle = nullptr;
92 //(*VRShutdownFn)();
93 }
94
95 UOpenVRExpansionFunctionLibrary::VRGetGenericInterfaceFn = nullptr;
96#endif
97}*/
98
99#undef LOCTEXT_NAMESPACE
100
IMPLEMENT_MODULE(FOpenXRExpansionEditorModule, OpenXRExpansionEditor)
virtual void StartupModule() override
virtual void ShutdownModule() override