> Last lines of the listing in this page show it:
> http://developer.apple.com/qa/qa2005/qa1446.html
> > However, instead of doing all this stuff, we can receive the unicode character asking for kEventParamKeyUnicodes parameter in kEventRawKeyDown/Repeat/Up event, and the "ascii" one asking for kEventParamKeyMacCharCodes parameter.

The unicode char is useless for reporting the VKey in up/down events. It gets messy when chars can be made by more than one key, or are composed. Been there, tried that and it didn't work.

Well, ok, I just used it for very few keys like alphabet, number, space and so on, since we can't find an exact mac keycode to translate to VK_A and friends.

> But here we have a problem: the Virtual Key Code is too low level, the character is too high level since we can't intercept arrows, function keys and so on. > > But, it looks like some keys are constant across all keyboards (I think it's because they are always in the same position on all keyboards), and they are the "non visual" characters.

I won't assume that.

Well, we have to other mean for keys like function keys, ins, del, arrows and so on. Moreover, i found some pieces of code around that do exactly this thing (use hardcoded values for these keys).
See later for more infos.

Hmm... I note the capslock key on that layout. I've read somewhere that macs don't have a numlock. Is that still the case (I can't check, since I hooked a pc keyboard to my mini)


Well, my old adb keyboard has both numlock and caps lock. And, watching in Macintosh ToolBox Essentials pdf, even the old Apple Keyboard II (I think it's the one of the first Mac made ever :D) has them (even if it lacks the function keys: but, considering that my machine is the oldest one that can run os x and that newer mac use pc-like keyboards, I think we should not have problems with these keys)

:) Even on other languages, it is a question if the VK_Q represents a "Q". This is only valid for roman layouts.

For the gtk mappings, I tried to match the VK_OEM keys to the notes MS gave themselves on the VirtualKeyCodes page.


Ok, you convinced me :)


However, trying to search for code examples, I found interesting things:
It looks like a lot of people did what I did (try with known keycodes, then rely on the ascii/unicode char to find the key), while Apple itself did something very similar to what you did for gtk in the implementation of the X Window server that runs under Mac OS X :) That is, they also use that list of hardcoded values (function keys, keypad and so on) to map to X11 keycodes, and for other values they try to get the char or unicode char for all keycodes. But they (as you did) initialize this map at startup: their list is 248 entries long for unicode keyboard layouts (I don't know where this number came from) and 128 entries for non unicode layouts. They try to get a char for every keycode, and then they try to find a X11 keycode for that char, and they save it to the map, and then they put in the map the known keycodes like funcion keys and so on.

They call again this function when, during X event dispatching, they notice that keyboard layout has changed: I think that we can easily do the same in kEventRawKeyDown/Repeat/Up events by inspecting parameter kEventParamKeyboardType.

This file is here:
http://webcvs.freedesktop.org/xorg/xc/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c?revision=1.4&view=markup

bye,
Giulio

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to