示例#1
0
    private void SendAxisEvents(int steamDeviceIndex, int deviceIndex)
    {
        int a = 0;

        for (int axis = (int)EVRButtonId.k_EButton_Axis0; axis <= (int)EVRButtonId.k_EButton_Axis4; ++axis)
        {
            Vector2 axisVec = SteamVR_Controller.Input(steamDeviceIndex).GetAxis((EVRButtonId)axis);
            for (XorY xy = XorY.X; (int)xy <= (int)XorY.Y; xy++, a++)
            {
                var         value     = xy == XorY.X ? axisVec.x : axisVec.y;
                const float kDeadZone = 0.05f;
                if (Mathf.Abs(value) < kDeadZone)
                {
                    value = 0f;
                }

                if (Mathf.Approximately(m_LastAxisValues[steamDeviceIndex, a], value))
                {
                    continue;
                }

                var inputEvent = InputSystem.CreateEvent <GenericControlEvent>();
                inputEvent.deviceType   = typeof(VRInputDevice);
                inputEvent.deviceIndex  = deviceIndex;
                inputEvent.controlIndex = a;
                inputEvent.value        = value;

                m_LastAxisValues[steamDeviceIndex, a] = inputEvent.value;

                InputSystem.QueueEvent(inputEvent);
            }
        }
    }
示例#2
0
    private void SendAxisEvents(int steamDeviceIndex, int deviceIndex)
    {
        int a = 0;

        for (int axis = (int)EVRButtonId.k_EButton_Axis0; axis <= (int)EVRButtonId.k_EButton_Axis4; ++axis)
        {
            Vector2 axisVec = SteamVR_Controller.Input(steamDeviceIndex).GetAxis((EVRButtonId)axis);
            for (XorY xy = XorY.X; (int)xy <= (int)XorY.Y; xy++, a++)
            {
                var inputEvent = InputSystem.CreateEvent <GenericControlEvent>();
                inputEvent.deviceType   = typeof(VRInputDevice);
                inputEvent.deviceIndex  = deviceIndex;
                inputEvent.controlIndex = a;
                inputEvent.value        = xy == XorY.X ? axisVec.x : axisVec.y;

                if (Mathf.Approximately(m_LastAxisValues[steamDeviceIndex, a], inputEvent.value))
                {
                    //TODO Does continue need to be commented out for some reason?
                    //continue;
                }
                m_LastAxisValues[steamDeviceIndex, a] = inputEvent.value;

                InputSystem.QueueEvent(inputEvent);
            }
        }
    }
示例#3
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("direction: " + _direction.ToString());
            sb.AppendLine("xory: " + XorY.ToString());
            sb.AppendLine("Start: " + string.Format("( {0:f1}, {1:f1} )", Start.X, Start.Y));
            sb.AppendLine("End: " + string.Format("( {0:f1}, {1:f1} )", End.X, End.Y));
            sb.AppendLine("Length: " + string.Format("{0:f1}", Length));
            sb.AppendLine("CrossPointCount: " + string.Format("{0:d}", CrossPointCount));
            sb.AppendLine("Segments: ");
            foreach (var seg in _segments)
            {
                sb.AppendLine(string.Format("    ( {0:f1}, {1:f1} ) - ( {2:f1}, {3:f1} )", seg.Start.X, seg.Start.Y, seg.End.X, seg.End.Y));
            }
            return(string.Format(sb.ToString()));
        }
        private static double search_min(List <System.Windows.Point> cdt, XorY xy)
        {
            double min     = 0.0;
            bool   isFirst = true;

            if (xy == XorY.X)
            {
                foreach (var value in cdt)
                {
                    if (isFirst)
                    {
                        min     = value.X;
                        isFirst = false;
                        continue;
                    }
                    if (min >= value.X)
                    {
                        min = value.X;
                    }
                }
            }
            else if (xy == XorY.Y)
            {
                foreach (var value in cdt)
                {
                    if (isFirst)
                    {
                        min     = value.Y;
                        isFirst = false;
                        continue;
                    }
                    if (min >= value.Y)
                    {
                        min = value.Y;
                    }
                }
            }

            return(min);
        }