Exemplo n.º 1
0
        public override void Update(params long[] values)
        {
            var outputValues = new long[] { values[0], values[1] };

            if (DeadZone != 0)
            {
                if (CircularDz)
                {
                    outputValues = _circularDeadZoneHelper.ApplyRangeDeadZone(outputValues);
                }
                else
                {
                    outputValues[0] = _deadZoneHelper.ApplyRangeDeadZone(outputValues[0]);
                    outputValues[1] = _deadZoneHelper.ApplyRangeDeadZone(outputValues[1]);
                }
            }
            if (Sensitivity != 100)
            {
                if (Linear)
                {
                    outputValues[0] = (long)(outputValues[0] * _linearSenstitivityScaleFactor);
                    outputValues[1] = (long)(outputValues[1] * _linearSenstitivityScaleFactor);
                }
                else
                {
                    outputValues[0] = _sensitivityHelper.ApplyRangeSensitivity(outputValues[0]);
                    outputValues[1] = _sensitivityHelper.ApplyRangeSensitivity(outputValues[1]);
                }
            }

            outputValues[0] = Functions.ClampAxisRange(outputValues[0]);
            outputValues[1] = Functions.ClampAxisRange(outputValues[1]);

            if (InvertX)
            {
                outputValues[0] = Functions.Invert(outputValues[0]);
            }
            if (InvertY)
            {
                outputValues[1] = Functions.Invert(outputValues[1]);
            }

            if (Math.Abs(Rotation) > 0)
            {
                var vector = new Vector(outputValues[0], outputValues[1]);
                vector          = vector.Rotate(Rotation);
                outputValues[0] = (long)vector.X;
                outputValues[1] = (long)vector.Y;
            }

            WriteOutput(0, outputValues[0]);
            WriteOutput(1, outputValues[1]);
        }
        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 (Sensitivity != 100)
            {
                value = _sensitivityHelper.ApplyRangeSensitivity(value);
            }

            _currentInputValue = value;

            if (RelativeContinue)
            {
                SetRelativeThreadState(value != 0);
            }
            else
            {
                RelativeUpdate();
            }
        }
Exemplo n.º 3
0
        public override void Update(params short[] values)
        {
            var value = values[0];

            if (value != 0)
            {
                value = _deadZoneHelper.ApplyRangeDeadZone(value);
            }
            if (Invert)
            {
                value = Functions.Invert(value);
            }
            if (Sensitivity != 100)
            {
                value = _sensitivityHelper.ApplyRangeSensitivity(value);
            }

            if (value == 0)
            {
                SetAbsoluteTimerState(false);
                _currentDelta = 0;
            }
            else
            {
                var sign = Math.Sign(value);
                _currentDelta = Functions.ClampAxisRange(Convert.ToInt32(Min + Functions.WideAbs(value) * _scaleFactor) * sign);
                //Debug.WriteLine($"New Delta: {_currentDelta}");
                SetAbsoluteTimerState(true);
            }
        }
Exemplo n.º 4
0
        public override void Update(params long[] values)
        {
            var value = values[0];

            if (Invert)
            {
                value = Functions.Invert(value);
            }
            if (DeadZone != 0)
            {
                value = _deadZoneHelper.ApplyRangeDeadZone(value);
            }
            if (Sensitivity != 100)
            {
                value = _sensitivityHelper.ApplyRangeSensitivity(value);
            }

            // Respect the axis min and max ranges.
            value = Math.Min(Math.Max(value, Constants.AxisMinValue), Constants.AxisMaxValue);
            _currentInputValue = value;

            if (RelativeContinue)
            {
                SetRelativeThreadState(value != 0);
            }
            else
            {
                RelativeUpdate();
            }
        }
Exemplo n.º 5
0
        public long SensitivityHelperValueLinearTests(long inputValue, int percentage)
        {
            var helper = new SensitivityHelper {
                Percentage = percentage, IsLinear = true
            };

            return(helper.ApplyRangeSensitivity(inputValue));
        }
Exemplo n.º 6
0
        public short SensitivityHelperValueTests(short inputValue, int percentage)
        {
            var helper = new SensitivityHelper {
                Percentage = percentage
            };

            return(helper.ApplyRangeSensitivity(inputValue));
        }
