Forum Discussion
kexar
6 years agoExplorer
Cross-platform input for Valve Index
Hi,
we are using Oculus integration 1.42 cross-platform input for Oculus Rift & Steam VR. On HTC Vive it is working but not on Valve index. For example left thumbstick and left hand grip are not working. Are there any other button mappings or should we use their SDK?
Thanks.
we are using Oculus integration 1.42 cross-platform input for Oculus Rift & Steam VR. On HTC Vive it is working but not on Valve index. For example left thumbstick and left hand grip are not working. Are there any other button mappings or should we use their SDK?
Thanks.
9 Replies
Replies have been turned off for this discussion
- billy.attawayExplorerI have the same question. Can anyone weigh in on this? Would be nice to just use Oculus SDK instead of having to use Steam SDK as well
- hokage3211ExplorerSame question, it feels like the steam library knows that it's coming in but it can't do analog inputs unless it has a pre-approved headset identified, so it knows menu buttons and triggers but can't figure out what to look for to implement the joystick controls.
- ThetaREZExplorerThis was the only issue I had porting my Oculus game to the Steam platform using the Oculus integration. The index thumb stick didn't get mapped. Ugh. Anyone? What did you do @kexar ?
- therewillbebradHonored GuestHas anyone figured out how to get this working with the index?
- hokage3211ExplorerSo to anyone having troubles, this is what my project ended up doing. I noticed that it had openvr_api.css in the files, so as such I remembered it was possible to circumvent it all and directly ask openVR what's going on from the controller. What follows will be a list of key lines and utility stuff I used to make it work.
This is to figure out if you can actually use the input yet, as openVR wasn't always initialized at any given time for us.bool isOpenVrSystemReady()
{
try
{
return OVR.OpenVR.OpenVR.System != null;
} catch(DllNotFoundException e)
{
return false;
}
}this is to get the index of the controller you want to get input from, which can change at runtime (right left switching), although I'm not sure if it works if the controllers aren't on when the game starts. I passed "OVR.OpenVR.ETrackedControllerRole.LeftHand" as the proper role to get the left controller inputs. I'm sure you can imagine what to pass for the right hand, as it's an enum, so replace the LeftHand name with RightHand.
this is to get the name of the controller you are looking at, which will let you test against the string "knuckles" to tell if you need to use special input exceptions (I know, even this code refers to them as knuckles and not indexes). Given you may call this so much, I also would opt to store the pre-created err somewhere else and not create a new one each time you call this, but I put it like this for easiest copy-pasting right now.uint getDeviceIndex(OVR.OpenVR.ETrackedControllerRole role)
{
//get device index of controller, may change during runtime as they turn on/off
if (isOpenVrSystemReady())
return OVR.OpenVR.OpenVR.System.GetTrackedDeviceIndexForControllerRole(role);
else return 1000;
}
to get the input, you will need to just make a "new OVR.OpenVR.VRControllerState_t()" and pass it to this after storing it (you don't need to make a new one each time you call this) which will give you the state of the controller.string getControllerName(OVR.OpenVR.ETrackedControllerRole controllerRole)
{
OVR.OpenVR.ETrackedPropertyError err = new OVR.OpenVR.ETrackedPropertyError();
//get name of controller
if (isOpenVrSystemReady())
{
OVR.OpenVR.OpenVR.System.GetStringTrackedDeviceProperty(getDeviceIndex(controllerRole), OVR.OpenVR.ETrackedDeviceProperty.Prop_ControllerType_String, controllerTitle, (uint)System.Runtime.InteropServices.Marshal.SizeOf(controllerTitle), ref err);
return controllerTitle.ToString();
}
else return "";
}
And after passing it to the last function, the state object will have the current state of the controller, which will mean you need to get the correct axis, which will be something like this line:bool updateControllerState(OVR.OpenVR.ETrackedControllerRole controllerRole, ref OVR.OpenVR.VRControllerState_t state)
{
//update the state of the controller
if (isOpenVrSystemReady())
return OVR.OpenVR.OpenVR.System.GetControllerState(getDeviceIndex(controllerRole), ref state, (uint)System.Runtime.InteropServices.Marshal.SizeOf(state)); //get the controller state which is weird structure
else return false;
}
(You may be able to get the fingers axis inputs through the other r.Axis1 through 4, but I give no gaurantees)storedState.rAxis0.x //or .rAxis.y
However some things of note, you will want to make sure to have a small dead zone around about .1 in size, because if they just touch their thumbstick (resting their finger on it even) it counts as an input on one of the axis, so to avoid weird drifting I just ended up testing if it was bigger than .1 then used the value otherwise.
So an example usage block we had was this, just to give people an idea.if (isOpenVrSystemReady() && getControllerName(OVR.OpenVR.ETrackedControllerRole.LeftHand) == "knuckles")
{//"vive_controller" is the name of vive wands
updateControllerState(OVR.OpenVR.ETrackedControllerRole.LeftHand, ref leftState);
if (Mathf.Abs(leftState.rAxis0.x) > 0.1f || Mathf.Abs(leftState.rAxis0.y) > 0.1f) //dead zone because touching thumbstick makes it register not 0
{
primaryAxis.x = leftState.rAxis0.x;
primaryAxis.y = leftState.rAxis0.y; //y is up-down, x is left-right.
}
}
Alright, that seems like enough to give people a good idea of how to get index controller inputs, at least not using the new XR management stuff, which I'm not sure if it breaks this. Anyway, I hope this all helps and alleviate the pains of oculus being weird! - therewillbebradHonored GuestReally appreciate your response. So would you just add this code in to your existing movement scripts since this issue seems to only be affecting the joystick?
- ThetaREZExplorerI can confirm this code works. I just abstracted the input for my joystick and on my controller manager as a static so anywhere and everywhere that need it could get it. My game even passed the steam store: https://store.steampowered.com/app/1276710/Cosmotic_Blast/
- hokage3211ExplorerHey guys, update on this code, it still works but is probably less preferable to the much simpler fix I ended up sussing out through prodding around in the code. This should fix both grip and thumbstick input for oculus sdk when using index controllers or some WMR controllers, but not sure if the dead-zone check is needed or not based on your purposes. One known strange artifact is that the A button on index also counts as the grip button, don't ask me why but there seemed to be no way to differentiate them according to the values coming in.
Located in OVRInput.cs, keep in mind this has to be mirrored to the left controller logic side (located above this), but you get the idea.
This should fix the direct button inputs, I have no idea where the "touched" (finger is touching a capacitive button, but not pressing down on it) button code for oculus is, or if that has to be fixed too, but I imagine it's somewhere else in the same file and it'll look something similar to this to fix.
Hope this helps! - hokage3211Explorer@therewillbebrad and @kexar long-delay ping, but hope the previous code helps, fixes both grip and thumbstick direct inputs without having to change standard movement scripts, since it goes under the, not above them.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 2 years ago
- 3 months ago
- 2 years ago