diff options
author | wm4 <wm4@nowhere> | 2013-04-24 17:42:58 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-04-24 18:07:01 +0200 |
commit | 97be5ead1401f48571a073d63a75fad7d29b4d56 (patch) | |
tree | 6e17037c4fc071ce5dd2b96de29f0ec6c225c614 /core/input | |
parent | 003a9302856897830716ea97a5e76290656a4107 (diff) | |
download | mpv-97be5ead1401f48571a073d63a75fad7d29b4d56.tar.bz2 mpv-97be5ead1401f48571a073d63a75fad7d29b4d56.tar.xz |
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.
Diffstat (limited to 'core/input')
-rw-r--r-- | core/input/input.c | 6 |
1 files changed, 4 insertions, 2 deletions
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); } } |