Keys held down, and those pressed or released since the start of the frame.
More...
#include <aegis2d/platform/keyboard.hpp>
|
| void | begin_frame () noexcept |
| | Starts a frame: forgets the presses and releases of the previous one.
|
| |
| void | press (Key key) noexcept |
| | Records that a key went down.
|
| |
| void | release (Key key) noexcept |
| | Records that a key went up.
|
| |
| void | release_all () noexcept |
| | Releases every held key, as when the window loses the keyboard focus.
|
| |
| bool | held (Key key) const noexcept |
| | Tells whether a key is down.
|
| |
| bool | pressed (Key key) const noexcept |
| | Tells whether a key went down during the frame.
|
| |
| bool | released (Key key) const noexcept |
| | Tells whether a key went up during the frame.
|
| |
| std::span< const Key > | pressed_keys () const noexcept |
| | Keys pressed during the frame, in the order they went down.
|
| |
| std::uint64_t | frame () const noexcept |
| | Number of frames started so far.
|
| |
Keys held down, and those pressed or released since the start of the frame.
The window feeds it in Window::poll_events(), which starts a new frame first. A key pressed and released within one frame is still seen as pressed, so short taps are never lost. Key repeats of the operating system are not presses.
◆ begin_frame()
| void aegis2d::platform::Keyboard::begin_frame |
( |
| ) |
|
|
noexcept |
Starts a frame: forgets the presses and releases of the previous one.
◆ frame()
| std::uint64_t aegis2d::platform::Keyboard::frame |
( |
| ) |
const |
|
noexcept |
Number of frames started so far.
- Returns
- 0 before the first begin_frame(), then 1, 2...
◆ held()
| bool aegis2d::platform::Keyboard::held |
( |
Key |
key | ) |
const |
|
noexcept |
Tells whether a key is down.
- Parameters
-
- Returns
true if it was pressed and not released yet.
◆ press()
| void aegis2d::platform::Keyboard::press |
( |
Key |
key | ) |
|
|
noexcept |
Records that a key went down.
- Parameters
-
| key | Key pressed; ignored if it is already held. |
◆ pressed()
| bool aegis2d::platform::Keyboard::pressed |
( |
Key |
key | ) |
const |
|
noexcept |
Tells whether a key went down during the frame.
- Parameters
-
- Returns
true if it was pressed since begin_frame(), even if it is released again.
◆ pressed_keys()
| std::span< const Key > aegis2d::platform::Keyboard::pressed_keys |
( |
| ) |
const |
|
noexcept |
Keys pressed during the frame, in the order they went down.
- Returns
- A view valid until the next call of a non-const function.
◆ release()
| void aegis2d::platform::Keyboard::release |
( |
Key |
key | ) |
|
|
noexcept |
Records that a key went up.
- Parameters
-
| key | Key released; ignored if it is not held. |
◆ release_all()
| void aegis2d::platform::Keyboard::release_all |
( |
| ) |
|
|
noexcept |
Releases every held key, as when the window loses the keyboard focus.
◆ released()
| bool aegis2d::platform::Keyboard::released |
( |
Key |
key | ) |
const |
|
noexcept |
Tells whether a key went up during the frame.
- Parameters
-
- Returns
true if it was released since begin_frame().
The documentation for this class was generated from the following file: