diff options
Diffstat (limited to 'core/input/input.c')
-rw-r--r-- | core/input/input.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/core/input/input.c b/core/input/input.c index 7a016a0e4f..ae1358a76d 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -92,13 +92,14 @@ struct key_name { #define ARG_INT { .type = {"", NULL, &m_option_type_int} } #define ARG_FLOAT { .type = {"", NULL, &m_option_type_float} } +#define ARG_DOUBLE { .type = {"", NULL, &m_option_type_double} } #define ARG_STRING { .type = {"", NULL, &m_option_type_string} } #define ARG_CHOICE(c) { .type = {"", NULL, &m_option_type_choice, \ M_CHOICES(c)} } #define ARG_TIME { .type = {"", NULL, &m_option_type_time} } -#define OARG_FLOAT(def) { .type = {"", NULL, &m_option_type_float}, \ - .optional = true, .v.f = def } +#define OARG_DOUBLE(def) { .type = {"", NULL, &m_option_type_double}, \ + .optional = true, .v.d = def } #define OARG_INT(def) { .type = {"", NULL, &m_option_type_int}, \ .optional = true, .v.i = def } #define OARG_CHOICE(def, c) { .type = {"", NULL, &m_option_type_choice, \ @@ -129,7 +130,7 @@ static const mp_cmd_t mp_cmds[] = { {"exact", 1}, {"1", 1}, {"keyframes", -1}, {"-1", -1})), }}, - { MP_CMD_SPEED_MULT, "speed_mult", { ARG_FLOAT } }, + { MP_CMD_SPEED_MULT, "speed_mult", { ARG_DOUBLE } }, { MP_CMD_QUIT, "quit", { OARG_INT(0) } }, { MP_CMD_QUIT_WATCH_LATER, "quit_watch_later", }, { MP_CMD_STOP, "stop", }, @@ -195,12 +196,12 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } }, { MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } }, { MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } }, - { MP_CMD_ADD, "add", { ARG_STRING, OARG_FLOAT(0) } }, + { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(0) } }, { MP_CMD_CYCLE, "cycle", { ARG_STRING, { .type = {"", NULL, &m_option_type_cycle_dir}, .optional = true, - .v.f = 1 }, + .v.d = 1 }, }}, { MP_CMD_ENABLE_INPUT_SECTION, "enable_section", { @@ -497,6 +498,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 +576,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), @@ -773,15 +777,15 @@ void mp_input_rm_key_fd(struct input_ctx *ictx, int fd) static int parse_cycle_dir(const struct m_option *opt, struct bstr name, struct bstr param, void *dst) { - float val; + double val; if (bstrcmp0(param, "up") == 0) { val = +1; } else if (bstrcmp0(param, "down") == 0) { val = -1; } else { - return m_option_type_float.parse(opt, name, param, dst); + return m_option_type_double.parse(opt, name, param, dst); } - *(float *)dst = val; + *(double *)dst = val; return 1; } @@ -2069,9 +2073,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 +2111,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 +2153,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 +2193,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 +2222,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; |