  | |  | Storing keybindings | Storing keybindings 2004-12-14 - By Wade Williams
Back All:
We're trying to solve a problem I can't believe hasn't been solved before, and I'm looking for ideas on solving it.
When a user maps a key in our GUI keymapping utility, we write the key corresponding the to virtual key (vKey) and any modifiers to a plain text file that stores the keymappings.
For example, they may map the "Fire guns" function to Shift-1, and we write:
Fire guns = Shift + 1
in our keymapping file.
When we read the file back in, we use some code that walks the KCHR resource to find the vKey associated with the "1" key and then map "fire guns" to Shift + that vKey. The code essentially does the reverse of KeyTranslate() - i.e. it goes from character to virtual key.
This all works fairly well. I'm sure there are some failure cases, but we haven't seem to hit many.
So, why not use ASCII character values? Because we don't want to store:
Fire guns = !
and the obvious problem that many keys don't produce characters, which would prevent them from being mapped under this method (how does write write an ASCII character to represent Control-Shift-D for example?)
Now we want to move our app to Unicode.
There appear to be two solutions:
1) Write code that walks the uchr resource and provides character-to-vKey mapping. Yes, the number of failure cases would be huge and I understand that some characters take multiple keypresses to generate. Still, if you want to store your key bindings in human-readable form, this is the only solution I can think of.
2) Come up with a completely new way to store key mappings.
We would *really* like the keyboard mappings to be in a user-editable file, so storing the vKey itself for example is not a desirable solution.
All thoughts appreciated.
Thanks,
Wade
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Do not post admin requests to the list. They will be ignored. Mac-games-dev mailing list (Mac-games-dev@(protected)) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/mac-games-dev/junlu%405341.com
This email sent to junlu@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |