mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 03:19:24 +01:00
41 lines
872 B
C++
41 lines
872 B
C++
#include <utils.hh>
|
|
|
|
#include "listener.hh"
|
|
|
|
ListenerManager::ListenerManager()
|
|
{
|
|
//commented since appear under the screen
|
|
//printf("Flushing listeners\n");
|
|
this->flushListeners();
|
|
}
|
|
|
|
void ListenerManager::registerListener(Listener *kl)
|
|
{
|
|
int n_listeners = sizeof(this->listeners) / sizeof(*this->listeners);
|
|
int i;
|
|
|
|
/* Don't register already registered listeners */
|
|
for (i = 0; i < n_listeners; i++)
|
|
if (this->listeners[i] == kl)
|
|
return;
|
|
/* Find a free spot */
|
|
for (i = 0; i < n_listeners; i++)
|
|
if (!this->listeners[i])
|
|
break;
|
|
|
|
panic_if(i == n_listeners,
|
|
"No free listeners!\n");
|
|
this->listeners[i] = kl;
|
|
}
|
|
|
|
void ListenerManager::unregisterListener(Listener *kl)
|
|
{
|
|
int n_listeners = sizeof(this->listeners) / sizeof(*this->listeners);
|
|
|
|
for (int i = 0; i < n_listeners; i++)
|
|
{
|
|
if (this->listeners[i] == kl)
|
|
this->listeners[i] = NULL;
|
|
}
|
|
}
|