# HG changeset patch # User reimar # Date 1301006063 0 # Node ID 03ed899a72bc5273e704e0a5903414472dd7f3a6 # Parent d88b8a9e989e6ded09f818ba3f8891f0d1b6ee43 Allow mouse wheel to work with a key fifo size of 2. diff -r d88b8a9e989e -r 03ed899a72bc input/input.c --- a/input/input.c Thu Mar 24 22:28:17 2011 +0000 +++ b/input/input.c Thu Mar 24 22:34:23 2011 +0000 @@ -1100,11 +1100,13 @@ unsigned int j; mp_cmd_t* ret; - if (code == MP_KEY_RELEASE_ALL) { + if (code & MP_KEY_RELEASE_ALL) { + code &= ~MP_KEY_RELEASE_ALL; memset(key_down, 0, sizeof(key_down)); num_key_down = 0; last_key_down = 0; - return NULL; + if (!code) + return NULL; } if(mp_input_key_cb) { diff -r d88b8a9e989e -r 03ed899a72bc mp_fifo.c --- a/mp_fifo.c Thu Mar 24 22:28:17 2011 +0000 +++ b/mp_fifo.c Thu Mar 24 22:34:23 2011 +0000 @@ -26,6 +26,7 @@ static int *key_fifo_data; static unsigned key_fifo_read; static unsigned key_fifo_write; +static int previous_down_key; static void mplayer_put_key_internal(int code){ int fifo_free = key_fifo_read + key_fifo_size - key_fifo_write; @@ -37,10 +38,21 @@ if((code & MP_KEY_DOWN) && fifo_free <= (key_fifo_size >> 1)) return; // in the worst case, just reset key state - if (fifo_free == 1) - code = MP_KEY_RELEASE_ALL; + if (fifo_free == 1) { + // HACK: this ensures that a fifo size of 2 does + // not queue any key presses while still allowing + // the mouse wheel to work (which sends down and up + // at nearly the same time + if (code != previous_down_key) + code = 0; + code |= MP_KEY_RELEASE_ALL; + } key_fifo_data[key_fifo_write % key_fifo_size]=code; key_fifo_write++; + if (code & MP_KEY_DOWN) + previous_down_key = code & ~MP_KEY_DOWN; + else + previous_down_key = 0; } int mplayer_get_key(int fd){