2009-05-21 19:01:41 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Dan Everton (safetydan)
|
|
|
|
* Copyright (C) 2009 Maurus Cuelenaere
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define lrocklib_c
|
|
|
|
#define LUA_LIB
|
|
|
|
|
|
|
|
#include "lua.h"
|
|
|
|
|
|
|
|
#include "lauxlib.h"
|
|
|
|
#include "rocklib.h"
|
2009-10-26 17:07:56 +00:00
|
|
|
#include "lib/helper.h"
|
2012-01-26 23:05:20 +00:00
|
|
|
#include "lib/pluginlib_actions.h"
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2009-05-21 19:42:14 +00:00
|
|
|
/*
|
|
|
|
* http://www.lua.org/manual/5.1/manual.html#lua_CFunction
|
|
|
|
*
|
|
|
|
* In order to communicate properly with Lua, a C function must use the following protocol,
|
|
|
|
* which defines the way parameters and results are passed: a C function receives its arguments
|
|
|
|
* from Lua in its stack in direct order (the first argument is pushed first). To return values to Lua,
|
|
|
|
* a C function just pushes them onto the stack, in direct order (the first result is pushed first),
|
|
|
|
* and returns the number of results. Any other value in the stack below the results will be properly
|
2017-12-18 07:18:44 +00:00
|
|
|
* discarded by Lua. Like a Lua function, a C function called by Lua can also return many results.
|
2010-06-18 12:28:34 +00:00
|
|
|
*
|
|
|
|
* When porting new functions, don't forget to check rocklib_aux.pl whether it automatically creates
|
|
|
|
* wrappers for the function and if so, add the function names to @forbidden_functions. This is to
|
|
|
|
* prevent namespace collisions and adding duplicate wrappers.
|
2009-05-21 19:42:14 +00:00
|
|
|
*/
|
2009-05-24 01:54:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* -----------------------------
|
|
|
|
*
|
|
|
|
* Rockbox Lua image wrapper
|
|
|
|
*
|
|
|
|
* -----------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define ROCKLUA_IMAGE "rb.image"
|
2018-05-28 15:50:02 +00:00
|
|
|
typedef struct rocklua_image
|
2009-05-24 01:54:15 +00:00
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
fb_data *data;
|
2009-05-24 02:18:03 +00:00
|
|
|
fb_data dummy[1][1];
|
2017-12-18 07:18:44 +00:00
|
|
|
} rocklua_image;
|
2009-05-24 01:54:15 +00:00
|
|
|
|
|
|
|
static void rli_wrap(lua_State *L, fb_data *src, int width, int height)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *a = (rocklua_image *)lua_newuserdata(L, sizeof(rocklua_image));
|
2009-05-24 01:54:15 +00:00
|
|
|
|
|
|
|
luaL_getmetatable(L, ROCKLUA_IMAGE);
|
|
|
|
lua_setmetatable(L, -2);
|
|
|
|
|
|
|
|
a->width = width;
|
|
|
|
a->height = height;
|
|
|
|
a->data = src;
|
|
|
|
}
|
|
|
|
|
2009-05-25 11:12:27 +00:00
|
|
|
static fb_data* rli_alloc(lua_State *L, int width, int height)
|
2009-05-24 01:54:15 +00:00
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
size_t nbytes = sizeof(rocklua_image) + ((width*height) - 1) * sizeof(fb_data);
|
|
|
|
rocklua_image *a = (rocklua_image *)lua_newuserdata(L, nbytes);
|
2009-05-24 01:54:15 +00:00
|
|
|
|
|
|
|
luaL_getmetatable(L, ROCKLUA_IMAGE);
|
|
|
|
lua_setmetatable(L, -2);
|
|
|
|
|
|
|
|
a->width = width;
|
|
|
|
a->height = height;
|
2009-05-24 02:18:03 +00:00
|
|
|
a->data = &a->dummy[0][0];
|
2009-05-25 11:12:27 +00:00
|
|
|
|
|
|
|
return a->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rli_new(lua_State *L)
|
|
|
|
{
|
|
|
|
int width = luaL_checkint(L, 1);
|
|
|
|
int height = luaL_checkint(L, 2);
|
|
|
|
|
|
|
|
rli_alloc(L, width, height);
|
|
|
|
|
2009-05-24 01:54:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-12-18 07:18:44 +00:00
|
|
|
static rocklua_image* rli_checktype(lua_State *L, int arg)
|
2009-05-24 01:54:15 +00:00
|
|
|
{
|
|
|
|
void *ud = luaL_checkudata(L, arg, ROCKLUA_IMAGE);
|
|
|
|
luaL_argcheck(L, ud != NULL, arg, "'" ROCKLUA_IMAGE "' expected");
|
2017-12-18 07:18:44 +00:00
|
|
|
return (rocklua_image*) ud;
|
2009-05-24 01:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rli_width(lua_State *L)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *a = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
lua_pushnumber(L, a->width);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rli_height(lua_State *L)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *a = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
lua_pushnumber(L, a->height);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static fb_data* rli_element(lua_State *L)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *a = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
int x = luaL_checkint(L, 2);
|
|
|
|
int y = luaL_checkint(L, 3);
|
|
|
|
|
|
|
|
luaL_argcheck(L, 1 <= x && x <= a->width, 2,
|
|
|
|
"index out of range");
|
|
|
|
luaL_argcheck(L, 1 <= y && y <= a->height, 3,
|
|
|
|
"index out of range");
|
|
|
|
|
|
|
|
/* return element address */
|
2009-05-24 02:28:03 +00:00
|
|
|
return &a->data[a->width * (y - 1) + (x - 1)];
|
2009-05-24 01:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rli_set(lua_State *L)
|
|
|
|
{
|
2014-06-18 05:15:00 +00:00
|
|
|
fb_data newvalue = FB_SCALARPACK((unsigned)luaL_checknumber(L, 4));
|
2009-05-24 01:54:15 +00:00
|
|
|
*rli_element(L) = newvalue;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rli_get(lua_State *L)
|
|
|
|
{
|
2014-06-18 05:15:00 +00:00
|
|
|
lua_pushnumber(L, FB_UNPACK_SCALAR_LCD(*rli_element(L)));
|
2009-05-24 01:54:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rli_tostring(lua_State *L)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *a = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
lua_pushfstring(L, ROCKLUA_IMAGE ": %dx%d", a->width, a->height);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
static const struct luaL_reg rli_lib [] =
|
2009-05-24 01:54:15 +00:00
|
|
|
{
|
|
|
|
{"__tostring", rli_tostring},
|
|
|
|
{"set", rli_set},
|
|
|
|
{"get", rli_get},
|
|
|
|
{"width", rli_width},
|
|
|
|
{"height", rli_height},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void rli_init(lua_State *L)
|
|
|
|
{
|
|
|
|
luaL_newmetatable(L, ROCKLUA_IMAGE);
|
|
|
|
|
|
|
|
lua_pushstring(L, "__index");
|
|
|
|
lua_pushvalue(L, -2); /* pushes the metatable */
|
|
|
|
lua_settable(L, -3); /* metatable.__index = metatable */
|
|
|
|
|
|
|
|
luaL_register(L, NULL, rli_lib);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* -----------------------------
|
|
|
|
*
|
|
|
|
* Rockbox wrappers start here!
|
|
|
|
*
|
|
|
|
* -----------------------------
|
|
|
|
*/
|
|
|
|
|
2012-02-17 11:08:27 +00:00
|
|
|
#define RB_WRAP(M) static int rock_##M(lua_State UNUSED_ATTR *L)
|
2009-10-26 17:07:56 +00:00
|
|
|
#define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2009-05-25 14:21:17 +00:00
|
|
|
/* Helper function for opt_viewport */
|
|
|
|
static void check_tablevalue(lua_State *L, const char* key, int tablepos, void* res, bool unsigned_val)
|
|
|
|
{
|
2009-05-25 19:05:53 +00:00
|
|
|
lua_getfield(L, tablepos, key); /* Find table[key] */
|
2009-05-25 14:21:17 +00:00
|
|
|
|
|
|
|
if(!lua_isnoneornil(L, -1))
|
|
|
|
{
|
|
|
|
if(unsigned_val)
|
|
|
|
*(unsigned*)res = luaL_checkint(L, -1);
|
|
|
|
else
|
|
|
|
*(int*)res = luaL_checkint(L, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pop(L, 1); /* Pop the value off the stack */
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct viewport* opt_viewport(lua_State *L, int narg, struct viewport* alt)
|
|
|
|
{
|
|
|
|
if(lua_isnoneornil(L, narg))
|
|
|
|
return alt;
|
|
|
|
|
|
|
|
int tablepos = lua_gettop(L);
|
2009-05-25 19:05:53 +00:00
|
|
|
struct viewport *vp;
|
2009-05-25 14:21:17 +00:00
|
|
|
|
2009-05-25 19:05:53 +00:00
|
|
|
lua_getfield(L, tablepos, "vp"); /* get table['vp'] */
|
|
|
|
if(lua_isnoneornil(L, -1))
|
|
|
|
{
|
|
|
|
lua_pop(L, 1); /* Pop nil off stack */
|
|
|
|
|
|
|
|
vp = (struct viewport*) lua_newuserdata(L, sizeof(struct viewport)); /* Allocate memory and push it as udata on the stack */
|
|
|
|
memset(vp, 0, sizeof(struct viewport)); /* Init viewport values to 0 */
|
|
|
|
lua_setfield(L, tablepos, "vp"); /* table['vp'] = vp (pops value off the stack) */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp = (struct viewport*) lua_touserdata(L, -1); /* Reuse viewport struct */
|
|
|
|
lua_pop(L, 1); /* We don't need the value on stack */
|
|
|
|
}
|
2009-05-25 14:21:17 +00:00
|
|
|
|
|
|
|
luaL_checktype(L, narg, LUA_TTABLE);
|
|
|
|
|
|
|
|
check_tablevalue(L, "x", tablepos, &vp->x, false);
|
|
|
|
check_tablevalue(L, "y", tablepos, &vp->y, false);
|
|
|
|
check_tablevalue(L, "width", tablepos, &vp->width, false);
|
|
|
|
check_tablevalue(L, "height", tablepos, &vp->height, false);
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
check_tablevalue(L, "font", tablepos, &vp->font, false);
|
|
|
|
check_tablevalue(L, "drawmode", tablepos, &vp->drawmode, false);
|
|
|
|
#endif
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
check_tablevalue(L, "fg_pattern", tablepos, &vp->fg_pattern, true);
|
|
|
|
check_tablevalue(L, "bg_pattern", tablepos, &vp->bg_pattern, true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return vp;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(set_viewport)
|
|
|
|
{
|
|
|
|
struct viewport *vp = opt_viewport(L, 1, NULL);
|
|
|
|
int screen = luaL_optint(L, 2, SCREEN_MAIN);
|
|
|
|
rb->screens[screen]->set_viewport(vp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(clear_viewport)
|
|
|
|
{
|
2009-05-25 14:56:59 +00:00
|
|
|
int screen = luaL_optint(L, 1, SCREEN_MAIN);
|
2009-05-25 14:21:17 +00:00
|
|
|
rb->screens[screen]->clear_viewport();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2009-05-24 01:54:15 +00:00
|
|
|
RB_WRAP(lcd_framebuffer)
|
|
|
|
{
|
|
|
|
rli_wrap(L, rb->lcd_framebuffer, LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-06-15 13:46:10 +00:00
|
|
|
RB_WRAP(lcd_mono_bitmap_part)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *src = rli_checktype(L, 1);
|
2009-06-15 13:46:10 +00:00
|
|
|
int src_x = luaL_checkint(L, 2);
|
|
|
|
int src_y = luaL_checkint(L, 3);
|
|
|
|
int stride = luaL_checkint(L, 4);
|
|
|
|
int x = luaL_checkint(L, 5);
|
|
|
|
int y = luaL_checkint(L, 6);
|
|
|
|
int width = luaL_checkint(L, 7);
|
|
|
|
int height = luaL_checkint(L, 8);
|
2009-07-05 19:34:57 +00:00
|
|
|
int screen = luaL_optint(L, 9, SCREEN_MAIN);
|
2009-06-15 13:46:10 +00:00
|
|
|
|
2009-07-05 19:34:57 +00:00
|
|
|
rb->screens[screen]->mono_bitmap_part((const unsigned char *)src->data, src_x, src_y, stride, x, y, width, height);
|
2009-06-15 13:46:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(lcd_mono_bitmap)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *src = rli_checktype(L, 1);
|
2009-06-15 13:46:10 +00:00
|
|
|
int x = luaL_checkint(L, 2);
|
|
|
|
int y = luaL_checkint(L, 3);
|
|
|
|
int width = luaL_checkint(L, 4);
|
|
|
|
int height = luaL_checkint(L, 5);
|
2009-07-05 19:34:57 +00:00
|
|
|
int screen = luaL_optint(L, 6, SCREEN_MAIN);
|
2009-06-15 13:46:10 +00:00
|
|
|
|
2009-07-05 19:34:57 +00:00
|
|
|
rb->screens[screen]->mono_bitmap((const unsigned char *)src->data, x, y, width, height);
|
2009-06-15 13:46:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-24 01:54:15 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
RB_WRAP(lcd_bitmap_part)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *src = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
int src_x = luaL_checkint(L, 2);
|
|
|
|
int src_y = luaL_checkint(L, 3);
|
|
|
|
int stride = luaL_checkint(L, 4);
|
|
|
|
int x = luaL_checkint(L, 5);
|
|
|
|
int y = luaL_checkint(L, 6);
|
|
|
|
int width = luaL_checkint(L, 7);
|
|
|
|
int height = luaL_checkint(L, 8);
|
2009-07-05 19:34:57 +00:00
|
|
|
int screen = luaL_optint(L, 9, SCREEN_MAIN);
|
2009-05-24 01:54:15 +00:00
|
|
|
|
2009-07-05 19:34:57 +00:00
|
|
|
rb->screens[screen]->bitmap_part(src->data, src_x, src_y, stride, x, y, width, height);
|
2009-05-24 01:54:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(lcd_bitmap)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *src = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
int x = luaL_checkint(L, 2);
|
|
|
|
int y = luaL_checkint(L, 3);
|
|
|
|
int width = luaL_checkint(L, 4);
|
|
|
|
int height = luaL_checkint(L, 5);
|
2009-07-05 19:34:57 +00:00
|
|
|
int screen = luaL_optint(L, 6, SCREEN_MAIN);
|
2009-05-24 01:54:15 +00:00
|
|
|
|
2009-07-05 19:34:57 +00:00
|
|
|
rb->screens[screen]->bitmap(src->data, x, y, width, height);
|
2009-05-24 01:54:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(lcd_get_backdrop)
|
|
|
|
{
|
|
|
|
fb_data* backdrop = rb->lcd_get_backdrop();
|
|
|
|
if(backdrop == NULL)
|
2009-10-29 17:13:36 +00:00
|
|
|
lua_pushnil(L);
|
2009-05-24 01:54:15 +00:00
|
|
|
else
|
|
|
|
rli_wrap(L, backdrop, LCD_WIDTH, LCD_HEIGHT);
|
2009-10-29 17:13:36 +00:00
|
|
|
|
|
|
|
return 1;
|
2009-05-24 01:54:15 +00:00
|
|
|
}
|
|
|
|
#endif /* LCD_DEPTH > 1 */
|
|
|
|
|
|
|
|
#if LCD_DEPTH == 16
|
|
|
|
RB_WRAP(lcd_bitmap_transparent_part)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *src = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
int src_x = luaL_checkint(L, 2);
|
|
|
|
int src_y = luaL_checkint(L, 3);
|
|
|
|
int stride = luaL_checkint(L, 4);
|
|
|
|
int x = luaL_checkint(L, 5);
|
|
|
|
int y = luaL_checkint(L, 6);
|
|
|
|
int width = luaL_checkint(L, 7);
|
|
|
|
int height = luaL_checkint(L, 8);
|
2009-07-05 19:34:57 +00:00
|
|
|
int screen = luaL_optint(L, 9, SCREEN_MAIN);
|
2009-05-24 01:54:15 +00:00
|
|
|
|
2009-07-05 19:34:57 +00:00
|
|
|
rb->screens[screen]->transparent_bitmap_part(src->data, src_x, src_y, stride, x, y, width, height);
|
2009-05-24 01:54:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(lcd_bitmap_transparent)
|
|
|
|
{
|
2017-12-18 07:18:44 +00:00
|
|
|
rocklua_image *src = rli_checktype(L, 1);
|
2009-05-24 01:54:15 +00:00
|
|
|
int x = luaL_checkint(L, 2);
|
|
|
|
int y = luaL_checkint(L, 3);
|
|
|
|
int width = luaL_checkint(L, 4);
|
|
|
|
int height = luaL_checkint(L, 5);
|
2009-07-05 19:34:57 +00:00
|
|
|
int screen = luaL_optint(L, 6, SCREEN_MAIN);
|
2009-05-24 01:54:15 +00:00
|
|
|
|
2009-07-05 19:34:57 +00:00
|
|
|
rb->screens[screen]->transparent_bitmap(src->data, x, y, width, height);
|
2009-05-24 01:54:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* LCD_DEPTH == 16 */
|
|
|
|
|
|
|
|
#endif /* defined(LCD_BITMAP) */
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
RB_WRAP(current_tick)
|
|
|
|
{
|
|
|
|
lua_pushinteger(L, *rb->current_tick);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-05-22 22:44:34 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
RB_WRAP(action_get_touchscreen_press)
|
|
|
|
{
|
|
|
|
short x, y;
|
|
|
|
int result = rb->action_get_touchscreen_press(&x, &y);
|
|
|
|
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
lua_pushinteger(L, x);
|
|
|
|
lua_pushinteger(L, y);
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
RB_WRAP(kbd_input)
|
|
|
|
{
|
2009-05-22 22:44:34 +00:00
|
|
|
luaL_Buffer b;
|
|
|
|
luaL_buffinit(L, &b);
|
|
|
|
|
2009-07-23 00:54:35 +00:00
|
|
|
const char *input = luaL_optstring(L, 1, NULL);
|
2009-05-22 22:44:34 +00:00
|
|
|
char *buffer = luaL_prepbuffer(&b);
|
|
|
|
|
2009-07-23 00:54:35 +00:00
|
|
|
if(input != NULL)
|
|
|
|
rb->strlcpy(buffer, input, LUAL_BUFFERSIZE);
|
|
|
|
else
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
|
|
|
if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE))
|
|
|
|
{
|
|
|
|
luaL_addsize(&b, strlen(buffer));
|
|
|
|
luaL_pushresult(&b);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lua_pushnil(L);
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-06-01 22:31:32 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
RB_WRAP(touchscreen_set_mode)
|
|
|
|
{
|
|
|
|
enum touchscreen_mode mode = luaL_checkint(L, 1);
|
|
|
|
rb->touchscreen_set_mode(mode);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-01-26 22:37:27 +00:00
|
|
|
RB_WRAP(touchscreen_get_mode)
|
|
|
|
{
|
|
|
|
lua_pushinteger(L, rb->touchscreen_get_mode());
|
|
|
|
return 1;
|
|
|
|
}
|
2009-06-01 22:31:32 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-24 01:54:15 +00:00
|
|
|
RB_WRAP(font_getstringsize)
|
|
|
|
{
|
|
|
|
const unsigned char* str = luaL_checkstring(L, 1);
|
|
|
|
int fontnumber = luaL_checkint(L, 2);
|
|
|
|
int w, h;
|
|
|
|
|
2017-12-18 07:18:44 +00:00
|
|
|
if(fontnumber == FONT_UI)
|
2011-09-24 13:19:34 +00:00
|
|
|
fontnumber = rb->global_status->font_id[SCREEN_MAIN];
|
|
|
|
else
|
|
|
|
fontnumber = FONT_SYSFIXED;
|
|
|
|
|
2009-05-24 01:54:15 +00:00
|
|
|
int result = rb->font_getstringsize(str, &w, &h, fontnumber);
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
lua_pushinteger(L, w);
|
|
|
|
lua_pushinteger(L, h);
|
|
|
|
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2009-05-24 02:18:03 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
RB_WRAP(lcd_rgbpack)
|
|
|
|
{
|
|
|
|
int r = luaL_checkint(L, 1);
|
|
|
|
int g = luaL_checkint(L, 2);
|
|
|
|
int b = luaL_checkint(L, 3);
|
|
|
|
int result = LCD_RGBPACK(r, g, b);
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(lcd_rgbunpack)
|
|
|
|
{
|
|
|
|
int rgb = luaL_checkint(L, 1);
|
|
|
|
lua_pushinteger(L, RGB_UNPACK_RED(rgb));
|
|
|
|
lua_pushinteger(L, RGB_UNPACK_GREEN(rgb));
|
|
|
|
lua_pushinteger(L, RGB_UNPACK_BLUE(rgb));
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-05-25 11:12:27 +00:00
|
|
|
RB_WRAP(read_bmp_file)
|
|
|
|
{
|
|
|
|
struct bitmap bm;
|
|
|
|
const char* filename = luaL_checkstring(L, 1);
|
2014-04-02 18:46:06 +00:00
|
|
|
bool dither = luaL_optboolean(L, 2, true);
|
|
|
|
bool transparent = luaL_optboolean(L, 3, false);
|
2009-05-25 11:12:27 +00:00
|
|
|
int format = FORMAT_NATIVE;
|
|
|
|
|
|
|
|
if(dither)
|
|
|
|
format |= FORMAT_DITHER;
|
|
|
|
|
|
|
|
if(transparent)
|
|
|
|
format |= FORMAT_TRANSPARENT;
|
|
|
|
|
|
|
|
int result = rb->read_bmp_file(filename, &bm, 0, format | FORMAT_RETURN_SIZE, NULL);
|
|
|
|
|
|
|
|
if(result > 0)
|
|
|
|
{
|
|
|
|
bm.data = (unsigned char*) rli_alloc(L, bm.width, bm.height);
|
2009-10-29 17:13:36 +00:00
|
|
|
if(rb->read_bmp_file(filename, &bm, result, format, NULL) < 0)
|
|
|
|
{
|
|
|
|
/* Error occured, drop newly allocated image from stack */
|
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_pushnil(L);
|
|
|
|
}
|
2009-05-25 11:12:27 +00:00
|
|
|
}
|
2009-10-29 17:13:36 +00:00
|
|
|
else
|
|
|
|
lua_pushnil(L);
|
2009-05-25 11:12:27 +00:00
|
|
|
|
2009-10-29 17:13:36 +00:00
|
|
|
return 1;
|
2009-05-25 11:12:27 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 22:31:32 +00:00
|
|
|
RB_WRAP(current_path)
|
|
|
|
{
|
2009-07-01 17:01:22 +00:00
|
|
|
const char *current_path = get_current_path(L, 1);
|
|
|
|
if(current_path != NULL)
|
|
|
|
lua_pushstring(L, current_path);
|
|
|
|
else
|
2009-10-29 17:13:36 +00:00
|
|
|
lua_pushnil(L);
|
|
|
|
|
|
|
|
return 1;
|
2009-06-01 22:31:32 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 16:41:16 +00:00
|
|
|
static void fill_text_message(lua_State *L, struct text_message * message,
|
|
|
|
int pos)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
luaL_checktype(L, pos, LUA_TTABLE);
|
2014-04-02 18:46:06 +00:00
|
|
|
int n = luaL_getn(L, pos);
|
2013-08-22 10:12:47 +00:00
|
|
|
const char **lines = (const char**) tlsf_malloc(n * sizeof(const char*));
|
2009-10-23 10:38:20 +00:00
|
|
|
if(lines == NULL)
|
|
|
|
luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*));
|
2009-07-05 16:41:16 +00:00
|
|
|
for(i=1; i<=n; i++)
|
|
|
|
{
|
|
|
|
lua_rawgeti(L, pos, i);
|
|
|
|
lines[i-1] = luaL_checkstring(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
message->message_lines = lines;
|
|
|
|
message->nb_lines = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(gui_syncyesno_run)
|
|
|
|
{
|
|
|
|
struct text_message main_message, yes_message, no_message;
|
|
|
|
struct text_message *yes = NULL, *no = NULL;
|
|
|
|
|
|
|
|
fill_text_message(L, &main_message, 1);
|
|
|
|
if(!lua_isnoneornil(L, 2))
|
|
|
|
fill_text_message(L, (yes = &yes_message), 2);
|
|
|
|
if(!lua_isnoneornil(L, 3))
|
|
|
|
fill_text_message(L, (no = &no_message), 3);
|
|
|
|
|
|
|
|
enum yesno_res result = rb->gui_syncyesno_run(&main_message, yes, no);
|
|
|
|
|
2013-08-22 10:12:47 +00:00
|
|
|
tlsf_free(main_message.message_lines);
|
2009-07-05 16:41:16 +00:00
|
|
|
if(yes)
|
2013-08-22 10:12:47 +00:00
|
|
|
tlsf_free(yes_message.message_lines);
|
2009-07-05 16:41:16 +00:00
|
|
|
if(no)
|
2013-08-22 10:12:47 +00:00
|
|
|
tlsf_free(no_message.message_lines);
|
2009-07-05 16:41:16 +00:00
|
|
|
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-23 10:38:20 +00:00
|
|
|
RB_WRAP(do_menu)
|
|
|
|
{
|
|
|
|
struct menu_callback_with_desc menu_desc = {NULL, NULL, Icon_NOICON};
|
|
|
|
struct menu_item_ex menu = {MT_RETURN_ID | MENU_HAS_DESC, {.strings = NULL},
|
|
|
|
{.callback_and_desc = &menu_desc}};
|
|
|
|
int i, n, start_selected;
|
|
|
|
const char **items, *title;
|
|
|
|
|
|
|
|
title = luaL_checkstring(L, 1);
|
|
|
|
luaL_checktype(L, 2, LUA_TTABLE);
|
|
|
|
start_selected = luaL_optint(L, 3, 0);
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
n = luaL_getn(L, 2);
|
2013-08-22 10:12:47 +00:00
|
|
|
items = (const char**) tlsf_malloc(n * sizeof(const char*));
|
2009-10-23 10:38:20 +00:00
|
|
|
if(items == NULL)
|
|
|
|
luaL_error(L, "Can't allocate %d bytes!", n * sizeof(const char*));
|
|
|
|
for(i=1; i<=n; i++)
|
|
|
|
{
|
|
|
|
lua_rawgeti(L, 2, i); /* Push item on the stack */
|
|
|
|
items[i-1] = luaL_checkstring(L, -1);
|
|
|
|
lua_pop(L, 1); /* Pop it */
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.strings = items;
|
|
|
|
menu.flags |= MENU_ITEM_COUNT(n);
|
|
|
|
menu_desc.desc = (unsigned char*) title;
|
|
|
|
|
|
|
|
int result = rb->do_menu(&menu, &start_selected, NULL, false);
|
|
|
|
|
2013-08-22 10:12:47 +00:00
|
|
|
tlsf_free(items);
|
2009-10-23 10:38:20 +00:00
|
|
|
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Add playlist wrappers for lua
adds wrappers for the functions playlist_sync, playlist_remove_all_tracks, and playlist_insert_track, playlist_insert_directory
playlist_{sync,remove_all_tracks} take no arguments
playlist_insert_{track,directory} only have one required argument (either the filename or directory name)
They take as optional arguments position, queue, and either sync or recurse
They all just pass NULL to work with the current playlist
also adds constants for:
PLAYLIST_PREPEND,
PLAYLIST_INSERT,
PLAYLIST_INSERT_LAST,
PLAYLIST_INSERT_FIRST,
PLAYLIST_INSERT_SHUFFLED,
PLAYLIST_REPLACE, and
PLAYLIST_INSERT_LAST_SHUFFLED
Change-Id: Ib7464cba50e7a250edf092e50668f11010f2b737
Reviewed-on: http://gerrit.rockbox.org/109
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
2012-02-16 13:20:41 +00:00
|
|
|
RB_WRAP(playlist_sync)
|
|
|
|
{
|
|
|
|
/* just pass NULL to work with the current playlist */
|
|
|
|
rb->playlist_sync(NULL);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(playlist_remove_all_tracks)
|
|
|
|
{
|
|
|
|
/* just pass NULL to work with the current playlist */
|
|
|
|
int result = rb->playlist_remove_all_tracks(NULL);
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(playlist_insert_track)
|
|
|
|
{
|
|
|
|
const char *filename;
|
|
|
|
int position, queue, sync;
|
|
|
|
|
|
|
|
/* for now don't take a playlist_info pointer, but just pass NULL to use
|
|
|
|
the current playlist. If this changes later, all the other
|
|
|
|
parameters can be shifted back. */
|
|
|
|
filename = luaL_checkstring(L, 1); /* only required parameter */
|
|
|
|
position = luaL_optint(L, 2, PLAYLIST_INSERT);
|
|
|
|
queue = lua_toboolean(L, 3); /* default to false */
|
|
|
|
sync = lua_toboolean(L, 4); /* default to false */
|
|
|
|
|
|
|
|
int result = rb->playlist_insert_track(NULL, filename, position,
|
|
|
|
queue, sync);
|
|
|
|
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_WRAP(playlist_insert_directory)
|
|
|
|
{
|
|
|
|
const char* dirname;
|
|
|
|
int position, queue, recurse;
|
|
|
|
|
|
|
|
/* just like in playlist_insert_track, only works with current playlist. */
|
|
|
|
dirname = luaL_checkstring(L, 1); /* only required parameter */
|
|
|
|
position = luaL_optint(L, 2, PLAYLIST_INSERT);
|
|
|
|
queue = lua_toboolean(L, 3); /* default to false */
|
|
|
|
recurse = lua_toboolean(L, 4); /* default to false */
|
|
|
|
|
|
|
|
int result = rb->playlist_insert_directory(NULL, dirname, position,
|
|
|
|
queue, recurse);
|
|
|
|
|
|
|
|
lua_pushinteger(L, result);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-26 17:07:56 +00:00
|
|
|
SIMPLE_VOID_WRAPPER(backlight_force_on);
|
|
|
|
SIMPLE_VOID_WRAPPER(backlight_use_settings);
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
SIMPLE_VOID_WRAPPER(remote_backlight_force_on);
|
|
|
|
SIMPLE_VOID_WRAPPER(remote_backlight_use_settings);
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_BUTTON_LIGHT
|
|
|
|
SIMPLE_VOID_WRAPPER(buttonlight_force_on);
|
|
|
|
SIMPLE_VOID_WRAPPER(buttonlight_use_settings);
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
|
|
|
RB_WRAP(backlight_brightness_set)
|
|
|
|
{
|
|
|
|
int brightness = luaL_checkint(L, 1);
|
|
|
|
backlight_brightness_set(brightness);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
SIMPLE_VOID_WRAPPER(backlight_brightness_use_setting);
|
|
|
|
#endif
|
|
|
|
|
2012-01-26 23:05:20 +00:00
|
|
|
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);
|
2017-12-18 07:18:44 +00:00
|
|
|
if(with_remote)
|
2012-01-26 23:05:20 +00:00
|
|
|
btn = pluginlib_getaction(timeout, m2, 2);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
btn = pluginlib_getaction(timeout, m1, 1);
|
|
|
|
|
|
|
|
lua_pushinteger(L, btn);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
#define R(NAME) {#NAME, rock_##NAME}
|
2009-05-21 19:42:14 +00:00
|
|
|
static const luaL_Reg rocklib[] =
|
|
|
|
{
|
2009-05-21 19:01:41 +00:00
|
|
|
/* Graphics */
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2009-05-24 01:54:15 +00:00
|
|
|
R(lcd_framebuffer),
|
2009-06-15 13:46:10 +00:00
|
|
|
R(lcd_mono_bitmap_part),
|
|
|
|
R(lcd_mono_bitmap),
|
2009-05-24 01:54:15 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
R(lcd_get_backdrop),
|
|
|
|
R(lcd_bitmap_part),
|
|
|
|
R(lcd_bitmap),
|
|
|
|
#endif
|
|
|
|
#if LCD_DEPTH == 16
|
|
|
|
R(lcd_bitmap_transparent_part),
|
|
|
|
R(lcd_bitmap_transparent),
|
|
|
|
#endif
|
2009-05-24 02:18:03 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
R(lcd_rgbpack),
|
|
|
|
R(lcd_rgbunpack),
|
2009-05-21 19:01:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Kernel */
|
|
|
|
R(current_tick),
|
|
|
|
|
|
|
|
/* Buttons */
|
2009-05-22 22:44:34 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
R(action_get_touchscreen_press),
|
2009-06-01 22:31:32 +00:00
|
|
|
R(touchscreen_set_mode),
|
2012-01-26 22:37:27 +00:00
|
|
|
R(touchscreen_get_mode),
|
2009-05-22 22:44:34 +00:00
|
|
|
#endif
|
2009-05-21 19:01:41 +00:00
|
|
|
R(kbd_input),
|
|
|
|
|
2009-05-24 01:54:15 +00:00
|
|
|
R(font_getstringsize),
|
2009-05-25 11:12:27 +00:00
|
|
|
R(read_bmp_file),
|
2009-05-25 14:21:17 +00:00
|
|
|
R(set_viewport),
|
|
|
|
R(clear_viewport),
|
2009-06-01 22:31:32 +00:00
|
|
|
R(current_path),
|
2009-07-05 16:41:16 +00:00
|
|
|
R(gui_syncyesno_run),
|
Add playlist wrappers for lua
adds wrappers for the functions playlist_sync, playlist_remove_all_tracks, and playlist_insert_track, playlist_insert_directory
playlist_{sync,remove_all_tracks} take no arguments
playlist_insert_{track,directory} only have one required argument (either the filename or directory name)
They take as optional arguments position, queue, and either sync or recurse
They all just pass NULL to work with the current playlist
also adds constants for:
PLAYLIST_PREPEND,
PLAYLIST_INSERT,
PLAYLIST_INSERT_LAST,
PLAYLIST_INSERT_FIRST,
PLAYLIST_INSERT_SHUFFLED,
PLAYLIST_REPLACE, and
PLAYLIST_INSERT_LAST_SHUFFLED
Change-Id: Ib7464cba50e7a250edf092e50668f11010f2b737
Reviewed-on: http://gerrit.rockbox.org/109
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
2012-02-16 13:20:41 +00:00
|
|
|
R(playlist_sync),
|
|
|
|
R(playlist_remove_all_tracks),
|
|
|
|
R(playlist_insert_track),
|
|
|
|
R(playlist_insert_directory),
|
2009-10-23 10:38:20 +00:00
|
|
|
R(do_menu),
|
2009-05-24 01:54:15 +00:00
|
|
|
|
2009-10-26 17:07:56 +00:00
|
|
|
/* Backlight helper */
|
|
|
|
R(backlight_force_on),
|
|
|
|
R(backlight_use_settings),
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
R(remote_backlight_force_on),
|
|
|
|
R(remote_backlight_use_settings),
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_BUTTON_LIGHT
|
|
|
|
R(buttonlight_force_on),
|
|
|
|
R(buttonlight_use_settings),
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
|
|
|
R(backlight_brightness_set),
|
|
|
|
R(backlight_brightness_use_setting),
|
|
|
|
#endif
|
2012-01-26 23:05:20 +00:00
|
|
|
R(get_plugin_action),
|
2009-10-26 17:07:56 +00:00
|
|
|
|
2009-05-24 01:54:15 +00:00
|
|
|
{"new_image", rli_new},
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
#undef R
|
2009-07-05 15:33:08 +00:00
|
|
|
extern const luaL_Reg rocklib_aux[];
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2012-01-29 20:55:26 +00:00
|
|
|
#define RB_CONSTANT(x) lua_pushinteger(L, x); lua_setfield(L, -2, #x);
|
|
|
|
#define RB_STRING_CONSTANT(x) lua_pushstring(L, x); lua_setfield(L, -2, #x);
|
2009-05-21 19:01:41 +00:00
|
|
|
/*
|
|
|
|
** Open Rockbox library
|
|
|
|
*/
|
|
|
|
LUALIB_API int luaopen_rock(lua_State *L)
|
|
|
|
{
|
2014-04-02 18:46:06 +00:00
|
|
|
luaL_register(L, LUA_ROCKLIBNAME, rocklib);
|
|
|
|
luaL_register(L, LUA_ROCKLIBNAME, rocklib_aux);
|
2009-05-21 19:42:14 +00:00
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
RB_CONSTANT(HZ);
|
2009-05-22 00:06:45 +00:00
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
RB_CONSTANT(LCD_WIDTH);
|
|
|
|
RB_CONSTANT(LCD_HEIGHT);
|
2009-10-29 07:48:26 +00:00
|
|
|
RB_CONSTANT(LCD_DEPTH);
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2009-05-25 14:21:17 +00:00
|
|
|
RB_CONSTANT(FONT_SYSFIXED);
|
|
|
|
RB_CONSTANT(FONT_UI);
|
2009-05-22 00:06:45 +00:00
|
|
|
|
Add playlist wrappers for lua
adds wrappers for the functions playlist_sync, playlist_remove_all_tracks, and playlist_insert_track, playlist_insert_directory
playlist_{sync,remove_all_tracks} take no arguments
playlist_insert_{track,directory} only have one required argument (either the filename or directory name)
They take as optional arguments position, queue, and either sync or recurse
They all just pass NULL to work with the current playlist
also adds constants for:
PLAYLIST_PREPEND,
PLAYLIST_INSERT,
PLAYLIST_INSERT_LAST,
PLAYLIST_INSERT_FIRST,
PLAYLIST_INSERT_SHUFFLED,
PLAYLIST_REPLACE, and
PLAYLIST_INSERT_LAST_SHUFFLED
Change-Id: Ib7464cba50e7a250edf092e50668f11010f2b737
Reviewed-on: http://gerrit.rockbox.org/109
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
2012-02-16 13:20:41 +00:00
|
|
|
RB_CONSTANT(PLAYLIST_PREPEND);
|
|
|
|
RB_CONSTANT(PLAYLIST_INSERT);
|
|
|
|
RB_CONSTANT(PLAYLIST_INSERT_LAST);
|
|
|
|
RB_CONSTANT(PLAYLIST_INSERT_FIRST);
|
|
|
|
RB_CONSTANT(PLAYLIST_INSERT_SHUFFLED);
|
|
|
|
RB_CONSTANT(PLAYLIST_REPLACE);
|
|
|
|
RB_CONSTANT(PLAYLIST_INSERT_LAST_SHUFFLED);
|
|
|
|
|
2009-06-01 22:31:32 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
RB_CONSTANT(TOUCHSCREEN_POINT);
|
|
|
|
RB_CONSTANT(TOUCHSCREEN_BUTTON);
|
|
|
|
#endif
|
|
|
|
|
2009-07-08 11:59:05 +00:00
|
|
|
RB_CONSTANT(SCREEN_MAIN);
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
RB_CONSTANT(SCREEN_REMOTE);
|
|
|
|
#endif
|
|
|
|
|
2012-01-29 20:55:26 +00:00
|
|
|
/* some useful paths constants */
|
|
|
|
RB_STRING_CONSTANT(ROCKBOX_DIR);
|
|
|
|
RB_STRING_CONSTANT(HOME_DIR);
|
|
|
|
RB_STRING_CONSTANT(PLUGIN_DIR);
|
|
|
|
RB_STRING_CONSTANT(PLUGIN_APPS_DATA_DIR);
|
|
|
|
RB_STRING_CONSTANT(PLUGIN_GAMES_DATA_DIR);
|
|
|
|
RB_STRING_CONSTANT(PLUGIN_DATA_DIR);
|
|
|
|
RB_STRING_CONSTANT(VIEWERS_DATA_DIR);
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
rli_init(L);
|
2009-05-24 01:54:15 +00:00
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|