Re: [AD] X11 key repeat fix

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


On Tue, 2003-12-09 at 07:51, Eric Botcazou wrote:
> > With the XWIN driver, and if your system is affected by it (if not,
> > compiling allegro in the background might help), it's impossible to move
> > the circle to the top of the screen. If it would be a platform game
> > written with Allegro, but in Windows, and there was a high jump, you'd
> > be stuck.
> 
> The testcase clearly demonstrates that there is a problem, so we really must 
> tackle it.

Yes. I read a bit in the mailing list archives, and it seems, the
original X11 version disabled key repeat while Allegro was running. If
messing with the events like my patch does turns out to be a bad idea
(but I guess it won't), this could be done again (with its own set of
problems). Or maybe just add a note that the key[] array is only
guaranteed to work 100% reliable if set_keyboard_rate (0, 0) is used,
and encourage to use it in games where it is needed (holding a key to
jump, holding a key to open a popup-menu, ...) for maximum portability.

> > The attached patch fixes is, but unfortunately I'm not quite sure how
> > hackish it is. Maybe there's a better way to distinguish repeated key
> > releases from real releases, or Allegro could switch off key repeat for
> > its X11 window somehow? And of course, getting the X11 driver to run
> > smoother in general, it would probably fix it as well. Someone should
> > look like SDL does it :)
> 
> We could maybe also use the 'time' field of the XKeyEvent structure, in 
> conjunction with your approach.  It could even be required if 'autorepeat' 
> is disabled in the X server, because otherwise we could discard the only 
> KeyRelease event.

> > +           if (event[i].xkey.keycode == event[i + 1].xkey.keycode &&
> > +              event[i].xkey.time == event[i + 1].xkey.time)

Yes, actually I'm using time already before dropping the release event.
The X11 server I'm using apparently adds a Relase/Pressed pair with the
same timestamp for key repeat, so my patch always works here. Didn't
look up any specifications which say that every X11 server must behave
like that - but seems to make sense to either do that, or send just the
Pressed event.

> Would you mind experimenting with it on top of your approach?  Could you also 
> replace the magic numbers in _xwin_private_handle_input with a CPP symbol?

Yes, the arbitrary 5 event limit looks, well, arbitrary. I remember
someone recently sent a patch to make it unlimited, but there was no
change on my system, so making it a #define should be enough.

> I think the result would be acceptable for mainline at least, maybe even for 
> the branch.
> 

Ok, I'll try having a more in-depth look, maybe finally figure out the
secrets of things like XLOCK and _xwin_keyboard_interrupt :) Might only
have time sometime after next week though.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





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