Commit dae71aac authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Change key items to string type

The configuration is simplified a bit.
Multiple keys per action will be easier to add.

N.B.: this commit breaks global hotkeys setup and hotkey prefs
parent 1b3b2112
......@@ -342,10 +342,10 @@ enum vlc_module_properties
add_int_inner( CONFIG_ITEM_INTEGER, name, text, longtext, advc, value )
#define add_key( name, value, text, longtext, advc ) \
add_int_inner( CONFIG_ITEM_KEY, "global-" name, text, longtext, advc, \
add_string_inner( CONFIG_ITEM_KEY, "global-" name, text, longtext, advc, \
KEY_UNSET ) \
change_need_restart() \
add_int_inner( CONFIG_ITEM_KEY, name, text, longtext, advc, value )
add_string_inner( CONFIG_ITEM_KEY, name, text, longtext, advc, value )
#define add_integer_with_range( name, value, i_min, i_max, p_callback, text, longtext, advc ) \
add_integer( name, value, text, longtext, advc ) \
......
......@@ -249,6 +249,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
case CONFIG_ITEM_LOADFILE:
case CONFIG_ITEM_SAVEFILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_KEY:
case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_MODULE_LIST:
case CONFIG_ITEM_MODULE_LIST_CAT:
......@@ -265,11 +266,6 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
var_Create( p_this, psz_name, VLC_VAR_FLOAT );
var_SetFloat( p_this, psz_name, us_atof(state.arg) );
break;
case CONFIG_ITEM_KEY:
var_Create( p_this, psz_name, VLC_VAR_INTEGER );
var_SetInteger( p_this, psz_name,
ConfigStringToKey( state.arg ) );
break;
case CONFIG_ITEM_BOOL:
var_Create( p_this, psz_name, VLC_VAR_BOOL );
var_SetBool( p_this, psz_name, !flag );
......
......@@ -49,8 +49,6 @@ static inline int IsConfigFloatType (int type)
return type == CONFIG_ITEM_FLOAT;
}
uint_fast32_t ConfigStringToKey( const char * );
extern vlc_rwlock_t config_lock;
/* The configuration file */
......
......@@ -48,8 +48,8 @@ int IsConfigStringType (int type)
{
static const unsigned char config_types[] =
{
CONFIG_ITEM_STRING, CONFIG_ITEM_MODULE,
CONFIG_ITEM_DIRECTORY, CONFIG_ITEM_MODULE_CAT, CONFIG_ITEM_PASSWORD,
CONFIG_ITEM_STRING, CONFIG_ITEM_MODULE, CONFIG_ITEM_DIRECTORY,
CONFIG_ITEM_KEY, CONFIG_ITEM_MODULE_CAT, CONFIG_ITEM_PASSWORD,
CONFIG_ITEM_MODULE_LIST, CONFIG_ITEM_MODULE_LIST_CAT,
CONFIG_ITEM_FONT, CONFIG_ITEM_LOADFILE, CONFIG_ITEM_SAVEFILE,
};
......@@ -63,7 +63,7 @@ int IsConfigIntegerType (int type)
{
static const unsigned char config_types[] =
{
CONFIG_ITEM_INTEGER, CONFIG_ITEM_KEY, CONFIG_ITEM_BOOL,
CONFIG_ITEM_INTEGER, CONFIG_ITEM_BOOL,
CONFIG_CATEGORY, CONFIG_SUBCATEGORY
};
......@@ -97,7 +97,6 @@ int config_GetType( vlc_object_t *p_this, const char *psz_name )
break;
case CONFIG_ITEM_INTEGER:
case CONFIG_ITEM_KEY:
i_type = VLC_VAR_INTEGER;
break;
......@@ -114,6 +113,7 @@ int config_GetType( vlc_object_t *p_this, const char *psz_name )
case CONFIG_ITEM_LOADFILE:
case CONFIG_ITEM_SAVEFILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_KEY:
i_type = VLC_VAR_STRING;
break;
......
......@@ -239,13 +239,6 @@ int config_LoadConfigFile( vlc_object_t *p_this )
item->saved.f = item->value.f;
break;
case CONFIG_ITEM_KEY:
if (!*psz_option_value)
break; /* ignore empty option */
item->value.i = ConfigStringToKey(psz_option_value);
item->saved.i = item->value.i;
break;
default:
free ((char *)item->value.psz);
free ((char *)item->saved.psz);
......@@ -547,16 +540,6 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
if (IsConfigIntegerType (p_item->i_type))
{
int64_t val = b_retain ? p_item->saved.i : p_item->value.i;
if (p_item->i_type == CONFIG_ITEM_KEY)
{
char *psz_key = vlc_keycode2str (val);
config_Write (file, p_item->psz_text, N_("key"),
val == p_item->orig.i,
p_item->psz_name, "%s",
psz_key ? psz_key : "");
free (psz_key);
}
else
config_Write (file, p_item->psz_text,
(p_item->i_type == CONFIG_ITEM_BOOL)
? N_("boolean") : N_("integer"),
......
......@@ -144,7 +144,12 @@ static char *utf8_cp (uint_fast32_t cp, char *buf)
return buf;
}
uint_fast32_t ConfigStringToKey (const char *name)
/**
* Parse a human-readable string representation of a VLC key code.
* @return a VLC key code, or KEY_UNSET on failure.
*/
static
uint_fast32_t vlc_str2keycode (const char *name)
{
uint_fast32_t mods = 0;
uint32_t cp;
......@@ -259,8 +264,11 @@ int vlc_InitActions (libvlc_int_t *libvlc)
/* Initialize from configuration */
for (size_t i = 0; i < libvlc_actions_count; i++)
{
char *str = var_InheritString (libvlc, libvlc_actions[i].name);
uint32_t code = str ? vlc_str2keycode (str) : KEY_UNSET;
keys[i].psz_action = libvlc_actions[i].name;
keys[i].i_key = var_InheritInteger (libvlc, libvlc_actions[i].name );
keys[i].i_key = code;
keys[i].i_action = libvlc_actions[i].value;
#ifndef NDEBUG
if (i > 0
......
......@@ -2376,118 +2376,118 @@ vlc_module_begin ()
alt + letter key, because they are usually for menu accelerators and you
don't know how the translator is going to do it.
*/
# define KEY_TOGGLE_FULLSCREEN 'f'
# define KEY_LEAVE_FULLSCREEN KEY_ESC
# define KEY_PLAY_PAUSE ' '
# define KEY_PAUSE KEY_UNSET
# define KEY_PLAY KEY_UNSET
# define KEY_FASTER '+'
# define KEY_SLOWER '-'
# define KEY_RATE_NORMAL '='
# define KEY_RATE_FASTER_FINE ']'
# define KEY_RATE_SLOWER_FINE '['
# define KEY_NEXT 'n'
# define KEY_PREV 'p'
# define KEY_STOP 's'
# define KEY_POSITION 't'
# define KEY_JUMP_MEXTRASHORT KEY_MODIFIER_SHIFT|KEY_LEFT
# define KEY_JUMP_PEXTRASHORT KEY_MODIFIER_SHIFT|KEY_RIGHT
# define KEY_JUMP_MSHORT KEY_MODIFIER_ALT|KEY_LEFT
# define KEY_JUMP_PSHORT KEY_MODIFIER_ALT|KEY_RIGHT
# define KEY_JUMP_MMEDIUM KEY_MODIFIER_CTRL|KEY_LEFT
# define KEY_JUMP_PMEDIUM KEY_MODIFIER_CTRL|KEY_RIGHT
# define KEY_JUMP_MLONG KEY_MODIFIER_CTRL|KEY_MODIFIER_ALT|KEY_LEFT
# define KEY_JUMP_PLONG KEY_MODIFIER_CTRL|KEY_MODIFIER_ALT|KEY_RIGHT
# define KEY_FRAME_NEXT 'e'
# define KEY_NAV_ACTIVATE KEY_ENTER
# define KEY_NAV_UP KEY_UP
# define KEY_NAV_DOWN KEY_DOWN
# define KEY_NAV_LEFT KEY_LEFT
# define KEY_NAV_RIGHT KEY_RIGHT
# define KEY_QUIT KEY_MODIFIER_CTRL|'q'
# define KEY_VOL_UP KEY_MODIFIER_CTRL|KEY_UP
# define KEY_VOL_DOWN KEY_MODIFIER_CTRL|KEY_DOWN
# define KEY_VOL_MUTE 'm'
# define KEY_SUBDELAY_UP 'h'
# define KEY_SUBDELAY_DOWN 'g'
# define KEY_SUBPOS_DOWN KEY_UNSET
# define KEY_SUBPOS_UP KEY_UNSET
# define KEY_AUDIODELAY_UP 'k'
# define KEY_AUDIODELAY_DOWN 'j'
# define KEY_RANDOM 'r'
# define KEY_LOOP 'l'
# define KEY_AUDIO_TRACK 'b'
# define KEY_SUBTITLE_TRACK 'v'
# define KEY_ASPECT_RATIO 'a'
# define KEY_CROP 'c'
# define KEY_TOGGLE_AUTOSCALE 'o'
# define KEY_SCALE_UP KEY_MODIFIER_ALT|'o'
# define KEY_SCALE_DOWN KEY_MODIFIER_SHIFT|KEY_MODIFIER_ALT|'o'
# define KEY_DEINTERLACE 'd'
# define KEY_INTF_SHOW 'i'
# define KEY_INTF_HIDE KEY_MODIFIER_SHIFT|'i'
# define KEY_DISC_MENU KEY_MODIFIER_SHIFT|'m'
# define KEY_TITLE_PREV KEY_MODIFIER_SHIFT|'o'
# define KEY_TITLE_NEXT KEY_MODIFIER_SHIFT|'b'
# define KEY_CHAPTER_PREV KEY_MODIFIER_SHIFT|'p'
# define KEY_CHAPTER_NEXT KEY_MODIFIER_SHIFT|'n'
# define KEY_SNAPSHOT KEY_MODIFIER_SHIFT|'s'
# define KEY_ZOOM 'z'
# define KEY_UNZOOM KEY_MODIFIER_SHIFT|'z'
# define KEY_AUDIODEVICE_CYCLE KEY_MODIFIER_SHIFT|'a'
# define KEY_RECORD KEY_MODIFIER_SHIFT|'r'
# define KEY_WALLPAPER 'w'
# define KEY_TOGGLE_FULLSCREEN "f"
# define KEY_LEAVE_FULLSCREEN "Esc"
# define KEY_PLAY_PAUSE "Space"
# define KEY_PAUSE NULL
# define KEY_PLAY NULL
# define KEY_FASTER "+"
# define KEY_SLOWER "-"
# define KEY_RATE_NORMAL "="
# define KEY_RATE_FASTER_FINE "]"
# define KEY_RATE_SLOWER_FINE "["
# define KEY_NEXT "n"
# define KEY_PREV "p"
# define KEY_STOP "s"
# define KEY_POSITION "t"
# define KEY_JUMP_MEXTRASHORT "Shift+Left"
# define KEY_JUMP_PEXTRASHORT "Shift+Right"
# define KEY_JUMP_MSHORT "Alt+Left"
# define KEY_JUMP_PSHORT "Alt+Right"
# define KEY_JUMP_MMEDIUM "Ctrl+Left"
# define KEY_JUMP_PMEDIUM "Ctrl+Right"
# define KEY_JUMP_MLONG "Ctrl+Alt+Left"
# define KEY_JUMP_PLONG "Ctrl+Alt+Right"
# define KEY_FRAME_NEXT "e"
# define KEY_NAV_ACTIVATE "Enter"
# define KEY_NAV_UP "Up"
# define KEY_NAV_DOWN "Down"
# define KEY_NAV_LEFT "Left"
# define KEY_NAV_RIGHT "Right"
# define KEY_QUIT "Ctrl+q"
# define KEY_VOL_UP "Ctrl+Up"
# define KEY_VOL_DOWN "Ctrl+Down"
# define KEY_VOL_MUTE "m"
# define KEY_SUBDELAY_UP "h"
# define KEY_SUBDELAY_DOWN "g"
# define KEY_SUBPOS_DOWN NULL
# define KEY_SUBPOS_UP NULL
# define KEY_AUDIODELAY_UP "k"
# define KEY_AUDIODELAY_DOWN "j"
# define KEY_RANDOM "r"
# define KEY_LOOP "l"
# define KEY_AUDIO_TRACK "b"
# define KEY_SUBTITLE_TRACK "v"
# define KEY_ASPECT_RATIO "a"
# define KEY_CROP "c"
# define KEY_TOGGLE_AUTOSCALE "o"
# define KEY_SCALE_UP "Alt+o"
# define KEY_SCALE_DOWN "Alt+Shift+o"
# define KEY_DEINTERLACE "d"
# define KEY_INTF_SHOW "i"
# define KEY_INTF_HIDE "Shift+i"
# define KEY_DISC_MENU "Shift+m"
# define KEY_TITLE_PREV "Shift+o"
# define KEY_TITLE_NEXT "Shift+b"
# define KEY_CHAPTER_PREV "Shift+p"
# define KEY_CHAPTER_NEXT "Shift+n"
# define KEY_SNAPSHOT "Shift+s"
# define KEY_ZOOM "z"
# define KEY_UNZOOM "Shift+z"
# define KEY_AUDIODEVICE_CYCLE "Shift+a"
# define KEY_RECORD "Shift+r"
# define KEY_WALLPAPER "w"
/* Cropping */
# define KEY_CROP_TOP KEY_MODIFIER_ALT|'r'
# define KEY_UNCROP_TOP KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'r'
# define KEY_CROP_LEFT KEY_MODIFIER_ALT|'d'
# define KEY_UNCROP_LEFT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'d'
# define KEY_CROP_BOTTOM KEY_MODIFIER_ALT|'c'
# define KEY_UNCROP_BOTTOM KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'c'
# define KEY_CROP_RIGHT KEY_MODIFIER_ALT|'f'
# define KEY_UNCROP_RIGHT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'f'
# define KEY_CROP_TOP "Alt+r"
# define KEY_UNCROP_TOP "Alt+Shift+r"
# define KEY_CROP_LEFT "Alt+d"
# define KEY_UNCROP_LEFT "Alt+Shift+d"
# define KEY_CROP_BOTTOM "Alt+c"
# define KEY_UNCROP_BOTTOM "Alt+Shift+c"
# define KEY_CROP_RIGHT "Alt+f"
# define KEY_UNCROP_RIGHT "Alt+Shift+f"
/* Zooming */
# define KEY_ZOOM_QUARTER KEY_MODIFIER_ALT|'1'
# define KEY_ZOOM_HALF KEY_MODIFIER_ALT|'2'
# define KEY_ZOOM_ORIGINAL KEY_MODIFIER_ALT|'3'
# define KEY_ZOOM_DOUBLE KEY_MODIFIER_ALT|'4'
# define KEY_ZOOM_QUARTER "Alt+1"
# define KEY_ZOOM_HALF "Alt+2"
# define KEY_ZOOM_ORIGINAL "Alt+3"
# define KEY_ZOOM_DOUBLE "Alt+4"
/* Bookmarks */
# define KEY_SET_BOOKMARK1 KEY_MODIFIER_CTRL|KEY_F1
# define KEY_SET_BOOKMARK2 KEY_MODIFIER_CTRL|KEY_F2
# define KEY_SET_BOOKMARK3 KEY_MODIFIER_CTRL|KEY_F3
# define KEY_SET_BOOKMARK4 KEY_MODIFIER_CTRL|KEY_F4
# define KEY_SET_BOOKMARK5 KEY_MODIFIER_CTRL|KEY_F5
# define KEY_SET_BOOKMARK6 KEY_MODIFIER_CTRL|KEY_F6
# define KEY_SET_BOOKMARK7 KEY_MODIFIER_CTRL|KEY_F7
# define KEY_SET_BOOKMARK8 KEY_MODIFIER_CTRL|KEY_F8
# define KEY_SET_BOOKMARK9 KEY_MODIFIER_CTRL|KEY_F9
# define KEY_SET_BOOKMARK10 KEY_MODIFIER_CTRL|KEY_F10
# define KEY_PLAY_BOOKMARK1 KEY_F1
# define KEY_PLAY_BOOKMARK2 KEY_F2
# define KEY_PLAY_BOOKMARK3 KEY_F3
# define KEY_PLAY_BOOKMARK4 KEY_F4
# define KEY_PLAY_BOOKMARK5 KEY_F5
# define KEY_PLAY_BOOKMARK6 KEY_F6
# define KEY_PLAY_BOOKMARK7 KEY_F7
# define KEY_PLAY_BOOKMARK8 KEY_F8
# define KEY_PLAY_BOOKMARK9 KEY_F9
# define KEY_PLAY_BOOKMARK10 KEY_F10
# define KEY_SET_BOOKMARK1 "Ctrl+F1"
# define KEY_SET_BOOKMARK2 "Ctrl+F2"
# define KEY_SET_BOOKMARK3 "Ctrl+F3"
# define KEY_SET_BOOKMARK4 "Ctrl+F4"
# define KEY_SET_BOOKMARK5 "Ctrl+F5"
# define KEY_SET_BOOKMARK6 "Ctrl+F6"
# define KEY_SET_BOOKMARK7 "Ctrl+F7"
# define KEY_SET_BOOKMARK8 "Ctrl+F8"
# define KEY_SET_BOOKMARK9 "Ctrl+F9"
# define KEY_SET_BOOKMARK10 "Ctrl+F10"
# define KEY_PLAY_BOOKMARK1 "F1"
# define KEY_PLAY_BOOKMARK2 "F2"
# define KEY_PLAY_BOOKMARK3 "F3"
# define KEY_PLAY_BOOKMARK4 "F4"
# define KEY_PLAY_BOOKMARK5 "F5"
# define KEY_PLAY_BOOKMARK6 "F6"
# define KEY_PLAY_BOOKMARK7 "F7"
# define KEY_PLAY_BOOKMARK8 "F8"
# define KEY_PLAY_BOOKMARK9 "F9"
# define KEY_PLAY_BOOKMARK10 "F10"
/* OSD menu */
# define KEY_MENU_ON KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'m'
# define KEY_MENU_OFF KEY_MODIFIER_ALT|KEY_MODIFIER_CTRL|'m'
# define KEY_MENU_RIGHT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_RIGHT
# define KEY_MENU_LEFT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_LEFT
# define KEY_MENU_UP KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_UP
# define KEY_MENU_DOWN KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_DOWN
# define KEY_MENU_SELECT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|KEY_ENTER
# define KEY_MENU_ON "Alt+Shift+m"
# define KEY_MENU_OFF "Ctrl+Alt+m"
# define KEY_MENU_RIGHT "Alt+Shift+Right"
# define KEY_MENU_LEFT "Alt+Shift+Left"
# define KEY_MENU_UP "Alt+Shift+Up"
# define KEY_MENU_DOWN "Alt+Shift+Down"
# define KEY_MENU_SELECT "Alt+Shift+Enter"
#endif
add_key( "key-toggle-fullscreen", KEY_TOGGLE_FULLSCREEN, TOGGLE_FULLSCREEN_KEY_TEXT,
......
......@@ -1522,6 +1522,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
case CONFIG_ITEM_LOADFILE:
case CONFIG_ITEM_SAVEFILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_KEY:
case CONFIG_ITEM_MODULE: /* We could also have "=<" here */
case CONFIG_ITEM_MODULE_CAT:
case CONFIG_ITEM_MODULE_LIST:
......@@ -1549,7 +1550,6 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
}
break;
case CONFIG_ITEM_INTEGER:
case CONFIG_ITEM_KEY: /* FIXME: do something a bit more clever */
print_help_section( p_parser, p_section, b_color,
b_description );
p_section = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment