Search Unity

SteamVR Oculus controller input

Discussion in 'AR/VR (XR) Discussion' started by seowen1, Jun 22, 2018.

  1. seowen1

    seowen1

    Joined:
    Feb 22, 2018
    Posts:
    11
    I'm trying to get the input working for my Oculus touch controller using the SteamVR plugin. Here's the code I have so far:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Valve.VR;
    5. using Valve.VR.InteractionSystem;
    6.  
    7. public class InputAssignSteamVRController : MonoBehaviour {
    8.  
    9.     private InputManager inputManager;
    10.     private float inputValue;
    11.     private float inputValueLast;
    12.  
    13.     public string inputID = "Click0";
    14.     public SteamVR_TrackedObject trackedObj;
    15.     private SteamVR_Controller.Device inputController;
    16.     public EVRButtonId inputAxis;
    17.  
    18.     // Use this for initialization
    19.     void Awake () {
    20.  
    21.         if (trackedObj == null) {
    22.             trackedObj = gameObject.GetComponent<SteamVR_TrackedObject>();
    23.         }
    24.         inputController = SteamVR_Controller.Input((int)trackedObj.index);
    25.  
    26.         inputManager = gameObject.GetComponent<InputManager>();
    27.  
    28.     }
    29.    
    30.     // Update is called once per frame
    31.     void Update () {
    32.  
    33.         CheckInput();
    34.  
    35.         inputManager.SetInput(inputID, inputValue, inputValueLast);
    36.  
    37.     }
    38.  
    39.     private void CheckInput() {
    40.  
    41.         inputValueLast = inputValue;
    42.  
    43.         inputValue = inputController.GetAxis(inputAxis).x;
    44.  
    45.         Debug.Log(inputValue);
    46.  
    47.     }
    48.  
    49. }
    50.  
    I'm just using the default [CameraRig] and attaching this script to the controller. I also set the inputAxis variable to "k_EButton_Axis1". I did notice that I needed to change the index to "Device 1" within the tracked object. Now all I get in the Debug log is a float of 0f, no matter what I press on the controller.

    Side note: I can see the controller animating it's buttons, so SteamVR plugin is registering the button presses.

    Help please?
     
  2. seowen1

    seowen1

    Joined:
    Feb 22, 2018
    Posts:
    11
    Just tested this on the Vive and it runs flawlessly. Only seeing this issue with the Oculus touch. Anyone else having issues getting controller input with SteamVR for Oculus Touch? This is Unity 2017.3.1f1
     
  3. ShakingEarthDigital

    ShakingEarthDigital

    Joined:
    Mar 20, 2014
    Posts:
    7
    Did you ever figure this out? Have the same issue here.