[MPlayer-cvslog] r33106 - in trunk: input/input.c mp_fifo.c

reimar subversion at mplayerhq.hu
Thu Mar 24 23:34:23 CET 2011


Author: reimar
Date: Thu Mar 24 23:34:23 2011
New Revision: 33106

Log:
Allow mouse wheel to work with a key fifo size of 2.

Modified:
   trunk/input/input.c
   trunk/mp_fifo.c

Modified: trunk/input/input.c
==============================================================================
--- trunk/input/input.c	Thu Mar 24 23:28:17 2011	(r33105)
+++ trunk/input/input.c	Thu Mar 24 23:34:23 2011	(r33106)
@@ -1100,11 +1100,13 @@ interpret_key(int code, int paused)
   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) {

Modified: trunk/mp_fifo.c
==============================================================================
--- trunk/mp_fifo.c	Thu Mar 24 23:28:17 2011	(r33105)
+++ trunk/mp_fifo.c	Thu Mar 24 23:34:23 2011	(r33106)
@@ -26,6 +26,7 @@ int key_fifo_size = 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 @@ static void mplayer_put_key_internal(int
   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){


More information about the MPlayer-cvslog mailing list