From 5270088f730a7e30155a642dcd5c4e9a80055d7a Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Sun, 8 May 2022 01:35:55 +1000 Subject: More messing around with plugin system Just more attempts, but I think I'm gonna switch over to dynamic .so/.dll loading. That would be pretty fun to check out. --- clak.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'clak.c') diff --git a/clak.c b/clak.c index eace40d..7a19f4a 100644 --- a/clak.c +++ b/clak.c @@ -6,14 +6,15 @@ #define VOLUME 0.15 -#include "board/boards.h" -#define BOARD(str, buf) { .name = str, .wav = buf }, +#define BOARD(x) { .name = #x, .on_down = x ## _on_down, .on_up = x ## _on_up }, +#include "boards.h" #include "platform/platform.h" typedef struct { char *name; - unsigned char* wav; + void (*on_down)(void); + void (*on_up)(void); } Board; Board boards[] = { @@ -44,13 +45,14 @@ void keyboard_on_down(void) { if (board == NULL) return; - sound_play(board->wav); + board->on_down(); } void keyboard_on_up(void) { - // if (board == NULL) - // return; + if (board == NULL) + return; + board->on_up(); } int main(int argc, char **argv) -- cgit