KeyReleased hangs device->run (Mac OSX X11 irrlicht v.1.3

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
aallison
Posts: 3
Joined: Wed May 21, 2008 10:05 pm
Location: Stanford

KeyReleased hangs device->run (Mac OSX X11 irrlicht v.1.3

Post by aallison »

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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

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.
aallison
Posts: 3
Joined: Wed May 21, 2008 10:05 pm
Location: Stanford

Post by aallison »

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: 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;
         }
         */
[/code]
Post Reply