Keyboard Handling
So I've run into an interesting issue. I've recently updated my game from using just KeyUp KeyDown to accepting the whole range of keys on my keyboard via keycodes.
This so far has worked our GREAT (minus a small bug dealing with flagsChanged not returning opposite events, but that's an easy fix). HOWEVER, I've run into an issue where keycodes have no earthly mapping to what's on the keyboard in any form. "wasd" on my qwerty keyboard is ",aoe" on my friend's keyboard. So how does one properly store keycode and still display the correct thing to the user.
This so far has worked our GREAT (minus a small bug dealing with flagsChanged not returning opposite events, but that's an easy fix). HOWEVER, I've run into an issue where keycodes have no earthly mapping to what's on the keyboard in any form. "wasd" on my qwerty keyboard is ",aoe" on my friend's keyboard. So how does one properly store keycode and still display the correct thing to the user.
Woo Dvorak!
Old Carbon based games seemed to always interpret keys as being in QWERTY, but as a non-QWERTY user I don't think you should do it. You really need to make the keys configurable.
Old Carbon based games seemed to always interpret keys as being in QWERTY, but as a non-QWERTY user I don't think you should do it. You really need to make the keys configurable.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
(Oct 25, 2010 02:40 PM)Skorche Wrote: Woo Dvorak!
Old Carbon based games seemed to always interpret keys as being in QWERTY, but as a non-QWERTY user I don't think you should do it. You really need to make the keys configurable.
I was thinking of leaving you guys out! but the stickler in me won't let me.
Something like http://github.com/OneSadCookie/ObjCGameB...KeyCodes.m
(Oct 25, 2010 02:42 PM)OneSadCookie Wrote: Something like http://github.com/OneSadCookie/ObjCGameB...KeyCodes.m
yes, something like that

Will try it out when I get home tonight.
Honestly, I wouldn't feel bad about being "left out". It's generally easier to switch the keyboard layout before playing a game than to reconfigure keys so I'm quite used to it.
It's the games that require typing/chatting AND don't allow the keys to be reconfigured that are killer.
It's the games that require typing/chatting AND don't allow the keys to be reconfigured that are killer.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
(Oct 25, 2010 02:42 PM)OneSadCookie Wrote: Something like http://github.com/OneSadCookie/ObjCGameB...KeyCodes.m
This seemed to mostly work except:
Caplocks showed up as Key #57
NumLock/Clear showed up as Key #71
Some other key on my keyboard that I don't know what it was showed up as another strange Key #098
No distinction between 1-0 and keypad 1-0,
For CapLock:
According to the function UCKeyTranslate returned with err equal to noErr, however "actualStringLength" was equal to 0, but the buffer had this in it:
[0] 19320
[1] 37395
[2] 0
misc...
my temp fix for this was just adding those keys to the fallback table. Though I'm concerned about spacebar showing up as blank instead of "Space". Just hacked that so that keycode 49 always returns "Space"
So.....
so far so good, time to test on dvorak!
Fork me and send a pull request so others can benefit
dude, I'm going to pretend I didn't just read that.
Quote:Skyhawk asked out-of-band
a) how to fork me
http://help.github.com/ covers everything you need in a few simple steps.
Github is really great. Git is pretty neat too. Well worth learning how to use both. Essentially all open development worth a damn is happening on Github these days, and participation is vastly easier than SourceForge.
Quote:b) whether there's a way to get modifier key changes via keyUp: and keyDown:
No, but flagsChanged: has a keyCode. See http://github.com/OneSadCookie/ObjCGameB...GBGLView.m for how I handle this.
(Oct 26, 2010 08:29 AM)OneSadCookie Wrote:yeah, I figured that much out, but your code handles it better than mine, so I switchedQuote:b) whether there's a way to get modifier key changes via keyUp: and keyDown:
No, but flagsChanged: has a keyCode. See http://github.com/OneSadCookie/ObjCGameB...GBGLView.m for how I handle this.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Event Handling (Keyboard and Mouse) | bwalters | 6 | 6,621 |
Mar 12, 2006 08:17 PM Last Post: OneSadCookie |
|
| CB Key handling | skyhawk | 6 | 3,193 |
Aug 12, 2003 10:13 AM Last Post: kelvin |
|

