Re: [AD] Keyboard timing problem

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


Hello Peter

On 01/06/2007, you wrote:
> 

[Snipped Amiga port]

> 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.

Um, I think I'm missing something here.  I have ported 4.3.1, which I
downloaded from a Sourceforge link that I found on www.allegro.cc.  In
docs/txt/allegro.txt it says "Version 4.3.1 (WIP)."  Does this use the new
keypress system?

>> 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.

The problem is, to quote yourself, that the program is unlikely to check
key[] just at the time the key is held down.

ie.  The main (user's) thread is paused waiting for vsync(), then the input
thread sees that key "x" has been pressed, marks key[x] as being pressed
and goes back to sleep.  The user then lets go of key "x" and the input
thread wakes up and marks key[x] as being unpressed.  Then the main thread
wakes up, checks key[x] which of couse is now marked unpressed, and so the
user thread has missed the keypress.

But surely this problem would appear on all ports, except thos that ignore
vsync()?

This new keyboard API that you mention, is it in 4.3.1?  If so, could you
give me a pointer to the files/functions to look at?

-- 
/-------------------------------------------------------------------\
[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/