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

core: allow multiple hotkeys for the same action

Hotkeys are separated by tabs. I would have allowed white spaces, but
they are found in some media key names :-(
parent 94a2b9d0
......@@ -370,6 +370,7 @@ static int vlc_key_to_action (vlc_object_t *libvlc, const char *varname,
*/
struct vlc_actions *vlc_InitActions (libvlc_int_t *libvlc)
{
vlc_object_t *obj = VLC_OBJECT(libvlc);
struct hotkey *keys;
struct vlc_actions *as = malloc (sizeof (*as) + (ACTIONS_COUNT + 1) * sizeof (*keys));
......@@ -397,11 +398,21 @@ struct vlc_actions *vlc_InitActions (libvlc_int_t *libvlc)
keys->i_action = actions[i].value;
keys++;
char *str = var_InheritString (libvlc, actions[i].name);
uint32_t code = str ? vlc_str2keycode (str) : KEY_UNSET;
char *str = var_InheritString (obj, actions[i].name);
if (str == NULL)
continue;
for (char *buf, *key = strtok_r (str, "\t", &buf);
key != NULL;
key = strtok_r (NULL, "\t", &buf))
{
uint32_t code = vlc_str2keycode (key);
if (code == KEY_UNSET)
{
msg_Warn (obj, "Key \"%s\" unrecognized", key);
continue;
}
struct mapping *entry = malloc (sizeof (*entry));
if (entry == NULL)
......@@ -415,8 +426,8 @@ struct vlc_actions *vlc_InitActions (libvlc_int_t *libvlc)
if (*pent != entry)
{
free (entry);
msg_Warn (libvlc, "Key code \"%s\" bound to multiple actions",
str);
msg_Warn (obj, "Key \"%s\" bound to multiple actions", key);
}
}
free (str);
}
......
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