77#include < string>
88#include < codecvt>
99#include < locale>
10- #include < GL/gl3w.h>
10+ #include " GL/gl3w.h"
1111
1212#ifdef __linux__
1313#include < unistd.h>
2424#include < openvr.h>
2525
2626#ifdef __linux__
27- // NOP
27+ # include " StaticConfig.h "
2828#else
2929#pragma comment(linker,"\"/manifestdependency:type='win32' \
3030name=' Microsoft.Windows.Common-Controls' version=' 6.0.0.0' \
@@ -40,9 +40,9 @@ extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x
4040#endif
4141
4242#ifdef __linux__
43- #define MANIFEST_END_PATH " /manifest.vrmanifest "
43+ #define MANIFEST_PATH ( CWD ) ( APP_MANIFEST_PATH )
4444#else
45- #define MANIFEST_END_PATH " \\ manifest.vrmanifest"
45+ #define MANIFEST_PATH ( CWD ) ( CWD + " \\ manifest.vrmanifest" )
4646#endif
4747
4848
@@ -474,6 +474,10 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
474474 std::cout << " -installmanifest install the application vrmanifest" << std::endl;
475475 std::cout << " -removemanifest remove the application vrmanifest" << std::endl;
476476 std::cout << " -activatemultipledrivers enable multiple drivers in steamvr" << std::endl;
477+ #ifdef __linux__
478+ std::cout << " -installdriver install the steam vr driver." << std::endl;
479+ std::cout << " -uninstalldriver uninstall the steam vr driver." << std::endl;
480+ #endif
477481 std::cout << " -help -h print this message" << std::endl;
478482 exit (0 );
479483 }
@@ -513,13 +517,14 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
513517 else
514518 {
515519 std::string manifestPath = oldWd;
516- manifestPath += MANIFEST_END_PATH ;
520+ manifestPath = MANIFEST_PATH (manifestPath) ;
517521 std::cout << " Removing old manifest path: " << manifestPath << std::endl;
518522 vr::VRApplications ()->RemoveApplicationManifest (manifestPath.c_str ());
519523 }
520524 }
521525 std::string manifestPath = cwd;
522- manifestPath += MANIFEST_END_PATH ;
526+ manifestPath = MANIFEST_PATH (manifestPath);
527+
523528 std::cout << " Adding manifest path: " << manifestPath << std::endl;
524529 auto vrAppErr = vr::VRApplications ()->AddApplicationManifest (manifestPath.c_str ());
525530 if (vrAppErr != vr::VRApplicationError_None)
@@ -545,8 +550,9 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
545550 {
546551 if (vr::VRApplications ()->IsApplicationInstalled (OPENVR_APPLICATION_KEY ))
547552 {
548- std::string manifestPath = cwd;
549- manifestPath += MANIFEST_END_PATH ;
553+ std::string manifestPath = cwd;
554+ manifestPath = MANIFEST_PATH (manifestPath);
555+
550556 std::cout << " Removing manifest path: " << manifestPath << std::endl;
551557 vr::VRApplications ()->RemoveApplicationManifest (manifestPath.c_str ());
552558 }
@@ -581,4 +587,56 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
581587 vr::VR_Shutdown ();
582588 exit (ret);
583589 }
590+ #ifdef __linux__
591+ else if (StringMatch (lpCmdLine, L" -installdriver" ))
592+ {
593+ auto vrErr = vr::VRInitError_None;
594+ vr::VR_Init (&vrErr, vr::VRApplication_Utility);
595+ if (vrErr != vr::VRInitError_None)
596+ {
597+ fprintf (stderr, " Failed to initialize OpenVR: %s\n " , vr::VR_GetVRInitErrorAsEnglishDescription (vrErr));
598+ vr::VR_Shutdown ();
599+ exit (-2 );
600+ }
601+
602+ char cruntimePath[MAX_PATH ] = { 0 };
603+ unsigned int pathLen;
604+ vr::VR_GetRuntimePath (cruntimePath, MAX_PATH , &pathLen);
605+
606+ const int cmdLength = 8196 ;
607+ char cmd[cmdLength];
608+
609+ snprintf (cmd, cmdLength, " python " DRIVER_INSTALLER_PATH " /driverInstall.py --toInstall " DRIVER_MANIFEST_PATH " --vrpathreg %s/bin/vrpathreg.sh" , cruntimePath);
610+ printf (" cmd: %s\n " , cmd);
611+ system (cmd);
612+
613+ vr::VR_Shutdown ();
614+ exit (0 );
615+ }
616+ else if (StringMatch (lpCmdLine, L" -uninstalldriver" ))
617+ {
618+ auto vrErr = vr::VRInitError_None;
619+ vr::VR_Init (&vrErr, vr::VRApplication_Utility);
620+ if (vrErr != vr::VRInitError_None)
621+ {
622+ fprintf (stderr, " Failed to initialize OpenVR: %s\n " , vr::VR_GetVRInitErrorAsEnglishDescription (vrErr));
623+ vr::VR_Shutdown ();
624+ exit (-2 );
625+ }
626+
627+ char cruntimePath[MAX_PATH ] = { 0 };
628+ unsigned int pathLen;
629+ vr::VR_GetRuntimePath (cruntimePath, MAX_PATH , &pathLen);
630+
631+ const int cmdLength = 8196 ;
632+ char cmd[cmdLength];
633+
634+ snprintf (cmd, cmdLength, " \" %s/bin/vrpathreg.sh\" removedriverwithname 01spacecalibrator" , cruntimePath);
635+ printf (" cmd: %s\n " , cmd);
636+
637+ vr::VR_Shutdown ();
638+ exit (0 );
639+ }
640+ #endif
641+
584642}
0 commit comments