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

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


Author: reimar
Date: Thu Mar 24 23:11:18 2011
New Revision: 33104

Log:
Make "stuck keys" problem impossibly by resetting the internal
key state when our key fifo overflowed.

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

Modified: trunk/input/input.c
==============================================================================
--- trunk/input/input.c	Thu Mar 24 22:58:06 2011	(r33103)
+++ trunk/input/input.c	Thu Mar 24 23:11:18 2011	(r33104)
@@ -1100,6 +1100,13 @@ interpret_key(int code, int paused)
   unsigned int j;
   mp_cmd_t* ret;
 
+  if (code == MP_KEY_RELEASE_ALL) {
+      memset(key_down, 0, sizeof(key_down));
+      num_key_down = 0;
+      last_key_down = 0;
+      return NULL;
+  }
+
   if(mp_input_key_cb) {
       if (code & MP_KEY_DOWN)
 	  return NULL;

Modified: trunk/input/input.h
==============================================================================
--- trunk/input/input.h	Thu Mar 24 22:58:06 2011	(r33103)
+++ trunk/input/input.h	Thu Mar 24 23:11:18 2011	(r33104)
@@ -191,6 +191,8 @@ typedef enum {
 #define MP_KEY_DOWN (1<<29)
 // Use this when the key shouldn't be auto-repeated (like mouse buttons)
 #define MP_NO_REPEAT_KEY (1<<28)
+// Special value to mark all keys as "up"
+#define MP_KEY_RELEASE_ALL (1<<27)
 
 #ifndef MP_MAX_KEY_DOWN
 #define MP_MAX_KEY_DOWN 32

Modified: trunk/mp_fifo.c
==============================================================================
--- trunk/mp_fifo.c	Thu Mar 24 22:58:06 2011	(r33103)
+++ trunk/mp_fifo.c	Thu Mar 24 23:11:18 2011	(r33104)
@@ -35,6 +35,9 @@ static void mplayer_put_key_internal(int
   // reserve some space for key release events to avoid stuck keys
   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;
   key_fifo_data[key_fifo_write % key_fifo_size]=code;
   key_fifo_write++;
 }


More information about the MPlayer-cvslog mailing list