Previous Book Contents Book Index Next

Inside Macintosh: Apple Game Sprockets Guide /
Chapter 3 - InputSprocket / InputSprocket Reference
Data Structures


Element Event Data Structure

The element event structure is a variable length structure that passes element event data. An element event data structure is defined by the ISpElementEvent data type.

typedef struct {
   AbsoluteTime   when;
   ISpElementReference element;
   UInt32         refCon;
   Uint32         data; 
} ISpElementEvent, *ISpElementEventPtr;
Field Description
when
The time the event happened. If the application is running on a PCI machine, the time will be in units of AbsoluteTime (as generated by the UpTime call). Otherwise, the when.hi field will be 0 and the when.lo field will be the time generated by TickCount.
element
A reference to the element that generated the event.
refCon
The reference constant assigned to this element on the element list that contains it (see the ISpElementList_AddElements function on (page 3-53). If you got this event from the ISpElement_GetNextEvent function or from a global list created by the systems, this field is 0.
data
The data for the event. It is a variable length field that is often, but not always, a 32-bit unsigned integer. Valid values include those given in the description of the "Button Element Data Information" (page 3-21), "Directional Pad Element Data Information" (page 3-21), "Axis Element Data Information" (page 3-22), and the "Movement Data Structure" (page 3-27). You need to examine the element kind to determine what size and type of data is reported.
For example, a new type of input data may refer to RGB color, so it requires 6 bytes of data instead of 4 bytes. It would be typed by a new element kind--for example, 'rgbc'. If you wanted to get RGB element kind data, you would have to allocate a larger structure when you were getting events via the event mechanism than you would allocate for 4-byte data.
The type of data varies for different elements.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996