Re: [AD] Oups....fixed my keyboard patch

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


varobert@xxxxxxxxxx writes:
> This patch adds a keyboard_midlevel_callback which gets called only on key 
> presses, and is sent the scan code and the keycode

This is redundant, because all that info is provided by the existing hooks. 
keyboard_lowlevel_callback() tells you about every physical press and 
release (as they go into the key[] array), while keyboard_callback() tells 
you about how these were converted into character values, as they are added 
to the readkey() buffer. If you need both types of information, just hook 
both callbacks: there's no need for a third.

I'd be a bit wary of using the callbacks at all, though, unless the standard 
keyboard routines absolutely can't do what you need (which in my experience 
they usually can). It's substantially more complicated to do this yourself, 
and raises all sorts of problems with memory locking, difficulty of 
debugging, and synchronisation of any shared data structures, that would be 
avoided if you used the more standard methods (I've already done all the 
work to make sure that the readkey() buffer is correctly locked, thread 
safe, etc). What exactly are you doing that readkey() and key[] can't 
provide?


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