aboutsummaryrefslogtreecommitdiffstats
path: root/c_src
diff options
context:
space:
mode:
Diffstat (limited to 'c_src')
-rw-r--r--c_src/esdl2.h3
-rw-r--r--c_src/sdl_video.c39
2 files changed, 42 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index 8c107f8..2cee676 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -410,6 +410,8 @@
F(get_version, 0) \
F(get_revision, 0) \
/* sdl_video */ \
+ F(disable_screensaver, 0) \
+ F(enable_screensaver, 0) \
F(get_closest_display_mode, 2) \
F(get_current_display_mode, 1) \
F(get_current_video_driver, 0) \
@@ -423,6 +425,7 @@
F(get_num_video_displays, 0) \
F(get_num_video_drivers, 0) \
F(get_video_driver, 1) \
+ F(is_screensaver_enabled, 0) \
F(video_init, 1) \
F(video_quit, 0) \
/* sdl_window */ \
diff --git a/c_src/sdl_video.c b/c_src/sdl_video.c
index 49dbe7f..e16c7d2 100644
--- a/c_src/sdl_video.c
+++ b/c_src/sdl_video.c
@@ -34,6 +34,30 @@ ERL_NIF_TERM display_mode_to_map(ErlNifEnv* env, SDL_DisplayMode* mode)
return map;
}
+// disable_screensaver
+
+NIF_CAST_HANDLER(thread_disable_screensaver)
+{
+ SDL_DisableScreenSaver();
+}
+
+NIF_FUNCTION(disable_screensaver)
+{
+ return nif_thread_cast(env, thread_disable_screensaver, 0);
+}
+
+// enable_screensaver
+
+NIF_CAST_HANDLER(thread_enable_screensaver)
+{
+ SDL_EnableScreenSaver();
+}
+
+NIF_FUNCTION(enable_screensaver)
+{
+ return nif_thread_cast(env, thread_enable_screensaver, 0);
+}
+
// get_closest_display_mode
NIF_CALL_HANDLER(thread_get_closest_display_mode)
@@ -323,6 +347,21 @@ NIF_FUNCTION(get_video_driver)
return enif_make_binary(env, &bin);
}
+// is_screensaver_enabled
+
+NIF_CALL_HANDLER(thread_is_screensaver_enabled)
+{
+ if (SDL_IsScreenSaverEnabled())
+ return atom_true;
+
+ return atom_false;
+}
+
+NIF_FUNCTION(is_screensaver_enabled)
+{
+ return nif_thread_call(env, thread_is_screensaver_enabled, 0);
+}
+
// video_init
NIF_CALL_HANDLER(thread_video_init)