Post by Joakim Arfvidsson NV98ATeIt's different on a keyboard-model basis.
Great.
Post by Joakim Arfvidsson NV98ATeI'm the author of MacBlox for DP4, and I have had the same problem. If
you think the same way some software developers do and shoot for "the
90 percent", you can safely assume the scan codes are identical. All
Apple's late USB and ADB keyboards have (almost, I believe) the same
scan codes. For the arrows and space I have confirmed this for Extended
I, II, Adjustable and USB.
That's actually not such a bad solution for me because my games minimum
requirements would limit it to machines with late model keyboards anyway.
What I don't like though is the idea that Apple may change the scan codes
on future keyboards, breaking my app.
Post by Joakim Arfvidsson NV98ATeI did see something very interesting when I dug around in the
Frameworks. I don't remember where, but I found a text file appearantly
containing descriptions for all Apple keyboards, including scan codes
and physical placement! That might be something. If you find out how to
use it, please tell me!
I assume you mean the files in /System/Library/Keyboards? The .keyboard
files describe the visual layout of the keyboard like you see in the
keymapping app. I assume the hex number is the scan code for the key at
that position. By parsing that file and using [NSEvent keyCode] is seems
like you should be able to map a physical key on the keyboard to some
action in your app. You need to know what keyboard your user has but I'm
sure you can find that out. Thats all way too much for me, though. I just
want the Cocoa version of Windows, VK_F1, etc, or XWindows XK_F1.
Meanwhile, NSF1FunctionKey and friends are defined in AppKit/NSEvent.h.
When are these returned by the system? Are they the result of [NSEvent
keyCode]? I'd like to know how the Quake/Hertic/Doom ports handle this kind
of stuff.
Thanks,
Guy