diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90fd257 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +generated diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..73126c3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.2) +project(OpenPSVR VERSION 0.1.0) + +set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) + +LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +set(CMAKE_CXX_STANDARD_17) +set(CMAKE_CXX_STANDARD_REQUIRED_ON) +IF (NOT MSVC) + set(CMAKE_CXX_FLAGS "-std=c++11") + IF (NOT CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + ENDIF() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch") +ENDIF() + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +add_subdirectory(src) diff --git a/OpenPSVR.sln b/OpenPSVR.sln deleted file mode 100644 index fc6ef06..0000000 --- a/OpenPSVR.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenPSVR", "OpenPSVR.vcxproj", "{704E455A-EA25-4090-9DAF-30AD9B4862EF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Debug|x64.ActiveCfg = Debug|x64 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Debug|x64.Build.0 = Debug|x64 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Debug|x86.ActiveCfg = Debug|Win32 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Debug|x86.Build.0 = Debug|Win32 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Release|x64.ActiveCfg = Release|x64 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Release|x64.Build.0 = Release|x64 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Release|x86.ActiveCfg = Release|Win32 - {704E455A-EA25-4090-9DAF-30AD9B4862EF}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {16717DEB-0305-4737-B8FA-B43D819897FF} - EndGlobalSection -EndGlobal diff --git a/OpenPSVR.vcxproj b/OpenPSVR.vcxproj deleted file mode 100644 index fd30eac..0000000 --- a/OpenPSVR.vcxproj +++ /dev/null @@ -1,242 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 15.0 - {704E455A-EA25-4090-9DAF-30AD9B4862EF} - Win32Proj - OpenPSVR - 10.0.16299.0 - - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - true - $(ProjectDir)3rdParty\glm\glm;$(ProjectDir)3rdParty\libpsvr\include;$(ProjectDir)3rdParty\libusb\libusb;$(ProjectDir)3rdParty\openvr\headers;$(IncludePath) - $(ProjectDir)3rdParty\libpsvr\LibPSVR\Debug\lib;$(ProjectDir)3rdParty\libusb\Win32\Debug\lib;$(ProjectDir)3rdParty\openvr\lib\win32;$(LibraryPath) - Clean - - - true - $(ProjectDir)3rdParty\glm\glm;$(ProjectDir)3rdParty\libpsvr\include;$(ProjectDir)3rdParty\libusb\libusb;$(ProjectDir)3rdParty\openvr\headers;$(IncludePath) - $(ProjectDir)3rdParty\libpsvr\LibPSVR\x64\Debug\lib;$(ProjectDir)3rdParty\libusb\x64\Debug\lib;$(ProjectDir)3rdParty\openvr\lib\win64;$(LibraryPath) - Clean - - - false - $(ProjectDir)3rdParty\glm\glm;$(ProjectDir)3rdParty\libpsvr\include;$(ProjectDir)3rdParty\libusb\libusb;$(ProjectDir)3rdParty\openvr\headers;$(IncludePath) - $(ProjectDir)3rdParty\libpsvr\LibPSVR\Release\lib;$(ProjectDir)3rdParty\libusb\Win32\Release\lib;$(ProjectDir)3rdParty\openvr\lib\win32;$(LibraryPath) - Clean - - - false - $(ProjectDir)3rdParty\glm\glm;$(ProjectDir)3rdParty\libpsvr\include;$(ProjectDir)3rdParty\libusb\libusb;$(ProjectDir)3rdParty\openvr\headers;$(IncludePath) - $(ProjectDir)3rdParty\libpsvr\LibPSVR\x64\Release\lib;$(ProjectDir)3rdParty\libusb\x64\Release\lib;$(ProjectDir)3rdParty\openvr\lib\win64;$(LibraryPath) - Clean - - - - NotUsing - Level3 - Disabled - true - WIN32;_DEBUG;OPENPSVR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - - - - - Windows - true - LibPSVR.lib;libusb-1.0.lib;openvr_api.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - mkdir "$(InstallDir)\bin\$(Platform)" -copy "$(OutDir)$(TargetName)$(TargetExt)" "$(InstallDir)\bin\$(Platform)\driver_$(TargetName)$(TargetExt)" -xcopy /s /i /y "$(ProjectDir)driver" "$(InstallDir)" - - - - - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;OPENPSVR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - - - - - Windows - true - LibPSVR.lib;libusb-1.0.lib;openvr_api.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - mkdir "$(InstallDir)\bin\Win64" -copy "$(OutDir)$(TargetName)$(TargetExt)" "$(InstallDir)\bin\Win64\driver_$(TargetName)$(TargetExt)" -xcopy /s /i /y "$(ProjectDir)driver" "$(InstallDir)" - - - - - - - - - NotUsing - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;OPENPSVR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - LibPSVR.lib;libusb-1.0.lib;openvr_api.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - mkdir "$(InstallDir)\bin\$(Platform)" -copy "$(OutDir)$(TargetName)$(TargetExt)" "$(InstallDir)\bin\$(Platform)\driver_$(TargetName)$(TargetExt)" -xcopy /s /i /y "$(ProjectDir)driver" "$(InstallDir)" - - - - - - - - - NotUsing - Level3 - MaxSpeed - true - true - true - NDEBUG;OPENPSVR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - LibPSVR.lib;libusb-1.0.lib;openvr_api.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - mkdir "$(InstallDir)\bin\Win64" -copy "$(OutDir)$(TargetName)$(TargetExt)" "$(InstallDir)\bin\Win64\driver_$(TargetName)$(TargetExt)" -xcopy /s /i /y "$(ProjectDir)driver" "$(InstallDir)" - - - - - - - - - - \ No newline at end of file diff --git a/OpenPSVR.vcxproj.filters b/OpenPSVR.vcxproj.filters deleted file mode 100644 index a439bb5..0000000 --- a/OpenPSVR.vcxproj.filters +++ /dev/null @@ -1,92 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {444bb1c2-1f5f-4cdc-b13e-5d59e2d0746e} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Driver - - - Driver - - - Driver - - - \ No newline at end of file diff --git a/OpenPSVR.vcxproj.user b/OpenPSVR.vcxproj.user deleted file mode 100644 index fbc2416..0000000 --- a/OpenPSVR.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - D:\Program Files %28x86%29\Steam\steamapps\common\SteamVR\bin\win32\vrserver.exe - WindowsLocalDebugger - - - D:\Program Files %28x86%29\Steam\steamapps\common\SteamVR\bin\win32\vrserver.exe - WindowsLocalDebugger - - - D:\Program Files %28x86%29\Steam\steamapps\common\SteamVR\bin\win64\vrserver.exe - WindowsLocalDebugger - - - D:\Program Files %28x86%29\Steam\steamapps\common\SteamVR\bin\win64\vrserver.exe - WindowsLocalDebugger - - \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..9bd41c1 --- /dev/null +++ b/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +#Function to build driver +buildDriver(){ + local BUILD_TYPE=$1 + cd generated + cmake --build . --target install --config $BUILD_TYPE || return $? + echo BUILD SUCCESS + echo -e "\E[1;32mBUILD SUCCESS\E[;0m"; + exit 0 +} + +#Function to handle errors +function handleError() { + error_msg="BUILD FAILED" + echo -e "\E[1;31m$error_msg\E[;0m"; + exit 1; +} + + +# this will trap any errors or commands with non-zero exit status +# by calling function catch_errors() +trap handleError ERR; + +#Main entry point +buildDriver diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..12ff87d --- /dev/null +++ b/generate.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -eE +########################################################################### +# Author: Stephen O'Hair +# +# Purpose: Generates the openpsvr driver make project files for use on linux. +########################################################################### + +# Initialise +PROJECT_ROOT=$PWD + +#Function loads configuration properties and generates project files +main(){ + # Generate the project files for PSMoveService + generateProjectFiles || return $? + + # Exit batch script successfully + echo -e "\E[1;32mBUILD SUCCESS\E[;0m"; + exit 0 +} + +#Function generates project files for the configured ide +generateProjectFiles(){ + if [ ! -d "$PROJECT_ROOT/generated" ]; then + mkdir $PROJECT_ROOT/generated + fi + echo "Generating OpenPSVR Project files..." + echo "Running cmake in $PROJECT_ROOT" + cd $PROJECT_ROOT/generated + cmake .. -G "Unix Makefiles" +} + +#Function to handle errors +function handleError() { + error_msg="GENERATE FAILED" + echo -e "\E[1;31m$error_msg\E[;0m"; + exit 1; +} + + +# this will trap any errors or commands with non-zero exit status +# by calling function catch_errors() +trap handleError ERR; + +# entry point of script +main diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..311ca20 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,92 @@ +cmake_minimum_required(VERSION 3.0) + +# initialise variables +set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..) +set(PROJECT_SRC_DIR ${ROOT_DIR}/src) +set(TARGET_BUILD_DIR ${ROOT_DIR}/build) + +# 3rd Party library and header paths +set(THIRD_PARTY ${ROOT_DIR}/3rdParty) +set(OPENVR_INCL_DIRS ${THIRD_PARTY}/openvr/headers) +set(GLM_INCL_DIRS ${THIRD_PARTY}/glm/glm) +set(LIBPSVR_INCL_DIRS ${THIRD_PARTY}/libpsvr/include) +set(LIBUSB_INCL_DIRS ${THIRD_PARTY}/libusb/libusb) +set(OPENVR_REQ_LIBS ${THIRD_PARTY}/openvr/lib/linux64) + +# Set OpenPSVR's project source files +add_library(OpenPSVR SHARED ${PROJECT_SRC_DIR}/BMI055Integrator.cpp + ${PROJECT_SRC_DIR}/BMI055Integrator.h + ${PROJECT_SRC_DIR}/BMI055MadgwickAHRS.cpp + ${PROJECT_SRC_DIR}/BMI055MadgwickAHRS.h + ${PROJECT_SRC_DIR}/driverlog.cpp + ${PROJECT_SRC_DIR}/driverlog.h + ${PROJECT_SRC_DIR}/MadgwickAHRS.cpp + ${PROJECT_SRC_DIR}/MadgwickAHRS.h + ${PROJECT_SRC_DIR}/MahonyAHRS.cpp + ${PROJECT_SRC_DIR}/MahonyAHRS.h + ${PROJECT_SRC_DIR}/OpenPSVR.cpp + ${PROJECT_SRC_DIR}/OpenPSVR.h + ${PROJECT_SRC_DIR}/OpenPSVRDeviceDriver.cpp + ${PROJECT_SRC_DIR}/OpenPSVRDeviceDriver.h + ${PROJECT_SRC_DIR}/ServerDriver_OpenPSVR.cpp + ${PROJECT_SRC_DIR}/ServerDriver_OpenPSVR.h + ${PROJECT_SRC_DIR}/WatchdogDriver_OpenPSVR.cpp + ${PROJECT_SRC_DIR}/WatchdogDriver_OpenPSVR.h +) + +# Set OpenPSVR's required include directories +target_include_directories(OpenPSVR PUBLIC ${OPENVR_INCL_DIRS} + ${GLM_INCL_DIRS} + ${LIBUSB_INCL_DIRS} + ${LIBPSVR_INCL_DIRS} +) + +# Set OpenPSVR's required libraries +target_link_libraries(OpenPSVR ${OPENVR_REQ_LIBS}) + +# Shared architecture label used for install folder locations +if (${CMAKE_C_SIZEOF_DATA_PTR} EQUAL 8) + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(ARCH_LABEL "Win64") + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(ARCH_LABEL "OSX64") + else() + set(ARCH_LABEL "Linux64") + endif() +else() + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(ARCH_LABEL "Win32") + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(ARCH_LABEL "OSX32") + else() + set(ARCH_LABEL "Linux32") + endif() +endif() + +# Define OpenPSVR install target +install(TARGETS OpenPSVR + RUNTIME DESTINATION ${TARGET_BUILD_DIR}/${ARCH_LABEL}/openpsvr + LIBRARY DESTINATION ${TARGET_BUILD_DIR}/${ARCH_LABEL}/lib + ARCHIVE DESTINATION ${TARGET_BUILD_DIR}/${ARCH_LABEL}/lib +) + +# Copy driver vr manifest +install( + FILES ${ROOT_DIR}/driver/driver.vrdrivermanifest + DESTINATION ${TARGET_BUILD_DIR}/${ARCH_LABEL}/openpsvr +) + +# Copy driver icon resources +install( + DIRECTORY ${ROOT_DIR}/driver/resources/icons + DESTINATION ${TARGET_BUILD_DIR}/${ARCH_LABEL}/openpsvr/resources + FILES_MATCHING PATTERN "*.png" +) + +# Copy the driver default settings +install( + DIRECTORY ${ROOT_DIR}/driver/resources/settings + DESTINATION ${TARGET_BUILD_DIR}/${ARCH_LABEL}/openpsvr/resources + FILES_MATCHING PATTERN "*.vrsettings" +) + diff --git a/src/OpenPSVR.cpp b/src/OpenPSVR.cpp index 46075fc..ea3c4c6 100644 Binary files a/src/OpenPSVR.cpp and b/src/OpenPSVR.cpp differ diff --git a/src/OpenPSVRDeviceDriver.cpp b/src/OpenPSVRDeviceDriver.cpp index cdbb554..841e053 100644 --- a/src/OpenPSVRDeviceDriver.cpp +++ b/src/OpenPSVRDeviceDriver.cpp @@ -230,9 +230,11 @@ void COpenPSVRDeviceDriver::Deactivate() { void COpenPSVRDeviceDriver::EnterStandby() {} void * COpenPSVRDeviceDriver::GetComponent(const char * pchComponentNameAndVersion) { +#if defined( _WINDOWS ) if (!_stricmp(pchComponentNameAndVersion, vr::IVRDisplayComponent_Version)) { return (vr::IVRDisplayComponent*)this; } +#endif // override this to add a component to a driver return nullptr; @@ -572,4 +574,4 @@ BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMoni return true; } -#endif \ No newline at end of file +#endif diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 7fe4734..a5cb3ac 100644 Binary files a/src/dllmain.cpp and b/src/dllmain.cpp differ