From d1179f95011103a1e3aa9bacd270e82935370f88 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 5 Aug 2015 23:55:16 +0200 Subject: command: add a command for defining input bindings This was requested. It was more or less present internally already and used for Lua scripting. Lua will switch to the "public" functions in the following commits. --- DOCS/man/input.rst | 20 ++++++++++++++++++++ input/cmd_list.c | 6 ++++++ input/cmd_list.h | 1 + player/command.c | 5 +++++ 4 files changed, 32 insertions(+) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index bbaa4bdb3a..9ad3122d3d 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -515,6 +515,26 @@ Input Commands that are Possibly Subject to Change ``disable_section "
"`` Disable the named input section. Undoes ``enable_section``. +``define-section "
" "" [default|forced]`` + Create a named input section, or replace the contents of an already existing + input section. The ``contents`` parameter uses the same syntax as the + ``input.conf`` file (except that using the section syntax in it is not + allowed), including the need to separate bindings with a newline character. + + The section with the name ``default`` is the normal input section. + + In general, input sections have to be enabled with the ``enable-section`` + command, or they are ignored. + + The last parameter has the following meaning: + + (also used if parameter omitted) + Use a key binding defined by this section only if the user hasn't + already bound this key to a command. + + Always bind a key. (The input section that was made active most recently + wins if there are ambiguities.) + ``overlay_add "" "" `` Add an OSD overlay sourced from raw data. This might be useful for scripts and applications controlling mpv, and which want to display things on top diff --git a/input/cmd_list.c b/input/cmd_list.c index b1db2e4f0c..250f451955 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -166,6 +166,12 @@ const struct mp_cmd_def mp_cmds[] = { {"exclusive", 1})), }}, { MP_CMD_DISABLE_INPUT_SECTION, "disable-section", { ARG_STRING } }, + { MP_CMD_DEFINE_INPUT_SECTION, "define-section", { + ARG_STRING, + ARG_STRING, + OARG_CHOICE(1, ({"default", 1}, + {"force", 0})), + }}, { MP_CMD_AB_LOOP, "ab-loop", }, diff --git a/input/cmd_list.h b/input/cmd_list.h index a41807f9fe..c8c0dc3593 100644 --- a/input/cmd_list.h +++ b/input/cmd_list.h @@ -79,6 +79,7 @@ enum mp_command_type { MP_CMD_ENABLE_INPUT_SECTION, MP_CMD_DISABLE_INPUT_SECTION, + MP_CMD_DEFINE_INPUT_SECTION, MP_CMD_AB_LOOP, diff --git a/player/command.c b/player/command.c index e4e1f2ea7b..edb1d81d66 100644 --- a/player/command.c +++ b/player/command.c @@ -4692,6 +4692,11 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re mp_input_disable_section(mpctx->input, cmd->args[0].v.s); break; + case MP_CMD_DEFINE_INPUT_SECTION: + mp_input_define_section(mpctx->input, cmd->args[0].v.s, "", + cmd->args[1].v.s, !!cmd->args[2].v.i); + break; + case MP_CMD_AB_LOOP: { double now = get_current_time(mpctx); int r = 0; -- cgit v1.2.3