Various extension methods for InputControl. Mostly low-level routines.
Inheritance
System.Object
InputControlExtensions
public static class InputControlExtensions
Methods
Declaration
public static bool CheckStateIsAtDefault(this InputControl control)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Check if the given state corresponds to the default state of the control.
Declaration
public static bool CheckStateIsAtDefault(this InputControl control, void *statePtr, void *maskPtr = default(void *))
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
statePtr |
Pointer to a state buffer containing the stateBlock for control .
|
System.Void* |
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.
|
Returns
Type |
Description |
System.Boolean |
True if the control/device is in its default state.
|
UnityEngine.InputSystem.LowLevel.InputStateBuffers.defaultStateBuffer
Declaration
public static bool CheckStateIsAtDefaultIgnoringNoise(this InputControl control)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static bool CheckStateIsAtDefaultIgnoringNoise(this InputControl control, void *statePtr)
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
statePtr |
|
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static bool CompareState(this InputControl control, void *statePtr, void *maskPtr = default(void *))
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
statePtr |
|
System.Void* |
maskPtr |
|
Returns
Type |
Description |
System.Boolean |
|
Compare the control's current state to the state stored in statePtr
.
Declaration
public static bool CompareStateIgnoringNoise(this InputControl control, void *statePtr)
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
statePtr |
State memory containing the control's .
|
Returns
Type |
Description |
System.Boolean |
True if
|
Declaration
public static void FindControlsRecursive<TControl>(this InputControl parent, IList<TControl> controls, Func<TControl, bool> predicate)
where TControl : InputControl
Parameters
Type |
Name |
Description |
InputControl |
parent |
|
System.Collections.Generic.IList<TControl> |
controls |
|
System.Func<TControl, System.Boolean> |
predicate |
|
Type Parameters
Name |
Description |
TControl |
|
Declaration
public static void *GetStatePtrFromStateEvent(this InputControl control, InputEventPtr eventPtr)
Parameters
Returns
Type |
Description |
System.Void* |
|
Declaration
public static bool HasValueChangeInEvent(this InputControl control, InputEventPtr eventPtr)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Return true if the actual value
Declaration
public static bool HasValueChangeInState(this InputControl control, void *statePtr)
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
statePtr |
|
Returns
Type |
Description |
System.Boolean |
|
Return true if the given control is actuated.
Declaration
public static bool IsActuated(this InputControl control, float threshold = 0F)
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Single |
threshold |
Magnitude threshold that the control must match or exceed to be considered actuated.
An exception to this is the default value of zero. If threshold is zero, the control must have a magnitude
greater than zero.
|
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static void ReadDefaultValue(this InputControl control, void *buffer, int bufferSize)
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
buffer |
|
System.Int32 |
bufferSize |
|
Read the control's default value and return it as an object.
Declaration
public static object ReadDefaultValueAsObject(this InputControl control)
Parameters
Type |
Name |
Description |
InputControl |
control |
Control to read default value from.
|
Returns
Type |
Description |
System.Object |
|
Exceptions
Type |
Condition |
System.ArgumentNullException |
control is null.
|
UnityEngine.InputSystem.InputControl.hasDefaultValue
Declaration
public static TValue ReadUnprocessedValueFromEvent<TValue>(this InputControl<TValue> control, InputEventPtr eventPtr)
where TValue : struct
Parameters
Returns
Type Parameters
Declaration
public static bool ReadUnprocessedValueFromEvent<TValue>(this InputControl<TValue> control, InputEventPtr inputEvent, out TValue value)
where TValue : struct
Parameters
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
Read the current value of the control and return it as an object.
Declaration
public static object ReadValueAsObject(this InputControl control)
Parameters
Returns
Type |
Description |
System.Object |
|
Read the value of the given control from an event.
Declaration
public static bool ReadValueFromEvent<TValue>(this InputControl<TValue> control, InputEventPtr inputEvent, out TValue value)
where TValue : struct
Parameters
Type |
Name |
Description |
InputControl<TValue> |
control |
|
InputEventPtr |
inputEvent |
Input event. This must be a StateEvent or DeltaStateEvent.
Note that in the case of a DeltaStateEvent, the control may not actually be part of the event. In this
case, the method returns false and stores default(TValue) in value .
|
TValue |
value |
Variable that receives the control value.
|
Returns
Type |
Description |
System.Boolean |
True if the value has been successfully read from the event, false otherwise.
|
Type Parameters
Exceptions
Type |
Condition |
System.ArgumentNullException |
control is null.
|
Read the current, processed value of the control and store it into the given memory buffer.
Declaration
public static void ReadValueIntoBuffer(this InputControl control, void *buffer, int bufferSize)
Parameters
Type |
Name |
Description |
InputControl |
control |
|
System.Void* |
buffer |
Buffer to store value in. Note that the value is not stored with the offset
found in byteOffset of the control's stateBlock. It will
be stored directly at the given address.
|
System.Int32 |
bufferSize |
Size of the memory available at buffer in bytes. Has to be
at least valueSizeInBytes. If the size is smaller, nothing will be written to the buffer.
|
Declaration
public static void WriteValueFromObjectIntoEvent(this InputControl control, InputEventPtr eventPtr, object value)
Parameters
Declaration
public static void WriteValueIntoEvent<TValue>(this InputControl control, TValue value, InputEventPtr eventPtr)
where TValue : struct
Parameters
Type Parameters
Declaration
public static void WriteValueIntoEvent<TValue>(this InputControl<TValue> control, TValue value, InputEventPtr eventPtr)
where TValue : struct
Parameters
Type Parameters
Write the control's current value into statePtr
.
Declaration
public static void WriteValueIntoState(this InputControl control, void *statePtr)
Parameters
Type |
Name |
Description |
InputControl |
control |
Control to read the current value from and to store state for in statePtr .
|
System.Void* |
statePtr |
State to receive the control's value in its respective stateBlock.
|
Exceptions
Type |
Condition |
System.ArgumentNullException |
control is null or statePtr is null.
|
System.NotSupportedException |
The control does not support writing. This is the case, for
example, that compute values (such as the magnitude of a vector).
|
Declaration
public static void WriteValueIntoState<TValue>(this InputControl control, TValue value, void *statePtr)
where TValue : struct
Parameters
Type |
Name |
Description |
InputControl |
control |
|
TValue |
value |
|
System.Void* |
statePtr |
|
Type Parameters
Declaration
public static void WriteValueIntoState<TValue>(this InputControl<TValue> control, TValue value, void *statePtr)
where TValue : struct
Parameters
Type |
Name |
Description |
InputControl<TValue> |
control |
|
TValue |
value |
|
System.Void* |
statePtr |
|
Type Parameters
Declaration
public static void WriteValueIntoState<TValue>(this InputControl<TValue> control, void *statePtr)
where TValue : struct
Parameters
Type |
Name |
Description |
InputControl<TValue> |
control |
|
System.Void* |
statePtr |
|
Type Parameters
Declaration
public static void WriteValueIntoState<TValue, TState>(this InputControl<TValue> control, TValue value, ref TState state)
where TValue : struct where TState : struct, IInputStateTypeInfo
Parameters
Type |
Name |
Description |
InputControl<TValue> |
control |
|
TValue |
value |
Value for control to write into state .
|
TState |
state |
|
Type Parameters
Name |
Description |
TValue |
|
TState |
|
Exceptions
Type |
Condition |
System.ArgumentNullException |
control is null.
|
System.ArgumentException |
Control's value does not fit within the memory of state .
|
System.NotSupportedException |
control does not support writing.
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.