aboutsummaryrefslogtreecommitdiffstats
path: root/c_src/sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'c_src/sdl.c')
-rw-r--r--c_src/sdl.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/c_src/sdl.c b/c_src/sdl.c
index 835b0f6..26a1d0e 100644
--- a/c_src/sdl.c
+++ b/c_src/sdl.c
@@ -14,17 +14,21 @@
#include "esdl2.h"
-#define INIT_FLAGS(F) \
+#define BASE_INIT_FLAGS(F) \
F(timer, SDL_INIT_TIMER) \
F(audio, SDL_INIT_AUDIO) \
F(video, SDL_INIT_VIDEO) \
F(joystick, SDL_INIT_JOYSTICK) \
F(haptic, SDL_INIT_HAPTIC) \
F(game_controller, SDL_INIT_GAMECONTROLLER) \
- F(events, SDL_INIT_EVENTS) \
+ F(events, SDL_INIT_EVENTS)
+
+#define INIT_FLAGS(F) \
+ BASE_INIT_FLAGS(F) \
F(everything, SDL_INIT_EVERYTHING)
NIF_LIST_TO_FLAGS_FUNCTION(list_to_init_flags, Uint32, INIT_FLAGS)
+NIF_FLAGS_TO_LIST_FUNCTION(init_flags_to_list, Uint32, BASE_INIT_FLAGS)
// init
@@ -105,23 +109,16 @@ NIF_FUNCTION(set_main_ready)
}
// was_init
-// @todo Implement the case where we want to receive a list of everything init.
NIF_CALL_HANDLER(thread_was_init)
{
- if (SDL_WasInit((long)args[0]))
- return atom_true;
-
- return atom_false;
+ return init_flags_to_list(env, SDL_WasInit((long)args[0]));
}
NIF_FUNCTION(was_init)
{
- unsigned int length;
Uint32 flags = 0;
- BADARG_IF(!enif_get_list_length(env, argv[0], &length));
- BADARG_IF(length == 0);
BADARG_IF(!list_to_init_flags(env, argv[0], &flags));
return nif_thread_call(env, thread_was_init, 1, flags);