From f379cf0bf89ca369e6cea957ef20e9e6579ec230 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 23 Nov 2019 00:39:07 +0100 Subject: command, input: add input-bindings property Read-only information about all bindings. Somewhat hoping someone can make a nice GUI-like overlay thing for it, which provides information about mapped keys. --- player/command.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index d667eb844f..e640ba933e 100644 --- a/player/command.c +++ b/player/command.c @@ -3505,6 +3505,22 @@ static int mp_property_commands(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_bindings(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + switch (action) { + case M_PROPERTY_GET_TYPE: + *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE}; + return M_PROPERTY_OK; + case M_PROPERTY_GET: { + *(struct mpv_node *)arg = mp_input_get_bindings(mpctx->input); + return M_PROPERTY_OK; + } + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + // Redirect a property name to another #define M_PROPERTY_ALIAS(name, real_property) \ {(name), mp_property_alias, .priv = (real_property)} @@ -3691,6 +3707,7 @@ static const struct m_property mp_properties_base[] = { {"property-list", mp_property_list}, {"profile-list", mp_profile_list}, {"command-list", mp_property_commands}, + {"input-bindings", mp_property_bindings}, {"play-dir", mp_property_play_direction}, @@ -5806,7 +5823,7 @@ static void cmd_dump_cache_ab(void *p) * command has an arbitrary number of arguments, all using the type indicated by * the last argument (they are appended to mp_cmd.args[] starting at the last * argument's index). - * Arguments have named, which can be used by named argument functions, e.g. in + * Arguments have names, which can be used by named argument functions, e.g. in * Lua with mp.command_native(). */ -- cgit v1.2.3