libdonut 2.3.6
Application framework for cross-platform game development in C++20
Loading...
Searching...
No Matches
EventPump.hpp
Go to the documentation of this file.
1#ifndef DONUT_EVENTS_EVENT_PUMP_HPP
2#define DONUT_EVENTS_EVENT_PUMP_HPP
3
4#include <donut/math.hpp>
5
6#include <span> // std::span
7#include <string> // std::string
8#include <vector> // std::vector
9
10namespace donut::events {
11
12struct Event; // Forward declaration, to avoid including Event.hpp.
13
23class EventPump {
24public:
32
35
37 EventPump(const EventPump&) = delete;
38
40 EventPump(EventPump&&) = delete;
41
43 EventPump& operator=(const EventPump&) = delete;
44
47
60 std::span<const Event> pollEvents();
61
74 void setRelativeMouseMode(bool relativeMouseMode);
75
85 void setTextInputRectangle(ivec2 offset, ivec2 size);
86
94
102
114 [[nodiscard]] std::span<const Event> getLatestPolledEvents() const noexcept;
115
123 [[nodiscard]] std::string getClipboardText() const;
124
132 [[nodiscard]] bool hasScreenKeyboardSupport() const noexcept;
133
134private:
135 std::vector<Event> events;
136};
137
138} // namespace donut::events
139
140#endif
Persistent system for polling Event data and other user input from the host environment on demand.
Definition EventPump.hpp:23
std::string getClipboardText() const
Get the current text contained in the clipboard.
std::span< const Event > getLatestPolledEvents() const noexcept
Get the latest events in the internal event buffer that were polled using pollEvents().
EventPump & operator=(const EventPump &)=delete
Copying an event pump is not allowed, since it manages global state.
EventPump()
Construct an event pump.
void startTextInput()
Start accepting text input events in the current text input rectangle.
EventPump(const EventPump &)=delete
Copying an event pump is not allowed, since it manages global state.
std::span< const Event > pollEvents()
Poll events from the environment and update the internal event buffer.
EventPump(EventPump &&)=delete
Moving an event pump is not allowed, since it manages global state.
EventPump & operator=(EventPump &&)=delete
Moving an event pump is not allowed, since it manages global state.
void stopTextInput()
Stop accepting text input events.
void setRelativeMouseMode(bool relativeMouseMode)
Enable or disable relative mouse mode.
bool hasScreenKeyboardSupport() const noexcept
Check if the application supports a screen keyboard.
void setTextInputRectangle(ivec2 offset, ivec2 size)
Set the input rectangle for text input.
Definition Error.hpp:7
Data structure containing information about an event.
Definition Event.hpp:339