AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
EventDispatcher Class Reference

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.
 

Detailed Description

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:

  • 0-3: Action buttons A-D
  • 4: Bank selection button

Definition at line 15 of file event_dispatcher.h.

Member Typedef Documentation

◆ EventCallback

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.

Member Function Documentation

◆ clearHandlers()

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.

◆ dispatch()

void EventDispatcher::dispatch ( uint8_t  button)

Executes the callback for the specified button.

Executes the callback associated with a button.

Parameters
buttonButton index (0-4) to dispatch

Performs bounds checking and null checking before execution.

Definition at line 21 of file event_dispatcher.cpp.

◆ registerHandler()

void EventDispatcher::registerHandler ( uint8_t  button,
EventCallback  callback 
)

Registers a callback function for a button.

Registers a callback function for a specific button.

Parameters
buttonButton index (0-4)
callbackFunction to call when button is pressed

Performs bounds checking to ensure valid button index.

Definition at line 8 of file event_dispatcher.cpp.


The documentation for this class was generated from the following files: