Beispiel #1
0
        /// <summary>
        /// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
        /// The new axes will appear after any that were previously defined.
        /// </summary>
        /// <param name="nameFormat">format string e.g. <c>"P1 Left {0}"</c> (will be used to interpolate <c>"X"</c> and <c>"Y"</c>)</param>
        /// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
        public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, Range <int> rangeX, int midX, Range <int> rangeY, int midY, AxisConstraint constraint = null)
        {
            var yAxisName       = string.Format(nameFormat, "Y");
            var finalConstraint = constraint ?? new NoOpAxisConstraint(yAxisName);

            return(def.AddAxis(string.Format(nameFormat, "X"), rangeX, midX, ((byte)pDir & 2) != 0, finalConstraint)
                   .AddAxis(yAxisName, rangeY, midY, ((byte)pDir & 1) != 0));
        }
Beispiel #2
0
 /// <summary>
 /// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
 /// The new axes will appear after any that were previously defined.
 /// </summary>
 /// <param name="nameFormat">format string e.g. <c>"P1 Left {0}"</c> (will be used to interpolate <c>"X"</c> and <c>"Y"</c>)</param>
 /// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
 public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, Range <int> rangeBoth, int midBoth, AxisConstraint constraint = null)
 => def.AddXYPair(nameFormat, pDir, rangeBoth, midBoth, rangeBoth, midBoth, constraint);
 public static List <AxisRange> CreateAxisRangePair(int min, int mid, int max, AxisPairOrientation pDir) => new List <AxisRange>
 {
     new AxisRange(min, mid, max, ((byte)pDir & 2) != 0),
     new AxisRange(min, mid, max, ((byte)pDir & 1) != 0)
 };