/// <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()); } }
/// <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); } }
public DSAxis(IDsAxis parDs3Axis, IDsAxis parDs4Axis, bool parTriggerHigh) { m_DS3 = parDs3Axis; m_DS4 = parDs4Axis; m_TriggerHigh = parTriggerHigh; }
/// <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; }
/// <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; }
/// <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; } }
/// <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(); } }