mirror of
https://github.com/Genaker/LoraSA.git
synced 2026-07-06 01:42:17 +02:00
drone_sound_alarm as event listener
This commit is contained in:
@@ -154,6 +154,21 @@ size_t Scan::addEventListener(EventType t, Listener &l)
|
||||
return c;
|
||||
}
|
||||
|
||||
struct CallbackFunction : Listener
|
||||
{
|
||||
void (*cb)(void *arg, Event &e);
|
||||
void *arg;
|
||||
|
||||
CallbackFunction(void cb(void *arg, Event &e), void *arg) : cb(cb), arg(arg) {}
|
||||
|
||||
void onEvent(Event &e) { cb(arg, e); }
|
||||
};
|
||||
|
||||
size_t Scan::addEventListener(EventType t, void cb(void *arg, Event &e), void *arg)
|
||||
{
|
||||
return addEventListener(t, *(new CallbackFunction(cb, arg)));
|
||||
}
|
||||
|
||||
void Scan::fireEvent(Event &event)
|
||||
{
|
||||
Listener **list = eventListeners[(size_t)event.type];
|
||||
|
||||
@@ -69,6 +69,7 @@ struct Scan
|
||||
int samples);
|
||||
|
||||
size_t addEventListener(EventType t, Listener &l);
|
||||
size_t addEventListener(EventType t, void cb(void *, Event &), void *arg);
|
||||
void fireEvent(Event &e);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user