From e3d7338a979e1c2cba2328df5ac29856f4de1e0e Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 31 Jul 2020 14:22:09 -0700 Subject: play: add flags to play_startup() Introduce flags for disabling audio/video/gamecontroller caps Most of the time, all of these will be desirable for a game. But sometimes I might use this as a quick bootstrap into SDL land, especially as I accumulate play_ops_t boilerplate I'd like to be maximally reusable. The video-only use case is particularly likely especially for development tools, and I'm likely to have a corpus of play_ops_t integrations for the myriad GL/vulkan flavors... Note the flags are plumbed down to the play_ops_t.init hook so ops implementations can also be flags-aware. I didn't try make things like audio samplerate/channels configurable, as this library is intended to be a vendored .a anyways there's no hard ABI/API commitments. It can always grow and evolve when the need arises. --- src/play.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/play.h') diff --git a/src/play.h b/src/play.h index 0f1d2da..73d3815 100644 --- a/src/play.h +++ b/src/play.h @@ -33,6 +33,10 @@ typedef enum play_ticks_t { PLAY_TICKS_CNT } play_ticks_t; +#define PLAY_FLAG_NOAUDIO (1L) +#define PLAY_FLAG_NOVIDEO (1L << 1) +#define PLAY_FLAG_NOGAMEPAD (1L << 2) + #define PLAY_MUSIC_FLAG_LOOP (1L) #define PLAY_MUSIC_FLAG_FADEIN (1L << 1) #define PLAY_MUSIC_FLAG_OPTIONAL (1L << 2) @@ -42,7 +46,7 @@ typedef enum play_ticks_t { typedef struct play_t play_t; typedef struct play_ops_t { - void * (*init)(play_t *play, int argc, char *argv[]); + void * (*init)(play_t *play, int argc, char *argv[], unsigned flags); void (*destroy)(play_t *play, void *context); void (*enter)(play_t *play, void *context); void (*leave)(play_t *play, void *context); @@ -51,7 +55,7 @@ typedef struct play_ops_t { void (*dispatch)(play_t *play, void *context, SDL_Event *event); } play_ops_t; -play_t * play_startup(int argc, char *argv[], const play_ops_t *ops[]); +play_t * play_startup(int argc, char *argv[], unsigned flags, const play_ops_t *ops[]); int play_shutdown(play_t *play); void play_run(play_t *play); -- cgit v1.2.3