Input System  v0.1
ISX.IInputProcessor< TValue > Interface Template Reference

A processor that conditions input values. More...

Public Member Functions

TValue Process (TValue value, InputControl control)
 Process the given value and return the result. More...
 

Detailed Description

A processor that conditions input values.

InputControls can have stacks of processors assigned to them.

Note that processors CANNOT be stateful. If you need processing that requires keeping mutating state over time, use InputActions. All mutable state needs to be kept in the central state buffers.

However, processors can have configurable parameters. Every public field on a processor object can be set using "parameters" in JSON or by supplying parameters through the InputControlAttribute.processors field.

Template Parameters
TValueType of value to be processed. Only InputControls that use the same value type will be compatible with the processor.
// To register the processor, call
//
// InputSystem.RegisterProcessor<ScalingProcessor>("scale");
//
public class ScalingProcessor : IInputProcessor<float>
{
// This field can be set as a parameter. See examples below.
// If not explicitly configured, will have its default value.
public float factor = 2.0f;
public float Process(float value, InputControl control)
{
return value * factor;
}
}
// Use processor in JSON:
const string json = @"
{
""name"" : ""MyDevice"",
""controls"" : [
{ ""name"" : ""axis"", ""template"" : ""Axis"", ""processors"" : ""scale(factor=4)"" }
]
}
";
// Use processor on C# state struct:
public struct MyDeviceState : IInputStateTypeInfo
{
[InputControl(template = "Axis", processors = "scale(factor=4)"]
public float axis;
}
See also
InputSystem.RegisterProcessor

Member Function Documentation

◆ Process()

TValue ISX.IInputProcessor< TValue >.Process ( TValue  value,
InputControl  control 
)

Process the given value and return the result.

The implementation of this method must not be stateful.

Parameters
valueInput value to process.
controlThe control the value is processed for. Note that value is not necessarily equal to InputControl<TValue>.value as other processors in the stack may have already altered the value.
Returns
Processed input value.