From 2fee408d6fe0964e245dc0bae90027baa13b159a Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Wed, 11 May 2022 19:22:08 +1000 Subject: Improve plugin loading architecture This should be better, maybe the variable names could be better though. Init is more extensible, we take in a 'board_data' struct on the plugin end that has everything it needs (mainly function pointers for now). Then, a 'board' struct is given back to the main Clak runtime, with everything it needs to know (again, mainly function pointers). It is a bit weird that the board is not stored with Clak but as a pointer to the dynamically loaded bit, but not sure. --- board/board.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'board/board.h') diff --git a/board/board.h b/board/board.h index 18f6afa..c7dfc1f 100644 --- a/board/board.h +++ b/board/board.h @@ -1,12 +1,16 @@ #ifndef CLAK_BOARD_H_ #define CLAK_BOARD_H_ -#include +struct board { + void (*on_down)(void); + void (*on_up)(void); + char *name; +}; -#include "../clak.h" +struct board_data { + void (*sound_play)(unsigned char *buffer); +}; -typedef void (*fn_board_init)(fn_sound_play sp); -typedef void (*fn_board_on_down)(void); -typedef void (*fn_board_on_up)(void); +typedef struct board *(*fn_board_init)(struct board_data data); #endif /* CLAK_BOARD_H_ */ \ No newline at end of file -- cgit