Exemplo n.º 1
0
        /// <summary>
        ///     Gets the axis state of the current packet.
        /// </summary>
        /// <param name="axis">The DualShock axis to question.</param>
        /// <returns>The value of the axis in question.</returns>
        public IDsAxisState this[IDsAxis axis]
        {
            get
            {
                if ((axis is Ds3Axis && Model == DsModel.DS3) ||
                    (axis is Ds4Axis && Model == DsModel.DS4))
                {
                    if (axis.Equals(Ds3Axis.None) || axis.Equals(Ds4Axis.None))
                    {
                        return new DsAxisState {
                                   IsEngaged = false
                        }
                    }
                    ;

                    return(new DsAxisState
                    {
                        Value = RawBytes[axis.Offset],
                        IsEngaged = (axis.DefaultValue == 0x00)
                            ? (axis.DefaultValue != RawBytes[axis.Offset])

                                    /*
                                     * match a range for jitter compensation
                                     * if axis value is between 117 and 137 it's not reported as engaged
                                     * */
                            : (((axis.DefaultValue - 10) > RawBytes[axis.Offset]) ||
                               ((axis.DefaultValue + 10) < RawBytes[axis.Offset]))
                    });
                }

                // default is centered
                return(new DsAxisState());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Gets the axis state of the current packet.
        /// </summary>
        /// <param name="axis">The DualShock axis to question.</param>
        /// <returns>The value of the axis in question.</returns>
        public IDsAxisState this[IDsAxis axis]
        {
            get
            {
                if ((!(axis is Ds3Axis) || Model != DsModel.DS3) && (!(axis is Ds4Axis) || Model != DsModel.DS4))
                {
                    throw new NotImplementedException();
                }

                if (axis.Equals(Ds3Axis.None) || axis.Equals(Ds4Axis.None))
                {
                    _currentDsAxisState.IsEngaged = false;
                    return(_currentDsAxisState);
                }

                _currentDsAxisState.Value     = RawBytes[axis.Offset];
                _currentDsAxisState.IsEngaged = axis.DefaultValue == 0x00
                    ? axis.DefaultValue != RawBytes[axis.Offset]

                                                /*
                                                 * match a range for jitter compensation
                                                 * if axis value is between 117 and 137 it's not reported as engaged
                                                 * */
                    : (axis.DefaultValue - 10 > RawBytes[axis.Offset]) ||
                                                (axis.DefaultValue + 10 < RawBytes[axis.Offset]);

                return(_currentDsAxisState);
            }
        }
Exemplo n.º 3
0
 public DSAxis(IDsAxis parDs3Axis, IDsAxis parDs4Axis, bool parTriggerHigh)
 {
     m_DS3         = parDs3Axis;
     m_DS4         = parDs4Axis;
     m_TriggerHigh = parTriggerHigh;
 }
Exemplo n.º 4
0
 public DSAxis(IDsAxis parDs3Axis, IDsAxis parDs4Axis, bool parTriggerHigh)
 {
     m_DS3 = parDs3Axis;
     m_DS4 = parDs4Axis;
     m_TriggerHigh = parTriggerHigh;
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Sets the value of an analog axis to it's default value.
 /// </summary>
 /// <param name="axis">The axis of the current report to manipulate.</param>
 public void Unset(IDsAxis axis)
 {
     RawBytes[axis.Offset] = axis.DefaultValue;
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Sets the value of an analog axis.
 /// </summary>
 /// <param name="axis">The axis of the current report to manipulate.</param>
 /// <param name="value">The value to set the axis to.</param>
 public void Set(IDsAxis axis, byte value)
 {
     RawBytes[axis.Offset] = value;
 }
Exemplo n.º 7
0
        /// <summary>
        ///     Gets the axis state of the current packet.
        /// </summary>
        /// <param name="axis">The DualShock axis to question.</param>
        /// <returns>The value of the axis in question.</returns>
        public IDsAxisState this[IDsAxis axis]
        {
            get
            {
                if ((!(axis is Ds3Axis) || Model != DsModel.DS3) && (!(axis is Ds4Axis) || Model != DsModel.DS4))
                    throw new NotImplementedException();

                if (axis.Equals(Ds3Axis.None) || axis.Equals(Ds4Axis.None))
                {
                    _currentDsAxisState.IsEngaged = false;
                    return _currentDsAxisState;
                }

                _currentDsAxisState.Value = RawBytes[axis.Offset];
                _currentDsAxisState.IsEngaged = axis.DefaultValue == 0x00
                    ? axis.DefaultValue != RawBytes[axis.Offset]
                    /* 
                        * match a range for jitter compensation
                        * if axis value is between 117 and 137 it's not reported as engaged
                        * */
                    : (axis.DefaultValue - 10 > RawBytes[axis.Offset])
                      || (axis.DefaultValue + 10 < RawBytes[axis.Offset]);

                return _currentDsAxisState;
            }
        }
Exemplo n.º 8
0
 /// <summary>
 ///     Sets the value of an analog axis to it's default value.
 /// </summary>
 /// <param name="axis">The axis of the current report to manipulate.</param>
 public void Unset(IDsAxis axis)
 {
     RawBytes[axis.Offset] = axis.DefaultValue;
 }
Exemplo n.º 9
0
 /// <summary>
 ///     Sets the value of an analog axis.
 /// </summary>
 /// <param name="axis">The axis of the current report to manipulate.</param>
 /// <param name="value">The value to set the axis to.</param>
 public void Set(IDsAxis axis, byte value)
 {
     RawBytes[axis.Offset] = value;
 }
Exemplo n.º 10
0
        /// <summary>
        ///     Gets the axis state of the current packet.
        /// </summary>
        /// <param name="axis">The DualShock axis to question.</param>
        /// <returns>The value of the axis in question.</returns>
        public IDsAxisState this[IDsAxis axis]
        {
            get
            {
                if ((axis is Ds3Axis && Model == DsModel.DS3)
                    || (axis is Ds4Axis && Model == DsModel.DS4))
                {
                    if (axis.Equals(Ds3Axis.None) || axis.Equals(Ds4Axis.None))
                        return new DsAxisState {IsEngaged = false};

                    return new DsAxisState
                    {
                        Value = RawBytes[axis.Offset],
                        IsEngaged = (axis.DefaultValue == 0x00)
                            ? (axis.DefaultValue != RawBytes[axis.Offset])
                            /*
                             * match a range for jitter compensation
                             * if axis value is between 117 and 137 it's not reported as engaged
                             * */
                            : (((axis.DefaultValue - 10) > RawBytes[axis.Offset])
                               || ((axis.DefaultValue + 10) < RawBytes[axis.Offset]))
                    };
                }

                // default is centered
                return new DsAxisState();
            }
        }