Ejemplo n.º 1
0
        void Update()
        {
            foreach (var index in controllerIndices)
            {
                foreach (var buttonId in buttonIds)
                {
                    if (Varjo_SteamVR_Controller.Input(index).GetPressDown(buttonId))
                    {
                        Debug.Log(buttonId + " press down");
                    }
                    if (Varjo_SteamVR_Controller.Input(index).GetPressUp(buttonId))
                    {
                        Debug.Log(buttonId + " press up");
                        if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                        {
                            Varjo_SteamVR_Controller.Input(index).TriggerHapticPulse();
                            PrintControllerStatus(index);
                        }
                    }
                    if (Varjo_SteamVR_Controller.Input(index).GetPress(buttonId))
                    {
                        Debug.Log(buttonId);
                    }
                }

                foreach (var buttonId in axisIds)
                {
                    if (Varjo_SteamVR_Controller.Input(index).GetTouchDown(buttonId))
                    {
                        Debug.Log(buttonId + " touch down");
                    }
                    if (Varjo_SteamVR_Controller.Input(index).GetTouchUp(buttonId))
                    {
                        Debug.Log(buttonId + " touch up");
                    }
                    if (Varjo_SteamVR_Controller.Input(index).GetTouch(buttonId))
                    {
                        var axis = Varjo_SteamVR_Controller.Input(index).GetAxis(buttonId);
                        Debug.Log("axis: " + axis);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void PrintControllerStatus(int index)
        {
            var device = Varjo_SteamVR_Controller.Input(index);

            Debug.Log("index: " + device.index);
            Debug.Log("connected: " + device.connected);
            Debug.Log("hasTracking: " + device.hasTracking);
            Debug.Log("outOfRange: " + device.outOfRange);
            Debug.Log("calibrating: " + device.calibrating);
            Debug.Log("uninitialized: " + device.uninitialized);
            Debug.Log("pos: " + device.transform.pos);
            Debug.Log("rot: " + device.transform.rot.eulerAngles);
            Debug.Log("velocity: " + device.velocity);
            Debug.Log("angularVelocity: " + device.angularVelocity);

            var l = Varjo_SteamVR_Controller.GetDeviceIndex(Varjo_SteamVR_Controller.DeviceRelation.Leftmost);
            var r = Varjo_SteamVR_Controller.GetDeviceIndex(Varjo_SteamVR_Controller.DeviceRelation.Rightmost);

            Debug.Log((l == r) ? "first" : (l == index) ? "left" : "right");
        }