Re: Detect Keyboard Layout for CGKeyCodes

2009-08-20 Thread Harry Jordan
Hi Joe, Sorry to misunderstand your intentions. I had an inkling I might be reading your question wrong. I'm intrigued now as to how you might do it. This low level c code makes my head spin, but if I read the docs correctly it should be possible to decode the keyCodes to Unicode

Re: Detect Keyboard Layout for CGKeyCodes

2009-08-20 Thread Joe Turner
Hey, Thanks for the tip. I started writing my own method, but then when searching for how to get the data from the UCKeyboardLayout, I found some code that I modified to work perfectly. I will share it here for those that need it. - (CGKeyCode)keyCodeForKeyboard:(const UCKeyboardLayout

Detect Keyboard Layout for CGKeyCodes

2009-08-19 Thread Joe Turner
Hey, I've got an application that basically simulates a keyboard using CGEvents with CGKeyCodes. However, because CGKeyCodes only map the position of the key on a keyboard, and not the actual key, I've run into some issues. Is there an easy way to detect the type of keyboard they have,

Re: Detect Keyboard Layout for CGKeyCodes

2009-08-19 Thread Harry Jordan
I've not used CGEvents much.. (Once upon a time, hopefully never again) but if I remember rightly CGKeyCodes are equivalent to NSEvent keyCodes*. If not you can easily convert between the two using: + (NSEvent *)eventWithCGEvent:(CGEventRef)cgEvent. Have a look at this:

Re: Detect Keyboard Layout for CGKeyCodes

2009-08-19 Thread Joe Turner
Hey, This is not *exactly* what I would like to achieve. Basically, what I would like to do is the reverse: I would like to convert a string into a CGKeyCode. Like on a US keyboard, I would input the string a and get returned the CGKeyCode 0. This would be extremely straight-forward (just a