mirror of https://code.videolan.org/videolan/vlc
Add vlc_GetActionId().
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().
This commit is contained in:
parent
621afc68d4
commit
469613e252
|
@ -205,4 +205,7 @@ typedef enum vlc_key {
|
|||
ACTIONID_RATE_FASTER_FINE,
|
||||
|
||||
} vlc_key_t;
|
||||
|
||||
VLC_EXPORT( vlc_key_t, vlc_GetActionId, (const char *psz_key) ) LIBVLC_USED;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#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 */
|
||||
|
@ -209,6 +210,15 @@ static int vlclua_intf_should_die( lua_State *L )
|
|||
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;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
@ -224,6 +234,8 @@ static const luaL_Reg vlclua_misc_reg[] = {
|
|||
{ "cachedir", vlclua_cachedir },
|
||||
{ "datadir_list", vlclua_datadir_list },
|
||||
|
||||
{ "action_id", vlclua_action_id },
|
||||
|
||||
{ "mdate", vlclua_mdate },
|
||||
{ "mwait", vlclua_mwait },
|
||||
|
||||
|
|
|
@ -23,7 +23,13 @@ end
|
|||
|
||||
-- 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
|
||||
|
|
|
@ -447,7 +447,7 @@ function menu(name,client,value)
|
|||
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
|
||||
|
|
|
@ -817,7 +817,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
|
|||
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;
|
||||
|
|
|
@ -494,6 +494,7 @@ vlc_fourcc_GetYUVFallback
|
|||
vlc_fourcc_AreUVPlanesSwapped
|
||||
vlc_gai_strerror
|
||||
vlc_gc_init
|
||||
vlc_GetActionId
|
||||
vlc_getaddrinfo
|
||||
vlc_getnameinfo
|
||||
vlc_gettext
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* 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
|
||||
|
@ -24,6 +25,7 @@
|
|||
|
||||
#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)
|
||||
|
@ -44,3 +46,11 @@ int vlc_key_to_action (vlc_object_t *libvlc, const char *varname,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue