path: root/input
diff options
authorUoti Urpala <>2011-05-01 15:57:39 +0300
committerUoti Urpala <>2011-05-02 00:44:21 +0300
commit5c4b059f1608f6d6a981b7d81a14f1c46e40ba52 (patch)
treea44d6824a334b23dd16ee60ef06302c973b00b28 /input
parentb9eaafe1ed4f38efcd08d113d9e51e9ebb034f6e (diff)
input: rewrite -key-fifo-size limiting logic
Instead of strictly limiting the number of total entries in the internal fifo, make the overall buffer bigger and try to limit entries based on how many bound commands they're expected to generate. Now doubleclick and button down events aren't counted for that limit. Normally the sequence down-doubleclick-up generates at most one command, so this better matches the quantity we actually want to limit. Also add a mechanism to clear the button combination state kept by input.c when the fifo is full; this avoids "stuck button" problems due to button release events being dropped. The key combination state clearing is partially based on MPlayer 1 changes by Reimar Döffinger (though overall the effects of this commit are quite different). It still doesn't make "stuck button" problems completely impossible; at least if the VO gets closed while a button was down then nothing will send a button up event or reset state.
Diffstat (limited to 'input')
2 files changed, 14 insertions, 2 deletions
diff --git a/input/input.c b/input/input.c
index 4c69d00400..9a74abcdfb 100644
--- a/input/input.c
+++ b/input/input.c
@@ -1318,8 +1318,17 @@ static mp_cmd_t *read_events(struct input_ctx *ictx, int time)
int code;
- while ((code = key_fds[i].read_func.key(key_fds[i].ctx,
- key_fds[i].fd)) >= 0) {
+ while (1) {
+ code = key_fds[i].read_func.key(key_fds[i].ctx, key_fds[i].fd);
+ if (code < 0) {
+ if (code == MP_INPUT_RELEASE_ALL) {
+ memset(ictx->key_down, 0, sizeof(ictx->key_down));
+ ictx->num_key_down = 0;
+ ictx->last_key_down = 0;
+ continue;
+ }
+ break;
+ }
mp_cmd_t *ret = interpret_key(ictx, code);
if (ret)
return ret;
diff --git a/input/input.h b/input/input.h
index 2e48679856..10469f13ad 100644
--- a/input/input.h
+++ b/input/input.h
@@ -181,6 +181,9 @@ typedef enum {
//! Input will be available if you try again
#define MP_INPUT_RETRY -4
+// Key FIFO was full - release events may be lost, zero button-down status
#define MP_MAX_KEY_DOWN 32