Carbon Key Events
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.
What's broken about GetKeys?
And what precisely do you want by way of a "good implementation"?
And what precisely do you want by way of a "good implementation"?
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 time...it 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.
The Fullscreen with AGL sample code part that uses GetKeys() doesn't work now.
Both these case are true most of the time...it 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.
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).
so...
if(IsKeyDown(0x37) && IsKeyDown(0x0C))
ExitToShell();
Then implement IsKeyDown() using GetKeys().
-- Ian
First check to see if the command key is down (0x37), and then check to see if the 'q' key is down (0x0C).
so...
if(IsKeyDown(0x37) && IsKeyDown(0x0C))
ExitToShell();
Then implement IsKeyDown() using GetKeys().
-- Ian
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....
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....
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...
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...
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()...
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()...
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| [For David, aarku] Carbon Events | OneSadCookie | 4 | 3,904 |
Mar 5, 2013 10:20 PM Last Post: SethWillits |
|
| Carbon events in windowed/full screen mode. Help needed. | Anton Petrov | 1 | 3,162 |
Dec 18, 2008 05:35 AM Last Post: DoG |
|
| Simulating "system idle" events in Carbon applications | ascotti | 4 | 2,924 |
May 2, 2006 03:22 PM Last Post: OneSadCookie |
|
| Carbon Keyboard Events | IBethune | 7 | 4,949 |
Oct 22, 2002 05:58 AM Last Post: IBethune |
|
| Carbon events (again) | sealfin | 2 | 3,252 |
Jul 1, 2002 06:34 AM Last Post: sealfin |
|

