1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-19 21:31:52 +00:00

input: make key binds order-independent again

This is for the sake of multi-key commands again. This could break:

   SPACE ignore
   SPACE-SPACE command

while this worked:

   SPACE-SPACE command
   SPACE ignore

The reason being that if the shorter command was first in the list,
it would obviously match, and searching was stopped.
This commit is contained in:
wm4 2014-04-19 14:31:54 +02:00
parent d910677937
commit 14421f732b

View File

@ -393,10 +393,14 @@ static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx,
memcpy(keys, ictx->key_history, sizeof(keys));
key_buf_add(keys, code);
struct cmd_bind *best = NULL;
// Prefer user-defined keys over builtin bindings
for (int builtin = 0; builtin < 2; builtin++) {
if (builtin && !ictx->default_bindings)
break;
if (best)
break;
for (int n = 0; n < bs->num_binds; n++) {
if (bs->binds[n].is_builtin == (bool)builtin) {
struct cmd_bind *b = &bs->binds[n];
@ -406,12 +410,13 @@ static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx,
if (b->keys[i] != keys[b->num_keys - 1 - i])
goto skip;
}
return b;
if (!best || b->num_keys >= best->num_keys)
best = b;
skip: ;
}
}
}
return NULL;
return best;
}
static struct cmd_bind *find_any_bind_for_key(struct input_ctx *ictx,