Search Unity

[SOLVED] Oculus Quest controllers don't automatically pair up to InputUsers.

Discussion in 'Input System' started by IgnisIncendio, Mar 1, 2021.

  1. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Related to: https://stackoverflow.com/questions...us-starts-unpaired-in-unitys-new-input-system

    XR Plugin Management 4.0.1
    Input System 1.0.2
    Oculus Quest 2 through Oculus Link

    TrackedPoseDriver (New Input System) works out of the box. However, the controller inputs through PlayerInput simply refused to work. The Input Debugger revealed that it was not paired to User #0.

    I tried manually pairing with

    InputUser.PerformPairingWithDevice(XRController.rightHand, inputSystemPlayerInput.user);
    in
    Start()
    but that returned an error that XRController.rightHand was null.

    Now I'm using
    ContextMenu
    to call the pairing function manually after my controller has been connected (by moving it around first). However, this is obviously not an ideal solution. Am I missing a better method for doing this?

    Edit: Just reworked my Action Map to use Control Schemes, but it still doesn't work. The Control Scheme defaults to Keyboard, then when I move my Oculus controllers around (connecting them in the Input Debugger), then pressing a non-noisy button, it does not automatically switch to the VR Control Scheme.

    Edit edit: Here's the new XR pairing code if you use Control Schemes. For editor only, still not sure how to implement this in the build.


    [ContextMenu("Pair XR Device")]
    public void PairXrDevice() {
    inputSystemPlayerInput.SwitchCurrentControlScheme("VR", XRController.leftHand, XRController.rightHand);
    }
     
    Last edited: Mar 1, 2021
  2. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Solved! Pretty dumb bug, I didn't realise I had accidentally added a PlayerInput component on the camera GameObject, which is consistent with documentation (the Input System thought I was making a multiplayer game).

    Still, it was good to switch to Control Schemes instead of just using a single one for KB&M, gamepad and VR, I guess :)