Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure multiple driver enabling directly through API #17

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenVR-SpaceCalibrator/Calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void ScanAndApplyProfile(CalibrationContext &ctx)
continue;
}

if (deviceClass == vr::TrackedDeviceClass_TrackingReference || deviceClass == vr::TrackedDeviceClass_HMD)
if (/*deviceClass == vr::TrackedDeviceClass_TrackingReference ||*/ deviceClass == vr::TrackedDeviceClass_HMD)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do this originally because it didn't work (the offsets wouldn't be reflected in the steamvr menu). I guess it works now?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this out and it still does not work with v1 lighthouses. Is it working for a different type of reference @lukis101?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had written my findings in commit description, copypasting with a lil more:
Does work with 2.0 stations and CV1, do not have 1.0s to test but other user on Discord had confirmed it working.
The lighthouse driver station poses get updated on their (re)initialization or some specific(dynamic recalibration?) cases and not immediately. So the offsets do get applied either when starting trackers after SteamVR is fully loaded, or by causing all LH devices to loose tracking (and thus disappear along with the chaperone corruption)

{
//auto p = ctx.devicePoses[id].mDeviceToAbsoluteTracking.m;
//printf("REF %d: %f %f %f\n", id, p[0][3], p[1][3], p[2][3]);
Expand Down
9 changes: 5 additions & 4 deletions OpenVR-SpaceCalibrator/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ static void ParseProfileV2(CalibrationContext &ctx, std::istream &stream);

static std::string ConfigFileName()
{
std::string vrRuntimeConfigName = vr::VR_RuntimePath();
char cruntimePath[MAX_PATH] = { 0 };
unsigned int pathLen;
vr::VR_GetRuntimePath(cruntimePath, MAX_PATH, &pathLen);
std::string vrRuntimeConfigName(cruntimePath);
return vrRuntimeConfigName + "\\..\\..\\..\\config\\01spacecalibrator\\calibration.json";
}

Expand Down Expand Up @@ -200,9 +203,7 @@ static void UpgradeProfileV1(CalibrationContext &ctx)

void WriteActivateMultipleDriversToConfig()
{
std::string configPath = vr::VR_RuntimePath();
configPath += "\\..\\..\\..\\config\\steamvr.vrsettings";

std::string configPath = ConfigFileName();
lukis101 marked this conversation as resolved.
Show resolved Hide resolved
std::ifstream ifile(configPath);
if (!ifile.good())
throw std::runtime_error("failed to read steamvr.vrsettings");
Expand Down
72 changes: 67 additions & 5 deletions OpenVR-SpaceCalibrator/OpenVR-SpaceCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void TryCreateVROverlay()

vr::VROverlay()->SetOverlayWidthInMeters(overlayMainHandle, 3.0f);
vr::VROverlay()->SetOverlayInputMethod(overlayMainHandle, vr::VROverlayInputMethod_Mouse);
vr::VROverlay()->SetOverlayFlag(overlayMainHandle, vr::VROverlayFlags_SendVRScrollEvents, true);
vr::VROverlay()->SetOverlayFlag(overlayMainHandle, vr::VROverlayFlags_SendVRDiscreteScrollEvents, true);

std::string iconPath = cwd;
iconPath += "\\icon.png";
Expand Down Expand Up @@ -148,6 +148,27 @@ void InitVR()
{
throw std::runtime_error("OpenVR error: Outdated IVROverlay_Version");
}

vr::EVRSettingsError vrSettingsError;
bool multipledrivers = vr::VRSettings()->GetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
&vrSettingsError);
if (vrSettingsError != vr::VRSettingsError_None)
{
std::string err = "Could not read \""
+ std::string(vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool)
+ "\" setting: "
+ vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
throw std::runtime_error(err);
}
if (!multipledrivers)
{
vr::VRSettings()->SetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
true);
}
}

void RunLoop()
Expand Down Expand Up @@ -192,10 +213,11 @@ void RunLoop()
char buf[0x400];
ImGui::GetActiveText(buf, sizeof buf);
buf[0x3ff] = 0;
uint32_t unFlags = 0; // EKeyboardFlags

vr::VROverlay()->ShowKeyboardForOverlay(
overlayMainHandle, vr::k_EGamepadTextInputModeNormal, vr::k_EGamepadTextInputLineModeSingleLine,
"Space Calibrator Overlay", sizeof buf, buf, false, 0
unFlags, "Space Calibrator Overlay", sizeof buf, buf, 0
);
keyboardOpen = true;
}
Expand All @@ -214,7 +236,7 @@ void RunLoop()
case vr::VREvent_MouseButtonUp:
io.MouseDown[vrEvent.data.mouse.button == vr::VRMouseButton_Left ? 0 : 1] = false;
break;
case vr::VREvent_Scroll:
case vr::VREvent_ScrollDiscrete:
io.MouseWheelH += vrEvent.data.scroll.xdelta * 360.0f * 8.0f;
io.MouseWheel += vrEvent.data.scroll.ydelta * 360.0f * 8.0f;
break;
Expand Down Expand Up @@ -342,7 +364,11 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
vr::VR_Init(&vrErr, vr::VRApplication_Utility);
if (vrErr == vr::VRInitError_None)
{
printf("%s", vr::VR_RuntimePath());
char cruntimePath[MAX_PATH] = { 0 };
unsigned int pathLen;
vr::VR_GetRuntimePath(cruntimePath, MAX_PATH, &pathLen);

printf("%s", cruntimePath);
vr::VR_Shutdown();
exit(0);
}
Expand Down Expand Up @@ -412,7 +438,7 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
vr::VR_Shutdown();
exit(-2);
}
else if (lstrcmp(lpCmdLine, L"-activatemultipledrivers") == 0)
else if (lstrcmp(lpCmdLine, L"-activatemultipledriversManual") == 0)
{
int ret = -2;
auto vrErr = vr::VRInitError_None;
Expand All @@ -436,4 +462,40 @@ static void HandleCommandLine(LPWSTR lpCmdLine)
vr::VR_Shutdown();
exit(ret);
}
else if (lstrcmp(lpCmdLine, L"-activatemultipledrivers") == 0)
{
int ret = -2;
auto vrErr = vr::VRInitError_None;
vr::VR_Init(&vrErr, vr::VRApplication_Utility);
if (vrErr == vr::VRInitError_None)
{
vr::EVRSettingsError vrSettingsError;
bool multipledrivers = vr::VRSettings()->GetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
&vrSettingsError);
if (vrSettingsError != vr::VRSettingsError_None)
{
std::string err = "Could not read \""
+ std::string(vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool)
+ "\" setting: "
+ vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
std::cerr << "Failed to set activateMultipleDrivers: " << err << std::endl;
}
else if (!multipledrivers)
{
vr::VRSettings()->SetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
true);
ret = 0;
}
lukis101 marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
fprintf(stderr, "Failed to initialize OpenVR: %s\n", vr::VR_GetVRInitErrorAsEnglishDescription(vrErr));
}
vr::VR_Shutdown();
exit(ret);
}
}
2 changes: 1 addition & 1 deletion OpenVR-SpaceCalibrator/UserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <algorithm>
#include <imgui/imgui.h>

#define VERSION_STRING "0.8"
#define VERSION_STRING "0.8.1"

struct VRDevice
{
Expand Down
Binary file modified lib/openvr/lib/win32/openvr_api.lib
Binary file not shown.
Binary file modified lib/openvr/lib/win64/openvr_api.lib
Binary file not shown.
Loading