options: drop --opt:subopt option names

For all suboptions, "flat" options were available by separating the
parent option and the sub option with ":", e.g. "--rawvideo:w=123". Drop
this syntax and use "-" as separator. This means even suboptions are
available as normal options now, e.g. "--rawvideo-w=123". The old syntax
doesn't work anymore.

Note that this is completely separate from actual suboptions. For
example, "-rawvideo w=123:h=123" still works. (Not that this syntax is
worth supporting, but it's needed anyway, for for other things like vf
and vo suboptions.)

As a consequence of this change, we also have to add new "no-" prefixed
options for flag suboptions, so that "--no-input-default-bindings"
works. ("--input-no-default-bindings" also works as a consequence of
allowing "-input no-default-bindings" - they are handled by the same
underlying option.)

For --input, always use the full syntax in the manpage. There exist
suboptions other than --input (like --tv, --rawvideo, etc.), but since
they might be handled differently in the future, don't touch these yet.

M_OPT_PREFIXED becomes the default, so remove it. As a minor unrelated
cleanup, get rid of M_OPT_MERGE too and use the OPT_SUBSTRUCT() macro in
some places.

Unrelated: remove the duplicated --tv:buffersize option, fix a typo in
changes.rst.
This commit is contained in:
wm4 2013-02-21 22:10:21 +01:00
parent e540e5d4da
commit 9b7fb867f7
10 changed files with 79 additions and 89 deletions

View File

@ -157,7 +157,7 @@ input.conf and slave commands
| | a negative step instead. |
+--------------------------------+----------------------------------------+
| step_property <prop> <step> | Prefix cycle or add with no-osd: |
| <dur> | no-osd cycle <prop> <step> |
| <dir> | no-osd cycle <prop> <step> |
+--------------------------------+----------------------------------------+
| osd_show_property_text <text> | show_text <text> |
| | The property expansion format string |

View File

@ -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 <seconds> [relative|absolute|absolute-percent|- [default-precise|exact|keyframes]]
Change the playback position. By default, seeks by a relative amount of

View File

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

View File

@ -896,55 +896,47 @@
their start timestamps differ, and then video timing is gradually adjusted
if necessary to reach correct synchronization later.
--input=<commands>
This option can be used to configure certain parts of the input system.
Paths are relative to ``~/.mpv/``.
--input-conf=<filename>
Specify input configuration file other than the default
``~/.mpv/input.conf``.
*NOTE*: Autorepeat is currently only supported by joysticks.
--input-ar-dev=<device>
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=<filename>
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>
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=<filename>
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=<filename>
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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