Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

SteamVR 2.0 - Is there a normal way to get low-level inputs as before version 2.0?

Discussion in 'VR' started by Artaani, Jan 22, 2019.

  1. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    403
    I just updated SteamVR Plugin and found out they decided to completely ruin it.
    The new version is soooo terrible.

    All what we need it is just get a simple low-level inputs, just an analogue of Unity Input.GetKeyDown method, but for VR. It it was possible before, but they decided "You don't need it. Who need this boring low-level? You better take this new super overcomplicated, not intuitive, useless thing!"

    So, a question.
    Someone figured out how to get basic inputs (state of VR buttons) as before, with a single line of code and without a lot of useless configurations? Or they turned out completely insane and decided to remove such possibility completely?

    Otherwise, seems like we need to continue to use previous, "deprecated" version of SteamVR which can be downloaded from GitHub.
     
  2. Rigaro

    Rigaro

    Joined:
    Dec 4, 2017
    Posts:
    1
    The "Actions" still allow you to get basic input, though you still need to bind actions to controller input. Say, you want the state from the 'x' button in your controller. You need to define an Action e.g. interfaceButton, of the type boolean, and assign it to that button in the binding interface.
    Then in your code you first define the action:
    Code (CSharp):
    1.  private SteamVR_Action_Boolean buttonAction = SteamVR_Input.vrproep.inActions.InterfaceButton;
    And to get its state you can use:
    Code (CSharp):
    1. bool buttonState = buttonAction.GetState(SteamVR_Input_Sources.Any);
    (Note that you can define the source explicitly, rather than Any).

    I do agree that the documentation is absolute trash and a lot of this I had to figure out digging through their demos and using Visual Studios auto-complete function and trying things out. I still get issues trying to get Pose out of trackers though.
     
    Artaani likes this.
  3. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    403
    Thanks you for the information! I will try to use this approach.
     
  4. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    @Rigaro: thanks very much for this. It's very close to what I need as well. What I need is a way to tell which controller triggered an action change, when controllers are mirrored-- so I have the grip trigger set to a Grab command, and when the listener detects an action change I want to be able to tell which grip trigger was pulled. Rigaro shows how to query the button, but that isn't enough, as the user might already be holding that button and triggering the action with the other controller.

    Here's something that doesn't work:
    Code (CSharp):
    1. public SteamVR_Action_Sources leftController;
    2.  
    3.  
    4.  
    5. void OnGrabActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue)
    6. {
    7. if (actionIn.activeDevice == leftController)
    8. {
    9. print("action from left controller");
    10. }
    11. }
    This doesn't work because actionIn.activeDevice seems to point to the controller that the present action was changed from: in other words, if I last released the right trigger and then pull the left trigger, actionIn.activeDevice returns the right controller.

    I can think of two kludgy workarounds for this problem, one involving setting up separate actions for the left and right grab triggers and the other involving setting up several flags. But there must be a direct way of querying an action to tell which controller triggered it. Maybe it involves SteamVR_Action_Out_Source, but I haven't been able to figure out how to use that class yet.

    Thanks in advance!