From ae5df9be98e4193342321f30285655fcf88e7e63 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 23 Nov 2014 15:08:49 +0100 Subject: input, lua: redo input handling Much of it is the same, but now there's the possibility to distinguish key down/up events in the Lua API. --- input/input.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'input/input.c') diff --git a/input/input.c b/input/input.c index 4133396399..7c647adef3 100644 --- a/input/input.c +++ b/input/input.c @@ -476,6 +476,7 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, keyname, cmd->cmd, ret->input_section); talloc_free(keyname); } + ret->is_mouse_button = code & MP_KEY_EMIT_ON_UP; } else { char *key_buf = mp_input_get_key_combo_name(&code, 1); MP_ERR(ictx, "Invalid command for bound key '%s': '%s'\n", @@ -518,6 +519,7 @@ static void release_down_cmd(struct input_ctx *ictx, bool drop_current) { memset(ictx->key_history, 0, sizeof(ictx->key_history)); ictx->current_down_cmd->key_up_follows = false; + ictx->current_down_cmd->is_up = true; mp_input_queue_cmd(ictx, ictx->current_down_cmd); } else { talloc_free(ictx->current_down_cmd); @@ -534,7 +536,7 @@ static void release_down_cmd(struct input_ctx *ictx, bool drop_current) static bool key_updown_ok(enum mp_command_type cmd) { switch (cmd) { - case MP_CMD_SCRIPT_DISPATCH: + case MP_CMD_SCRIPT_BINDING: return true; default: return false; @@ -589,8 +591,11 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale) // Cancel current down-event (there can be only one) release_down_cmd(ictx, true); cmd = resolve_key(ictx, code); - if (cmd && (code & MP_KEY_EMIT_ON_UP)) - cmd->key_up_follows = true; + if (cmd) { + cmd->is_up_down = true; + cmd->key_up_follows = (code & MP_KEY_EMIT_ON_UP) | + key_updown_ok(cmd->id); + } ictx->last_key_down = code; ictx->last_key_down_time = mp_time_us(); ictx->ar_state = 0; @@ -885,8 +890,7 @@ mp_cmd_t *mp_input_read_cmd(struct input_ctx *ictx) struct mp_cmd *ret = queue_remove_head(&ictx->cmd_queue); if (!ret) { ret = check_autorepeat(ictx); - // (if explicitly repeated, don't let command.c ignore it) - if (ret && !(ret->flags & MP_ALLOW_REPEAT)) + if (ret) ret->repeated = true; } if (ret && ret->mouse_move) { -- cgit v1.2.3