From 115dfe5f7066963843d026dfceef4362bcad2a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20K=C3=BChling?= Date: Sat, 31 Mar 2012 01:10:05 +0200 Subject: [PATCH] liballegro: cleanup and improve keyboard driver fix --- liballegro/patches/060-fix-keyboard-drv.patch | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/liballegro/patches/060-fix-keyboard-drv.patch b/liballegro/patches/060-fix-keyboard-drv.patch index 868d6c1..29ec16b 100644 --- a/liballegro/patches/060-fix-keyboard-drv.patch +++ b/liballegro/patches/060-fix-keyboard-drv.patch @@ -1,7 +1,7 @@ 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/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 @@ /* convert Allegro format scancodes into key_shifts flag bits */ 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; /* 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_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 + 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; + } -+ } ++ } while (avail < 0); + + do { + 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; + } while (bytes_read < 0);