summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-11 01:54:03 +0200
committerwm4 <wm4@nowhere>2014-06-11 01:54:03 +0200
commitbe5725ebc4813f9d5c582fd0f30fe1ebc661e3e1 (patch)
tree18102331bfc7e9adc824b082721e6319bc5decca
parent654930aa47e10c07aa0399f515a8dd04d34efa3a (diff)
downloadmpv-be5725ebc4813f9d5c582fd0f30fe1ebc661e3e1.tar.bz2
mpv-be5725ebc4813f9d5c582fd0f30fe1ebc661e3e1.tar.xz
input: make option struct local
Similar to previous commits. This also renames --doubleclick-time to --input-doubleclick-time, and --key-fifo-size to --input-key-fifo-size. We could keep the old names, but these options are very obscure, and renaming them seems better for consistency.
-rw-r--r--DOCS/man/en/options.rst22
-rw-r--r--input/input.c83
-rw-r--r--options/options.c18
-rw-r--r--options/options.h19
4 files changed, 70 insertions, 72 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index d2ae257d91..d121fe2adc 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -723,10 +723,6 @@ OPTIONS
``--demuxer-rawvideo-size=<value>``
Frame size in bytes when using ``--demuxer=rawvideo``.
-``--doubleclick-time=<milliseconds>``
- Time in milliseconds to recognize two consecutive button presses as a
- double-click (default: 300).
-
``--dump-stats=<filename>``
Write certain statistics to the given file. The file is truncated on
opening. The file will contain raw samples, each with a timestamp. To
@@ -1166,9 +1162,20 @@ OPTIONS
``--input-cmdlist``
Prints all commands that can be bound to keys.
+``--input-doubleclick-time=<milliseconds>``
+ Time in milliseconds to recognize two consecutive button presses as a
+ double-click (default: 300).
+
``--input-keylist``
Prints all keys that can be bound to commands.
+``--input-key-fifo-size=<2-65000>``
+ Specify the size of the FIFO that buffers key events (default: 7). If it
+ is too small some events may be lost. The main disadvantage of setting it
+ to a very large value is that if you hold down a key triggering some
+ particularly slow command then the player may be unresponsive while it
+ processes all the queued commands.
+
``--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
@@ -1248,13 +1255,6 @@ OPTIONS
chapter will terminate playback as well, even if ``--keep-open`` is
given.
-``--key-fifo-size=<2-65000>``
- Specify the size of the FIFO that buffers key events (default: 7). If it
- is too small some events may be lost. The main disadvantage of setting it
- to a very large value is that if you hold down a key triggering some
- particularly slow command then the player may be unresponsive while it
- processes all the queued commands.
-
``--length=<relative time>``
Stop after a given time relative to the start time.
See ``--start`` for valid option values and examples.
diff --git a/input/input.c b/input/input.c
index adc4e048ff..212a6ff92d 100644
--- a/input/input.c
+++ b/input/input.c
@@ -190,36 +190,65 @@ int async_quit_request;
static int parse_config(struct input_ctx *ictx, bool builtin, bstr data,
const char *location, const char *restrict_section);
-#define OPT_BASE_STRUCT struct MPOpts
-
-// Our command line options
-static const m_option_t input_config[] = {
- OPT_STRING("conf", input.config_file, CONF_GLOBAL),
- OPT_INT("ar-delay", input.ar_delay, CONF_GLOBAL),
- OPT_INT("ar-rate", input.ar_rate, CONF_GLOBAL),
- OPT_PRINT("keylist", mp_print_key_list),
- OPT_PRINT("cmdlist", mp_print_cmd_list),
- OPT_STRING("js-dev", input.js_dev, CONF_GLOBAL),
- OPT_STRING("file", input.in_file, CONF_GLOBAL),
- OPT_FLAG("default-bindings", input.default_bindings, CONF_GLOBAL),
- OPT_FLAG("test", input.test, CONF_GLOBAL),
- { NULL, NULL, 0, 0, 0, 0, NULL}
+#define OPT_BASE_STRUCT struct input_opts
+struct input_opts {
+ char *config_file;
+ int doubleclick_time;
+ int key_fifo_size;
+ int ar_delay;
+ int ar_rate;
+ char *js_dev;
+ char *in_file;
+ int use_joystick;
+ int use_lirc;
+ char *lirc_configfile;
+ int use_lircc;
+ int use_alt_gr;
+ int use_appleremote;
+ int use_media_keys;
+ int default_bindings;
+ int test;
};
-const m_option_t mp_input_opts[] = {
- { "input", (void *)&input_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
- OPT_INTRANGE("doubleclick-time", input.doubleclick_time, 0, 0, 1000),
- OPT_FLAG("input-joystick", input.use_joystick, CONF_GLOBAL),
- OPT_FLAG("input-lirc", input.use_lirc, CONF_GLOBAL),
- OPT_FLAG("input-right-alt-gr", input.use_alt_gr, CONF_GLOBAL),
-#if HAVE_LIRC
- OPT_STRING("input-lirc-conf", input.lirc_configfile, CONF_GLOBAL),
-#endif
+const struct m_sub_options input_config = {
+ .opts = (const m_option_t[]) {
+ OPT_STRING("conf", config_file, CONF_GLOBAL),
+ OPT_INT("ar-delay", ar_delay, CONF_GLOBAL),
+ OPT_INT("ar-rate", ar_rate, CONF_GLOBAL),
+ OPT_PRINT("keylist", mp_print_key_list),
+ OPT_PRINT("cmdlist", mp_print_cmd_list),
+ OPT_STRING("js-dev", js_dev, CONF_GLOBAL),
+ OPT_STRING("file", in_file, CONF_GLOBAL),
+ OPT_FLAG("default-bindings", default_bindings, CONF_GLOBAL),
+ OPT_FLAG("test", test, CONF_GLOBAL),
+ OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000),
+ OPT_FLAG("joystick", use_joystick, CONF_GLOBAL),
+ OPT_FLAG("lirc", use_lirc, CONF_GLOBAL),
+ OPT_FLAG("right-alt-gr", use_alt_gr, CONF_GLOBAL),
+ OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000),
+ #if HAVE_LIRC
+ OPT_STRING("lirc-conf", lirc_configfile, CONF_GLOBAL),
+ #endif
+ #if HAVE_COCOA
+ OPT_FLAG("appleremote", use_appleremote, CONF_GLOBAL),
+ OPT_FLAG("media-keys", use_media_keys, CONF_GLOBAL),
+ #endif
+ {0}
+ },
+ .size = sizeof(struct input_opts),
+ .defaults = &(const struct input_opts){
+ .key_fifo_size = 7,
+ .doubleclick_time = 300,
+ .ar_delay = 200,
+ .ar_rate = 40,
+ .use_lirc = 1,
+ .use_alt_gr = 1,
#if HAVE_COCOA
- OPT_FLAG("input-appleremote", input.use_appleremote, CONF_GLOBAL),
- OPT_FLAG("input-media-keys", input.use_media_keys, CONF_GLOBAL),
+ .use_appleremote = 1,
+ .use_media_keys = 1,
#endif
- { NULL, NULL, 0, 0, 0, 0, NULL}
+ .default_bindings = 1,
+ },
};
static const char builtin_input_conf[] =
@@ -1456,7 +1485,7 @@ static int read_wakeup(void *ctx, int fd)
struct input_ctx *mp_input_init(struct mpv_global *global)
{
- struct input_conf *input_conf = &global->opts->input;
+ struct input_opts *input_conf = global->opts->input_opts;
struct input_ctx *ictx = talloc_ptrtype(NULL, ictx);
*ictx = (struct input_ctx){
diff --git a/options/options.c b/options/options.c
index c494a23dd3..a34f0e7bf5 100644
--- a/options/options.c
+++ b/options/options.c
@@ -65,6 +65,7 @@ extern const struct m_sub_options demux_rawvideo_conf;
extern const struct m_sub_options demux_lavf_conf;
extern const struct m_sub_options vd_lavc_conf;
extern const struct m_sub_options ad_lavc_conf;
+extern const struct m_sub_options input_config;
extern const struct m_obj_list vf_obj_list;
extern const struct m_obj_list af_obj_list;
@@ -81,7 +82,6 @@ static const m_option_t screenshot_conf[] = {
{0},
};
-extern const m_option_t mp_input_opts[];
const m_option_t mp_opts[] = {
// handled in command line pre-parser (parse_commandline.c)
@@ -492,13 +492,12 @@ const m_option_t mp_opts[] = {
OPT_FLAG("slave-broken", slave_mode, CONF_GLOBAL),
OPT_FLAG("idle", player_idle_mode, M_OPT_GLOBAL),
- OPT_INTRANGE("key-fifo-size", input.key_fifo_size, CONF_GLOBAL, 2, 65000),
OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL),
OPT_FLAG("input-cursor", vo.enable_mouse_movements, CONF_GLOBAL),
{"screenshot", (void *) screenshot_conf, CONF_TYPE_SUBCONFIG},
- {"", (void *) mp_input_opts, CONF_TYPE_SUBCONFIG},
+ OPT_SUBSTRUCT("input", input_opts, input_config, 0),
OPT_PRINT("list-properties", property_print_help),
OPT_PRINT("help", print_help),
@@ -645,19 +644,6 @@ const struct MPOpts mp_default_opts = {
.mf_fps = 1.0,
- .input = {
- .key_fifo_size = 7,
- .doubleclick_time = 300,
- .ar_delay = 200,
- .ar_rate = 40,
- .use_lirc = 1,
- .use_alt_gr = 1,
-#if HAVE_COCOA
- .use_appleremote = 1,
- .use_media_keys = 1,
-#endif
- .default_bindings = 1,
- },
.encode_output = {
.metadata = 1,
},
diff --git a/options/options.h b/options/options.h
index b87c64ed17..ec66b33c8b 100644
--- a/options/options.h
+++ b/options/options.h
@@ -263,24 +263,7 @@ typedef struct MPOpts {
struct vd_lavc_params *vd_lavc_params;
struct ad_lavc_params *ad_lavc_params;
- struct input_conf {
- char *config_file;
- int doubleclick_time;
- int key_fifo_size;
- int ar_delay;
- int ar_rate;
- char *js_dev;
- char *in_file;
- int use_joystick;
- int use_lirc;
- char *lirc_configfile;
- int use_lircc;
- int use_alt_gr;
- int use_appleremote;
- int use_media_keys;
- int default_bindings;
- int test;
- } input;
+ struct input_opts *input_opts;
struct encode_output_conf {
char *file;