summaryrefslogtreecommitdiffstats
path: root/core/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-27 21:26:00 +0200
committerwm4 <wm4@nowhere>2013-07-28 18:44:21 +0200
commitc070fa865fcf75cace05bf492a68f6a2c6137fb3 (patch)
tree87cdc963094ed5604121d5f2f6e354cf52503c1e /core/input
parentda2b4aa5870f407ad322b6116ed8d66a66dbeadf (diff)
downloadmpv-c070fa865fcf75cace05bf492a68f6a2c6137fb3.tar.bz2
mpv-c070fa865fcf75cace05bf492a68f6a2c6137fb3.tar.xz
m_config: refactor some things
Change how m_config is initialized. Make it more uniform; now all m_config structs are intialized in exactly the same way. Make sure there's only a single m_option[] array defining the options, and keep around the pointer to the optstruct default value, and the optstruct size as well. This will allow reconstructing the option default values in the following commit. In particular, stop pretending that the handling of some special options (like --profile, --v, and some others) is in any way elegant, and make them explicit hacks. This is really more readable and easier to understand than what was before, and simplifies the code.
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input.c25
-rw-r--r--core/input/input.h10
2 files changed, 16 insertions, 19 deletions
diff --git a/core/input/input.c b/core/input/input.c
index 7a016a0e4f..855e09887b 100644
--- a/core/input/input.c
+++ b/core/input/input.c
@@ -497,6 +497,9 @@ struct cmd_queue {
};
struct input_ctx {
+ bool using_ar;
+ bool using_cocoa_media_keys;
+
// Autorepeat stuff
short ar_state;
int64_t last_ar;
@@ -572,7 +575,7 @@ static const m_option_t input_config[] = {
{ NULL, NULL, 0, 0, 0, 0, NULL}
};
-static const m_option_t mp_input_opts[] = {
+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("joystick", input.use_joystick, CONF_GLOBAL),
@@ -2069,9 +2072,10 @@ void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,
}
}
-struct input_ctx *mp_input_init(struct input_conf *input_conf,
- bool load_default_conf)
+struct input_ctx *mp_input_init(struct MPOpts *opts)
{
+ struct input_conf *input_conf = &opts->input;
+
struct input_ctx *ictx = talloc_ptrtype(NULL, ictx);
*ictx = (struct input_ctx){
.key_fifo_size = input_conf->key_fifo_size,
@@ -2106,7 +2110,7 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf,
bool config_ok = false;
if (input_conf->config_file)
config_ok = parse_config_file(ictx, input_conf->config_file, true);
- if (!config_ok && load_default_conf) {
+ if (!config_ok && opts->load_config) {
// Try global conf dir
char *file = mp_find_config_file("input.conf");
config_ok = file && parse_config_file(ictx, file, false);
@@ -2148,10 +2152,12 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf,
#ifdef CONFIG_COCOA
if (input_conf->use_ar) {
cocoa_init_apple_remote();
+ ictx->using_ar = true;
}
if (input_conf->use_media_keys) {
cocoa_init_media_keys();
+ ictx->using_cocoa_media_keys = true;
}
#endif
@@ -2186,17 +2192,17 @@ static void clear_queue(struct cmd_queue *queue)
}
}
-void mp_input_uninit(struct input_ctx *ictx, struct input_conf *input_conf)
+void mp_input_uninit(struct input_ctx *ictx)
{
if (!ictx)
return;
#ifdef CONFIG_COCOA
- if (input_conf->use_ar) {
+ if (ictx->using_ar) {
cocoa_uninit_apple_remote();
}
- if (input_conf->use_media_keys) {
+ if (ictx->using_cocoa_media_keys) {
cocoa_uninit_media_keys();
}
#endif
@@ -2215,11 +2221,6 @@ void mp_input_uninit(struct input_ctx *ictx, struct input_conf *input_conf)
talloc_free(ictx);
}
-void mp_input_register_options(m_config_t *cfg)
-{
- m_config_register_options(cfg, mp_input_opts);
-}
-
static int print_key_list(m_option_t *cfg, char *optname, char *optparam)
{
int i;
diff --git a/core/input/input.h b/core/input/input.h
index f4f5621e9f..92e2a32c4f 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -257,14 +257,10 @@ bool mp_input_test_mouse_active(struct input_ctx *ictx, int x, int y);
bool mp_input_test_dragging(struct input_ctx *ictx, int x, int y);
// Initialize the input system
-struct input_conf;
-struct input_ctx *mp_input_init(struct input_conf *input_conf,
- bool load_default_conf);
+struct MPOpts;
+struct input_ctx *mp_input_init(struct MPOpts *opts);
-void mp_input_uninit(struct input_ctx *ictx, struct input_conf *input_conf);
-
-struct m_config;
-void mp_input_register_options(struct m_config *cfg);
+void mp_input_uninit(struct input_ctx *ictx);
// Wake up sleeping input loop from another thread.
void mp_input_wakeup(struct input_ctx *ictx);