/// <summary> /// Check if the given state corresponds to the default state of the control. /// </summary> /// <param name="statePtr">Pointer to a state buffer containing the <see cref="InputControl.stateBlock"/> for <paramref name="control"/>.</param> /// <param name="maskPtr">If not null, only bits set to true in the buffer will be taken into account. This can be used /// to mask out noise.</param> /// <returns>True if the control/device is in its default state.</returns> /// <remarks> /// Note that default does not equate all zeroes. Stick axes, for example, that are stored as unsigned byte /// values will have their resting position at 127 and not at 0. This is why we explicitly store default /// state in a memory buffer instead of assuming zeroes. /// </remarks> /// <seealso cref="InputStateBuffers.defaultStateBuffer"/> public static unsafe bool CheckStateIsAtDefault(this InputControl control, void *statePtr, void *maskPtr = null) { if (control == null) { throw new ArgumentNullException(nameof(control)); } if (statePtr == null) { throw new ArgumentNullException(nameof(statePtr)); } return(control.CompareState(statePtr, control.defaultStatePtr, maskPtr)); }
public static unsafe bool CompareState(this InputControl control, void *statePtr, void *maskPtr = null) { if (control == null) { throw new ArgumentNullException(nameof(control)); } if (statePtr == null) { throw new ArgumentNullException(nameof(statePtr)); } return(control.CompareState(control.currentStatePtr, statePtr, maskPtr)); }
/// <summary> /// Compare the control's current state to the state stored in <paramref name="statePtr"/>. /// </summary> /// <param name="statePtr">State memory containing the control's <see cref="stateBlock"/>.</param> /// <returns>True if </returns> /// <seealso cref="currentStatePtr"/> /// <remarks> /// This method ignores noise /// /// This method will not actually read values but will instead compare state directly as it is stored /// in memory. <see cref="InputControl{TValue}.ReadValue"/> is not invoked and thus processors will /// not be run. /// </remarks> public static unsafe bool CompareStateIgnoringNoise(this InputControl control, void *statePtr) { if (control == null) { throw new ArgumentNullException("control"); } if (statePtr == null) { throw new ArgumentNullException("statePtr"); } return(control.CompareState(control.currentStatePtr, statePtr, control.noiseMaskPtr)); }