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

◆ signal()

void MayaFlux::Vruta::WindowEventSource::signal ( Core::WindowEvent  event)

Enqueue a window event and resume matching waiters.

Parameters
eventEvent produced by the GLFW backend.

Updates input state caches before dispatching.

Definition at line 7 of file WindowEventSource.cpp.

8{
9 if (auto* kd = std::get_if<Core::WindowEvent::KeyData>(&event.data)) {
10 if (event.type == Core::WindowEventType::KEY_PRESSED) {
11 m_key_states[kd->key] = true;
12 } else if (event.type == Core::WindowEventType::KEY_RELEASED) {
13 m_key_states[kd->key] = false;
14 }
15 }
16
17 if (auto* bd = std::get_if<Core::WindowEvent::MouseButtonData>(&event.data)) {
19 m_button_states[bd->button] = true;
20 } else if (event.type == Core::WindowEventType::MOUSE_BUTTON_RELEASED) {
21 m_button_states[bd->button] = false;
22 }
23 }
24
25 if (auto* pd = std::get_if<Core::WindowEvent::MousePosData>(&event.data)) {
26 m_mouse_x = pd->x;
27 m_mouse_y = pd->y;
28 }
29
30 m_pending_events.push(event);
31 dispatch(&event);
32}
void dispatch(const void *event)
Iterates the waiter list, passing the type-erased signal to each.
std::queue< Core::WindowEvent > m_pending_events
std::unordered_map< int16_t, bool > m_key_states
std::unordered_map< int, bool > m_button_states

References MayaFlux::Core::WindowEvent::data, MayaFlux::Vruta::EventSource::dispatch(), MayaFlux::Core::KEY_PRESSED, MayaFlux::Core::KEY_RELEASED, m_button_states, m_key_states, m_mouse_x, m_mouse_y, m_pending_events, MayaFlux::Core::MOUSE_BUTTON_PRESSED, MayaFlux::Core::MOUSE_BUTTON_RELEASED, and MayaFlux::Core::WindowEvent::type.

+ Here is the call graph for this function: