wiki:InputClass

Version 5 (modified by chris, 3 years ago) (diff)

--

Purpose

To handle all input (this is one of the more obvious purpose statements).

How it Works

Input takes all input via SDL calls (keyboard, mouse, joystick) and generates a STL list called events, filled with InputEvent?'s. There are various types of input, MOUSEDOWN, MOUSEUP, KEYDOWN, KEYUP, KEYTYPED, KEYPRESSED and more. This events list is then passed to the various subsystems in a specific order, e.g. UI takes it first, then HUD and so on. If a specific subsystem handles an event in the events list (or events chain it's sometimes called), it will remove that particular item from the events chain so future subsystems don't see it. This way, if UI handles a 'p' KEYTYPED event because a text box is highlighted (the cursor is blinking) and a 'p' is to be typed, it won't accidentally then pass that 'p' along to the game which would then fire off a pause.

Keyboard Events Explained

KEYDOWN: Fired once when a key is physically pressed down.
KEYUP: Fired once when a key is physically released.
KEYDOWN: Fired continually (every loop) while a key is held down.
KEYTYPED: Fired like a text editor if you held down a key; at first you get the KEYTYPED event, then there's a small delay before the key repeat rate kicks in and KEYTYPED events are fired off at regular intervals.

Major Functions

Considerations When Using