I ran into this issue when dealing with keyboard input. After a keyboard button was pressed and released, our call to IrrlichtDevice::run() would hang because of the call to XPeekEvent (which blocks if there are no more events on the queue)
Perhaps we wrote our code wrong, but our program works fine when we run it on linux (so perhaps Mac X11 has bugs?)
I fixed the issue by commenting out the code that used XPeekEvent (which means we don't watch out for repeated key events anymore, but oh well).
-Abel
KeyReleased hangs device->run (Mac OSX X11 irrlicht v.1.3
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Well, also on Linux it might block the event queue, so maybe we should use XCheck*Event and XPutBackEvent to test for the key repeat. The reason that Linux might work correctly could be that the automatic key repeat handling might be more widely supported under Linux. In case the system does support it there's no PeekEvent call made.
So I made the following change as per your suggestion. The old code is commented out below the new code. It seems to work with my applcation both on linux and mac.
As a side note, your engine is great. The code is extremely readable and easy to get familiar with. Good work!
-Abel
[/code]
As a side note, your engine is great. The code is extremely readable and easy to get familiar with. Good work!
-Abel
Code: Select all
// check for Autorepeat manually
// We'll do the same as Windows does: Only send KeyPressed
// So every KeyRelease is a real release
XEvent next_event;
if (XCheckWindowEvent(event.xkey.display, window, ~0, &next_event))
{
XPutBackEvent(event.xkey.display, &next_event);
if ((next_event.type == KeyPress) &&
(next_event.xkey.keycode == event.xkey.keycode) &&
(next_event.xkey.time == event.xkey.time))
{
/* Ignore the key release event */
break;
}
}
/*
XEvent next_event;
XPeekEvent (event.xkey.display, &next_event);
if ((next_event.type == KeyPress) &&
(next_event.xkey.keycode == event.xkey.keycode) &&
(next_event.xkey.time == event.xkey.time))
{
// Ignore the key release event
break;
}
*/