Example #1
0
 bool BIsHTCViveController(SteamVR_TrackedObject.EIndex type)
 {
     System.Text.StringBuilder      sbType = new System.Text.StringBuilder(1000);
     Valve.VR.ETrackedPropertyError err    = Valve.VR.ETrackedPropertyError.TrackedProp_Success;
     SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)type, Valve.VR.ETrackedDeviceProperty.Prop_ManufacturerName_String, sbType, 1000, ref err);
     return(err == Valve.VR.ETrackedPropertyError.TrackedProp_Success && sbType.ToString().StartsWith("HTC"));
 }
Example #2
0
 public bool BIsManufacturerController(string name)
 {
     System.Text.StringBuilder      sbType = new System.Text.StringBuilder(1000);
     Valve.VR.ETrackedPropertyError err    = Valve.VR.ETrackedPropertyError.TrackedProp_Success;
     SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)0, Valve.VR.ETrackedDeviceProperty.Prop_ManufacturerName_String, sbType, 1000, ref err);
     return(err == Valve.VR.ETrackedPropertyError.TrackedProp_Success && sbType.ToString().StartsWith(name));
 }
Example #3
0
        private void GetControllerType()
        {
            // string property for?
            Valve.VR.ETrackedPropertyError  error = Valve.VR.ETrackedPropertyError.TrackedProp_Success;
            Valve.VR.ETrackedDeviceProperty manufacturerNameProperty = Valve.VR.ETrackedDeviceProperty.Prop_ManufacturerName_String;
            uint manufacturerNameCapacity = SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)steamVRPose.GetDeviceIndex(), manufacturerNameProperty,
                                                                                                null, 0, ref error);

            string manufacturerResultAsString = "";

            if (manufacturerNameCapacity > 1)
            {
                var manufacturerResult = new System.Text.StringBuilder((int)manufacturerNameCapacity);
                SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)steamVRPose.GetDeviceIndex(), manufacturerNameProperty, manufacturerResult, manufacturerNameCapacity, ref error);

                manufacturerResultAsString = manufacturerResult.ToString();

                if (manufacturerResultAsString.Equals("Oculus"))
                {
                    steamVRControllerType = SteamVR_ControllerType.Touch;
                }
                else
                {
                    // figure out if we're vive or touch
                    error = ETrackedPropertyError.TrackedProp_Success;
                    Valve.VR.ETrackedDeviceProperty renderModelName = ETrackedDeviceProperty.Prop_RenderModelName_String;

                    uint renderModelStringCapacity = SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)steamVRPose.GetDeviceIndex(), renderModelName, null, 0, ref error);

                    if (renderModelStringCapacity > 1)
                    {
                        var renderModelResult = new System.Text.StringBuilder((int)renderModelStringCapacity);
                        SteamVR.instance.hmd.GetStringTrackedDeviceProperty((uint)steamVRPose.GetDeviceIndex(), renderModelName, renderModelResult, renderModelStringCapacity, ref error);
                        Debug.Log("Controller rendermodel name: " + renderModelResult.ToString());

                        if (renderModelResult.ToString().ToLower().Contains("index"))
                        {
                            steamVRControllerType = SteamVR_ControllerType.Knuckles;
                        }
                        else
                        {
                            steamVRControllerType = SteamVR_ControllerType.Vive;
                        }
                    }
                }
                //steamVRControllerType = (manufacturerResultAsString.Equals("Oculus")) ? SteamVR_ControllerType.Touch : SteamVR_ControllerType.Vive;
                Debug.Log("controller manufacturer: " + manufacturerResultAsString);
                Debug.Log("Controller type detected: " + steamVRControllerType);
            }
            else
            {
                steamVRControllerType = SteamVR_ControllerType.Unknown;
            }
        }