The
InputManager
is responsible for converting input events received from the Key, Mouse and Joy Input implementations into an abstract, input device independent representation that user code can use.
By default an InputManager
is included with every Application instance for use in user code to query input, unless the Application is created as headless or with input explicitly disabled.
The input manager has two concepts, a {@link Trigger} and a mapping.A trigger represents a specific input trigger, such as a key button, or a mouse axis. A mapping represents a link onto one or several triggers, when the appropriate trigger is activated (e.g. a key is pressed), the mapping will be invoked. Any listeners registered to receive an event from the mapping will have an event raised.
There are two types of events that {@link InputListener input listeners}can receive, one is {@link ActionListener#onAction(java.lang.String,boolean,float) action}events and another is {@link AnalogListener#onAnalog(java.lang.String,float,float) analog}events.
onAction
events are raised when the specific input activates or deactivates. For a digital input such as key press, the onAction()
event will be raised with the isPressed
argument equal to true, when the key is released, onAction
is called again but this time with the isPressed
argument set to false. For analog inputs, the onAction
method will be called any time the input is non-zero, however an exception to this is for joystick axis inputs, which are only called when the input is above the {@link InputManager#setAxisDeadZone(float) dead zone}.
onAnalog
events are raised every frame while the input is activated. For digital inputs, every frame that the input is active will cause the onAnalog
method to be called, the argument value
argument will equal to the frame's time per frame (TPF) value but only for digital inputs. For analog inputs however, the value
argument will equal the actual analog value.