Re: [AD] More Unix patches

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


Michael Bukin <M.A.Bukin@xxxxxxxxxx> writes:
> I'm not sure what functions to use.  X-server generates KeyPress and
> KeyRelease events with keycodes in the range [8,255].  In XwinAllegro 
> keycodes were converted to the keyboard controller hardware format 
> (sequence of scancodes) which was processed similar to DOS version (now 
> this sequence can be processed with _handle_pckeys). I don't think that 
> processing with functions from keyboard.c can be as simple as with 
> _handle_pckeys function.  AFAICS, it will be necessary to calculate ASCII 
> values and scancodes according to state of modifier keys. 

It's up to you. Converting to scancode format will certainly need less code 
in the X handler, but it is quite messy as an intermediate format. If you go 
straight to the keyboard.c routines, you have to do your own translation 
from scancode into an ASCII value, and update the _key_shifts flags whenever 
one of the modifier keys change state. Basically you just call 
_handle_key_press() whenever a key goes down, and _handle_key_release() when 
it comes back up again, passing them both the scancode value (Allegro 
format, not hardware: these are different things now, since I changed the 
mapping to avoid normal and extended keys sharing the same scancode value), 
and an ASCII code for the key.

If you have to do your own conversion from X codes to ASCII, you will 
probably want to use pckeys to help with this, but surely there must be some 
X call that can do this for you? If so, letting X do it would have the 
advantage of being more consistent with the rest of the OS, and X almost 
certainly has better localisation support than Allegro...


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