1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-21 14:22:17 +00:00

command: add input-key-list property

Fixes: #7698
This commit is contained in:
wm4 2020-05-14 22:22:33 +02:00
parent c6369933f1
commit a58b2df3f8
4 changed files with 29 additions and 0 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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 */

View File

@ -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},