Re: [AD] Keyboard timing problem

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


On 2007-06-01, Colin Ward <lists@xxxxxxxxxx> wrote:
> Hello all.
> 
> I have just successfully ported Allegro to Amiga OS4 and have it running
> quite nicely (albeit waiting for some optimisation), but I have a problem
> that I would like to get some feedback on.
> 
> The problem is with games accessing the key[] array.  I have a separate
> thread that is waiting for keyboard events from the OS.  I then send those
> events to cokeybd_thread_func() using the standard
> _al_event_source_emit_event() mechanism.  Eventually the keypress makes its
> way into the key[] array for the game to poll.  This worked fine until I
> implemented my GFX_DRIVER->vsync() routine.

I didn't realise you were targeting the 4.9 branch.  Cool.  The
events/input stuff won't be changing much any more, but other stuff like
graphics will be changing, so if you want something stable you should
target the 4.2 branch, or maybe the 4.3 branch that we are planning on
opening.

> The problem is that now that vsync() is implemented it stops the games from
> polling the key[] array at such a high frequency, meaning that the key down
> event goes to cokeybd_thread_func() followed by the key up event, and by
> the time the game wakes up from its call to vsync() and polls the key[]
> array, the key is gone!  So you have to hold the keys down for a while
> (maybe a half a second) for them to register with the game.  It has made
> games quite unplayable.

Do you mean the vsync function is hogging all the CPU and preventing the
keyboard events from getting through?  If possible you should make the
background threads higher priority than the user's thread.  It might
help with lag.

Or is it just that the program is unlikely to check key[] just at the
time the key is held down?  There is no real solution for that.  That's
partially why the new event API exists.

Peter





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