InputHandler - SC-SGS/surviving-sarntal GitHub Wiki
This page aims to describe the functionality of the input handler.
The input handler supports input from the keyboard as well as up to eight gamepads at the same time. The functionality of the individual inputs on the devices is described here.
The input handler gathers the device events that are recognised by the input device. Depending on the intended functionality of inputs in the game, we distinguish the following types of inputs:
- Key/Button pressed: For events that are to be executed once (e.g., use item).
- Key/Button down: For events that are executed repeatedly over many time steps (e.g., move in x-direction, crouch).
- Key/Button released: Used in combination with Key/Button down, to reset some state if the Key/Button down event sets that state (e.g., uncrouch).
- Trigger position (for gamepad only): Used for nonbinary events (e.g., move in x-direction), so that the user has more nuanced control.
After the device events have been gathered, they are mapped to Game events. Game events include the following information:
- The type of event to be triggered (e.g., hiker jump)
- Whether the event is an axis modification (e.g., movement in x-direction is an axis modification, use item is not)
- The value of the axis if needed
- Whether the event is executed repeatedly at every time step or only once (e.g, move in x-Direction is executed repeatedly, switching the selected item slot is executed only once)
Here, the input handler serves as an interface for the Event processor, since it provides a method that returns all game events that were triggered by the user.