diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-01-27 00:05:20 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-01-27 09:15:05 +0100 |
commit | c406f945924412f4c472413b578e396036e63626 (patch) | |
tree | 53004fdcc96fb8f6334f5c70ebd9a20dbe617c9c /apps/plugins/lua/rocklib.c | |
parent | 6eeca7096d6cfe5dd6007dab88c9d84677608ab5 (diff) | |
download | rockbox-c406f945924412f4c472413b578e396036e63626.tar.gz rockbox-c406f945924412f4c472413b578e396036e63626.zip |
Lua: Add pluginlib_actions wrapper for lua scripts.
Scripts can now make use of PLA_* actions to be more target independant.
Change-Id: I1b9f69e07f41b2187ecc1bad25a2c20eaaef92b4
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 8e1ab19941..809b269b47 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "lauxlib.h" | 28 | #include "lauxlib.h" |
29 | #include "rocklib.h" | 29 | #include "rocklib.h" |
30 | #include "lib/helper.h" | 30 | #include "lib/helper.h" |
31 | #include "lib/pluginlib_actions.h" | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * http://www.lua.org/manual/5.1/manual.html#lua_CFunction | 34 | * http://www.lua.org/manual/5.1/manual.html#lua_CFunction |
@@ -613,6 +614,24 @@ RB_WRAP(backlight_brightness_set) | |||
613 | SIMPLE_VOID_WRAPPER(backlight_brightness_use_setting); | 614 | SIMPLE_VOID_WRAPPER(backlight_brightness_use_setting); |
614 | #endif | 615 | #endif |
615 | 616 | ||
617 | RB_WRAP(get_plugin_action) | ||
618 | { | ||
619 | static const struct button_mapping *m1[] = { pla_main_ctx }; | ||
620 | int timeout = luaL_checkint(L, 1); | ||
621 | int btn; | ||
622 | #ifdef HAVE_REMOTE_LCD | ||
623 | static const struct button_mapping *m2[] = { pla_main_ctx, pla_remote_ctx }; | ||
624 | bool with_remote = luaL_optint(L, 2, 0); | ||
625 | if (with_remote) | ||
626 | btn = pluginlib_getaction(timeout, m2, 2); | ||
627 | else | ||
628 | #endif | ||
629 | btn = pluginlib_getaction(timeout, m1, 1); | ||
630 | |||
631 | lua_pushinteger(L, btn); | ||
632 | return 1; | ||
633 | } | ||
634 | |||
616 | #define R(NAME) {#NAME, rock_##NAME} | 635 | #define R(NAME) {#NAME, rock_##NAME} |
617 | static const luaL_Reg rocklib[] = | 636 | static const luaL_Reg rocklib[] = |
618 | { | 637 | { |
@@ -670,6 +689,7 @@ static const luaL_Reg rocklib[] = | |||
670 | R(backlight_brightness_set), | 689 | R(backlight_brightness_set), |
671 | R(backlight_brightness_use_setting), | 690 | R(backlight_brightness_use_setting), |
672 | #endif | 691 | #endif |
692 | R(get_plugin_action), | ||
673 | 693 | ||
674 | {"new_image", rli_new}, | 694 | {"new_image", rli_new}, |
675 | 695 | ||