MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
InputEvents.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux {
6namespace Core {
7 class Window;
8}
9
10namespace Vruta {
11 class TaskScheduler;
12 class Event;
13 class WindowEventSource;
14}
15namespace Kriya {
16
17 /**
18 * @brief Creates an Event coroutine that triggers on specific key press
19 * @param window Window to listen to
20 * @param key The key to wait for
21 * @param callback Function to call on key press
22 * @return Event coroutine that can be added to EventManager
23 *
24 * Example:
25 * @code
26 * auto task = on_key_pressed(window, IO::Keys::Escape,
27 * []() {
28 * // Handle Escape key press
29 * });
30 * @endcode
31 */
32 MAYAFLUX_API Vruta::Event key_pressed(
33 std::shared_ptr<Core::Window> window,
34 IO::Keys key,
35 std::function<void()> callback);
36
37 /**
38 * @brief Creates an Event coroutine that triggers on specific key release
39 * @param window Window to listen to
40 * @param key The key to wait for
41 * @param callback Function to call on key release
42 * @return Event coroutine that can be added to EventManager
43 *
44 * Example:
45 * @code
46 * auto task = key_released(window, IO::Keys::Enter,
47 * []() {
48 * // Handle Enter key release
49 * });
50 * @endcode
51 */
52 MAYAFLUX_API Vruta::Event key_released(
53 std::shared_ptr<Core::Window> window,
54 IO::Keys key,
55 std::function<void()> callback);
56
57 /**
58 * @brief Creates an Event coroutine that triggers on key press and repeats while held.
59 *
60 * Fires the callback on initial press and on each repeat tick until the key
61 * is released. Suspends between ticks; does not spin.
62 *
63 * @param window Window to listen to.
64 * @param key Key to wait for.
65 * @param callback Called on press and each repeat tick.
66 * @return Event coroutine that can be added to EventManager.
67 */
68 MAYAFLUX_API Vruta::Event key_held(
69 std::shared_ptr<Core::Window> window,
70 IO::Keys key,
71 std::function<void()> callback);
72
73 /**
74 * @brief Creates an Event coroutine that triggers on resolved text input.
75 *
76 * Delivers composed Unicode codepoints (shift, layout, dead-key/compose,
77 * and IME already resolved by the backend), distinct from key_pressed's
78 * raw keycodes. See Core::WindowEventType::TEXT_INPUT.
79 *
80 * @param window Window to listen to.
81 * @param callback Called with the resolved Unicode codepoint.
82 * @return Event coroutine that can be added to EventManager.
83 */
84 MAYAFLUX_API Vruta::Event text_input(
85 std::shared_ptr<Core::Window> window,
86 std::function<void(uint32_t)> callback);
87
88 /**
89 * @brief Creates an Event coroutine that triggers on any key press
90 * @param window Window to listen to
91 * @param callback Function to call with key code when any key is pressed
92 * @return Event coroutine that can be added to EventManager
93 *
94 * Example:
95 * @code
96 * auto task = any_key(window,
97 * [](IO::Keys key) {
98 * // Handle any key press, key code in 'key'
99 * });
100 * @endcode
101 */
102 MAYAFLUX_API Vruta::Event any_key(
103 std::shared_ptr<Core::Window> window,
104 std::function<void(IO::Keys)> callback);
105
106 /**
107 * @brief Creates an Event coroutine that triggers on specific mouse button press
108 * @param window Window to listen to
109 * @param button Mouse button to wait for
110 * @param callback Function to call on button press
111 * @return Event coroutine that can be added to EventManager
112 *
113 * Example:
114 * @code
115 * auto task = mouse_pressed(window, IO::MouseButtons::Left,
116 * [](double x, double y) {
117 * // Handle left mouse button press at (x, y)
118 * });
119 * @endcode
120 */
121 MAYAFLUX_API Vruta::Event mouse_pressed(
122 std::shared_ptr<Core::Window> window,
123 IO::MouseButtons button,
124 std::function<void(double, double)> callback);
125
126 /**
127 * @brief Creates an Event coroutine that triggers on specific mouse button release
128 * @param window Window to listen to
129 * @param button Mouse button to wait for
130 * @param callback Function to call on button release
131 * @return Event coroutine that can be added to EventManager
132 *
133 * Example:
134 * @code
135 * auto task = mouse_released(window, IO::MouseButtons::Right,
136 * [](double x, double y) {
137 * // Handle right mouse button release at (x, y)
138 * });
139 * @endcode
140 */
141 MAYAFLUX_API Vruta::Event mouse_released(
142 std::shared_ptr<Core::Window> window,
143 IO::MouseButtons button,
144 std::function<void(double, double)> callback);
145
146 /**
147 * @brief Creates an Event coroutine that triggers on mouse movement
148 * @param window Window to listen to
149 * @param callback Function to call on mouse move
150 * @return Event coroutine that can be added to EventManager
151 *
152 * Example:
153 * @code
154 * auto task = mouse_moved(window,
155 * [](double x, double y) {
156 * // Handle mouse move at (x, y)
157 * });
158 * @endcode
159 */
160 MAYAFLUX_API Vruta::Event mouse_moved(
161 std::shared_ptr<Core::Window> window,
162 std::function<void(double, double)> callback);
163
164 /**
165 * @brief Creates an Event coroutine that triggers on mouse drag with specific button
166 * @param window Window to listen to
167 * @param button Mouse button that must be held for drag
168 * @param callback Function to call on mouse drag with current position
169 * @return Event coroutine that can be added to EventManager
170 *
171 * Example:
172 * @code
173 * auto task = mouse_dragged(window, IO::MouseButtons::Left,
174 * [](double x, double y) {
175 * // Handle mouse drag with left button at (x, y)
176 * });
177 * @endcode
178 */
179 MAYAFLUX_API Vruta::Event mouse_dragged(
180 std::shared_ptr<Core::Window> window,
181 IO::MouseButtons button,
182 std::function<void(double, double)> callback);
183
184 /**
185 * @brief Creates an Event coroutine that triggers on mouse scroll
186 * @param window Window to listen to
187 * @param callback Function to call on scroll with ScrollData
188 * @return Event coroutine that can be added to EventManager
189 *
190 * Example:
191 * @code
192 * auto task = mouse_scrolled(window,
193 * [](double xoffset, double yoffset) {
194 * // Handle mouse scroll with offsets
195 * });
196 * @endcode
197 */
198 MAYAFLUX_API Vruta::Event mouse_scrolled(
199 std::shared_ptr<Core::Window> window,
200 std::function<void(double, double)> callback);
201
202 /**
203 * @brief Creates an Event coroutine that triggers on window resize.
204 *
205 * Delivers the new logical window size (Core::WindowEventType::WINDOW_RESIZED),
206 * the same event the Vulkan backend uses to flag swapchain recreation. Not the
207 * framebuffer pixel size (Core::WindowEventType::FRAMEBUFFER_RESIZED).
208 *
209 * @param window Window to listen to.
210 * @param callback Called with the new (width, height).
211 * @return Event coroutine that can be added to EventManager.
212 */
213 MAYAFLUX_API Vruta::Event window_resized(
214 std::shared_ptr<Core::Window> window,
215 std::function<void(uint32_t, uint32_t)> callback);
216
217 /**
218 * @brief Creates an Event coroutine that triggers on window close.
219 *
220 * @param window Window to listen to.
221 * @param callback Called when the window is closed.
222 * @return Event coroutine that can be added to EventManager.
223 */
224 MAYAFLUX_API Vruta::Event window_closed(
225 std::shared_ptr<Core::Window> window,
226 std::function<void()> callback);
227
228} // namespace Kriya
229} // namespace MayaFlux
PickCallback callback
Definition Picker.cpp:22
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
MouseButtons
Enumeration for mouse buttons.
Definition Keys.hpp:147
@ Vruta
Coroutines, schedulers, clocks, task management.
@ Core
Core engine, backend, subsystems.
@ Kriya
Automatable tasks and fluent scheduling api for Nodes and Buffers.
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 window_closed(std::shared_ptr< Core::Window > window, std::function< void()> callback)
Creates an Event coroutine that triggers on window close.
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 window_resized(std::shared_ptr< Core::Window > window, std::function< void(uint32_t, uint32_t)> callback)
Creates an Event coroutine that triggers on window resize.
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.
Vruta::Event text_input(std::shared_ptr< Core::Window > window, std::function< void(uint32_t)> callback)
Creates an Event coroutine that triggers on resolved text input.
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12