Ejemplo n.º 1
0
        public short AntiDeadZoneHelperValueTests(short inputValue, int percentage)
        {
            var helper = new AntiDeadZoneHelper {
                Percentage = percentage
            };

            return(helper.ApplyRangeAntiDeadZone(inputValue));
        }
Ejemplo n.º 2
0
        public override void Update(params short[] values)
        {
            var value = values[0];


            // Empirical:
            // Throttle 0%   == 32k
            // Throttle 100% == -32k

            var axisPercentage = (32768 - value) / 65536f; // Percentage of input axis that is activated

            // rangeStart will represent where our range will begin
            int rangeStart = (int)Math.Ceiling((65536 * LowRange) / 100f);

            // rangeEnd will represent the end of our range
            int rangeEnd = (int)Math.Round((65536 * HighRange) / 100f);

            // outputRange is the range we are scaling the input axis to
            int outputRange = rangeEnd - rangeStart;

            // Calculate output value by scaling range to the absolute throttle percentage and offsetting with the max value and range start
            var tmp = 32768 - rangeStart - (int)Math.Round(outputRange * axisPercentage);

            // Debug.WriteLine($"d: {d} range: {range} Input: {value} output: {tmp}");

            // Let's limit the output value
            tmp   = Math.Max(tmp, -32767);
            tmp   = Math.Min(tmp, 32768);
            value = (short)tmp;

            if (Invert)
            {
                value = Functions.Invert(value);
            }
            if (DeadZone != 0)
            {
                value = _deadZoneHelper.ApplyRangeDeadZone(value);
            }
            if (AntiDeadZone != 0)
            {
                value = _antiDeadZoneHelper.ApplyRangeAntiDeadZone(value);
            }
            if (Sensitivity != 100)
            {
                value = _sensitivityHelper.ApplyRangeSensitivity(value);
            }
            WriteOutput(0, value);
        }
Ejemplo n.º 3
0
        public override void Update(params short[] values)
        {
            var value = values[0];

            if (Invert)
            {
                value = Functions.Invert(value);
            }
            if (DeadZone != 0)
            {
                value = _deadZoneHelper.ApplyRangeDeadZone(value);
            }
            if (AntiDeadZone != 0)
            {
                value = _antiDeadZoneHelper.ApplyRangeAntiDeadZone(value);
            }
            if (Sensitivity != 100)
            {
                value = _sensitivityHelper.ApplyRangeSensitivity(value);
            }
            WriteOutput(0, value);
        }
Ejemplo n.º 4
0
        public long AntiDeadZoneHelperInitTests(short inputValue)
        {
            var helper = new AntiDeadZoneHelper();

            return(helper.ApplyRangeAntiDeadZone(inputValue));
        }