aboutsummaryrefslogtreecommitdiff
path: root/board/board.h
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2023-08-15 20:45:39 +1000
committerNicholas Tay <nick@windblume.net>2023-08-15 20:45:39 +1000
commita689ba41dadad0093f7545dd8999d41a165ceb98 (patch)
treeffb517c40ac8a750554eba610574008cfb45d27b /board/board.h
parent7d2f0751d0043a4f5ac0c1a6118622202e4e9e47 (diff)
downloadclak-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 'board/board.h')
-rw-r--r--board/board.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/board/board.h b/board/board.h
index 36d39fb..0c95b9c 100644
--- a/board/board.h
+++ b/board/board.h
@@ -1,16 +1,22 @@
#ifndef CLAK_BOARD_H_
#define CLAK_BOARD_H_
-struct board {
- void (*on_down)(void);
- void (*on_up)(void);
+struct board_state;
+
+typedef void (*board_init_fn_t)(struct board_state *board_state);
+typedef void (*key_event_fn_t)(struct board_state *board_state);
+
+typedef void (*sound_play_fn_t)(unsigned char *buffer, unsigned int buffer_len);
+
+struct board_state {
+ /* Populated by plugin */
+ key_event_fn_t on_down;
+ key_event_fn_t on_up;
char *name;
-};
-struct board_data {
- void (*sound_play)(unsigned char *buffer, unsigned int buffer_len);
+ /* Runtime from main */
+ board_init_fn_t board_init;
+ sound_play_fn_t sound_play;
};
-typedef struct board *(*fn_board_init)(struct board_data data);
-
#endif /* CLAK_BOARD_H_ */