Search Unity

XR.InputDevice with Oculus Quest Controller Joysticks

Discussion in 'AR/VR (XR) Discussion' started by Claytonious, Aug 8, 2019.

  1. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    I'm unable to make XR.InputDevice read the joystick positions of the primary thumb joysticks on the right and left controllers on Quest. I'm using CommonUsages.primary2DAxis but it always returns a value of 0,0.

    It also seems to "ping pong" between either recognizing the left controller or the right controller at any one time, based on which one I touch most recently, with the other going into an invalid state.

    Do the joysticks on these work with XR.InputDevice?

    I'm testing with Unity 2019.2.0f1 with XR Management package 2.0.0 (preview) and "Oculus Loader" installed.

    Here's the test script I'm running:

    Code (CSharp):
    1.  
    2. public class TestController : MonoBehaviour
    3. {
    4.     private readonly List<InputDevice> _allInputDevices = new List<InputDevice>();
    5.     private readonly List<InputDevice> _axisInputDevices = new List<InputDevice>();
    6.     private string _currentDebugMessage = "";
    7.  
    8.     [SerializeField]
    9.     private TextMeshProUGUI _debugText;
    10.  
    11.     private IEnumerator Start()
    12.     {
    13.         var waiter = new WaitForSeconds(5f);
    14.         while (true)
    15.         {
    16.             UpdateInputDevices();
    17.             yield return waiter;
    18.         }
    19.     }
    20.    
    21.     private void UpdateInputDevices()
    22.     {
    23.         _axisInputDevices.Clear();
    24.         _allInputDevices.Clear();
    25.         InputDevices.GetDevices(_allInputDevices);
    26.         foreach (var device in _allInputDevices)
    27.         {
    28.             Vector2 discardedValue;
    29.             if(device.TryGetFeatureValue(CommonUsages.primary2DAxis, out discardedValue))
    30.             {
    31.                 _axisInputDevices.Add(device);
    32.                 Debug.Log($"TestController: {device.name} is an axis input device");
    33.             }
    34.             else
    35.             {
    36.                 Debug.Log($"TestController: {device.name} is not an axis input device");
    37.             }
    38.         }
    39.     }
    40.    
    41.     private void Update()
    42.     {
    43.         _currentDebugMessage = _axisInputDevices.Count == 0 ? "Waiting for Input Devices..." : "";
    44.         foreach (var dev in _axisInputDevices)
    45.         {
    46.             if (dev.isValid &&
    47.                 dev.TryGetFeatureValue(CommonUsages.primary2DAxis, out var axisInput))
    48.             {
    49.                 _currentDebugMessage += $"{dev.name}: {axisInput.x:n1},{axisInput.y:n1}\n";
    50.             }
    51.             else
    52.             {
    53.                 _currentDebugMessage += $"{dev.name}: failed\n";
    54.             }
    55.         }
    56.     }
    57.  
    58.     private void LateUpdate()
    59.     {
    60.         if (_debugText != null && _debugText.text != _currentDebugMessage)
    61.         {
    62.             _debugText.text = _currentDebugMessage;
    63.         }
    64.     }
    65. }
    66.  
    At runtime on the device, I initially see 0.0,0.0 for the joystick position of the Right controller no matter how I move the joystick. If I then move the joystick of the left controller, then the right controller fails to read for some number of frames until the left controller becomes active, at which point it always reads 0.0,0.0.

    Any help is much appreciated!
     
  2. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Sounds like this is probably related to this problem, huh?
     
  3. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Confirmed. Putting this stuff into the AndroidManifest.xml fixed the problem.
     
    ROBYER1 and StayTalm_Unity like this.