MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ key_held()

MAYAFLUX_API Vruta::Event MayaFlux::Kriya::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.

Fires the callback on initial press and on each repeat tick until the key is released. Suspends between ticks; does not spin.

Parameters
windowWindow to listen to.
keyKey to wait for.
callbackCalled on press and each repeat tick.
Returns
Event coroutine that can be added to EventManager.

Definition at line 54 of file InputEvents.cpp.

58{
59 auto& promise = co_await GetEventPromise {};
60 auto& source = window->get_event_source();
61
63 filter.key_code = key;
64
65 while (true) {
66 if (promise.should_terminate)
67 break;
68
69 auto ev = co_await WindowEventAwaiter(source, filter);
70
71 if (ev.type == Core::WindowEventType::KEY_RELEASED) {
72 continue;
73 }
74
75 callback();
76 }
77}
Event-domain promise accessor with optional NetworkSource ownership transfer.
Filter criteria for GLFW window input events.

References MayaFlux::Vruta::WindowEventFilter::key_code, and MayaFlux::Core::KEY_RELEASED.

Referenced by MayaFlux::Nexus::Wiring::finalise(), and MayaFlux::Portal::Forma::Context::on_held().

+ Here is the caller graph for this function: