Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GetKeys() and KeyMap?



On Jul 27, 2004, at 2:50 PM, email@hidden wrote:

How in do you get the (128) elements of a KeyMap and read true/false
separately???

The 128 elements are all bits.

I've seen two types of KeyMaps in reference PDF's:
(1) struct KeyMap { UInt32[4] };

Where are you seeing this? The typedef I see from documentation is:

struct KeyMap
{
char map[16];
};

(2) typedef long KeyMap[16];

Where have you seen (2)? That container contains 512 bits. Now if 'long' is replaced by char, then you'd have 128 bits.

and two types of KeyMaps in Events.h (the one the compiler uses):
(1)typedef UInt32 KeyMap[4];
(2)typedef BigEndianLong KeyMap[4];

(if you notice long and UInt32 are the same)
(and I have no idea what BigEndianLong is)

Big Endian is how PowerPC (and 680x0) stores data in memory. The type signals developers that its contents are in Big Endian byte order. I've usually seen this type of stuff declared in cross-platform code. When relevant, platform-specific code would need to do byte-swapping.

My compiler gives me an error when I try this:
/*KeyMap*/ keys = /*UInt8*/ trykeys; /*UInt8 trykeys[128]*/

I don't understand what you were trying here.

When I do this:
GetKeys((KeyMap) trykeys);

My compiler gives me a new error (as in first time ever gotten).
Eventhough (to me) this should work??

The following code works for me (Xcode 1.2):

void foo (void)
{
KeyMap aKeyMap;

GetKeys (aKeyMap);
}

I'm trying to rewrite a cross-platform library that doesn't work with Mac os
9,
the closest thing that would be to it in Carbon is GetKeys.
There is also a glut event handler that is exactly like it, but glut
does not work with Mac os 9 (new versions of glut).

Can't help you here.

Note: I am extremely bad when it comes to working with bytes (and other valu
es)
BinarySpike

Then why do you call yourself BinarySpike? :)

#include <Carbon.h>
Boolean Done;
KeyMap keys;
UInt8 trykeys[128];
^^^^^^^^^^^^^^^^^^^
You don't need this tryKeys. This has a size of 1024 bits.
Just use your 'keys' declaration above.

main()
{
while (!Button() && (Done == false))
{
GetKeys((KeyMap)trykeys); // error here:

As above, use keys as the parameter to GetKeys. You also don't need to cast it.


if (trykeys[24] == true) // if +/= button down

You need to test the individual bit here, and not a byte. I'll leave that an exercise for you.

{
Done = true; // Go ahead and quit
SysBeep(2); // Beep Beep
}
}
}

___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.


References: 
 >GetKeys() and KeyMap? (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.