コード例 #1
0
        /// <summary>
        /// Register an axis to be then tracked by the recorder.
        /// </summary>
        /// <param name="axis"></param>
        public static void RecordAxis(AxisInfo axis)
        {
            if (instance.recordedAxis.ContainsKey(axis.name))
            {
                return;
            }

            instance.recordedAxis.Add(axis.name, new Status
            {
                posStatus = new AxisStatus(),
                negStatus = new AxisStatus()
            });
        }
コード例 #2
0
ファイル: Profile.cs プロジェクト: Ayoub-AH/LightIsLife
        public Profile(int playerNum, int deviceNum)
        {
            var model = Models[playerNum];

            keys   = model.keys;
            axises = model.keys.Values
                     .Where(KeyGroup.IsFromAxis)
                     .ToDictionary(
                key => key,
                key => AxisInfo.From(key, deviceNum));

            foreach (var axis in axises.Values)
            {
                Recorder.RecordAxis(axis);
            }
            keyShift = deviceNum * ((int)KeyCode.Joystick2Button0 - (int)KeyCode.Joystick1Button0);
        }
コード例 #3
0
        /// <summary>
        /// Returns the status of the axis button.
        /// </summary>
        /// <param name="axis"></param>
        /// <returns></returns>
        public static AxisStatus StatusOf(AxisInfo axis)
        {
            var status = instance.recordedAxis[axis.name];

            return(axis.positiveValue ? status.posStatus : status.negStatus);
        }
コード例 #4
0
ファイル: AxisInfo.cs プロジェクト: Ayoub-AH/LightIsLife
        /// <summary>
        /// Retrieves axis info from a key and the device's number used.
        /// This function must be updated when new axes are added in Unity.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="deviceNum"></param>
        /// <returns></returns>
        public static AxisInfo From(Key key, int deviceNum)
        {
            var info = new AxisInfo();

            info.name = "Gamepad" + (deviceNum + 1);

            switch (key)
            {
            case Key.GamepadLeftJoystickUp:
                info.name         += "LeftJoystickUp";
                info.positiveValue = true;
                break;

            case Key.GamepadLeftJoystickDown:
                info.name         += "LeftJoystickUp";
                info.positiveValue = false;
                break;

            case Key.GamepadLeftJoystickLeft:
                info.name         += "LeftJoystickLeft";
                info.positiveValue = true;
                break;

            case Key.GamepadLeftJoystickRight:
                info.name         += "LeftJoystickLeft";
                info.positiveValue = false;
                break;

            case Key.GamepadRightJoystickUp:
                info.name         += "RightJoystickUp";
                info.positiveValue = true;
                break;

            case Key.GamepadRightJoystickDown:
                info.name         += "RightJoystickUp";
                info.positiveValue = false;
                break;

            case Key.GamepadRightJoystickLeft:
                info.name         += "RightJoystickLeft";
                info.positiveValue = true;
                break;

            case Key.GamepadRightJoystickRight:
                info.name         += "RightJoystickLeft";
                info.positiveValue = false;
                break;

            case Key.GamepadPadUp:
                info.name         += "PadUp";
                info.positiveValue = true;
                break;

            case Key.GamepadPadDown:
                info.name         += "PadUp";
                info.positiveValue = false;
                break;

            case Key.GamepadPadLeft:
                info.name         += "PadLeft";
                info.positiveValue = true;
                break;

            case Key.GamepadPadRight:
                info.name         += "PadLeft";
                info.positiveValue = false;
                break;

            case Key.GamepadL2:
                info.name         += "Triggers";
                info.positiveValue = true;
                break;

            case Key.GamepadR2:
                info.name         += "Triggers";
                info.positiveValue = false;
                break;

            default:
                throw new ArgumentOutOfRangeException("key", key, null);
            }
            return(info);
        }