From 3ded6077ae325f1c14ba347ec72e208fcd22abb9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 Apr 2014 18:13:58 +0200 Subject: input: don't wakeup core if key repeat is requested but not possible There's no need to wakeup the core in this situation. --- input/input.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'input') diff --git a/input/input.c b/input/input.c index d7844a79c9..01c97c4c8b 100644 --- a/input/input.c +++ b/input/input.c @@ -1012,7 +1012,7 @@ static void input_wait_read(struct input_ctx *ictx, int time) */ static void read_events(struct input_ctx *ictx, int time) { - if (ictx->last_key_down && ictx->ar_rate > 0) { + if (ictx->last_key_down && ictx->ar_rate > 0 && ictx->ar_state >= 0) { time = FFMIN(time, 1000 / ictx->ar_rate); time = FFMIN(time, ictx->ar_delay); } @@ -1057,8 +1057,10 @@ int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd) static mp_cmd_t *check_autorepeat(struct input_ctx *ictx) { // No input : autorepeat ? - if (ictx->ar_rate > 0 && ictx->ar_state >= 0 && ictx->last_key_down - && !(ictx->last_key_down & MP_NO_REPEAT_KEY)) { + if (ictx->ar_rate <= 0 || !ictx->current_down_cmd || !ictx->last_key_down || + (ictx->last_key_down & MP_NO_REPEAT_KEY)) + ictx->ar_state = -1; // disable + if (ictx->ar_state >= 0) { int64_t t = mp_time_us(); if (ictx->last_ar + 2000000 < t) ictx->last_ar = t; @@ -1066,10 +1068,6 @@ static mp_cmd_t *check_autorepeat(struct input_ctx *ictx) if (ictx->ar_state == 0 && (t - ictx->last_key_down_time) >= ictx->ar_delay * 1000) { - if (!ictx->current_down_cmd) { - ictx->ar_state = -1; - return NULL; - } ictx->ar_state = 1; ictx->last_ar = ictx->last_key_down_time + ictx->ar_delay * 1000; return mp_cmd_clone(ictx->current_down_cmd); -- cgit v1.2.3