Exemplo n.º 7
0
        public override void Update(params short[] values)
        {
            var outputValues = new short[] { values[0], values[1] };

            if (DeadZone != 0)
            {
                if (CircularDz)
                {
                    outputValues = _circularDeadZoneHelper.ApplyRangeDeadZone(outputValues);
                }
                else
                {
                    outputValues[0] = _deadZoneHelper.ApplyRangeDeadZone(outputValues[0]);
                    outputValues[1] = _deadZoneHelper.ApplyRangeDeadZone(outputValues[1]);
                }
            }
            if (Sensitivity != 100)
            {
                if (Linear)
                {
                    outputValues[0] = (short)(outputValues[0] * _linearSensitivityScaleFactor);
                    outputValues[1] = (short)(outputValues[1] * _linearSensitivityScaleFactor);
                }
                else
                {
                    outputValues[0] = _sensitivityHelper.ApplyRangeSensitivity(outputValues[0]);
                    outputValues[1] = _sensitivityHelper.ApplyRangeSensitivity(outputValues[1]);
                }
            }

            outputValues[0] = Functions.ClampAxisRange(outputValues[0]);
            outputValues[1] = Functions.ClampAxisRange(outputValues[1]);

            if (InvertX)
            {
                outputValues[0] = Functions.Invert(outputValues[0]);
            }
            if (InvertY)
            {
                outputValues[1] = Functions.Invert(outputValues[1]);
            }

            WriteOutput(0, outputValues[0]);
            WriteOutput(1, outputValues[1]);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public override void Update(params short[] values)
        {
            var   valueHigh = values[0];
            var   valueLow  = values[1];
            short valueOutput;

            if (InvertHigh)
            {
                valueHigh = Functions.Invert(valueHigh);
            }
            if (InvertLow)
            {
                valueLow = Functions.Invert(valueLow);
            }

            switch (Mode)
            {
            case AxisMergerMode.Average:
                valueOutput = (short)((valueHigh + valueLow) / 2);
                break;

            case AxisMergerMode.Greatest:
                valueOutput = (Functions.SafeAbs(valueHigh) > Functions.SafeAbs(valueLow)) ? valueHigh : valueLow;
                break;

            case AxisMergerMode.Sum:
                valueOutput = Functions.ClampAxisRange(valueHigh + valueLow);
                break;

            default:
                valueOutput = 0;
                break;
            }

            if (DeadZone != 0)
            {
                valueOutput = _deadZoneHelper.ApplyRangeDeadZone(valueOutput);
            }

            if (Sensitivity != 100)
            {
                valueOutput = _sensitivityHelper.ApplyRangeSensitivity(valueOutput);
            }

            WriteOutput(0, valueOutput);
        }
Exemplo n.º 10
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 (Sensitivity != 100)
            {
                value = _sensitivityHelper.ApplyRangeSensitivity(value);
            }
            WriteOutput(0, value);
        }
Exemplo n.º 11
0
        public override void Update(params short[] values)
        {
            if (values[3] == 1)
            {
                // Reset held
                _trimX = 0;
                _trimY = 0;
            }
            else if (values[2] == 1)
            {
                // Trim held
                if (!_trimValueTaken)
                {
                    // First iteration through, store new trim value and set _trimValueTaken flag
                    _trimX         += values[0];
                    _trimY         += values[1];
                    _trimValueTaken = true;
                }
            }
            else
            {
                var outputValues = new[] { values[0], values[1] };
                if (values[2] == 0)
                {
                    _trimValueTaken = false;                    // ToDo: This is clumsy, fix once we can get notification of *which* input changed state
                }
                if (DeadZone != 0)
                {
                    if (CircularDz)
                    {
                        outputValues = _circularDeadZoneHelper.ApplyRangeDeadZone(outputValues);
                    }
                    else
                    {
                        outputValues[0] = _deadZoneHelper.ApplyRangeDeadZone(outputValues[0]);
                        outputValues[1] = _deadZoneHelper.ApplyRangeDeadZone(outputValues[1]);
                    }
                }
                if (Sensitivity != 100)
                {
                    if (Linear)
                    {
                        outputValues[0] = (short)(outputValues[0] * _linearSenstitivityScaleFactor);
                        outputValues[1] = (short)(outputValues[1] * _linearSenstitivityScaleFactor);
                    }
                    else
                    {
                        outputValues[0] = _sensitivityHelper.ApplyRangeSensitivity(outputValues[0]);
                        outputValues[1] = _sensitivityHelper.ApplyRangeSensitivity(outputValues[1]);
                    }
                }

                // Apply trim
                outputValues[0] += _trimX;
                outputValues[1] += _trimY;

                outputValues[0] = Functions.ClampAxisRange(outputValues[0]);
                outputValues[1] = Functions.ClampAxisRange(outputValues[1]);

                if (InvertX)
                {
                    outputValues[0] = Functions.Invert(outputValues[0]);
                }
                if (InvertY)
                {
                    outputValues[1] = Functions.Invert(outputValues[1]);
                }

                WriteOutput(0, outputValues[0]);
                WriteOutput(1, outputValues[1]);
            }
        }
Exemplo n.º 12
0
        public long SensitivityHelperInitTests(long inputValue)
        {
            var helper = new SensitivityHelper();

            return(helper.ApplyRangeSensitivity(inputValue));
        }
Exemplo n.º 13
0
        public short SensitivityHelperInitTests(short inputValue)
        {
            var helper = new SensitivityHelper();

            return(helper.ApplyRangeSensitivity(inputValue));
        }