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 | |
| parent | 6eeca7096d6cfe5dd6007dab88c9d84677608ab5 (diff) | |
| download | rockbox-c406f945924412f4c472413b578e396036e63626.zip rockbox-c406f945924412f4c472413b578e396036e63626.tar.gz rockbox-c406f945924412f4c472413b578e396036e63626.tar.bz2 rockbox-c406f945924412f4c472413b578e396036e63626.tar.xz | |
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')
| -rwxr-xr-x | apps/plugins/lua/action_helper.pl | 6 | ||||
| -rw-r--r-- | apps/plugins/lua/lua.make | 2 | ||||
| -rw-r--r-- | apps/plugins/lua/rocklib.c | 20 |
3 files changed, 27 insertions, 1 deletions
diff --git a/apps/plugins/lua/action_helper.pl b/apps/plugins/lua/action_helper.pl index eb66c2b..f225952 100755 --- a/apps/plugins/lua/action_helper.pl +++ b/apps/plugins/lua/action_helper.pl @@ -28,6 +28,12 @@ while(my $line = <STDIN>) $actions[$i] = sprintf("\t%s = %d,\n", $1, $i); $i++; } + elsif($line =~ /^\s*(PLA_[^\s]+)(\s*=.*)?,\s*$/) + { + # PLA_* begins at LAST_ACTION_PLACEHOLDER+1, thus i+1 + $actions[$i] = sprintf("\t%s = %d,\n", $1, $i+1); + $i++; + } elsif($line =~ /^\s*(CONTEXT_[^\s]+)(\s*=.*)?,\s*$/) { $contexts[$j] = sprintf("\t%s = %d,\n", $1, $j); diff --git a/apps/plugins/lua/lua.make b/apps/plugins/lua/lua.make index f4dd771..9e2db62 100644 --- a/apps/plugins/lua/lua.make +++ b/apps/plugins/lua/lua.make @@ -33,7 +33,7 @@ endif $(LUA_BUILDDIR)/lua.rock: $(LUA_OBJ) $(LUA_BUILDDIR)/actions.lua $(LUA_BUILDDIR)/buttons.lua $(LUA_BUILDDIR)/rocklib_aux.o $(LUA_BUILDDIR)/actions.lua: $(LUA_OBJ) $(LUA_SRCDIR)/action_helper.pl - $(call PRINTS,GEN $(@F))$(CC) $(PLUGINFLAGS) $(INCLUDES) -E $(APPSDIR)/action.h | $(LUA_SRCDIR)/action_helper.pl > $(LUA_BUILDDIR)/actions.lua + $(call PRINTS,GEN $(@F))$(CC) $(PLUGINFLAGS) $(INCLUDES) -E $(APPSDIR)/plugins/lib/pluginlib_actions.h | $(LUA_SRCDIR)/action_helper.pl > $(LUA_BUILDDIR)/actions.lua $(LUA_BUILDDIR)/buttons.lua: $(LUA_OBJ) $(LUA_SRCDIR)/button_helper.pl $(SILENT)$(CC) $(INCLUDES) -dM -E -include button-target.h - < /dev/null | $(LUA_SRCDIR)/button_helper.pl | $(HOSTCC) -fno-builtin $(INCLUDES) -x c -o $(LUA_BUILDDIR)/button_helper - diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 8e1ab19..809b269 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c @@ -28,6 +28,7 @@ #include "lauxlib.h" #include "rocklib.h" #include "lib/helper.h" +#include "lib/pluginlib_actions.h" /* * http://www.lua.org/manual/5.1/manual.html#lua_CFunction @@ -613,6 +614,24 @@ RB_WRAP(backlight_brightness_set) SIMPLE_VOID_WRAPPER(backlight_brightness_use_setting); #endif +RB_WRAP(get_plugin_action) +{ + static const struct button_mapping *m1[] = { pla_main_ctx }; + int timeout = luaL_checkint(L, 1); + int btn; +#ifdef HAVE_REMOTE_LCD + static const struct button_mapping *m2[] = { pla_main_ctx, pla_remote_ctx }; + bool with_remote = luaL_optint(L, 2, 0); + if (with_remote) + btn = pluginlib_getaction(timeout, m2, 2); + else +#endif + btn = pluginlib_getaction(timeout, m1, 1); + + lua_pushinteger(L, btn); + return 1; +} + #define R(NAME) {#NAME, rock_##NAME} static const luaL_Reg rocklib[] = { @@ -670,6 +689,7 @@ static const luaL_Reg rocklib[] = R(backlight_brightness_set), R(backlight_brightness_use_setting), #endif + R(get_plugin_action), {"new_image", rli_new}, |