Class InputMapper

java.lang.Object
com.simsilica.lemur.input.InputMapper

public class InputMapper extends Object
Wraps the normal InputManager to provide enhanced function mapping that completely decouples the registration of input from the listeners that are executed. Inputs can be dynamically registered to trigger certain logical "functions" based on a FunctionId. Separately, analog and state change listeners can be registered for specific FunctionIds. In addition to decoupling, any number of inputs can be registered to a particular FunctionId at any time. This is different than the default InputManager which will throw an exception if new inputs are added to an existing trigger mapping.

The design of InputMapper is setup to better handle the case where an application wants to allow the user to configure their own input mappings through a GUI... and specifically where the application may allow multiple separately configured inputs to trigger the same set of functions. For example, an application may map a joystick axis, the mouse wheel, and/or one or two keys to a specific function.

Also, any logical FunctionId can be treated as both an analog input or a trinary state input. Key inputs can trigger analog functions and analog axes can trigger Positive, Off, Negative state transitions. For example, the key 'A' can be mapped to a "move" function and 'S' can be mapped to the "move" function as being inverted. 'A' and 'S' will then trigger analog values of 1.0 and -1.0 respectively. The "move" function can then also be mapped to an analog joystick axis and the code remains the same. On the other end, if a StateFunctionListener is registered with to a logical FunctionId being fed by an analog Axis then it will see Positive, Negative, and Off as the axis transitions from greater than 0, less than 0, and 0, respectively. (A small neutrality threshold is effected to make extremely small analog values operate as 0.)

When registering inputs, a series of combinations can be included that must all be present to invoke the function. As an example, "mouse wheel" and "ctrl + mouse wheel" can be treated as two separate function triggers.

Entire groups of logical functions can be enabled and disabled by their groups. Multiple groups can be active at any given time and only active groups are elegible to receive input.