1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-30 02:12:48 +02:00
openwrt-packages/liballegro/patches/060-fix-keyboard-drv.patch

85 lines
3.2 KiB
Diff
Raw Normal View History

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 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] =
{
- __allegro_KB_SHIFT_FLAG, __allegro_KB_SHIFT_FLAG, __allegro_KB_CTRL_FLAG,
+ __allegro_KB_SHIFT_FLAG, __allegro_KB_SHIFT_FLAG,
+ /* note: we drop LCONTROL here, as the NanoNote uses it as modifier key
+ 'Fn', passing it as CTRL causes problems with ASE's key bindings */
+ /*__allegro_KB_CTRL_FLAG*/ 0,
__allegro_KB_CTRL_FLAG, __allegro_KB_ALT_FLAG, __allegro_KB_ALT_FLAG,
__allegro_KB_LWIN_FLAG, __allegro_KB_RWIN_FLAG, __allegro_KB_MENU_FLAG,
__allegro_KB_SCROLOCK_FLAG, __allegro_KB_NUMLOCK_FLAG, __allegro_KB_CAPSLOCK_FLAG
@@ -204,7 +207,10 @@
map = 0;
if (key[__allegro_KEY_LSHIFT] || key[__allegro_KEY_RSHIFT]) map |= 1;
if (key[__allegro_KEY_ALTGR]) map |= 2;
- if (key[__allegro_KEY_LCONTROL] || key[__allegro_KEY_RCONTROL]) map |= 4;
+
+ /* fixes for nanonote's keyboard: LCONTROL is 'Fn' modifier */
+ if (key[__allegro_KEY_LCONTROL]) map |= (1<<6);
+ if (key[__allegro_KEY_RCONTROL]) map |= 4;
if (key[__allegro_KEY_ALT]) map |= 8;
/* Map scancode to type and value */
@@ -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);
- if (select (FD_SETSIZE, &set, NULL, NULL, &tv) <= 0)
- return 0;
- bytes_read = read(std_keyboard.fd, &buf, sizeof(buf));
- if (bytes_read < 1)
- return 0;
+ /* Possible heisenbug here. when doing readkey(), the main thread does
+ select with timeout and causes us EINTR here. One lost select() an we
+ already hit that "select() is not fully level triggered" lost-wakeup
+ deadlock!? Also note EINTR problem with read() below. */
+
+ do
+ {
+ 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 && errno != EINTR) || bytes_read == 0)
+ return 0;
+ } while (bytes_read < 0);
process_keyboard_data(buf, bytes_read);
Index: allegro-4.4.2/src/keyboard.c
===================================================================
--- allegro-4.4.2.orig/src/keyboard.c 2012-03-29 02:21:50.328523081 +0200
+++ allegro-4.4.2/src/keyboard.c 2012-03-29 02:22:58.768808442 +0200
@@ -625,6 +625,11 @@
_DRIVER_INFO *driver_list;
int i;
+ /* readkey() uses rest(1) which deadlocks unless we call install_timer()
+ first. this bug occurs e.g. with exhello (but not with any of the
+ event-loop driven allegro games) */
+ install_timer();
+
if (keyboard_driver)
return 0;