9 if (
auto* kd = std::get_if<Core::WindowEvent::KeyData>(&event.
data)) {
17 if (
auto* bd = std::get_if<Core::WindowEvent::MouseButtonData>(&event.
data)) {
25 if (
auto* pd = std::get_if<Core::WindowEvent::MousePosData>(&event.
data)) {
55 std::queue<Core::WindowEvent> tmp;
56 std::optional<Core::WindowEvent> result;
68 if (
auto* kd = std::get_if<Core::WindowEvent::KeyData>(&ev.data)) {
69 matches = kd->key ==
static_cast<int16_t
>(*filter.
key_code);
75 if (matches && filter.
button) {
76 if (
auto* bd = std::get_if<Core::WindowEvent::MouseButtonData>(&ev.data)) {
77 matches = bd->button ==
static_cast<int>(*filter.
button);
83 if (matches && !result) {
Awaiter for suspending on GLFW window input events with optional filtering.
void dispatch(const void *event)
Iterates the waiter list, passing the type-erased signal to each.
bool is_key_pressed(IO::Keys key) const
Returns true if the given key is currently held.
bool is_mouse_pressed(int button) const
Returns true if the given mouse button is currently held.
std::queue< Core::WindowEvent > m_pending_events
Kriya::WindowEventAwaiter await_event(Core::WindowEventType type)
Creates an awaiter that resumes on the next event matching a type.
std::unordered_map< int16_t, bool > m_key_states
void signal(Core::WindowEvent event)
Enqueue a window event and resume matching waiters.
std::pair< double, double > get_mouse_position() const
Returns the last known cursor position in screen coordinates.
std::optional< Core::WindowEvent > pop_event(const WindowEventFilter &filter)
Removes and returns the first pending event matching the filter.
Kriya::WindowEventAwaiter next_event()
Creates an awaiter that resumes on the next event of any type.
std::unordered_map< int, bool > m_button_states
WindowEventType
Types of window and input events.
Event data for window and input events.
std::optional< IO::Keys > key_code
std::optional< Core::WindowEventType > event_type
std::optional< IO::MouseButtons > button
Filter criteria for GLFW window input events.