ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.12k stars 1.28k forks source link

How to have multiple active controllers from different controllers/drivers? (ex: Oculus Controller & Treadmill) #1585

Open matinlotfali opened 3 years ago

matinlotfali commented 3 years ago

I have been developing my own OpenVR driver for a custom-made treadmill. I can see the driver appear in the SteamVR test controllers and I am able to show movement directions as if it is a two-axis joystick. I can also bind that to the walking movement inside the Half-Life: Alyx.

The problem is: I can only use my Oculus controllers or the Treadmill. I only have one active controller/driver set in my settings and only one of their bindings is being shown at once.

How can I have both Oculus controllers and the Treadmill to be active? Am I missing a tiny config somewhere?

okawo80085 commented 3 years ago

It should be possible, but again we don't have proper documentation for doing so

Here is what i know: Drivers can register however many handed controllers, but an app can only use 2, it doesn't matter which driver they belong to, only 2 will be used.

This does not mean that treadmills are impossible tho, in particular if you look at the ETrackedControllerRole enum

...
/** Describes what specific role associated with a tracked device */
enum ETrackedControllerRole
{
    TrackedControllerRole_Invalid = 0,                  // Invalid value for controller type
    TrackedControllerRole_LeftHand = 1,                 // Tracked device associated with the left hand
    TrackedControllerRole_RightHand = 2,                // Tracked device associated with the right hand
    TrackedControllerRole_OptOut = 3,                   // Tracked device is opting out of left/right hand selection
    TrackedControllerRole_Treadmill = 4,                // Tracked device is a treadmill or other locomotion device
    TrackedControllerRole_Stylus = 5,                   // Tracked device is a stylus
    TrackedControllerRole_Max = 5
};
...

Left and right controllers roles are known(there are working drivers using them, but im pretty sure you already knew that), the rest however are a complete mystery, im guessing TrackedControllerRole_Treadmill is what you should be using, but i never used it, i don't know how it affects bindings, device order for applications, etc.

i haven't seen any open drivers using it in their devices, nor TrackedControllerRole_Stylus or TrackedControllerRole_OptOut actually, but they certainly affect devices, how? i wish i knew, best option for you right now is trial and error, it may be as simple as setting your device's role to TrackedControllerRole_Treadmill or that might do nothing, it would be nice if valve provided us with documentation, but lets face it, they never do :)

i have not tried it yet, focusing on other things like linux compatibility for my driver, but when i do i'll be sure to post an update.

zhang49 commented 1 year ago

Hello, I am currently adapting Alyx, and I also encountered this problem. How did you end up solving this problem?