[Vm-dev] Handling function keys in unix
Igor Stasenko
siguctua at gmail.com
Tue Nov 22 15:06:48 UTC 2011
On 22 November 2011 15:51, Guillermo Polito <guillermopolito at gmail.com> wrote:
>
> So far, what I've learnt/found :).
>
> 1) I assume my build is using X11-display, since my keyboard events are generated there :P.
>
> 2) The X11 keyboard events are adapted to sq events in sqUnixX11.c >> x2sqKeyPlain
>
> 3) This build uses XLookupString, which brings char codes in Latin 1 instead of UTF-8. But X11 seems to support UTF-8 :/.
>
> 4) When pressing a function key, XLookupString does not fill the buffer with chars... and the KeySym is not handled. I added a line like
>
> case XK_F1: return 50;
>
> and
>
> Character class>>F1
> ^ self value: 50
>
> to test, and It works :). But I'm not sure which code is better to be returned yet :P.
>
> 5) My image now handles the F1, but only the keyDown and keyUp, since in sqUnixX11.c >> handleEvent I have something like:
>
> if (ucs4) /* only generate a key char event if there's a code. */
> recordKeyboardEvent(keyCode, EventKeyChar, modifierState, ucs4);
>
> 6) I tried commenting the if, but that generates some garbage in my image when pressing Alt, Shift, Control...
>
because these keys are not producing "characters", but they are kind
of "meta" keys which could modify the input.
as far as i understood, this line of code tells that it generates the
"KeyChar" event only if there's a character key pressed.
for other keys, like arrows, home/pgUp/pgDn etc you have key codes,
but not char codes, because there is no direct mapping between them
and any ascii/unicode character.
imagine that all keys on your keyboard having a number. Esc - 1 , F1 - 2 , etc.
So, these numbers are key codes. Now some keys can be directly
translated to characters when pressed (depending on keyboard
layout/language settings), but some of them not, and has only the key
code.
>
> So, some questions I have at this point:
>
> - Which are the restrictions on the codes returned on translateCode (point 4) ? Are they ascii characters? In the image I see the value is the keychar + the modifiers encoded
> - Based on the prior question, Which codes should be assigned to function keys?
> - I don't fully understand yet what a ucs4 code is, but the keysyms are translated to them in sqUnixX11.c >> xkeysym2ucs4 which looks pretty magical :). Does someone know how this works? The comments are not really helpful :(.
>
>
cannot help with it, i am complete newbie concerning unix/X11 keyboard handling.
> Thanks!
> Guille, vming :)
>
>
--
Best regards,
Igor Stasenko.
More information about the Vm-dev
mailing list