iDevGames Forums
Carbon Key Events - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Carbon Key Events (/thread-7494.html)

Carbon Key Events - Nickolei - Nov 15, 2002 04:47 PM

Now that Jaguar broke GetKeys for me I'm wondering if anyone has a good implementation of Carbon key events they'd like to share.

Carbon Key Events - OneSadCookie - Nov 15, 2002 06:10 PM

What's broken about GetKeys?

And what precisely do you want by way of a "good implementation"?

Carbon Key Events - Nickolei - Nov 15, 2002 07:16 PM

When I moved to Jaguar my GetKeys code doesn't get input.

The Fullscreen with AGL sample code part that uses GetKeys() doesn't work now.

Both these case are true most of the has worked sparingly.

As far as a good implementation goes, I just wanted to see how somebody deals with Modifier keys and translating key events specifically for a game. My efforts haven't gone so well and I'm sure somebody has figured it out already.

Carbon Key Events - Ian Kerr - Nov 15, 2002 07:44 PM

Let's say you want to check for Command + Q.

First check to see if the command key is down (0x37), and then check to see if the 'q' key is down (0x0C).


if(IsKeyDown(0x37) && IsKeyDown(0x0C))

Then implement IsKeyDown() using GetKeys().

-- Ian

Carbon Key Events - NCarter - Nov 17, 2002 03:22 AM

I guess that Nickolei is referring to something that I saw briefly after I first installed Jaguar. Basically, GetKeys() would just stop working at random. Logging out and in again would fix it temporarily, though.

I haven't seen this problem recur for a long time though, so I assume that it's something to do with some new Jaguar feature that I messed around with for a while and then stopped using. You're not using Inkwell, are you? That's the only thing I can think of....

Carbon Key Events - Nickolei - Nov 17, 2002 09:23 AM

Nope not inkwell.

I recently updated to 10.2.2 but that may as well be coincidence.

So is the official stance is that GetKeys is naughty but not broken?

And nobody can point to an example of Carbon key Events done 'right'? Maybe I'll have to post something...

Carbon Key Events - OneSadCookie - Nov 17, 2002 12:31 PM

To use Carbon events for key tracking:

Keep a global array of booleans. You probably need 128 of them, depending on what character codes are returned. Also keep an array of 5 booleans for the modifier keys.

Register for raw key down and raw key up events, and when you receive one of these, change the state of the appropriate element of your large array.

Register for modifier changed events, and when you receive one, set the state of all your modifier booleans.

Then in your game loop, just check whether a given element of one of the arrays is true to know whether that key is currently down.

It'll end up feeling like GetKeys()...

Carbon Key Events - codemattic - Nov 17, 2002 03:37 PM

Quote:Originally posted by Nickolei
Now that Jaguar broke GetKeys for me

yup - when I upgraded to Jag most of my games stopped getting keyboard input. Rebooting fixed that for me - havent had it again since. Of course that doesnt help if someone d/ls your game and it doesnt work b/c they didnt know they had to reboot their machine after installing Jag the first time.