示例#1
0
        /// <summary>
        /// Registers an axis input to the controller.
        /// </summary>
        /// <param name="inputName">Name used for identification.</param>
        /// <param name="theAxis">Axis input.</param>
        /// <param name="replace">Whether or not to replace an existing input with the same inputName.</param>
        /// <returns>An AxisInputSet created from the provided AxisInput.</returns>
        public AxisInputSet AddAxisInput(string inputName, AxisInput theAxis, bool replace = false)
        {
            AxisInputSet set;

            if (axis.ContainsKey(inputName))
            {
                if (replace)
                {
                    axis.Remove(inputName);
                    set = new AxisInputSet(theAxis);
                    axis.Add(inputName, set);
                }
                else
                {
                    set = axis[inputName];
                    set.Inputs.Add(theAxis);
                }
            }
            else
            {
                set = new AxisInputSet(theAxis);
                axis.Add(inputName, set);
            }
            set.PlayerIndex = PlayerIndex;
            set.Key         = inputName;
            return(set);
        }
示例#2
0
 /// <summary>
 /// Removes an AxisInputSet from the controller.
 /// </summary>
 /// <param name="input">AxisInputSet to remove.</param>
 /// <returns>True if the AxisInputSet was found and removed.</returns>
 public bool RemoveAxisInput(AxisInputSet input)
 {
     foreach (KeyValuePair <string, AxisInputSet> btn in axis)
     {
         if (btn.Value == input)
         {
             buttons.Remove(btn.Key);
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        public AxisInputSet DeepCopy()
        {
            List <AxisInput> copyInputs = new List <AxisInput>();

            foreach (AxisInput existing in Inputs)
            {
                copyInputs.Add(existing.DeepCopy());
            }

            AxisInputSet copy = new AxisInputSet(copyInputs);

            return(copy);
        }
示例#4
0
        public bool RemoveAxisInput(string inputName, AxisInput theAxis)
        {
            if (!buttons.ContainsKey(inputName))
            {
                return(false);
            }

            AxisInputSet axisInput = axis[inputName];

            axisInput.Inputs.Remove(theAxis);
            if (axis.Count == 0)
            {
                buttons.Remove(inputName);
            }
            return(true);
        }
示例#5
0
        /// <summary>
        /// Registers multiple axis inputs to the controller, under a shared ID.
        /// </summary>
        /// <param name="inputName">Name used for identification.</param>
        /// <param name="replace">Whether or not to replace existing inputs with the same inputName.</param>
        /// <param name="axis">One or more axis to be added. All axis inputs will be assigned to the same ID.</param>
        /// <returns>An AxisInputSet created from the provided AxisInputs.</returns>
        public AxisInputSet AddAxisInput(string inputName, bool replace = false, params AxisInput[] axis)
        {
            AxisInputSet set = null;

            if (replace)
            {
                this.axis.Remove(inputName);
            }
            for (int i = 0; i < axis.Length; i++)
            {
                set = AddAxisInput(inputName, axis[i]);
            }
            if (set == null)
            {
                return(null);
            }

            set.Key         = inputName;
            set.PlayerIndex = PlayerIndex;
            return(set);
        }