|
AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
|
Manages event callbacks for button presses. More...
#include <event_dispatcher.h>
Public Types | |
| using | EventCallback = std::function< void()> |
| Callback function type for button events. | |
Public Member Functions | |
| void | registerHandler (uint8_t button, EventCallback callback) |
| Registers a callback function for a button. | |
| void | dispatch (uint8_t button) |
| Executes the callback for the specified button. | |
| void | clearHandlers () |
| Clears all registered event handlers. | |
Manages event callbacks for button presses.
This class provides a simple event dispatching system that maps button indices to callback functions. It supports 5 buttons:
Definition at line 15 of file event_dispatcher.h.
| using EventDispatcher::EventCallback = std::function<void()> |
Callback function type for button events.
Function signature for event handlers (no parameters, void return)
Definition at line 23 of file event_dispatcher.h.
| void EventDispatcher::clearHandlers | ( | ) |
Clears all registered event handlers.
Resets all callbacks to empty functions.
Sets all callbacks to nullptr, effectively disabling them.
Definition at line 34 of file event_dispatcher.cpp.
| void EventDispatcher::dispatch | ( | uint8_t | button | ) |
Executes the callback for the specified button.
Executes the callback associated with a button.
| button | Button index (0-4) to dispatch |
Performs bounds checking and null checking before execution.
Definition at line 21 of file event_dispatcher.cpp.
| void EventDispatcher::registerHandler | ( | uint8_t | button, |
| EventCallback | callback | ||
| ) |
Registers a callback function for a button.
Registers a callback function for a specific button.
| button | Button index (0-4) |
| callback | Function to call when button is pressed |
Performs bounds checking to ensure valid button index.
Definition at line 8 of file event_dispatcher.cpp.