コード例 #1
0
ファイル: InputManager.cs プロジェクト: tammukul/InputManager
        public static AxisConfiguration CreateRemoteAxis(string inputConfigName, string axisName)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
                return(null);
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(axisName))
            {
                Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName));
                return(null);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(axisName);

            axisConfig.type        = InputType.RemoteAxis;
            axisConfig.positive    = KeyCode.None;
            axisConfig.negative    = KeyCode.None;
            axisConfig.altPositive = KeyCode.None;
            axisConfig.altNegative = KeyCode.None;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(axisName, axisConfig);

            return(axisConfig);
        }
コード例 #2
0
ファイル: InputManager.cs プロジェクト: tammukul/InputManager
        public static AxisConfiguration CreateButton(string inputConfigName, string buttonName, KeyCode primaryKey, KeyCode secondaryKey)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
                return(null);
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(buttonName))
            {
                Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName));
                return(null);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(buttonName);

            axisConfig.type        = InputType.Button;
            axisConfig.positive    = primaryKey;
            axisConfig.altPositive = secondaryKey;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(buttonName, axisConfig);

            return(axisConfig);
        }
コード例 #3
0
        public static AxisConfiguration CreateMouseAxis(string configuration, string name, int axis, float sensitivity)
        {
            InputConfiguration inputConfig = GetConfiguration(configuration);

            if (inputConfig == null)
            {
                throw new ArgumentException("Unable to find any input configuration named " + configuration);
            }
            if (_instance._axesTable[configuration].ContainsKey(name))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", configuration, name);
                throw new ArgumentException(error);
            }
            if (axis < 0 || axis > 2)
            {
                throw new ArgumentOutOfRangeException("axis");
            }

            AxisConfiguration axisConfig = new AxisConfiguration(name);

            axisConfig.type        = InputType.MouseAxis;
            axisConfig.axis        = axis;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[configuration];

            table.Add(name, axisConfig);

            return(axisConfig);
        }
コード例 #4
0
        public static AxisConfiguration CreateEmptyAxis(string configuration, string name)
        {
            InputConfiguration inputConfig = GetConfiguration(configuration);

            if (inputConfig == null)
            {
                throw new ArgumentException("Unable to find any input configuration named " + configuration);
            }
            if (_instance._axesTable[configuration].ContainsKey(name))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", configuration, name);
                throw new ArgumentException(error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(name);

            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[configuration];

            table.Add(name, axisConfig);

            return(axisConfig);
        }
コード例 #5
0
        public static AxisConfiguration CreateButton(string configuration, string name, KeyCode primaryKey, KeyCode secondaryKey)
        {
            InputConfiguration inputConfig = GetConfiguration(configuration);

            if (inputConfig == null)
            {
                throw new ArgumentException("Unable to find any input configuration named " + configuration);
            }
            if (_instance._axesTable[configuration].ContainsKey(name))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", configuration, name);
                throw new ArgumentException(error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(name);

            axisConfig.type        = InputType.Button;
            axisConfig.positive    = primaryKey;
            axisConfig.altPositive = secondaryKey;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[configuration];

            table.Add(name, axisConfig);

            return(axisConfig);
        }
コード例 #6
0
        public static AxisConfiguration CreateDigitalAxis(string configuration, string name, KeyCode positive, KeyCode negative,
                                                          KeyCode altPositive, KeyCode altNegative, float gravity, float sensitivity)
        {
            InputConfiguration inputConfig = GetConfiguration(configuration);

            if (inputConfig == null)
            {
                throw new ArgumentException("Unable to find any input configuration named " + configuration);
            }
            if (_instance._axesTable[configuration].ContainsKey(name))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", configuration, name);
                throw new ArgumentException(error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(name);

            axisConfig.type        = InputType.DigitalAxis;
            axisConfig.positive    = positive;
            axisConfig.negative    = negative;
            axisConfig.altPositive = altPositive;
            axisConfig.altNegative = altNegative;
            axisConfig.gravity     = gravity;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[configuration];

            table.Add(name, axisConfig);

            return(axisConfig);
        }
コード例 #7
0
        public static AxisConfiguration CreateEmptyAxis(string inputConfigName, string axisName)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                throw new ArgumentException(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(axisName))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName);
                throw new ArgumentException(error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(axisName);

            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(axisName, axisConfig);

            return(axisConfig);
        }
コード例 #8
0
ファイル: InputManager.cs プロジェクト: tammukul/InputManager
        public static AxisConfiguration CreateMouseAxis(string inputConfigName, string axisName, int axis, float sensitivity)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
                return(null);
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(axisName))
            {
                Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName));
                return(null);
            }
            if (axis < 0 || axis > 2)
            {
                Debug.LogError("Mouse axis is out of range. Cannot create new mouse axis.");
                return(null);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(axisName);

            axisConfig.type        = InputType.MouseAxis;
            axisConfig.axis        = axis;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(axisName, axisConfig);

            return(axisConfig);
        }
