summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-05-14 22:22:33 +0200
committerwm4 <wm4@nowhere>2020-05-14 22:22:33 +0200
commita58b2df3f84da9c19e4900e2524036a176c16c7a (patch)
tree78eff7220527e9682e72ca6394553ef74a3081ca
parentc6369933f1d9cd204b09be95ef7d4ed1351610e2 (diff)
downloadmpv-a58b2df3f84da9c19e4900e2524036a176c16c7a.tar.bz2
mpv-a58b2df3f84da9c19e4900e2524036a176c16c7a.tar.xz
command: add input-key-list property
Fixes: #7698
-rw-r--r--DOCS/man/input.rst3
-rw-r--r--input/keycodes.c10
-rw-r--r--input/keycodes.h1
-rw-r--r--player/command.c15
4 files changed, 29 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index be48644cfd..200b3d403f 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -3046,6 +3046,9 @@ Property list
List of available libavformat demuxers' names. This can be used to check
for support for a specific format or use with ``--demuxer-lavf-format``.
+``input-key-list``
+ List of `Key names`_, same as output by ``--input-keylist``.
+
``mpv-version``
Return the mpv version/copyright string. Depending on how the binary was
built, it might contain either a release version, or just a git hash.
diff --git a/input/keycodes.c b/input/keycodes.c
index bb92994479..312ffc4893 100644
--- a/input/keycodes.c
+++ b/input/keycodes.c
@@ -322,6 +322,16 @@ void mp_print_key_list(struct mp_log *out)
mp_info(out, "%s\n", key_names[i].name);
}
+char **mp_get_key_list(void)
+{
+ char **list = NULL;
+ int num = 0;
+ for (int i = 0; key_names[i].name != NULL; i++)
+ MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(NULL, key_names[i].name));
+ MP_TARRAY_APPEND(NULL, list, num, NULL);
+ return list;
+}
+
int mp_normalize_keycode(int keycode)
{
if (keycode <= 0)
diff --git a/input/keycodes.h b/input/keycodes.h
index 3a33258031..6373a6e21a 100644
--- a/input/keycodes.h
+++ b/input/keycodes.h
@@ -253,5 +253,6 @@ int mp_input_get_keys_from_string(char *str, int max_num_keys,
struct mp_log;
void mp_print_key_list(struct mp_log *out);
+char **mp_get_key_list(void);
#endif /* MPLAYER_KEYCODES_H */
diff --git a/player/command.c b/player/command.c
index 322ce973c9..04e84c998f 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3016,6 +3016,20 @@ static int mp_property_protocols(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_keylist(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ switch (action) {
+ case M_PROPERTY_GET:
+ *(char ***)arg = mp_get_key_list();
+ return M_PROPERTY_OK;
+ case M_PROPERTY_GET_TYPE:
+ *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
+ return M_PROPERTY_OK;
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
static int get_decoder_entry(int item, int action, void *arg, void *ctx)
{
struct mp_decoder_list *codecs = ctx;
@@ -3533,6 +3547,7 @@ static const struct m_property mp_properties_base[] = {
{"decoder-list", mp_property_decoders},
{"encoder-list", mp_property_encoders},
{"demuxer-lavf-list", mp_property_lavf_demuxers},
+ {"input-key-list", mp_property_keylist},
{"mpv-version", mp_property_version},
{"mpv-configuration", mp_property_configuration},