- Home /
Haptics/Vibrations only with OpenVr
Hello ! I am currently working on a VR project with OpenVr, and without any other plugIn (SteamVr or OVR), and I was wondering how I could make the controllers vibrate using only OpenVr. Is it possible ? Or do I have to use SteamVr plugIn or OVR ?
Thanks !
Comment
Answer by StudioPanko · Jan 02, 2019 at 07:32 AM
InputDevice XRController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
if (XRController.IsValid)
{
HapticCapabilities hapcap = new HapticCapabilities();
XRController.TryGetHapticCapabilities(out hapcap);
Debug.Log("DOES XR CONTROLLER SUPPORT HAPTIC BUFFER: " + hapcap.supportsBuffer);
Debug.Log("DOES XR CONTROLLER SUPPORT HAPTIC IMPULSE: " + hapcap.supportsImpulse);
Debug.Log("DOES XR CONTROLLER SUPPORT HAPTIC CHANNELS: " + hapcap.numChannels);
Debug.Log("DOES XR CONTROLLER SUPPORT HAPTIC BUFFER FREQUENCY HZ: " + hapcap.bufferFrequencyHz);
if (hapcap.supportsImpulse)
{
XRController.SendHapticImpulse(0, 0.5f);
}
}
I'm using OpenVR on 2018.3 with HTC Vive. Managed to get s short buzz on my controller with the above code triggered in Start().
Will test further.
Thank you StudioPanko!
A 2021 update that might be useful to others
Using openXR I got this haptic feedback code to work by changing the channel to 1 (using the oculus quest 2)
For example, 'XRController.SendHapticImpulse(1, 0.5f);