command: fix keybind command with sequence keys

The command is documented to use the same syntax as input.conf, but
it doesn't work with sequence keys because it uses
mp_input_get_key_from_name for checking key names, when it should
use mp_input_get_keys_from_string instead.

Fix this by using the correct function.
This commit is contained in:
nanahi
2024-10-23 03:17:32 -04:00
committed by Kacper Michajłow
parent 56e2689894
commit 1b9d070786
3 changed files with 19 additions and 11 deletions

View File

@@ -6626,17 +6626,15 @@ static void cmd_key_bind(void *p)
struct mp_cmd_ctx *cmd = p;
struct MPContext *mpctx = cmd->mpctx;
int code = mp_input_get_key_from_name(cmd->args[0].v.s);
if (code < 0) {
MP_ERR(mpctx, "%s is not a valid input name.\n", cmd->args[0].v.s);
cmd->success = false;
return;
}
const char *key = cmd->args[0].v.s;
const char *target_cmd = cmd->args[1].v.s;
const char *comment = cmd->args[2].v.s;
if (comment && !*comment)
comment = NULL;
mp_input_bind_key(mpctx->input, code, bstr0(target_cmd), comment);
if (!mp_input_bind_key(mpctx->input, key, bstr0(target_cmd), comment)) {
MP_ERR(mpctx, "%s is not a valid input name.\n", key);
cmd->success = false;
}
}
static void cmd_apply_profile(void *p)