I have a number of questions about how virtual keycodes are
generated for CG Events.
A. I've been looking everywhere trying to find the mapping from
virtual keycodes in CGEvents to "whatever" but haven't found
anything. I noticed a reference to a 'uchr' resource and the
function UCKeyTranslate in the Unicode Utilities that can map a
keycode to a Unicode character. However, the virtual keycodes appear
to map to all sorts of things other than Unicode characters:
- Media Control (e.g. volume up and down, start, stop, mute, track
skip)
- Function Keys
- Numeric Keypad
- Navigation keys (e.g. Home, Page Down)
- Language input keys (e.g. Kana key)
- etc.
Is there a place that defines what all these mappings are?
Also, it would be great if these mappings take into account the
various international keyboards out there? (Japanese, Chinese,
Tibetan, Hebrew, Arabic, etc.) Although I wouldn't mind if there was
something for the standard US English USB keyboard.
Assuming CG uses the same virtual key codes that occur elsewhere,
there's a list in Events.h (Carbon.framework -> HIToolbox.framework)
in the Leopard SDK. I’ve got a library for high-level VKC->description
handling at http://jens.ayton.se/code/keynaming/ , which also contains
a list of key codes, and a mapping from USB HID usages to VKCs, but
it’s currently missing some documented VKCs – specifically the three
volume ones and F17-F20.
My real goal is to be able to be able to get raw scancodes from the
keyboard and to inject scancodes into this event queue and have
virtual keys be given to the user via CGEvents. If the CGEvents come
from the driver directly, then I suppose I would need to act like a
driver and deal with the scancode to virtual keycode mapping myself.
Then I could deal with third-party keyboards that have special keys
(Internet keys, gaming keyboards, etc.) and all international
keyboards.
Your best bet for reading would be the IOKit HID interface
(IOKit.framework/hid). This comes in two flavours; the Leopard-only
one is quite usable, the legacy one is horribly scary. I don’t know
how to go about synthesizing events, though.
--
Jens Ayton
Sed quis custodiet ipsos custodes?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden