11 std::shared_ptr<Core::Window> window,
13 std::function<
void()> callback)
16 auto& source = window->get_event_source();
23 if (promise.should_terminate) {
33 std::shared_ptr<Core::Window> window,
35 std::function<
void()> callback)
38 auto& source = window->get_event_source();
45 if (promise.should_terminate) {
55 std::shared_ptr<Core::Window> window,
57 std::function<
void()> callback)
60 auto& source = window->get_event_source();
66 if (promise.should_terminate)
80 std::shared_ptr<Core::Window> window,
81 std::function<
void(
IO::Keys)> callback)
84 auto& source = window->get_event_source();
90 if (promise.should_terminate) {
96 if (
auto* key_data = std::get_if<Core::WindowEvent::KeyData>(&event.data)) {
97 callback(
static_cast<IO::Keys>(key_data->key));
103 std::shared_ptr<Core::Window> window,
105 std::function<
void(
double,
double)> callback)
108 auto& source = window->get_event_source();
115 if (promise.should_terminate) {
121 auto [x, y] = source.get_mouse_position();
127 std::shared_ptr<Core::Window> window,
129 std::function<
void(
double,
double)> callback)
132 auto& source = window->get_event_source();
139 if (promise.should_terminate) {
145 auto [x, y] = source.get_mouse_position();
151 std::shared_ptr<Core::Window> window,
152 std::function<
void(
double,
double)> callback)
155 auto& source = window->get_event_source();
161 if (promise.should_terminate) {
167 if (
auto* pos_data = std::get_if<Core::WindowEvent::MousePosData>(&event.data)) {
168 callback(pos_data->x, pos_data->y);
174 std::shared_ptr<Core::Window> window,
176 std::function<
void(
double,
double)> callback)
179 auto& source = window->get_event_source();
185 if (promise.should_terminate)
190 if (!source.is_mouse_pressed(
static_cast<int>(button)))
193 if (
auto* pos = std::get_if<Core::WindowEvent::MousePosData>(&event.data))
194 callback(pos->x, pos->y);
199 std::shared_ptr<Core::Window> window,
200 std::function<
void(
double,
double)> callback)
203 auto& source = window->get_event_source();
209 if (promise.should_terminate) {
215 if (
auto* scroll_data = std::get_if<Core::WindowEvent::ScrollData>(&event.data)) {
216 callback(scroll_data->x_offset, scroll_data->y_offset);
Awaiter for suspending on GLFW window input events with optional filtering.
Coroutine type for event-driven suspension.
MouseButtons
Enumeration for mouse buttons.
Vruta::Event key_released(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on specific key release.
Vruta::Event any_key(std::shared_ptr< Core::Window > window, std::function< void(IO::Keys)> callback)
Creates an Event coroutine that triggers on any key press.
Vruta::Event key_pressed(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on specific key press.
Vruta::Event mouse_moved(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse movement.
Vruta::Event mouse_scrolled(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse scroll.
Vruta::Event key_held(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on key press and repeats while held.
Vruta::Event mouse_released(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button release.
Vruta::Event mouse_pressed(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button press.
Vruta::Event mouse_dragged(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse drag with specific button.
Event-domain promise accessor with optional NetworkSource ownership transfer.
std::optional< IO::Keys > key_code
std::optional< Core::WindowEventType > event_type
std::optional< IO::MouseButtons > button
Filter criteria for GLFW window input events.