diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-10-26 17:07:56 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-10-26 17:07:56 +0000 |
commit | 8dbef6d8d0990049e5cb7af4633262e9f145860d (patch) | |
tree | 0b1ce788bf23dd58d346b1d198e737baa668536b | |
parent | 10f46b3c8a35780c807122a52974f46bbe7b8de1 (diff) | |
download | rockbox-8dbef6d8d0990049e5cb7af4633262e9f145860d.tar.gz rockbox-8dbef6d8d0990049e5cb7af4633262e9f145860d.zip |
Lua: add lib/helper.c wrappers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23360 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/lua/rocklib.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index cb90eddcd6..0b336b3784 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include "lauxlib.h" | 28 | #include "lauxlib.h" |
29 | #include "rocklib.h" | 29 | #include "rocklib.h" |
30 | #include "lib/helper.h" | ||
30 | 31 | ||
31 | /* | 32 | /* |
32 | * http://www.lua.org/manual/5.1/manual.html#lua_CFunction | 33 | * http://www.lua.org/manual/5.1/manual.html#lua_CFunction |
@@ -180,6 +181,7 @@ static inline void rli_init(lua_State *L) | |||
180 | */ | 181 | */ |
181 | 182 | ||
182 | #define RB_WRAP(M) static int rock_##M(lua_State *L) | 183 | #define RB_WRAP(M) static int rock_##M(lua_State *L) |
184 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } | ||
183 | 185 | ||
184 | /* Helper function for opt_viewport */ | 186 | /* Helper function for opt_viewport */ |
185 | static void check_tablevalue(lua_State *L, const char* key, int tablepos, void* res, bool unsigned_val) | 187 | static void check_tablevalue(lua_State *L, const char* key, int tablepos, void* res, bool unsigned_val) |
@@ -573,6 +575,27 @@ RB_WRAP(do_menu) | |||
573 | return 1; | 575 | return 1; |
574 | } | 576 | } |
575 | 577 | ||
578 | SIMPLE_VOID_WRAPPER(backlight_force_on); | ||
579 | SIMPLE_VOID_WRAPPER(backlight_use_settings); | ||
580 | #ifdef HAVE_REMOTE_LCD | ||
581 | SIMPLE_VOID_WRAPPER(remote_backlight_force_on); | ||
582 | SIMPLE_VOID_WRAPPER(remote_backlight_use_settings); | ||
583 | #endif | ||
584 | #ifdef HAVE_BUTTON_LIGHT | ||
585 | SIMPLE_VOID_WRAPPER(buttonlight_force_on); | ||
586 | SIMPLE_VOID_WRAPPER(buttonlight_use_settings); | ||
587 | #endif | ||
588 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
589 | RB_WRAP(backlight_brightness_set) | ||
590 | { | ||
591 | int brightness = luaL_checkint(L, 1); | ||
592 | backlight_brightness_set(brightness); | ||
593 | |||
594 | return 0; | ||
595 | } | ||
596 | SIMPLE_VOID_WRAPPER(backlight_brightness_use_setting); | ||
597 | #endif | ||
598 | |||
576 | #define R(NAME) {#NAME, rock_##NAME} | 599 | #define R(NAME) {#NAME, rock_##NAME} |
577 | static const luaL_Reg rocklib[] = | 600 | static const luaL_Reg rocklib[] = |
578 | { | 601 | { |
@@ -614,6 +637,22 @@ static const luaL_Reg rocklib[] = | |||
614 | R(gui_syncyesno_run), | 637 | R(gui_syncyesno_run), |
615 | R(do_menu), | 638 | R(do_menu), |
616 | 639 | ||
640 | /* Backlight helper */ | ||
641 | R(backlight_force_on), | ||
642 | R(backlight_use_settings), | ||
643 | #ifdef HAVE_REMOTE_LCD | ||
644 | R(remote_backlight_force_on), | ||
645 | R(remote_backlight_use_settings), | ||
646 | #endif | ||
647 | #ifdef HAVE_BUTTON_LIGHT | ||
648 | R(buttonlight_force_on), | ||
649 | R(buttonlight_use_settings), | ||
650 | #endif | ||
651 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
652 | R(backlight_brightness_set), | ||
653 | R(backlight_brightness_use_setting), | ||
654 | #endif | ||
655 | |||
617 | {"new_image", rli_new}, | 656 | {"new_image", rli_new}, |
618 | 657 | ||
619 | {NULL, NULL} | 658 | {NULL, NULL} |