Remove callbacks from libsaria class

These can easily exist as its own set of functions, and I want to remove
the libsaria class in the future.
This commit is contained in:
Bryan Schumaker 2011-09-10 13:46:09 -04:00
parent a660d5a34a
commit 33fe24fc64
5 changed files with 9 additions and 6 deletions

View File

@ -7,4 +7,7 @@ enum callback_t {
VOLUME, VOLUME,
}; };
void register_callback(callback_t, void (*)());
void trigger_callback(callback_t);
#endif /* LIBSARIA_CALLBACKS_H */ #endif /* LIBSARIA_CALLBACKS_H */

View File

@ -11,7 +11,6 @@ class Libsaria
private: private:
Audio audio; Audio audio;
Idle idle; Idle idle;
void trigger_callback(callback_t);
public: public:
Libsaria(int, char**); Libsaria(int, char**);
@ -21,7 +20,6 @@ class Libsaria
void load(string); void load(string);
void set_volume(double); void set_volume(double);
double get_volume(); double get_volume();
void register_callback(callback_t, void (*)());
void run_idle_task(); void run_idle_task();
/* Control functions */ /* Control functions */

View File

@ -7,7 +7,7 @@ using namespace std;
static map<callback_t, void (*)()> callbacks; static map<callback_t, void (*)()> callbacks;
void Libsaria::trigger_callback(callback_t type) void trigger_callback(callback_t type)
{ {
map<callback_t, void (*)()>::iterator it; map<callback_t, void (*)()>::iterator it;
it=callbacks.find(type); it=callbacks.find(type);
@ -15,7 +15,7 @@ void Libsaria::trigger_callback(callback_t type)
it->second(); it->second();
} }
void Libsaria::register_callback(callback_t type, void (* func)()) void register_callback(callback_t type, void (* func)())
{ {
callbacks[type] = func; callbacks[type] = func;
} }

View File

@ -1,5 +1,6 @@
#include <libsaria/libsaria.h> #include <libsaria/libsaria.h>
#include <libsaria/callback.h>
#include <libsaria/audio.h> #include <libsaria/audio.h>
/* /*

View File

@ -1,5 +1,6 @@
#include <libsaria/libsaria.h> #include <libsaria/callback.h>
#include <libsaria/print.h>
#include <ocarina/button.h> #include <ocarina/button.h>
void cb_play() void cb_play()
@ -18,7 +19,7 @@ void cb_pause()
static void add_callback(callback_t type, void (* func)()) static void add_callback(callback_t type, void (* func)())
{ {
libsaria_get()->register_callback(type, func); register_callback(type, func);
} }
void setup_callbacks() void setup_callbacks()