コード例 #9
0
        public static AxisConfiguration CreateRemoteButton(string inputConfigName, string buttonName)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                throw new ArgumentException(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(buttonName))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName);
                throw new ArgumentException(error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(buttonName);

            axisConfig.type        = InputType.RemoteButton;
            axisConfig.positive    = KeyCode.None;
            axisConfig.negative    = KeyCode.None;
            axisConfig.altPositive = KeyCode.None;
            axisConfig.altNegative = KeyCode.None;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(buttonName, axisConfig);

            return(axisConfig);
        }
コード例 #10
0
        public static AxisConfiguration CreateMouseAxis(string inputConfigName, string axisName, int axis, float sensitivity)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                throw new ArgumentException(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(axisName))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName);
                throw new ArgumentException(error);
            }
            if (axis < 0 || axis > 2)
            {
                throw new ArgumentOutOfRangeException("axis");
            }

            AxisConfiguration axisConfig = new AxisConfiguration(axisName);

            axisConfig.type        = InputType.MouseAxis;
            axisConfig.axis        = axis;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(axisName, axisConfig);

            return(axisConfig);
        }
コード例 #11
0
        public static AxisConfiguration CreateDigitalAxis(string inputConfigName, string axisName, KeyCode positive, KeyCode negative,
                                                          KeyCode altPositive, KeyCode altNegative, float gravity, float sensitivity)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                throw new ArgumentException(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(axisName))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName);
                throw new ArgumentException(error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(axisName);

            axisConfig.type        = InputType.DigitalAxis;
            axisConfig.positive    = positive;
            axisConfig.negative    = negative;
            axisConfig.altPositive = altPositive;
            axisConfig.altNegative = altNegative;
            axisConfig.gravity     = gravity;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(axisName, axisConfig);

            return(axisConfig);
        }
コード例 #12
0
ファイル: InputManager.cs プロジェクト: tammukul/InputManager
        public static AxisConfiguration CreateAnalogButton(string inputConfigName, string buttonName, int joystick, int axis)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
                return(null);
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(buttonName))
            {
                Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName));
                return(null);
            }
            if (axis < 0 || axis >= AxisConfiguration.MaxJoystickAxes)
            {
                Debug.LogError("Joystick axis is out of range. Cannot create new analog button.");
                return(null);
            }
            if (joystick < 0 || joystick >= AxisConfiguration.MaxJoysticks)
            {
                Debug.LogError("Joystick is out of range. Cannot create new analog button.");
                return(null);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(buttonName);

            axisConfig.type        = InputType.AnalogButton;
            axisConfig.joystick    = joystick;
            axisConfig.axis        = axis;
            axisConfig.positive    = KeyCode.None;
            axisConfig.negative    = KeyCode.None;
            axisConfig.altPositive = KeyCode.None;
            axisConfig.altNegative = KeyCode.None;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(buttonName, axisConfig);

            return(axisConfig);
        }
