Re: [AD] Keyboard timing problem

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


Hello Julien

On 02/06/2007, you wrote:
> 

[Snip]

> I haven't used Allegro in quite some time, but here are my thoughts on
> the matter.
>
> The problem you describe is possible, but you have to put it into
> context. If your screen is set to a refresh rate of 60 Hz (a minimum
> nowadays), a vertical sync will happen roughly every 17 ms. In other
> words, a call vsync() should theoretically only wait between 0 and 17
> ms. Managing to press and then release a key in this short a time is
> quite an accomplishment :-)

Well I figured out the problem!  Took a while.  I had to scratch my head for
a while, stare at the code, put some debug output in, scratch my head
again, take the dog for a walk, put some more debug output in and bingo! 
Found it.  :-)

It seems that the Amiga implementation of pthread_cond_timedwait() is
buffering up events!  So if you wait for 250 ms and then a key down comes
in during that time, followed, say 100 ms later, by a key up event, then
neither event will cause the call to return.  It then returns when it times
out, at which point cokeybd/cokeybd_thread_func() processes *both* events
one after the after!  So of course the main thread never gets to see the
key in they key[] array as it is only set for a matter of microseconds!

This is the second nasty bug that I have found in the Amiga version of
pthreads (and I suspect a third).  It is a fairly new library and I think
that Allegro is probably the first system that has really stressed it.

-- 
/-------------------------------------------------------------------\
[Hitman/Code HQ - 6502/z80/68000/604e/80x86/ARM coder - Amiga rulez!]
[VZ-200/VIC-20/MZ-700/c16/c64*10/c128*8/Plus-4/CPC464/CD32/500*2    ]
[600/1000/1200*2/A4000/SNES/N64/Dreamcast/Athlon 1100/AmigaOne      ]
[Assembly Language: The most fun you can have with your clothes on! ]
\-------------------------------------------------------------------/





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