Check if Controller is Active

How do I check if a controller is present/in use?

I’m developing for the Oculus Go, which only has one controller, and I’d like to disable the unused controller. I’m attempting to make this game forwards-compatible - so that two controller users can still play. And, of course, there’s the fact that not all players have the use of both arms.
Plus, it’s just annoying having that raycast from the unused controller blasting!

My plan is to do something like this:

void ControlCheck()
    {
        if (BOOL TRUE IF THIS CONTROLLER IS IN USE)
        {
            Debug.Log(gameObject.name + " is in use");
        }
        else
        {
            gameObject.SetActive(false);
            Debug.Log(gameObject.name + " is NOT not in use");
        }
    }

Use the input system to get all input devices and then check their characteristics to see if the device is a HMD, left or right associated controller and depending on that info disable your gameobjects.

How does one get a list of all input devices?
I’m not getting very far with google.

Yata!
I found it!

    public void CheckForControllers()
    {
        bool xrControllerFound = false;
        bool leftFound = false;
        bool rightFound = false;

        List<InputDevice> leftHandDevices = new List<InputDevice>();
        InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.Left, leftHandDevices);

        if (leftHandDevices.Count > 0)
        {
            xrControllerFound = true;
            leftFound = true;
        }

        List<InputDevice> rightHandDevices = new List<InputDevice>();
        InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.Right, rightHandDevices);
        if (rightHandDevices.Count > 0)
        {
            xrControllerFound = true;
            rightFound = true;
        }

        if (!xrControllerFound)
        {
           // deal with this
        }

        leftController.SetActive(leftFound);
        rightController.SetActive(rightFound);
    }

You could get all devices at once with
InputDevices.GetDevices(m_InputDevices);
and then loop over them as an improvement, but I guess as you only run the code once it wont make any difference