コード例 #13
0
ファイル: InputManager.cs プロジェクト: tammukul/InputManager
        public static AxisConfiguration CreateAnalogAxis(string inputConfigName, string axisName, int joystick, int axis, float sensitivity, float deadZone)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
                return(null);
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(axisName))
            {
                Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName));
                return(null);
            }
            if (axis < 0 || axis >= AxisConfiguration.MaxJoystickAxes)
            {
                Debug.LogError("Joystick axis is out of range. Cannot create new analog axis.");
                return(null);
            }
            if (joystick < 0 || joystick >= AxisConfiguration.MaxJoysticks)
            {
                Debug.LogError("Joystick is out of range. Cannot create new analog axis.");
                return(null);
            }

            AxisConfiguration axisConfig = new AxisConfiguration(axisName);

            axisConfig.type        = InputType.AnalogAxis;
            axisConfig.axis        = axis;
            axisConfig.joystick    = joystick;
            axisConfig.deadZone    = deadZone;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(axisName, axisConfig);

            return(axisConfig);
        }
コード例 #14
0
        public static AxisConfiguration CreateAnalogButton(string inputConfigName, string buttonName, int joystick, int axis)
        {
            InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);

            if (inputConfig == null)
            {
                throw new ArgumentException(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable[inputConfigName].ContainsKey(buttonName))
            {
                string error = string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName);
                throw new ArgumentException(error);
            }
            if (axis < 0 || axis >= AxisConfiguration.MaxJoystickAxes)
            {
                throw new ArgumentOutOfRangeException("axis");
            }
            if (joystick < 0 || joystick >= AxisConfiguration.MaxJoysticks)
            {
                throw new ArgumentOutOfRangeException("joystick");
            }

            AxisConfiguration axisConfig = new AxisConfiguration(buttonName);

            axisConfig.type        = InputType.AnalogButton;
            axisConfig.joystick    = joystick;
            axisConfig.axis        = axis;
            axisConfig.positive    = KeyCode.None;
            axisConfig.negative    = KeyCode.None;
            axisConfig.altPositive = KeyCode.None;
            axisConfig.altNegative = KeyCode.None;
            axisConfig.Initialize();
            inputConfig.axes.Add(axisConfig);

            var table = _instance._axesTable[inputConfigName];

            table.Add(buttonName, axisConfig);

            return(axisConfig);
        }
