event.h¶
| File Path | engine/include/conjure/platform/event.h |
| API ↗ | Windows and events |
The event stream a window produces once per frame. Every alternative is a trivially copyable struct; the one payload with external data (drop_files_event) points into a window-owned buffer that stays valid until the next pump_events(). input_event lists the alternatives input::apply consumes; event adds the window-level ones. Both list the input alternatives first and in the same order, so the conversions below are index remaps.
Structs¶
Type Aliases¶
event¶
using event = std::variant< key_event, text_event, mouse_move_event, mouse_button_event, mouse_scroll_event, cursor_enter_event, gamepad_connection_event, gamepad_button_event, gamepad_axis_event, framebuffer_resized_event, content_scale_changed_event, focus_event, minimise_event, close_event, drop_files_event>;
input_event¶
using input_event = std::variant< key_event, text_event, mouse_move_event, mouse_button_event, mouse_scroll_event, cursor_enter_event, gamepad_connection_event, gamepad_button_event, gamepad_axis_event>;
Constants¶
| Name | Type | Value | Description |
|---|---|---|---|
EVENT_COUNT |
inline constexpr usize |
std:: |
Number of alternatives of event. |
INPUT_EVENT_COUNT |
inline constexpr usize |
std:: |
Number of input alternatives; they occupy the first INPUT_EVENT_COUNT indices of event. |
Functions¶
Public¶
event_as¶
event_as¶template <typename EventType> [[nodiscard]] const EventType *event_as(
const event &value) noexcept;The payload when the event holds EventType, otherwise nullptr (std::get_if).
event_name¶
event_name¶[[nodiscard]] CONJURE_API std::string_view event_name(
const event &value) noexcept;The alternative name of an event ("key_event", "close_event", ...).
is_input_event¶
is_input_event¶[[nodiscard]] CONJURE_API bool is_input_event(
const event &value) noexcept;True when the event is one of the input alternatives (what input::apply consumes).
to_event¶
to_event¶[[nodiscard]] CONJURE_API event to_event(
const input_event &value) noexcept;Widens an input_event to an event (never fails).
to_input_event¶
to_input_event¶[[nodiscard]] CONJURE_API std::optional<input_event> to_input_event(
const event &value) noexcept;The event as an input_event, or nullopt for a window event.