vlc_GetActionId() is used to get an ACTIONID from the action's name, which is way better than getting the hotkey setting from the hotkey name and then, if the hotkey was set, looking up the corresponding action id ... since this also works if the hotkey isn't set. Export this function in lua and use in common.hotkey().
ACTIONID_RATE_FASTER_FINE,
} vlc_key_t;
+
+VLC_EXPORT( vlc_key_t, vlc_GetActionId, (const char *psz_key) ) LIBVLC_USED;
+
#endif
#include <vlc_charset.h>
#include <vlc_aout.h>
#include <vlc_interface.h>
+#include <vlc_keys.h>
#include <lua.h> /* Low level lua C API */
#include <lauxlib.h> /* Higher level C API */
return 1;
}
+static int vlclua_action_id( lua_State *L )
+{
+ vlc_key_t i_key = vlc_GetActionId( luaL_checkstring( L, 1 ) );
+ if (i_key == 0)
+ return 0;
+ lua_pushnumber( L, i_key );
+ return 1;
+}
+
/*****************************************************************************
*
*****************************************************************************/
{ "cachedir", vlclua_cachedir },
{ "datadir_list", vlclua_datadir_list },
+ { "action_id", vlclua_action_id },
+
{ "mdate", vlclua_mdate },
{ "mwait", vlclua_mwait },
-- Trigger a hotkey
function hotkey(arg)
- vlc.var.set( vlc.object.libvlc(), "key-pressed", vlc.config.get( arg ) )
+ local id = vlc.misc.action_id( arg )
+ if id ~= nil then
+ vlc.var.set( vlc.object.libvlc(), "key-action", id )
+ return true
+ else
+ return false
+ end
end
-- Take a video snapshot
end
function eval(client,val)
- client:append(loadstring("return "..val)())
+ client:append(tostring(loadstring("return "..val)()))
end
--[[ Declare commands, register their callback functions and provide
struct hotkey *p_keys =
malloc( (libvlc_actions_count + 1) * sizeof (*p_keys) );
- /* Initialize from configuration */
+ /* Initialize from configuration */
for( size_t i = 0; i < libvlc_actions_count; i++ )
{
p_keys[i].psz_action = libvlc_actions[i].name;
vlc_fourcc_AreUVPlanesSwapped
vlc_gai_strerror
vlc_gc_init
+vlc_GetActionId
vlc_getaddrinfo
vlc_getnameinfo
vlc_gettext
* action.c: key to action mapping
*****************************************************************************
* Copyright © 2008 Rémi Denis-Courmont
+ * © 2009 Antoine Cellerier
*
* 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
#include <vlc_common.h>
#include "../libvlc.h"
+#include <vlc_keys.h>
int vlc_key_to_action (vlc_object_t *libvlc, const char *varname,
vlc_value_t prevkey, vlc_value_t curkey, void *priv)
return var_SetInteger (libvlc, "key-action", key->i_action);
}
+vlc_key_t vlc_GetActionId(const char *name)
+{
+ for (size_t i = 0; i < libvlc_actions_count; i++)
+ if (!strcmp(libvlc_actions[i].name, name))
+ return libvlc_actions[i].value;
+ return 0;
+}
+