MayaFlux 0.4.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 any key press
75 * @param window Window to listen to
76 * @param callback Function to call with key code when any key is pressed
77 * @return Event coroutine that can be added to EventManager
78 *
79 * Example:
80 * @code
81 * auto task = any_key(window,
82 * [](IO::Keys key) {
83 * // Handle any key press, key code in 'key'
84 * });
85 * @endcode
86 */
87 MAYAFLUX_API Vruta::Event any_key(
88 std::shared_ptr<Core::Window> window,
89 std::function<void(IO::Keys)> callback);
90
91 /**
92 * @brief Creates an Event coroutine that triggers on specific mouse button press
93 * @param window Window to listen to
94 * @param button Mouse button to wait for
95 * @param callback Function to call on button press
96 * @return Event coroutine that can be added to EventManager
97 *
98 * Example:
99 * @code
100 * auto task = mouse_pressed(window, IO::MouseButtons::Left,
101 * [](double x, double y) {
102 * // Handle left mouse button press at (x, y)
103 * });
104 * @endcode
105 */
106 MAYAFLUX_API Vruta::Event mouse_pressed(
107 std::shared_ptr<Core::Window> window,
108 IO::MouseButtons button,
109 std::function<void(double, double)> callback);
110
111 /**
112 * @brief Creates an Event coroutine that triggers on specific mouse button release
113 * @param window Window to listen to
114 * @param button Mouse button to wait for
115 * @param callback Function to call on button release
116 * @return Event coroutine that can be added to EventManager
117 *
118 * Example:
119 * @code
120 * auto task = mouse_released(window, IO::MouseButtons::Right,
121 * [](double x, double y) {
122 * // Handle right mouse button release at (x, y)
123 * });
124 * @endcode
125 */
126 MAYAFLUX_API Vruta::Event mouse_released(
127 std::shared_ptr<Core::Window> window,
128 IO::MouseButtons button,
129 std::function<void(double, double)> callback);
130
131 /**
132 * @brief Creates an Event coroutine that triggers on mouse movement
133 * @param window Window to listen to
134 * @param callback Function to call on mouse move
135 * @return Event coroutine that can be added to EventManager
136 *
137 * Example:
138 * @code
139 * auto task = mouse_moved(window,
140 * [](double x, double y) {
141 * // Handle mouse move at (x, y)
142 * });
143 * @endcode
144 */
145 MAYAFLUX_API Vruta::Event mouse_moved(
146 std::shared_ptr<Core::Window> window,
147 std::function<void(double, double)> callback);
148
149 /**
150 * @brief Creates an Event coroutine that triggers on mouse drag with specific button
151 * @param window Window to listen to
152 * @param button Mouse button that must be held for drag
153 * @param callback Function to call on mouse drag with current position
154 * @return Event coroutine that can be added to EventManager
155 *
156 * Example:
157 * @code
158 * auto task = mouse_dragged(window, IO::MouseButtons::Left,
159 * [](double x, double y) {
160 * // Handle mouse drag with left button at (x, y)
161 * });
162 * @endcode
163 */
164 MAYAFLUX_API Vruta::Event mouse_dragged(
165 std::shared_ptr<Core::Window> window,
166 IO::MouseButtons button,
167 std::function<void(double, double)> callback);
168
169 /**
170 * @brief Creates an Event coroutine that triggers on mouse scroll
171 * @param window Window to listen to
172 * @param callback Function to call on scroll with ScrollData
173 * @return Event coroutine that can be added to EventManager
174 *
175 * Example:
176 * @code
177 * auto task = mouse_scrolled(window,
178 * [](double xoffset, double yoffset) {
179 * // Handle mouse scroll with offsets
180 * });
181 * @endcode
182 */
183 MAYAFLUX_API Vruta::Event mouse_scrolled(
184 std::shared_ptr<Core::Window> window,
185 std::function<void(double, double)> callback);
186
187} // namespace Kriya
188} // namespace MayaFlux
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 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.
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12