Problems with AWT input on Linux

hi

I’ve problems with repeated “keyPressed” and “keyReleased” events from the AWT event queue. When a key (all except modifyers) is held, the “keyPressed” event is not fired only once and the “keyReleased” event once with the physical key-releasement, but all three events pressed-typed-released-pressed-typed-released are continousely fired in that order.

I emailed with Will on this topic and want to make the discussion public. Here is the last message I sent to Will:


Hi, Will

I searched the internet once more for this problem, and found some posts
telling this is a Java+Linux issue, which exists for a very long time
and has never been fixed :(

This is the output of a program printing out a line from keypressed and
keyreleased:

##################################
down: 70 (1156373986543)
up: 70 (1156373986796)
down: 70 (1156373986796)
up: 70 (1156373986832)
down: 70 (1156373986832)
up: 70 (1156373986865)
down: 70 (1156373986865)
up: 70 (1156373986900)
down: 70 (1156373986900)
up: 70 (1156373986936)
down: 70 (1156373986936)
up: 70 (1156373986972)
...
...
...
down: 70 (1156373986936)
up: 70 (1156373986972)
##################################

The value in brackets is the result of e.getWhen(), which is the timestamp
of the event. As you can see the timestamp of a "down" event following
an "up" event being produced by auto-repeat is always equal.


There're three workarounds for it. But none of them is perfect:

1. Delay the event dispatching and ignore two events being in a quantum.
--> This is the worst workaround and is absolutely useless in my opinion.

2. Check the platform type and in case of linux do a system call
   "xset r off", which disables auto-repeat (system-wide).
--> This is better but not usable, too, sice it acts system-wide and
    blocks the possibility to make use of auto-repeat.

3. Monitor the timestamps of the events and simply ignore events with equal
   timestamps.
--> This is the way I would prefer to go. But I don't have an idea how
    to accomplish this. If I waited for the next "down" event to check the
    timestamp, the up event could get missing.

Without a solution for this problem, keyboard input is not usable for games
on Linux. This is not an option, since one of the biggest xith's targets
are games.

Do you have an idea? I'll paste this into a new thread in the xith-forum.