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

WIP: Linux support #90

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

WIP: Linux support #90

wants to merge 27 commits into from

Conversation

AngriestSCV
Copy link

Working Linux support

It's a little rough, but now feels like time to start a conversation about if this kind of thing is valuable and how turn key it should be for Linux users.

The state as of generating the PR is that there are undocumented dependencies, automatic calibration does not work quite right, and the VR UI works incorrectly. The base functionality does work if you can get it built however.

…ities

linux builder

Now runs on linux

warning crushing

warning crushing

Add subhook submodule

Adding some override markers

Misc small changes

Improved comms

driver now starts under linux

still not hooking functions, but can call virutal functions with direct function pointers

Kind of works now with hooking

Linux port now functional

Reducing delta to windows version

adding linux to version string
@pushrax
Copy link
Owner

pushrax commented Aug 28, 2022

If someone volunteers to maintain Linux support, this seems like a valuable addition.

@gyroninja
Copy link

gyroninja commented Aug 30, 2022

BTW I got my Linux port working a week ago https://github.com/gyroninja/OpenVR-SpaceCalibrator to work. It does require you to manually create the addon folder and use vrpathreg to add it.I do assume that ~/.config/OpenVR-SpaceCalibrator and "/.local/share/OpenVR-SpaceCalibrator exist.

I did not bother with keeping Windows support in my fork so props to you for doing this.

It's funny how we both did this at almost the name time despite this not having been ported for years.

@AngriestSCV
Copy link
Author

@gyroninja
Did you experience any bugs that are hard to explain? IIRC The in VR menu seems to have the "mouse" running the wrong way and the standard calibration is pretty far of on this one.

Going with those are you using ALVR?

Removing unused module

Have CMake pull the submodules

Added Linux CMake  installer

Removing unused code

Partially working auto installer.
@AngriestSCV AngriestSCV changed the title WIP: Linux support Linux support Sep 5, 2022
@AngriestSCV
Copy link
Author

At this point there are no known deficiencies in either the Windows or Linux build caused by this merge. Let me know if there's anything else I can do to push this forward.

@@ -142,17 +152,77 @@ static void WriteProfile(CalibrationContext &ctx, std::ostream &out)
out << profilesV.serialize(true);
}

#ifdef __linux__
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would be a bit worried that the use of #ifdef scattered about the codebase will create maintenance problems in the future. Usually the way this is approached in larger codebases would be to refactor out the code that needs to differ into its own function, then have a set of windows-specific or linux-specific .cpp files. Having it scattered everywhere makes it hard to see what differs between the platforms, and because the surface area that differs is so ad-hoc, it makes it too easy to forget to carry across a change between the two variants.

Copy link
Author

Choose a reason for hiding this comment

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

I can swap things over to that. I can see how it would be a better solution.

OpenVR-SpaceCalibratorDriver/Hooking.h Outdated Show resolved Hide resolved
stop = true;

#ifdef __linux__
//NOP
Copy link
Collaborator

Choose a reason for hiding this comment

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

So we don't support unloading on linux? If the driver .so is unloaded we'll end up crashing vrserver afterward...


serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(COMM_PORT_SERVER);
serverAddr.sin_addr.s_addr = INADDR_ANY;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably better to use a unix domain socket, as there's no reason for this to be accessible remotely.

OpenVR-SpaceCalibratorDriver/InterfaceHookInjector.cpp Outdated Show resolved Hide resolved
Comment on lines +6 to +10
#ifdef __linux__
#include "StaticConfig.h"
#else
#define DRIVER_LOG_FILE "space_calibrator_driver.log"
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this different on different platforms?

Copy link
Author

Choose a reason for hiding this comment

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

StaticConfig.h.in contains paths set up in CMake to contain the directories to log to and the ones where the config will be stored. StaticConfig.h is a generated file so I'm not sure if or how it would be used in a windows build. Without swapping the Windows build to CMake I'm not sure what another good solution would be.

void * nothing;
} OVERLAPPED;

typedef void* HANDLE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This kind of thing makes me very worried that future changes will break linux support in subtle ways, simply because they might introduce Windowisms without having random #ifdefs scattered about. A proper port needs to refactor out the OS-specific portions of the code into a well-contained area, and needs to ensure the build will fail, hard, if OSisms like HANDLE leak out into shared code.

OpenVR-SpaceCalibratorDriver/compat.h Outdated Show resolved Hide resolved
Comment on lines +12 to +13
#define COMM_PORT_SERVER 5473
#define COMM_PORT_CLIENT 5474
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using a unix domain socket will avoid the risk of conflicting with other users of these ports.

Comment on lines +64 to +65
SetDeviceTransform(uint32_t id, bool _enabled, vr::HmdVector3d_t _translation, vr::HmdQuaternion_t _rotation, double _scale) :
openVRID(id), enabled(_enabled), updateTranslation(true), updateRotation(true), updateScale(true), translation(_translation), rotation(_rotation), scale(_scale) { }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why these refactors?

Copy link
Author

Choose a reason for hiding this comment

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

I was getting warnings due to shadowing. My IDE settings might be too aggressive. Let me know if you'd want them removed.

Version.h Outdated Show resolved Hide resolved
@AngriestSCV AngriestSCV changed the title Linux support WIP: Linux support Oct 17, 2022
@galister
Copy link

galister commented Jan 9, 2023

Build is failing as of a4151fc on the make step due to missing files imgui.h and imconfig.h.
Workaround is to manually copy these to the build folder.

@galister
Copy link

galister commented Aug 8, 2023

Those looking for working Linux support, you can try this fork here: https://github.com/galister/OpenVR-SpaceCalibrator

It's pieced together from the contributors of this thread, and I plan on maintaining this, but not going to try and merge it upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants