diff options
author | Nicholas Tay <nick@windblume.net> | 2023-08-15 20:45:39 +1000 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2023-08-15 20:45:39 +1000 |
commit | a689ba41dadad0093f7545dd8999d41a165ceb98 (patch) | |
tree | ffb517c40ac8a750554eba610574008cfb45d27b /platform | |
parent | 7d2f0751d0043a4f5ac0c1a6118622202e4e9e47 (diff) | |
download | clak-a689ba41dadad0093f7545dd8999d41a165ceb98.tar.gz clak-a689ba41dadad0093f7545dd8999d41a165ceb98.tar.bz2 clak-a689ba41dadad0093f7545dd8999d41a165ceb98.zip |
Initial refactor of plugin system (darwin only)plugin-refactor
Darwin only for now since that's what I'm on, will migrate the others a
bit later. Trying out a different plugin system that probably makes more
sense as an interface to each other. Might shuffle things around even
more later.
This is based somewhat on Tsoding's audio visualiser plugin system, I
thought that was way more elegant (the 'state' object), as opposed to
whatever the hell we were doing.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin.c | 10 | ||||
-rw-r--r-- | platform/platform.h | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/platform/darwin.c b/platform/darwin.c index 3189a5d..2ffdbe3 100644 --- a/platform/darwin.c +++ b/platform/darwin.c @@ -45,7 +45,7 @@ void enter_idle(void) } /* TODO: probably also merge into a *nix module */ -struct board *load_board(char *board_name) +bool load_board(struct board_state *state, char *board_name) { char so_name[100]; int r = snprintf(so_name, 100, "./board/%s.dylib", board_name); @@ -60,16 +60,14 @@ struct board *load_board(char *board_name) return false; } - fn_board_init board_init = dlsym(board_module, "board_init"); + board_init_fn_t board_init = dlsym(board_module, "board_init"); if (board_init == NULL) { printf("ERROR: No board initialisation function could be loaded.\n"); return false; } + state->board_init = board_init; - struct board_data data = { - .sound_play = &sound_play - }; - return board_init(data); + return true; } /* https://developer.apple.com/documentation/iokit/iohidvaluecallback */ diff --git a/platform/platform.h b/platform/platform.h index ca07789..34f1200 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -5,7 +5,7 @@ #include "../board/board.h" -struct board *load_board(char *board_name); +bool load_board(struct board_state *state, char *board_name); bool sound_init(float volume); void sound_play(unsigned char *buffer, unsigned int buffer_len); |