11class WindowEventAwaiter;
29 std::optional<IO::MouseButtons>
button;
76 static constexpr size_t k_max_pending_events = 1024;
92 void signal(Core::WindowEvent event);
99 void defer(
std::function<
void()> action);
104 Kriya::WindowEventAwaiter next_event();
110 Kriya::WindowEventAwaiter await_event(Core::WindowEventType
type);
112 [[nodiscard]]
bool has_pending()
const override {
return !m_pending_events.empty(); }
113 [[nodiscard]]
size_t pending_count()
const {
return m_pending_events.size(); }
116 m_pending_events.clear();
117 m_pending_counts.fill(0);
124 [[nodiscard]]
bool is_key_pressed(
IO::Keys key)
const;
130 [[nodiscard]]
bool is_mouse_pressed(
int button)
const;
135 [[nodiscard]] std::pair<double, double> get_mouse_position()
const;
139 std::array<size_t, 256> m_pending_counts {};
145 size_t m_signal_depth {};
vk::PhysicalDeviceType type
Awaiter for suspending on window input events with optional filtering.
Base for event filters used by EventSources to match signals to awaiters.
Abstract base for all awaitable signal sources.
size_t pending_count() const
WindowEventSource()=default
WindowEventSource & operator=(const WindowEventSource &)=delete
WindowEventSource(WindowEventSource &&) noexcept=default
std::unordered_map< int16_t, bool > m_key_states
void clear() override
Discards all buffered signals.
std::vector< std::function< void()> > m_deferred_actions
std::deque< Core::WindowEvent > m_pending_events
~WindowEventSource() override=default
WindowEventSource(const WindowEventSource &)=delete
std::unordered_map< int, bool > m_button_states
Awaitable stream of window input events.
WindowEventType
Types of window and input events.
std::optional< IO::Keys > key_code
WindowEventFilter()=default
std::optional< Core::WindowEventType > event_type
WindowEventFilter(Core::WindowEventType type)
Constructs a filter matching a specific event type.
WindowEventFilter(IO::Keys key)
Constructs a filter matching a specific key.
std::optional< IO::MouseButtons > button
Filter criteria for window input events.