├── .idea
├── vcs.xml
├── modules.xml
├── misc.xml
└── vrpn-openvr.iml
├── .gitmodules
├── VRPN-OpenVR
├── vrpn_Tracker_OpenVR_HMD.cpp
├── vrpn_Tracker_OpenVR_HMD.h
├── vrpn_Tracker_OpenVR.h
├── vrpn_Tracker_OpenVR_Controller.h
├── main.cpp
├── vrpn_Server_OpenVR.h
├── VRPN-OpenVR.vcxproj.filters
├── vrpn_Tracker_OpenVR_Controller.cpp
├── vrpn_Tracker_OpenVR.cpp
├── vrpn_Server_OpenVR.cpp
└── VRPN-OpenVR.vcxproj
├── CMakeLists.txt
├── OpenVR
├── OpenVR.vcxitems.filters
└── OpenVR.vcxitems
├── README.md
├── .gitattributes
├── VRPN-OpenVR.sln
└── .gitignore
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "vendor/openvr"]
2 | path = vendor/openvr
3 | url = https://github.com/ValveSoftware/openvr.git
4 | [submodule "vendor/vrpn"]
5 | path = vendor/vrpn
6 | url=https://github.com/sat-metalab/vrpn.git
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/VRPN-OpenVR/vrpn_Tracker_OpenVR_HMD.cpp:
--------------------------------------------------------------------------------
1 | #include "vrpn_Tracker_OpenVR_HMD.h"
2 |
3 | vrpn_Tracker_OpenVR_HMD::vrpn_Tracker_OpenVR_HMD(const std::string& name, vrpn_Connection* connection, vr::IVRSystem * vr) :
4 | vrpn_Tracker_OpenVR(name.c_str(), connection, vr)
5 | {
6 | }
7 |
8 | void vrpn_Tracker_OpenVR_HMD::mainloop() {
9 | vrpn_Tracker_OpenVR::mainloop();
10 | }
--------------------------------------------------------------------------------
/VRPN-OpenVR/vrpn_Tracker_OpenVR_HMD.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include "vrpn_Tracker_OpenVR.h"
6 |
7 | class vrpn_Tracker_OpenVR_HMD :
8 | public vrpn_Tracker_OpenVR
9 | {
10 | public:
11 | vrpn_Tracker_OpenVR_HMD() = delete;
12 | vrpn_Tracker_OpenVR_HMD(const std::string& name, vrpn_Connection* connection, vr::IVRSystem * vr);
13 | void mainloop();
14 | private:
15 | };
16 |
17 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | project(VRPN-OpenVR)
4 |
5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
6 |
7 | include_directories(
8 | vendor/openvr/headers
9 | vendor/vrpn/quat
10 | vendor/vrpn
11 | )
12 |
13 | add_executable(shingles
14 | VRPN-OpenVR/main.cpp
15 | VRPN-OpenVR/vrpn_Server_OpenVR.cpp
16 | VRPN-OpenVR/vrpn_Tracker_OpenVR.cpp
17 | VRPN-OpenVR/vrpn_Tracker_OpenVR_HMD.cpp
18 | VRPN-OpenVR/vrpn_Tracker_OpenVR_Controller.cpp
19 | )
--------------------------------------------------------------------------------
/VRPN-OpenVR/vrpn_Tracker_OpenVR.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | class vrpn_Tracker_OpenVR :
9 | public vrpn_Tracker
10 | {
11 | public:
12 | vrpn_Tracker_OpenVR(const std::string& name, vrpn_Connection* connection, vr::IVRSystem * vr);
13 | void mainloop();
14 | void updateTracking(vr::TrackedDevicePose_t *pose);
15 | protected:
16 | vr::IVRSystem * vr;
17 | private:
18 | std::string name;
19 | q_matrix_type matrix;
20 | static void ConvertSteamVRMatrixToQMatrix(const vr::HmdMatrix34_t &matPose, q_matrix_type &matrix);
21 | };
22 |
23 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/VRPN-OpenVR/vrpn_Tracker_OpenVR_Controller.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include "vrpn_Tracker_OpenVR.h"
8 |
9 | class vrpn_Tracker_OpenVR_Controller :
10 | public vrpn_Tracker_OpenVR,
11 | public vrpn_Analog,
12 | public vrpn_Button_Filter
13 | {
14 | public:
15 | vrpn_Tracker_OpenVR_Controller() = delete;
16 | vrpn_Tracker_OpenVR_Controller(const std::string& name, vrpn_Connection* connection, vr::IVRSystem * vr);
17 | void mainloop();
18 | void updateController(vr::TrackedDeviceIndex_t unTrackedDevice);
19 | private:
20 | vr::VRControllerState_t pControllerState;
21 | };
--------------------------------------------------------------------------------
/OpenVR/OpenVR.vcxitems.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {7e90a88f-90cb-4050-b8e4-d04a20676da7}
6 | h;hh;hpp;hxx;hm;inl;inc;xsd
7 |
8 |
9 |
10 |
11 | Header Files
12 |
13 |
14 | Header Files
15 |
16 |
17 | Header Files
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VRPN-OpenVR
2 | OpenVR support for VRPN. Builds as a server that exposes OpenVR HMDs and controllers as as openvr/[hmd|controller]/[trackedDeviceId].
3 | Each of which having the relevant vrpn devices that it supports: vrpn_Tracker for HMDs and vrpn_Tracker, crpn_Analog and vrpn_Button
4 | for the controllers.
5 |
6 | # Building
7 | This server currently only builds in Visual Studio (2015 was used) as OpenVR is only supported in windows and we ran
8 | into issues trying to build it with CMake under Cygwin. A CMake file generating a VS project was considered but was
9 | found to introduce too many steps for the end result still requiring switching to VS for the build.
10 |
11 | Note: the current `CMakeLists.txt` is only a dummy to allow CLion to understand the project.
12 |
13 | * Initialize the repository with submodules in order to retrieve OpenVR and VRPN
14 |
15 | git submodule update --init --recursive
16 |
17 | * Open the `VRNP-OpenVR.sln` solution and build from the IDE
18 |
19 | # Acknowledgements
20 | This is still very much a work in progress and is by no means a complete and stable solution for using OpenVR with VRPN.
21 | The primary goal of this server is to provide controller data to a Blender instance running on a separate Linux machine.
--------------------------------------------------------------------------------
/VRPN-OpenVR/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "vrpn_Server_OpenVR.h"
4 |
5 | static volatile int done = 0;
6 | std::unique_ptr server{};
7 |
8 | // install a signal handler to shut down the devices
9 | // On Windows, the signal handler is run in a different thread from
10 | // the main application. We don't want to go destroying things in
11 | // here while they are being used there, so we set a flag telling the
12 | // main program it is time to exit.
13 | #if defined(_WIN32) && !defined(__CYGWIN__)
14 | /**
15 | * Handle exiting cleanly when we get ^C or other signals.
16 | */
17 | BOOL WINAPI handleConsoleSignalsWin(DWORD signaltype)
18 | {
19 | switch (signaltype) {
20 | case CTRL_C_EVENT:
21 | case CTRL_BREAK_EVENT:
22 | case CTRL_CLOSE_EVENT:
23 | case CTRL_SHUTDOWN_EVENT:
24 | done = 1;
25 | return TRUE;
26 | // Don't exit, but return FALSE so default handler
27 | // gets called. The default handler, ExitProcess, will exit.
28 | default:
29 | return FALSE;
30 | }
31 | }
32 | #endif
33 |
34 | int main(int argc, char *argv[]) {
35 | server = std::make_unique();
36 | while (!done) {
37 | server->mainloop();
38 | vrpn_SleepMsecs(16);
39 | }
40 | server.reset(nullptr);
41 | return 0;
42 | }
--------------------------------------------------------------------------------
/OpenVR/OpenVR.vcxitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}
7 | OpenVR
8 |
9 |
10 |
11 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/VRPN-OpenVR/vrpn_Server_OpenVR.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include