コード例 #15
0
		public static AxisConfiguration CreateButton(string inputConfigName, string buttonName, KeyCode primaryKey, KeyCode secondaryKey)
		{
			InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);
			if(inputConfig == null)
			{
				Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
				return null;
			}
			if(_instance._axesTable[inputConfigName].ContainsKey(buttonName))
			{
				Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName));
				return null;
			}
			
			AxisConfiguration axisConfig = new AxisConfiguration(buttonName);
			axisConfig.type = InputType.Button;
			axisConfig.positive = primaryKey;
			axisConfig.altPositive = secondaryKey;
			axisConfig.Initialize();
			inputConfig.axes.Add(axisConfig);
			
			var table = _instance._axesTable[inputConfigName];
			table.Add(buttonName, axisConfig);
			
			return axisConfig;
		}
        public static AxisConfiguration CreateDigitalAxis(string inputConfigName, string axisName, KeyCode positive, KeyCode negative,
                                                          KeyCode altPositive, KeyCode altNegative, float gravity, float sensitivity)
        {
            InputConfiguration inputConfig = GetInputConfiguration (inputConfigName);
            if (inputConfig == null) {
                throw new ArgumentException (string.Format ("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable [inputConfigName].ContainsKey (axisName)) {
                string error = string.Format ("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName);
                throw new ArgumentException (error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration (axisName);
            axisConfig.type = InputType.DigitalAxis;
            axisConfig.positive = positive;
            axisConfig.negative = negative;
            axisConfig.altPositive = altPositive;
            axisConfig.altNegative = altNegative;
            axisConfig.gravity = gravity;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize ();
            inputConfig.axes.Add (axisConfig);

            var table = _instance._axesTable [inputConfigName];
            table.Add (axisName, axisConfig);

            return axisConfig;
        }
        public static AxisConfiguration CreateMouseAxis(string inputConfigName, string axisName, int axis, float sensitivity)
        {
            InputConfiguration inputConfig = GetInputConfiguration (inputConfigName);
            if (inputConfig == null) {
                throw new ArgumentException (string.Format ("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable [inputConfigName].ContainsKey (axisName)) {
                string error = string.Format ("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName);
                throw new ArgumentException (error);
            }
            if (axis < 0 || axis > 2)
                throw new ArgumentOutOfRangeException ("axis");

            AxisConfiguration axisConfig = new AxisConfiguration (axisName);
            axisConfig.type = InputType.MouseAxis;
            axisConfig.axis = axis;
            axisConfig.sensitivity = sensitivity;
            axisConfig.Initialize ();
            inputConfig.axes.Add (axisConfig);

            var table = _instance._axesTable [inputConfigName];
            table.Add (axisName, axisConfig);

            return axisConfig;
        }
コード例 #18
0
        private void Start()
        {
            InputConfiguration inputConfig = InputManager.GetInputConfiguration(_inputConfiguration);

            if (inputConfig == null)
            {
                Debug.LogWarning(string.Format("An input configuration named \'{0}\' does not exist", _inputConfiguration), this);
                return;
            }

            int axisCount           = inputConfig.axes.Count;
            int joystickButtonCount = (int)KeyCode.Joystick1Button19 - (int)KeyCode.Joystick1Button0 + 1;

            //	All new axes will be added at the end of the list so it's safe to iterate normally to
            //	the initial number of axes
            for (int i = 0; i < axisCount; i++)
            {
                AxisConfiguration orig = inputConfig.axes[i];
                if (!orig.name.EndsWith("_P1"))
                {
                    continue;
                }

                if (orig.joystick > 0)
                {
                    Debug.LogError(string.Format("Cannot clone axis {0} of configuration {1} because joystick is {2} instead of 0", orig.name, _inputConfiguration, orig.joystick), this);
                    continue;
                }

                if ((orig.positive != KeyCode.None && ((int)orig.positive < (int)KeyCode.Joystick1Button0 || (int)orig.positive > (int)KeyCode.Joystick1Button19)) ||
                    (orig.altPositive != KeyCode.None && ((int)orig.altPositive < (int)KeyCode.Joystick1Button0 || (int)orig.altPositive > (int)KeyCode.Joystick1Button19)) ||
                    (orig.negative != KeyCode.None && ((int)orig.negative < (int)KeyCode.Joystick1Button0 || (int)orig.negative > (int)KeyCode.Joystick1Button19)) ||
                    (orig.altNegative != KeyCode.None && ((int)orig.altNegative < (int)KeyCode.Joystick1Button0 || (int)orig.altNegative > (int)KeyCode.Joystick1Button19)))
                {
                    Debug.LogError(string.Format("Cannot clone axis {0} of configuration {1} because some key codes are invalid", orig.name, _inputConfiguration), this);
                    continue;
                }

                for (int c = 0; c < _numberOfClones; c++)
                {
                    string            axisName = orig.name.Substring(0, orig.name.Length - 3) + "_P" + (c + 2);
                    AxisConfiguration clone    = InputManager.CreateEmptyAxis(_inputConfiguration, axisName);
                    clone.Copy(orig);
                    clone.name = axisName;
                    if (orig.positive != KeyCode.None)
                    {
                        clone.positive = (KeyCode)((int)orig.positive + (c + 1) * joystickButtonCount);
                    }
                    if (orig.altPositive != KeyCode.None)
                    {
                        clone.altPositive = (KeyCode)((int)orig.altPositive + (c + 1) * joystickButtonCount);
                    }
                    if (orig.negative != KeyCode.None)
                    {
                        clone.negative = (KeyCode)((int)orig.negative + (c + 1) * joystickButtonCount);
                    }
                    if (orig.altNegative != KeyCode.None)
                    {
                        clone.altNegative = (KeyCode)((int)orig.altNegative + (c + 1) * joystickButtonCount);
                    }
                    clone.joystick = c + 1;
                    clone.Initialize();
                }
            }
        }
コード例 #19
0
		public static AxisConfiguration CreateAnalogButton(string inputConfigName, string buttonName, int joystick, int axis)
		{
			InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);
			if(inputConfig == null)
			{
				Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
				return null;
			}
			if(_instance._axesTable[inputConfigName].ContainsKey(buttonName))
			{
				Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName));
				return null;
			}
			if(axis < 0 || axis >= AxisConfiguration.MaxJoystickAxes)
			{
				Debug.LogError("Joystick axis is out of range. Cannot create new analog button.");
				return null;
			}
			if(joystick < 0 || joystick >= AxisConfiguration.MaxJoysticks)
			{
				Debug.LogError("Joystick is out of range. Cannot create new analog button.");
				return null;
			}
			
			AxisConfiguration axisConfig = new AxisConfiguration(buttonName);
			axisConfig.type = InputType.AnalogButton;
			axisConfig.joystick = joystick;
			axisConfig.axis = axis;
			axisConfig.positive = KeyCode.None;
			axisConfig.negative = KeyCode.None;
			axisConfig.altPositive = KeyCode.None;
			axisConfig.altNegative = KeyCode.None;
			axisConfig.Initialize();
			inputConfig.axes.Add(axisConfig);
			
			var table = _instance._axesTable[inputConfigName];
			table.Add(buttonName, axisConfig);
			
			return axisConfig;
		}
        public static AxisConfiguration CreateAnalogButton(string inputConfigName, string buttonName, int joystick, int axis)
        {
            InputConfiguration inputConfig = GetInputConfiguration (inputConfigName);
            if (inputConfig == null) {
                throw new ArgumentException (string.Format ("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable [inputConfigName].ContainsKey (buttonName)) {
                string error = string.Format ("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName);
                throw new ArgumentException (error);
            }
            if (axis < 0 || axis >= AxisConfiguration.MaxJoystickAxes)
                throw new ArgumentOutOfRangeException ("axis");
            if (joystick < 0 || joystick >= AxisConfiguration.MaxJoysticks)
                throw new ArgumentOutOfRangeException ("joystick");

            AxisConfiguration axisConfig = new AxisConfiguration (buttonName);
            axisConfig.type = InputType.AnalogButton;
            axisConfig.joystick = joystick;
            axisConfig.axis = axis;
            axisConfig.positive = KeyCode.None;
            axisConfig.negative = KeyCode.None;
            axisConfig.altPositive = KeyCode.None;
            axisConfig.altNegative = KeyCode.None;
            axisConfig.Initialize ();
            inputConfig.axes.Add (axisConfig);

            var table = _instance._axesTable [inputConfigName];
            table.Add (buttonName, axisConfig);

            return axisConfig;
        }
コード例 #21
0
		public static AxisConfiguration CreateMouseAxis(string inputConfigName, string axisName, int axis, float sensitivity)
		{
			InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);
			if(inputConfig == null)
			{
				Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
				return null;
			}
			if(_instance._axesTable[inputConfigName].ContainsKey(axisName))
			{
				Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName));
				return null;
			}
			if(axis < 0 || axis > 2)
			{
				Debug.LogError("Mouse axis is out of range. Cannot create new mouse axis.");
				return null;
			}
			
			AxisConfiguration axisConfig = new AxisConfiguration(axisName);
			axisConfig.type = InputType.MouseAxis;
			axisConfig.axis = axis;
			axisConfig.sensitivity = sensitivity;
			axisConfig.Initialize();
			inputConfig.axes.Add(axisConfig);
			
			var table = _instance._axesTable[inputConfigName];
			table.Add(axisName, axisConfig);
			
			return axisConfig;
		}
        public static AxisConfiguration CreateEmptyAxis(string inputConfigName, string axisName)
        {
            InputConfiguration inputConfig = GetInputConfiguration (inputConfigName);
            if (inputConfig == null) {
                throw new ArgumentException (string.Format ("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable [inputConfigName].ContainsKey (axisName)) {
                string error = string.Format ("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName);
                throw new ArgumentException (error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration (axisName);
            axisConfig.Initialize ();
            inputConfig.axes.Add (axisConfig);

            var table = _instance._axesTable [inputConfigName];
            table.Add (axisName, axisConfig);

            return axisConfig;
        }
コード例 #23
0
		public static AxisConfiguration CreateAnalogAxis(string inputConfigName, string axisName, int joystick, int axis, float sensitivity, float deadZone)
		{
			InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);
			if(inputConfig == null)
			{
				Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
				return null;
			}
			if(_instance._axesTable[inputConfigName].ContainsKey(axisName))
			{
				Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName));
				return null;
			}
			if(axis < 0 || axis >= AxisConfiguration.MaxJoystickAxes)
			{
				Debug.LogError("Joystick axis is out of range. Cannot create new analog axis.");
				return null;
			}
			if(joystick < 0 || joystick >= AxisConfiguration.MaxJoysticks)
			{
				Debug.LogError("Joystick is out of range. Cannot create new analog axis.");
				return null;
			}
			
			AxisConfiguration axisConfig = new AxisConfiguration(axisName);
			axisConfig.type = InputType.AnalogAxis;
			axisConfig.axis = axis;
			axisConfig.joystick = joystick;
			axisConfig.deadZone = deadZone;
			axisConfig.sensitivity = sensitivity;
			axisConfig.Initialize();
			inputConfig.axes.Add(axisConfig);
			
			var table = _instance._axesTable[inputConfigName];
			table.Add(axisName, axisConfig);
			
			return axisConfig;
		}
        public static AxisConfiguration CreateRemoteButton(string inputConfigName, string buttonName)
        {
            InputConfiguration inputConfig = GetInputConfiguration (inputConfigName);
            if (inputConfig == null) {
                throw new ArgumentException (string.Format ("An input configuration named \'{0}\' does not exist", inputConfigName));
            }
            if (_instance._axesTable [inputConfigName].ContainsKey (buttonName)) {
                string error = string.Format ("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, buttonName);
                throw new ArgumentException (error);
            }

            AxisConfiguration axisConfig = new AxisConfiguration (buttonName);
            axisConfig.type = InputType.RemoteButton;
            axisConfig.positive = KeyCode.None;
            axisConfig.negative = KeyCode.None;
            axisConfig.altPositive = KeyCode.None;
            axisConfig.altNegative = KeyCode.None;
            axisConfig.Initialize ();
            inputConfig.axes.Add (axisConfig);

            var table = _instance._axesTable [inputConfigName];
            table.Add (buttonName, axisConfig);

            return axisConfig;
        }
コード例 #25
0
		public static AxisConfiguration CreateRemoteAxis(string inputConfigName, string axisName)
		{
			InputConfiguration inputConfig = GetInputConfiguration(inputConfigName);
			if(inputConfig == null)
			{
				Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", inputConfigName));
				return null;
			}
			if(_instance._axesTable[inputConfigName].ContainsKey(axisName))
			{
				Debug.LogError(string.Format("The input configuration named {0} already contains an axis configuration named {1}", inputConfigName, axisName));
				return null;
			}
			
			AxisConfiguration axisConfig = new AxisConfiguration(axisName);
			axisConfig.type = InputType.RemoteAxis;
			axisConfig.positive = KeyCode.None;
			axisConfig.negative = KeyCode.None;
			axisConfig.altPositive = KeyCode.None;
			axisConfig.altNegative = KeyCode.None;
			axisConfig.Initialize();
			inputConfig.axes.Add(axisConfig);
			
			var table = _instance._axesTable[inputConfigName];
			table.Add(axisName, axisConfig);
			
			return axisConfig;
		}