Translating HID keyboard events to unicode chars

elias
Unregistered
 
Post: #1
I want to access the mouse and keyboard through HID, and so far I have managed to get everything I need, except translated characters from the keyboard. I know about the function UCKeyTranslate, but it only takes virtual key codes, and I don't know a way to come from HID usage codes to virtual key codes.

Can it be done? I suspect a similar process is already done by the Mac kernel anyway, because it needs the characters from HID devices too.

- elias
Quote this message in a reply
Moderator
Posts: 434
Joined: 2002.09
Post: #2
Wish I could answer your question, but I don't know how it's done.

Perhaps you might consider creating your own game event type. This would isolate your game from caring about the source of the events. Then you just write constructors that would create your "game events" from an HID signal, NSEvent, network packet, or anything else that might supply information to your game.

This would work around your problem by allowing you to handle keyboard events as Cocoa/Carbon events (which give you unicode) but the gamepad/joystick signals could come from HID.

I suppose this suggestion might not help you if you are trying to handle multiple keyboards as separate devices... I'm not sure.

I don't know if Amelio uses unicode, but it does handle keyboards, mice, and gamepads side-by-side, so you might have a look at it. I don't have the link handy, but it was posted recently in the iDG forums message so a quick search will give it to you.

Just some suggestions...

Measure twice, cut once, curse three or four times.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  What... the... heck? Const Char & Chars. Jones 6 3,361 Jun 12, 2006 03:54 PM
Last Post: akb825
  Translating a window coordinate to a view coordinate emileej 3 2,835 Jun 20, 2005 11:25 AM
Last Post: emileej
  Carbon Keyboard Events IBethune 7 5,554 Oct 22, 2002 05:58 AM
Last Post: IBethune