I'm building a game with jogl which runs fine on my Windows and Linux PC, which uses the latest stable jogl version. However on Mac I need to use the autobuilds to get GL3.2 support, and the keypress behaviour breaks. I have a listener that both handles keyPressed and keyReleased events and sets state. The problem is if I hold two keys down, say W and D for forward and strafe right and I release both of them then the one I pressed first becomes "stuck". as in it doesn't fire it's keyreleased event. It seems to depend on how long I hold the keys, how slowly I release them, it's very inconsistent. Also, for a key like W the keycode for the key pressed is 83 however while it's held down it reports that key 13 is being released and when I finally actually release it keycode 83 is reported as being released. This is critical as flying a space ship is hard when the left or forward key is stuck in the "pressed" state. @Override public void keyPressed(KeyEvent arg0) { System.out.println("KeyPressed! : " + arg0.getKeyCode()); switch(arg0.getKeyCode()){ case FORWARD: shipEvent.setAction(ShipControlEvent.ACTION_FORWARD); shipEvent.setStatus(ShipControlEvent.STATUS_START); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case BACKWARD: shipEvent.setAction(ShipControlEvent.ACTION_BACKWARD); shipEvent.setStatus(ShipControlEvent.STATUS_START); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case STRAFE_LEFT: shipEvent.setAction(ShipControlEvent.ACTION_TURN_LEFT); shipEvent.setStatus(ShipControlEvent.STATUS_START); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case STRAFE_RIGHT: shipEvent.setAction(ShipControlEvent.ACTION_TURN_RIGHT); shipEvent.setStatus(ShipControlEvent.STATUS_START); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case SPRINT: shipEvent.setAction(ShipControlEvent.ACTION_SPRINT); shipEvent.setStatus(ShipControlEvent.STATUS_START); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; } } @Override public void keyReleased(KeyEvent arg0) { System.out.println("KeyReleased! : " + arg0.getKeyCode()); switch(arg0.getKeyCode()){ case FORWARD: shipEvent.setAction(ShipControlEvent.ACTION_FORWARD); shipEvent.setStatus(ShipControlEvent.STATUS_STOP); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case BACKWARD: shipEvent.setAction(ShipControlEvent.ACTION_BACKWARD); shipEvent.setStatus(ShipControlEvent.STATUS_STOP); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case STRAFE_LEFT: shipEvent.setAction(ShipControlEvent.ACTION_TURN_LEFT); shipEvent.setStatus(ShipControlEvent.STATUS_STOP); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case STRAFE_RIGHT: shipEvent.setAction(ShipControlEvent.ACTION_TURN_RIGHT); shipEvent.setStatus(ShipControlEvent.STATUS_STOP); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; case SPRINT: shipEvent.setAction(ShipControlEvent.ACTION_SPRINT); shipEvent.setStatus(ShipControlEvent.STATUS_STOP); Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent); break; } //} }
Does multiple key press/release work on: - Linux/X11 - Windows ? This is not quite clears, since it would be possible you tested this w/ an older version. Can you check Bug 601 (not quite related .. but touches the issue a bit) and use one of the new unit tests as a template to create a new one reproducing the erroneous behavior ? http://jogamp.org/git/?p=jogl.git;a=commit;h=b008de41549e38aebdfcb7b094046235a8dde72f This would really help a lot in fixing it. Thank you.
Enhanced w/ multiple key support, see: <http://jogamp.org/git/?p=jogl.git;a=commit;h=2f9c77a347b76bebdadd4bec1ac92aa7ab72365f>
Pulled latest repo, confirmed fixed! Thank you so much :D