Re: [AD] keyboard_lowlevel_callback

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Wang <tjaden@xxxxxxxxxx> writes:
> In Linux console and DOS, when a key is pressed, the callback is called 
> with the down message, then repeats of the down message for key repeat, 
> then the up message when the key is released.
> 
> In X an additional up message is given for every key repeat.

Ouch! That's pretty bad, as it leaves you with no way to detect the 
difference between a genuine release vs. the autorepeat. The key[] array is 
also potentially vulnerable to this, as there will be a moment when the flag 
is cleared even though the key is still held down (such a short time that I 
can't imagine anyone hitting it in practice, but still...)

> After playing around with xev, I can't figure out a way of fixing this. 
>  Maybe there is a way to control this with an X call?  If not,
> then I guess it should be [pedanticly] documented as a gotcha.

For sure. I can't see any way around it, though, barring Michael knowing 
some obscure way to get this info from X. The only other workaround would be 
a short time delay before handling release events, to see if another press 
came inside that period, but I don't like that on the grounds of ugliness, 
latency (major problem if you are trying to pull off combos in a fighting 
game!) and potential for still missing things if input events are badly 
delayed. Methinks there should be an extra flag in XKeyEvent to tell whether 
it's a genuine hardware change or autorepeat: shame there is no such thing!


--
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/