1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-25 16:05:20 +02:00

liballegro: cleanup and improve keyboard driver fix

This commit is contained in:
David Kühling 2012-03-31 01:10:05 +02:00
parent 1efced8ff8
commit 115dfe5f70

View File

@ -1,7 +1,7 @@
Index: allegro-4.4.2/src/linux/lkeybd.c Index: allegro-4.4.2/src/linux/lkeybd.c
=================================================================== ===================================================================
--- allegro-4.4.2.orig/src/linux/lkeybd.c 2011-06-19 11:32:20.000000000 +0200 --- allegro-4.4.2.orig/src/linux/lkeybd.c 2011-06-19 11:32:20.000000000 +0200
+++ allegro-4.4.2/src/linux/lkeybd.c 2012-03-29 02:24:07.317094564 +0200 +++ allegro-4.4.2/src/linux/lkeybd.c 2012-03-29 03:58:32.357827856 +0200
@@ -143,7 +143,10 @@ @@ -143,7 +143,10 @@
/* convert Allegro format scancodes into key_shifts flag bits */ /* convert Allegro format scancodes into key_shifts flag bits */
static unsigned short modifier_table[__allegro_KEY_MAX - __allegro_KEY_MODIFIERS] = static unsigned short modifier_table[__allegro_KEY_MAX - __allegro_KEY_MODIFIERS] =
@ -26,7 +26,15 @@ Index: allegro-4.4.2/src/linux/lkeybd.c
if (key[__allegro_KEY_ALT]) map |= 8; if (key[__allegro_KEY_ALT]) map |= 8;
/* Map scancode to type and value */ /* Map scancode to type and value */
@@ -312,12 +318,25 @@ @@ -304,6 +310,7 @@
{
unsigned char buf[128];
int bytes_read;
+ int avail;
fd_set set;
struct timeval tv = { 0, 0 };
@@ -312,12 +319,26 @@
FD_ZERO(&set); FD_ZERO(&set);
FD_SET(std_keyboard.fd, &set); FD_SET(std_keyboard.fd, &set);
@ -41,17 +49,18 @@ Index: allegro-4.4.2/src/linux/lkeybd.c
+ already hit that "select() is not fully level triggered" lost-wakeup + already hit that "select() is not fully level triggered" lost-wakeup
+ deadlock!? Also note EINTR problem with read() below. */ + deadlock!? Also note EINTR problem with read() below. */
+ +
+ while (select (FD_SETSIZE, &set, NULL, NULL, &tv) < 0) + do
+ { + {
+ if (errno != EINTR) + avail = select (FD_SETSIZE, &set, NULL, NULL, &tv);
+ if ((avail < 0 && errno != EINTR) || avail == 0)
+ { + {
+ return 0; + return 0;
+ } + }
+ } + } while (avail < 0);
+ +
+ do { + do {
+ bytes_read = read(std_keyboard.fd, &buf, sizeof(buf)); + bytes_read = read(std_keyboard.fd, &buf, sizeof(buf));
+ if (bytes_read < 1 && (bytes_read >= 0 || errno != EINTR)) + if ((bytes_read < 1 && errno != EINTR) || bytes_read == 0)
+ return 0; + return 0;
+ } while (bytes_read < 0); + } while (bytes_read < 0);