Interface IInputStateCallbackReceiver
Allows a device to intercept operations performed on its state.
Namespace: UnityEngine.Experimental.Input.LowLevel
Syntax
public interface IInputStateCallbackReceiver
Remarks
This is an expensive interface that incurs costly extra processing. Only put this on a device if it is really needed.
Methods
OnBeforeWriteNewState(Void*, Void*)
Called when a new state is received for the device but before it is copied over the device's current state.
Declaration
void OnBeforeWriteNewState(void *oldStatePtr, void *newStatePtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | oldStatePtr | Pointer to the buffer containing the current state of the device. |
System.Void* | newStatePtr | Pointer to the buffer containing the new state that has been received for the device. |
Remarks
This method can be used to alter the newly received state before it is written into the device. Pointer delta controls, for example, should accumulate values from multiple consecutive events that happen in the same frame rather than just overwriting the previously stored delta. This can be achieved by reading the current delta from oldStatePtr and then adding it on top of the delta found in newStatePtr.
Note that this callback is invoked before state change monitors are run to compare the two states. Thus, if in this method, newStatePtr is changed thus that there is no difference anymore to the old state, state change monitors will not fire and actions will not get triggered.
OnCarryStateForward(Void*)
Called when a new input update is started and existing state of a device is carried forward.
Declaration
bool OnCarryStateForward(void *statePtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | statePtr | Pointer to the buffer containing the state of the device that is carried forward. |
Returns
Type | Description |
---|---|
System.Boolean | True if you have modified the state in statePtr, false if you have left it as is. |
Remarks
This method is mainly useful to implement auto-resetting of state. For example, pointer position deltas should go back to their default state at the beginning of a frame. Using this state callback, it's possible to zero out delta control state at the beginning of an update.
Note that the system will still run change monitors over the old and new version of the state after calling this method. This means that actions are able to observe changes applied to state in this method.
OnReceiveStateWithDifferentFormat(Void*, FourCC, UInt32, ref UInt32)
Called when a device receives a chunk of state that is tagged with a different format than the state of the device itself.
Declaration
bool OnReceiveStateWithDifferentFormat(void *statePtr, FourCC stateFormat, uint stateSize, ref uint offsetToStoreAt)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | statePtr | |
FourCC | stateFormat | |
System.UInt32 | stateSize | |
System.UInt32 | offsetToStoreAt |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
This method permits a device to integrate state into its own that is not sent as full-device snapshots or deltas with specific offsets.