NEWT & Linux KeyEvents

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

NEWT & Linux KeyEvents

amalsek
Hello again all,

Since the last time I posted I made some progress on the newt side. However I ran into a KeyEvent X11 related problem ( described here ). I implemented a variation of the solution ( not all was available to newt, and I didn't want to import the swing's timer ), however I still have two key events when I only push once.
I put the minimum delay between two KEY_PRESSED event to 50ms, but here the second event ( the automatic one ) comes after 500ms ( I verified, no other events are passed between the first and the second ).

See the log :
19:00:17.901  [main] DEBUG o.b.keeper.application.Application - Starting main loop...
19:00:18.522  [main-Display-X11_:0.0-1-EDT-1] DEBUG o.b.k.i.n.NewtKeyboardListenerImpl - Key z pressed, processing GO_FORWARD.
19:00:19.022  [main-Display-X11_:0.0-1-EDT-1] DEBUG o.b.k.i.n.NewtKeyboardListenerImpl - Key z pressed, processing GO_FORWARD.
19:00:21.026  [Timer-0] DEBUG o.b.k.i.n.NewtKeyboardListenerImpl - Key z released, processing GO_FORWARD.

Anyway the point of this is : is there already a method in newt that can disable the KeyEvent repeat that I may have missed ?

Thanks in advance

NB: The implementation of the class in charge of the keyboard is here on github
Reply | Threaded
Open this post in threaded view
|

Re: NEWT & Linux KeyEvents

amalsek
Duh, the solution was simple. Maintain a Map containing the Action and its current state. If a new KEY_PRESSED comes, check the state of the corresponding action. If it's the same, drop it...
Reply | Threaded
Open this post in threaded view
|

Re: NEWT & Linux KeyEvents

gouessej
Administrator
Hi

Another solution consists in disabling key repeat on Linux and re-enabling it when the VM is exiting (use a shutdown hook). I did it for my own game some years ago. Let me know whether this is interesting for you.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: NEWT & Linux KeyEvents

Sven Gothel
Administrator
On Sunday, June 12, 2011 02:19:52 PM gouessej [via jogamp] wrote:
>
> Hi
>
> Another solution consists in disabling key repeat on Linux and re-enabling
> it when the VM is exiting (use a shutdown hook). I did it for my own game
> some years ago. Let me know whether this is interesting for you.
>

If this is a cool feature, maybe we shall add it to NEWT ?

Same thing for the requested 'hide mouse pointer', 'grab mouse pointer' etc ..,
just waiting for volunteers to do one impl. .. if not all (X11, Windows, .. OSX later).

Sure, will do it in the end, just don't know when this will be :)

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: NEWT & Linux KeyEvents

gouessej
Administrator
I call "xset r off" to disable key repeat and "xset r on" to enable it. However, this approach has 2 limitations:
- as I always enable autorepeat when exiting, it is a wrong behavior when the user disables it by default
- xset changes the behavior of the x server for all applications, not only the Java program calling this command
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: NEWT & Linux KeyEvents

gouessej
Administrator
This post was updated on .
In reply to this post by Sven Gothel
Another solution would consist in rather using XkbSetDetectableAutoRepeat, XkbGetControls (or XGetKeyboardControl) and XkbSetControls to get the value of the autorepeat property and set it properly but I don't feel comfortable with JNI and GlueGen :( How is this limitation worked around in other APIs?
Julien Gouesse | Personal blog | Website