- cpp3ds
- Keyboard
Give access to the real-time state of the keyboard. More...
#include <Keyboard.hpp>
Public Types | |
enum | Key { A = 1, B = 1 << 1, Select = 1 << 2, Start = 1 << 3, DPadRight = 1 << 4, DPadLeft = 1 << 5, DPadUp = 1 << 6, DPadDown = 1 << 7, R = 1 << 8, L = 1 << 9, X = 1 << 10, Y = 1 << 11, ZL = 1 << 14, ZR = 1 << 15, Touchpad = 1 << 20, CStickRight = 1 << 24, CStickLeft = 1 << 25, CStickUp = 1 << 26, CStickDown = 1 << 27, CPadRight = 1 << 28, CPadLeft = 1 << 29, CPadUp = 1 << 30, CPadDown = 1 << 31, Up = DPadUp | CPadUp, Down = DPadDown | CPadDown, Left = DPadLeft | CPadLeft, Right = DPadRight | CPadRight } |
Key codes. More... | |
Static Public Member Functions | |
static bool | isKeyDown (Key key) |
Check if a key is still being pressed. More... | |
static bool | isKeyPressed (Key key) |
Check if a key is now being pressed. More... | |
static bool | isKeyReleased (Key key) |
Check if a key is now being released. More... | |
static float | getSlider3D () |
static float | getSliderVolume () |
static void | update () |
Update cache values for input. More... | |
Give access to the real-time state of the keyboard.
cpp3ds::Keyboard provides an interface to the state of the keyboard.
It only contains static functions (a single keyboard is assumed), so it's not meant to be instantiated.
This class allows users to query the keyboard state at any time and directly, without having to deal with a window and its events. Compared to the KeyPressed and KeyReleased events, cpp3ds::Keyboard can retrieve the state of a key at any time (you don't need to store and update a boolean on your side in order to know if a key is pressed or released), and you always get the real state of the keyboard, even if keys are pressed or released when your window is out of focus and no event is triggered.
Usage example:
Definition at line 14 of file Keyboard.hpp.
Key codes.
Definition at line 21 of file Keyboard.hpp.
|
static |
Check if a key is still being pressed.
key | Key to check |
|
static |
Check if a key is now being pressed.
key | Key to check |
|
static |
Check if a key is now being released.
key | Key to check |
|
static |
Update cache values for input.