Hello, I would like to know how can I simulate controllers inputs from a csharp script.
My goal is to trigger input events like ‘Grip’, ‘Trigger’ or ‘Pad’ pressed without using the real HTC controller and for example, call these events from the keyboard. Exactly like the “NoSteamVRFallback” system the simulate controller’s actions with the mouse.
For now I can only simulate the Trigger button using “GetStandardInteractionButton()” function within the Hand script. Instead of GetMouse, I just use GetKey(something). But it’s obviously not the right way to get this works properly without modifying the steamvr_plugin’s script.
PS : I’m using the last version of the plugin and I don’t want to use VRTK for this. So thanks in advance for your help
What you want is to use the Unity Input mapping, see here:
So, for example, Trigger press (not touch) on Right Vive Controller (or Oculus Touch) is Unity Axis 10. So you go into Edit->Project Settings->Input and add a new input entry. Name it whatever, say “openvr-r-trigger-press”, and for type choose “Joystick Axis” and for axis choose “10th”. Now, to simulate with a key, under positive button put, say “z”.
Now, in your script, call Input.GetAxis(“openvr-r-trigger-press”) and if the value is > 0.1f say then it’s pressed.
If you press Z it will work, and if you have a real controller it will also work.
Unfortunately I can’t do it this way. My goal is to interact with native SteamVR components like “Throwable”, “Interactable” or the teleportation system using "Hand’ component with a device that isn’t a HTC Controller (I wanna use a bluetooth remote tracked with an infra-red motion capture system within a CAVE).
But I don’t want to code my own overlay like VRTK or NewtonVR, I just want to keep it as simple as possible ^^. Isn’t there a way to throw events ?
Within the SDK, a “No SteamVR fallback” system does exist but it works only with the Trigger button using “Hand.GetStandardInteractionButtonDown()” to check if the mouse button was clicked.
Did you ever make any progress with this? I’ve been attempting the same thing (even trying with VRTK) and I’ve still not been able to achieve interactability.
Bump! Has anybody managed to do this yet? I am trying to emulate the OnTriggerDown Event of VRTK without actually pressing the trigger on a physical controller, but via script