[AD] keyboard hang, linux, 4.1.8

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I'm encountering some strange behaviour in WIP 4.1.8, regarding the
keyboard.  I can reproduce it with the grabber and with my own othello
program, so I am assuming it is something in the latest WIP (or maybe
one before, recent anyway).

symptoms: when pressing a key, the program will randomly hang (sometimes
yes, sometimes no. about 1 in 3 hang). cpu usage remains consistent,
4.2% for the grabber and > 80% for my othello program. Some further
testing shows that it mostly happens when you press a key and move the
mouse at the same time.

I cannot debug the grabber right now (no debug info built-in) but I've
traced the cause of the problem in my othello program to the following
function:

void clear_kbd(int k)
{
    do
    {
//	poll_keyboard();
	rest(1);
    }
    while (key[k]);

    clear_keybuf();
}

I use this as follows:

if (key[KEY_ESC])
{
    clear_kbd(KEY_ESC);      
    // do something
}

This is to wait until the key is released and clear the buffer to
avoid detecting multiple keypresses. The program will hang in the
while loop: key[k] is never reset to 0 in the tight loop. I have tried
this with and without poll_keyboard (calling it everywhere
appropriately), with and without rest(1), all to no avail. Somehow, in
a tight loop like this, the key[] array doesn't seem to get updated
properly, even though a rest call is inserted or the keyboard is
explicitly polled.

Any ideas what could be causing this? I could start guessing but I
really have no clue. If I am making a programming error here, please
let me know how to do this in a better way, I don't know how to.

system:
	allegro 4.1.8, with and without debug build, with threads
	linux 2.4.9 (redhat 7.2)
	gcc 3.2.1
	X 4.1.something
	laptop PII 300

Hein Zelle

>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-< 
 Unix is user friendly. It's just very particular about who 
 it's friends are.

 Hein Zelle                     hein@xxxxxxxxxx
	                        http://www.icce.rug.nl/~hein
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/