From 97be5ead1401f48571a073d63a75fad7d29b4d56 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 24 Apr 2013 17:42:58 +0200 Subject: input: don't reset time on each key repeat Key repeats were skipped when playloop iterations took too long. Fix this by using the total times for key repeat calculation, instead of the time difference to the last key repeat event. --- core/input/input.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/input/input.c b/core/input/input.c index 4f97189d1d..17ad7c3aeb 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -1276,6 +1276,8 @@ static mp_cmd_t *check_autorepeat(struct input_ctx *ictx) if (ictx->ar_rate > 0 && ictx->ar_state >= 0 && ictx->num_key_down > 0 && !(ictx->key_down[ictx->num_key_down - 1] & MP_NO_REPEAT_KEY)) { unsigned int t = GetTimer(); + if (ictx->last_ar + 2000000 < t) + ictx->last_ar = t; // First time : wait delay if (ictx->ar_state == 0 && (t - ictx->last_key_down) >= ictx->ar_delay * 1000) @@ -1288,12 +1290,12 @@ static mp_cmd_t *check_autorepeat(struct input_ctx *ictx) return NULL; } ictx->ar_state = 1; - ictx->last_ar = t; + ictx->last_ar = ictx->last_key_down + ictx->ar_delay * 1000; return mp_cmd_clone(ictx->ar_cmd); // Then send rate / sec event } else if (ictx->ar_state == 1 && (t - ictx->last_ar) >= 1000000 / ictx->ar_rate) { - ictx->last_ar = t; + ictx->last_ar += 1000000 / ictx->ar_rate; return mp_cmd_clone(ictx->ar_cmd); } } -- cgit v1.2.3