Persistent system for polling Event data and other user input from the host environment on demand.
More...
#include <donut/events/EventPump.hpp>
Persistent system for polling Event data and other user input from the host environment on demand.
The latest events are stored in a buffer that can be accessed until the next time events are polled. The main intended usage pattern for this is to call pollEvents() once at the start of each Application frame and then access the event buffer immediately or throughout the rest of the frame as necessary.
- Examples
- example_game.cpp, and example_rectangle.cpp.
◆ EventPump() [1/3]
donut::events::EventPump::EventPump |
( |
| ) |
|
Construct an event pump.
- Exceptions
-
events::Error | on failure to initialize the required global subsystems. |
◆ ~EventPump()
donut::events::EventPump::~EventPump |
( |
| ) |
|
◆ EventPump() [2/3]
donut::events::EventPump::EventPump |
( |
const EventPump & |
| ) |
|
|
delete |
Copying an event pump is not allowed, since it manages global state.
◆ EventPump() [3/3]
donut::events::EventPump::EventPump |
( |
EventPump && |
| ) |
|
|
delete |
Moving an event pump is not allowed, since it manages global state.
◆ operator=() [1/2]
Copying an event pump is not allowed, since it manages global state.
◆ operator=() [2/2]
Moving an event pump is not allowed, since it manages global state.
◆ pollEvents()
std::span<const Event> donut::events::EventPump::pollEvents |
( |
| ) |
|
Poll events from the environment and update the internal event buffer.
- Returns
- a non-owning read-only view over the polled events, stored in the internal event buffer, which is valid until the next call to pollEvents() or until the event pump is destroyed, whichever happens first.
- Exceptions
-
std::bad_alloc | on allocation failure. |
- See also
- getLatestPolledEvents()
◆ setRelativeMouseMode()
void donut::events::EventPump::setRelativeMouseMode |
( |
bool |
relativeMouseMode | ) |
|
Enable or disable relative mouse mode.
When relative mouse mode is enabled, it hides the mouse cursor, locks it to the window and causes all further mouse motion to be provided as relative motion events until it is disabled again.
- Parameters
-
relativeMouseMode | true to enable relative mouse mode, false to disable. |
- Exceptions
-
◆ setTextInputRectangle()
void donut::events::EventPump::setTextInputRectangle |
( |
ivec2 |
offset, |
|
|
ivec2 |
size |
|
) |
| |
Set the input rectangle for text input.
- Parameters
-
offset | offset of the input rectangle, in screen coordinates. |
size | size of the input rectangle, in screen coordinates. |
- See also
- startTextInput()
-
stopTextInput()
◆ startTextInput()
void donut::events::EventPump::startTextInput |
( |
| ) |
|
◆ stopTextInput()
void donut::events::EventPump::stopTextInput |
( |
| ) |
|
◆ getLatestPolledEvents()
std::span<const Event> donut::events::EventPump::getLatestPolledEvents |
( |
| ) |
const |
|
noexcept |
Get the latest events in the internal event buffer that were polled using pollEvents().
- Returns
- a non-owning read-only view over the polled events, stored in the internal event buffer, which is valid until the next call to pollEvents() or until the event pump is destroyed, whichever happens first.
- See also
- pollEvents()
◆ getClipboardText()
std::string donut::events::EventPump::getClipboardText |
( |
| ) |
const |
Get the current text contained in the clipboard.
- Returns
- the text in the clipboard.
- Exceptions
-
std::bad_alloc | on allocation failure. |
◆ hasScreenKeyboardSupport()
bool donut::events::EventPump::hasScreenKeyboardSupport |
( |
| ) |
const |
|
noexcept |
The documentation for this class was generated from the following file: