Posted by
gouessej on
May 31, 2012; 9:21am
URL: https://forum.jogamp.org/NEWT-KeyEvents-behaving-odd-in-Linux-tp4021912p4024317.html
I checked that yesterday, it is not a problem in my first person shooter because the main author (Renanse) of the engine (Ardor3D) knows this behavior and the NEWT part I added uses a similar code to avoid bothering me with useless key release events. I can update my demo if you want to check that.
xset is a bad solution and I used it badly, I always (re)enabled the auto-repeat even when it was not previously enabled.
NEVER DISTRIBUTE A GAME AS A SINGLE JAR. I'm sorry to repeat that once again but this is a very bad way of deploying a game, any archiver (WinRAR, Arch) may open the JAR instead of Java, the final user won't understand what is happening and will complain. I advise you to use Java Wet Start (a bit buggy but I know how to work around its main bugs or broken features, very simple, very complete), GetDown (stable, used by a few commercial games but a bit complicated) or IzPack (stable but quite complicated and some major features are missing).
We plan to ease the use of JInput with JogAmp, this minimal fork is "JInput for JogAmp". Using JInput and NEWT is not contradictory. Anyway, I assume JInput doesn't "fix" this "bug" as it uses the native events.
Microsoft Windows does that when you press and release a key:
pressed key event
pressed key event
pressed key event
pressed key event
released key event
typed key event
In games, we often just want to get that:
pressed key event
released key event
typed key event
In my humble opinion, tinkering key events is almost always necessary when writing games. Neither the default behavior under Windows nor the default behavior under Linux with auto-repeat enabled is satisfying. We could modify NEWT in order to avoid getting these events but it would be bothering for people who rely on auto-repeat and who port a program from AWT to NEWT.
Qt solution is interesting, a key event generated by the auto-repeat is marked so that you can skip it easily. I want to avoid suggesting a solution that would affect the whole operating system and not only our applications. XAutoRepeatOff or XkbSetDetectableAutorepeat affects the whole session.
The best idea I have found is this one:
http://stackoverflow.com/posts/3220822/revisionsWe have two choices to solve our problem:
- flag auto-repeat events in the native part of NEWT
- add an option into NEWT that would allow to enable or disable auto-repeat for a particular application
Both could be implemented too. What's your opinion about that?