コード例 #1
0
ファイル: VRDevices.cs プロジェクト: asdlei99/Vivista
    public static void OnDeviceConnect(InputDevice device)
    {
        //TODO(Simon): This should be more robust
        var name = device.name.ToLowerInvariant();

        if (name.Contains("left"))
        {
            Debug.Log("left controller connected: " + device.name);
            hasLeftController = true;
        }
        if (name.Contains("right"))
        {
            Debug.Log("right controller connected: " + device.name);
            hasRightController = true;
        }
        if (name.Contains("oculus"))
        {
            Debug.Log("oculus device connected: " + device.name);
            loadedControllerSet = LoadedControllerSet.Oculus;
        }
        else if (name.Contains("vive"))
        {
            Debug.Log("vive device connected: " + device.name);
            loadedControllerSet = LoadedControllerSet.Vive;
        }
    }
コード例 #2
0
    public static void DetectDevices()
    {
        var devices = Input.GetJoystickNames();

        switch (loadedSdk)
        {
        case LoadedSdk.Oculus:
            hasLeftController   = devices.Contains("Oculus Touch Controller - Left");
            hasRightController  = devices.Contains("Oculus Touch Controller - Right");
            hasRemote           = devices.Contains("Oculus Remote");
            loadedControllerSet = LoadedControllerSet.Oculus;
            break;

        case LoadedSdk.OpenVr:
            //NOTE(Kristof): Better way to do this?
            if (devices.Contains("OpenVR Controller(Oculus Rift CV1 (Left Controller)) - Left") || devices.Contains("OpenVR Controller(Oculus Rift CV1 (Right Controller)) - Right"))
            {
                hasLeftController  = devices.Contains("OpenVR Controller(Oculus Rift CV1 (Left Controller)) - Left");
                hasRightController = devices.Contains("OpenVR Controller(Oculus Rift CV1 (Right Controller)) - Right");
                //NOTE(kristof): OpenVR doesn't seem to detect the remote
                hasRemote = false;

                loadedControllerSet = LoadedControllerSet.Oculus;
            }
            else if (devices.Contains("OpenVR Controller(Vive. Controller MV) - Left") || devices.Contains("OpenVR Controller(Vive. Controller MV) - Right"))
            {
                hasLeftController  = devices.Contains("OpenVR Controller(Vive. Controller MV) - Left");
                hasRightController = devices.Contains("OpenVR Controller(Vive. Controller MV) - Right");

                loadedControllerSet = LoadedControllerSet.Vive;
            }
            else
            {
                hasLeftController   = false;
                hasRightController  = false;
                hasRemote           = false;
                loadedControllerSet = LoadedControllerSet.NoControllers;
            }

            break;

        case LoadedSdk.None:
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }