diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst index adaf1aa0d2..7f09d942a0 100644 --- a/DOCS/man/en/changes.rst +++ b/DOCS/man/en/changes.rst @@ -157,7 +157,7 @@ input.conf and slave commands | | a negative step instead. | +--------------------------------+----------------------------------------+ | step_property | Prefix cycle or add with no-osd: | - | | no-osd cycle | + | | no-osd cycle | +--------------------------------+----------------------------------------+ | osd_show_property_text | show_text | | | The property expansion format string | diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 8a9b4f0e42..a0d2ad00c4 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -14,7 +14,7 @@ with shift. A list of special keys can be obtained with -| **mpv** --input=keylist +| **mpv** --input-keylist In general, keys can be combined with ``Shift``, ``Ctrl`` and ``Alt``: @@ -23,7 +23,7 @@ In general, keys can be combined with ``Shift``, ``Ctrl`` and ``Alt``: **mpv** can be started in input test mode, which displays key bindings and the commands they're bound to on the OSD, instead of running the commands: -| **mpv** --input=test --demuxer=rawvideo --rawvideo=w=1280:h=720 /dev/zero +| **mpv** --input-test --demuxer=rawvideo --rawvideo=w=1280:h=720 /dev/zero (Commands which normally close the player will not work in this mode, and you must kill **mpv** externally to make it exit.) @@ -51,7 +51,7 @@ List of input commands ignore Use this to "block" keys that should be unbound, and do nothing. Useful for disabling default bindings, without disabling all bindings with - ``--input=default-bindings=no``. + ``--no-input-default-bindings``. seek [relative|absolute|absolute-percent|- [default-precise|exact|keyframes]] Change the playback position. By default, seeks by a relative amount of diff --git a/DOCS/man/en/mpv.rst b/DOCS/man/en/mpv.rst index 415e19c7e8..c784d90704 100644 --- a/DOCS/man/en/mpv.rst +++ b/DOCS/man/en/mpv.rst @@ -49,7 +49,7 @@ INTERACTIVE CONTROL mpv has a fully configurable, command-driven control layer which allows you to control mpv using keyboard, mouse, joystick or remote control (with -LIRC). See the ``--input`` option for ways to customize it. +LIRC). See the ``--input-`` options for ways to customize it. keyboard control ---------------- @@ -588,7 +588,7 @@ FILES mpv user settings ``~/.mpv/input.conf`` - input bindings (see ``--input=keylist`` for the full list) + input bindings (see ``--input-keylist`` for the full list) ``~/.mpv/DVDkeys/`` cached CSS keys diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index fcab7ae8e0..fcfc17923e 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -896,55 +896,47 @@ their start timestamps differ, and then video timing is gradually adjusted if necessary to reach correct synchronization later. ---input= - This option can be used to configure certain parts of the input system. - Paths are relative to ``~/.mpv/``. +--input-conf= + Specify input configuration file other than the default + ``~/.mpv/input.conf``. - *NOTE*: Autorepeat is currently only supported by joysticks. +--input-ar-dev= + Device to be used for Apple IR Remote (default is autodetected, Linux + only). - Available commands are: +--input-ar-delay + Delay in milliseconds before we start to autorepeat a key (0 to + disable). - conf= - Specify input configuration file other than the default - ``~/.mpv/input.conf``. +--input-ar-rate + Number of key presses to generate per second on autorepeat. - ar-dev= - Device to be used for Apple IR Remote (default is autodetected, Linux - only). +--no-input-default-bindings + Use the key bindings that mpv ships with by default. - ar-delay - Delay in milliseconds before we start to autorepeat a key (0 to - disable). +--input-keylist + Prints all keys that can be bound to commands. - ar-rate - Number of key presses to generate per second on autorepeat. +--input-cmdlist + Prints all commands that can be bound to keys. - (no-)default-bindings - Use the key bindings that mpv ships with by default. +--input-js-dev + Specifies the joystick device to use (default: ``/dev/input/js0``). - keylist - Prints all keys that can be bound to commands. +--input-file= + Read commands from the given file. Mostly useful with a FIFO. + See also ``--slave``. - cmdlist - Prints all commands that can be bound to keys. + *NOTE*: When the given file is a FIFO mpv opens both ends so you + can do several `echo "seek 10" > mp_pipe` and the pipe will stay + valid. - js-dev - Specifies the joystick device to use (default: ``/dev/input/js0``). - - file= - Read commands from the given file. Mostly useful with a FIFO. - See also ``--slave``. - - *NOTE*: When the given file is a FIFO mpv opens both ends so you - can do several `echo "seek 10" > mp_pipe` and the pipe will stay - valid. - - test - Input test mode. Instead of executing commands on key presses, mpv - will show the keys and the bound commands on the OSD. Has to be used - with a dummy video, and the normal ways to quit the player will not - work (key bindings that normally quit will be shown on OSD only, just - like any other binding). +--input-test + Input test mode. Instead of executing commands on key presses, mpv + will show the keys and the bound commands on the OSD. Has to be used + with a dummy video, and the normal ways to quit the player will not + work (key bindings that normally quit will be shown on OSD only, just + like any other binding). --ipv4-only-proxy Skip any HTTP proxy for IPv6 addresses. It will still be used for IPv4 diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 3a79702959..30096ff295 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -95,11 +95,8 @@ const m_option_t tvopts_conf[]={ {"saturation", &stream_tv_defaults.saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL}, {"gain", &stream_tv_defaults.gain, CONF_TYPE_INT, CONF_RANGE, -1, 100, NULL}, #if defined(CONFIG_TV_V4L2) - {"buffersize", &stream_tv_defaults.buffer_size, CONF_TYPE_INT, CONF_RANGE, 16, 1024, NULL}, {"amode", &stream_tv_defaults.amode, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL}, {"volume", &stream_tv_defaults.volume, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL}, -#endif -#if defined(CONFIG_TV_V4L2) {"bass", &stream_tv_defaults.bass, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL}, {"treble", &stream_tv_defaults.treble, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL}, {"balance", &stream_tv_defaults.balance, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL}, @@ -502,12 +499,8 @@ const m_option_t common_opts[] = { OPT_FLAG("osd-bar", osd_bar_visible, 0), OPT_FLOATRANGE("osd-bar-align-x", osd_bar_align_x, 0, -1.0, +1.0), OPT_FLOATRANGE("osd-bar-align-y", osd_bar_align_y, 0, -1.0, +1.0), - OPT_GENERAL("osd", osd_style, M_OPT_PREFIXED, - .type = &m_option_type_subconfig_struct, - .priv = (void*)&osd_style_conf), - OPT_GENERAL("sub-text", sub_text_style, M_OPT_PREFIXED, - .type = &m_option_type_subconfig_struct, - .priv = (void*)&osd_style_conf), + OPT_SUBSTRUCT("osd", osd_style, osd_style_conf, 0), + OPT_SUBSTRUCT("sub-text", sub_text_style, osd_style_conf, 0), {NULL, NULL, 0, 0, 0, 0, NULL} }; @@ -523,7 +516,7 @@ const m_option_t tvscan_conf[]={ extern const struct m_sub_options image_writer_conf; const m_option_t screenshot_conf[] = { - OPT_SUBSTRUCT(screenshot_image_opts, image_writer_conf, M_OPT_MERGE), + OPT_SUBSTRUCT("", screenshot_image_opts, image_writer_conf, 0), OPT_STRING("template", screenshot_template, 0), {0}, }; @@ -694,8 +687,7 @@ const m_option_t mplayer_opts[]={ {"tvscan", (void *) tvscan_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, #endif /* CONFIG_TV */ - {"screenshot", (void *) screenshot_conf, CONF_TYPE_SUBCONFIG, - M_OPT_PREFIXED, 0, 0, NULL}, + {"screenshot", (void *) screenshot_conf, CONF_TYPE_SUBCONFIG}, OPT_FLAG("list-properties", list_properties, CONF_GLOBAL), {"identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_FLAG, CONF_GLOBAL, 0, MSGL_V, NULL}, diff --git a/core/m_config.c b/core/m_config.c index 6ecfa13a39..b6c15d3d9a 100644 --- a/core/m_config.c +++ b/core/m_config.c @@ -154,6 +154,7 @@ static void substruct_write_ptr(void *ptr, void *val) } static void m_config_add_option(struct m_config *config, + const char *prefix, struct m_config_option *parent, const struct m_option *arg); @@ -205,7 +206,7 @@ struct m_config *m_config_new(void *optstruct, *p = (struct m_option){ "include", NULL, CONF_TYPE_STRING, 0, }; - m_config_add_option(config, NULL, p); + m_config_add_option(config, "", NULL, p); config->includefunc = includefunc; } @@ -285,13 +286,22 @@ static void add_negation_option(struct m_config *config, .name = talloc_asprintf(no_opt, "no-%s", opt->name), .type = CONF_TYPE_STORE, .flags = opt->flags & (M_OPT_NOCFG | M_OPT_GLOBAL | M_OPT_LOCAL | - M_OPT_PRE_PARSE | M_OPT_PREFIXED | M_OPT_MERGE), + M_OPT_PRE_PARSE), .new = opt->new, .p = opt->p, .offset = opt->offset, .max = value, }; - m_config_add_option(config, parent, no_opt); + m_config_add_option(config, "", parent, no_opt); + // Consider a parent option "--sub" and a subopt "opt". Then the above + // call will add "no-opt". Add "--no-sub-opt" too. (This former call will + // also generate "--sub-no-opt", which is not really needed or wanted, but + // is a consequence of supporting "--sub=...:no-opt".) + if (parent && parent->name && strlen(parent->name)) { + no_opt = talloc_memdup(config, no_opt, sizeof(*no_opt)); + no_opt->name = opt->name; + m_config_add_option(config, "no-", parent, no_opt); + } } static void add_options(struct m_config *config, @@ -299,20 +309,25 @@ static void add_options(struct m_config *config, const struct m_option *defs) { for (int i = 0; defs[i].name; i++) - m_config_add_option(config, parent, defs + i); + m_config_add_option(config, "", parent, defs + i); +} + +// Sub-config that adds all its children to the parent. +static bool is_merge_opt(const struct m_option *opt) +{ + return (opt->type->flags & M_OPT_TYPE_HAS_CHILD) && strlen(opt->name) == 0; } static void m_config_add_option(struct m_config *config, + const char *prefix, struct m_config_option *parent, const struct m_option *arg) { - struct m_config_option *co; - assert(config != NULL); assert(arg != NULL); // Allocate a new entry for this option - co = talloc_zero(config, struct m_config_option); + struct m_config_option *co = talloc_zero(config, struct m_config_option); co->opt = arg; void *optstruct = config->optstruct; @@ -323,19 +338,16 @@ static void m_config_add_option(struct m_config *config, if (parent) { // Merge case: pretend it has no parent (note that we still must follow // the "real" parent for accessing struct fields) - if (parent->opt->flags & M_OPT_MERGE) - co->parent = parent->parent; - else - co->parent = parent; + co->parent = is_merge_opt(parent->opt) ? parent->parent : parent; } // Fill in the full name if (co->parent) { - const char *sep = (co->parent->opt->flags & M_OPT_PREFIXED) ? "-" : ":"; - co->name = talloc_asprintf(co, "%s%s%s", co->parent->name, sep, - arg->name); - } else + co->name = talloc_asprintf(co, "%s-%s", co->parent->name, arg->name); + } else { co->name = (char *)arg->name; + } + co->name = talloc_asprintf(co, "%s%s", prefix, co->name); // Option with children -> add them if (arg->type->flags & M_OPT_TYPE_HAS_CHILD) { @@ -385,7 +397,7 @@ static void m_config_add_option(struct m_config *config, } // pretend that merge options don't exist (only their children matter) - if (!(arg->flags & M_OPT_MERGE)) { + if (!is_merge_opt(co->opt)) { co->next = config->opts; config->opts = co; } @@ -465,7 +477,7 @@ static int m_config_parse_option(struct m_config *config, void *optstruct, if (co->opt->type->flags & M_OPT_TYPE_HAS_CHILD) { char prefix[110]; assert(strlen(co->name) < 100); - sprintf(prefix, "%s:", co->name); + sprintf(prefix, "%s-", co->name); return parse_subopts(config, optstruct, co->name, prefix, param, flags); } diff --git a/core/m_config.h b/core/m_config.h index 86376e4849..345141a72a 100644 --- a/core/m_config.h +++ b/core/m_config.h @@ -35,7 +35,7 @@ struct m_sub_options; // Config option struct m_config_option { struct m_config_option *next; - // Full name (ie option:subopt). + // Full name (ie option-subopt). char *name; // Option description. const struct m_option *opt; diff --git a/core/m_option.h b/core/m_option.h index bbf1efaec7..7b1e36eed7 100644 --- a/core/m_option.h +++ b/core/m_option.h @@ -355,14 +355,6 @@ struct m_option { // The option should be set during command line pre-parsing #define M_OPT_PRE_PARSE (1 << 6) -// For options with children, add all children as top-level arguments -// (e.g. "--parent=child=value" becomes "--parent-child=value") -#define M_OPT_PREFIXED (1 << 8) - -// Similar to M_OPT_PREFIXED, but drop the prefix. -// (e.g. "--parent=child=value" becomes "--child=value") -#define M_OPT_MERGE (1 << 9) - // See M_OPT_TYPE_OPTIONAL_PARAM. #define M_OPT_OPTIONAL_PARAM (1 << 10) @@ -555,10 +547,12 @@ static inline void m_option_free(const m_option_t *opt, void *dst) #define OPT_TRACKCHOICE(name, var) OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1})) // subconf must have the type struct m_sub_options. -// flagv should be M_OPT_MERGE or M_OPT_FLATTEN. +// All sub-options are prefixed with "name-" and are added to the current +// (containing) option list. +// If name is "", add the sub-options directly instead. // varname refers to the field, that must be a pointer to a field described by // the subconf struct. -#define OPT_SUBSTRUCT(varname, subconf, flagv) OPT_GENERAL("-", varname, flagv, .type = &m_option_type_subconfig_struct, .priv = (void*)&subconf) +#define OPT_SUBSTRUCT(name, varname, subconf, flagv) OPT_GENERAL(name, varname, flagv, .type = &m_option_type_subconfig_struct, .priv = (void*)&subconf) #define OPT_BASE_STRUCT struct MPOpts diff --git a/etc/input.conf b/etc/input.conf index 3b34545705..59b7a97d40 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -3,10 +3,10 @@ # You are able to redefine default keyboard/joystick/mouse/LIRC bindings, or # add new ones here. # See DOCS/man/en/input.rst for possible commands that can be bound. -# Also see mpv --input=cmdlist for other possible options. +# Also see mpv --input-cmdlist for other possible options. # The file should be placed in the $HOME/.mpv directory. # -# mpv --input=test --pause dummy.mkv can be used to test which commands keys are +# mpv --input-test --pause dummy.mkv can be used to test which commands keys are # bound to. # # If you wish to unbind a key, use key ignore. @@ -14,7 +14,7 @@ # # Note that merely removing default key bindings from this file won't remove # the default bindings mpv was compiled with, unless -# --input=no-default-bindings +# --no-input-default-bindings # is specified. # # Lines starting with # are comments. Use SHARP to assign the # key. diff --git a/video/out/vo_image.c b/video/out/vo_image.c index 7188abf9b0..95caf2611f 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -196,7 +196,7 @@ const struct vo_driver video_out_image = .colorspace = MP_CSP_DETAILS_DEFAULTS, }, .options = (const struct m_option[]) { - OPT_SUBSTRUCT(opts, image_writer_conf, M_OPT_MERGE), + OPT_SUBSTRUCT("", opts, image_writer_conf, 0), OPT_STRING("outdir", outdir, 0), {0}, },