|
P-E-R-R-Y
Utilitaires, contrats et vendors du moteur, en une seule doc
|
Keyboard interface. More...
#include <IKeyboard.hpp>

Public Member Functions | |
| virtual | ~IKeyboard () |
| Destroy the IKeyboard object. | |
| virtual std::vector< Keys > | whichKeyDown () const =0 |
| Every key HELD right now - like isKeyDown, without having to name the key. | |
| virtual bool | isKeyPressed (Keys key) const =0 |
| Check if the key is pressed. | |
| virtual bool | isKeyReleased (Keys key) const =0 |
| Check if the key is released. | |
| virtual bool | isKeyDown (Keys key) const =0 |
| Check if the key is down. | |
| virtual bool | isKeyUp (Keys key) const =0 |
| Check if the key is up. | |
Keyboard interface.
Four methods, two behaviours.
isKeyPressed / isKeyReleased are true for ONE FRAME only, the one where the key changes state. Holding a key does not re-trigger isKeyPressed, even when the OS sends key repeat.
isKeyDown / isKeyUp are true EVERY FRAME for as long as the key is held (or released).
For a key pressed on frame 3 and released on frame 6 :
key ______/‾‾‾‾‾‾‾‾‾‾‾\______ frame 1 2 3 4 5 6 7 isKeyDown 0 0 1 1 1 0 0 isKeyUp 1 1 0 0 0 1 1 isKeyPressed 0 0 1 0 0 0 0 isKeyReleased 0 0 0 0 0 1 0
Hence the run / jump pair : isKeyDown(KEY_W) keeps moving while W is held, isKeyPressed(KEY_SPACE) jumps once. Jumping on isKeyDown jumps sixty times a second.
All four are readable ANYWHERE in the frame, on every vendor : the window drains its queue once in pollEvent() and folds it into state, so nothing has to be read at a particular moment.
The condition is an optimisation, not a rule : with no event the fronts are false anyway. It only holds for the fronts - isKeyDown, isKeyUp and whichKeyDown() are true across frames where nothing happened, so putting them inside would silently drop them on a vendor that has a queue and keep them on one that has not.
The boundary between two frames is endDraw(). A press + release inside the same frame is lost, on every vendor.
Modifiers are keys like any other : Shift+E is isKeyDown(KEY_LEFT_SHIFT) and isKeyPressed(KEY_E), composed by the caller.
Scan codes.
| Enumerator | |
|---|---|
| KEY_UNKNOWN | |
| KEY_ESCAPE | Line 0. |
| KEY_F1 | |
| KEY_F2 | |
| KEY_F3 | |
| KEY_F4 | |
| KEY_F5 | |
| KEY_F6 | |
| KEY_F7 | |
| KEY_F8 | |
| KEY_F9 | |
| KEY_F10 | |
| KEY_F11 | |
| KEY_F12 | |
| KEY_1 | Line 1. |
| KEY_2 | |
| KEY_3 | |
| KEY_4 | |
| KEY_5 | |
| KEY_6 | |
| KEY_7 | |
| KEY_8 | |
| KEY_9 | |
| KEY_0 | |
| KEY_MINUS | |
| KEY_EQUAL | |
| KEY_BACKSPACE | |
| KEY_TAB | Line 2. |
| KEY_Q | |
| KEY_W | |
| KEY_E | |
| KEY_R | |
| KEY_T | |
| KEY_Y | |
| KEY_U | |
| KEY_I | |
| KEY_O | |
| KEY_P | |
| KEY_LEFT_BRACKET | |
| KEY_RIGHT_BRACKET | |
| KEY_CAPS_LOCK | Line 3. |
| KEY_LEFT_CONTROL | |
| KEY_A | |
| KEY_S | |
| KEY_D | |
| KEY_F | |
| KEY_G | |
| KEY_H | |
| KEY_J | |
| KEY_K | |
| KEY_L | |
| KEY_SEMICOLON | |
| KEY_APOSTROPHE | |
| KEY_BACKTICK | |
| KEY_ENTER | |
| KEY_LEFT_SHIFT | Line 4. |
| KEY_BACKSLASH | |
| KEY_Z | |
| KEY_X | |
| KEY_C | |
| KEY_V | |
| KEY_B | |
| KEY_N | |
| KEY_M | |
| KEY_COMMA | |
| KEY_PERIOD | |
| KEY_SLASH | |
| KEY_RIGHT_SHIFT | |
| KEY_LEFT_ALT | Line 5. |
| KEY_LEFT_SUPER | |
| KEY_SPACE | |
| KEY_RIGHT_ALT | |
| KEY_RIGHT_SUPER | |
| KEY_RIGHT_CONTROL | |
| KEY_PAD_0 | KEYPAD. |
| KEY_PAD_1 | |
| KEY_PAD_2 | |
| KEY_PAD_3 | |
| KEY_PAD_4 | |
| KEY_PAD_5 | |
| KEY_PAD_6 | |
| KEY_PAD_7 | |
| KEY_PAD_8 | |
| KEY_PAD_9 | |
| KEY_PAD_MINUS | |
| KEY_PAD_PLUS | |
| KEY_PAD_DOT | |
| KEY_PAD_ENTER | |
| KEY_UP | ARROWS. |
| KEY_DOWN | |
| KEY_LEFT | |
| KEY_RIGHT | |
| KEY_COUNT | |
|
inlinevirtual |
Destroy the IKeyboard object.
|
pure virtual |
Check if the key is down.
| key |
Implemented in RayKeyboard, SdlKeyboard, SdlKeyboard, and SfmlKeyboard.
|
pure virtual |
Check if the key is pressed.
| key |
Implemented in RayKeyboard, SdlKeyboard, SdlKeyboard, and SfmlKeyboard.
|
pure virtual |
Check if the key is released.
| key |
Implemented in RayKeyboard, SdlKeyboard, SdlKeyboard, and SfmlKeyboard.
|
pure virtual |
Check if the key is up.
| key |
Implemented in RayKeyboard, SdlKeyboard, SdlKeyboard, and SfmlKeyboard.
|
pure virtual |
Every key HELD right now - like isKeyDown, without having to name the key.
A held key stays in the list every frame. For a debug overlay, a state readout, chord detection.
Walks the whole keyboard : avoid in a hot loop, isKeyDown is a direct lookup.
Implemented in RayKeyboard, SdlKeyboard, SdlKeyboard, and SfmlKeyboard.