home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Apple Game Sprockets / InputSprocket / Headers and Libraries / InputSprocketDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-17  |  8.6 KB  |  320 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        InputSprocketDriver.h
  3.  
  4.      Contains:    Driver interfaces for InputSprocket.
  5.                 Requires the software link with InputSprocketLib
  6.  
  7.      Version:    Technology:    InputSprocket 1.3
  8.                  Release:    InputSprocket 1.3
  9.  
  10.      Copyright:    © 1986-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  11.  
  12.      Bugs?:        Please include the the file and version information (from above) with
  13.                  the problem description.  Developers belonging to one of the Apple
  14.                  developer programs can submit bug reports to:
  15.  
  16.                      devsupport@apple.com
  17.  
  18. */
  19.  
  20. #ifndef __INPUTSPROCKETDRIVER__
  21. #define __INPUTSPROCKETDRIVER__
  22.  
  23.  
  24. #ifndef __MACTYPES__
  25. #include <MacTypes.h>
  26. #endif
  27.  
  28. #ifndef __ICONS__
  29. #include <Icons.h>
  30. #endif
  31.  
  32. #ifndef __DIALOGS__
  33. #include <Dialogs.h>
  34. #endif
  35.  
  36. #ifndef __INPUTSPROCKET__
  37. #include <InputSprocket.h>
  38. #endif
  39.  
  40. #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
  41.     #pragma import on
  42. #endif
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. #if PRAGMA_ALIGN_SUPPORTED
  49. #pragma options align=power
  50. #endif
  51.  
  52. /*
  53.  
  54. Resource File Concerns
  55.  
  56. 1. All resource ids of a driver should be in the range of 256 to 2048
  57. and the res file should only be open while the drivers panel is visable.
  58.  
  59. */
  60.  
  61. enum
  62. {
  63.     kOSType_ISpDriverFileType                = 'shlb',
  64.     kOSType_ISpDriverCreator                = 'insp'
  65. };
  66.  
  67. /*
  68.  *
  69.  * this function will plot an icon suite of the application (usually for a need)
  70.  *
  71.  */
  72.  
  73. OSErr ISpPlotAppIconSuite(const Rect *theRect,
  74.                     IconAlignmentType align, 
  75.                     IconTransformType transform, 
  76.                     short iconSuiteResourceId);
  77.  
  78. // label2,5,6,7, disabled and offline are reserved
  79.  
  80. enum
  81. {
  82.     kISpIconTransform_Selected                = kTransformSelected,
  83.     
  84.     // choose one of these (optionally) (these all erase what is behind them to the dialog color)
  85.     kISpIconTransform_PlotIcon                 = kTransformLabel1,
  86.     kISpIconTransform_PlotPopupButton         = kTransformLabel3,
  87.     kISpIconTransform_PlotButton             = kTransformLabel4,
  88.     
  89.     // use this is you want to plot the icon while the devices button is pressed
  90.     // or the devices axis is activated and so on
  91.     kISpIconTransform_DeviceActive            = kTransformOpen
  92. };
  93.  
  94. typedef UInt32 ISpMetaHandlerSelector;
  95. enum
  96. {
  97.     kISpSelector_Init =1,
  98.     kISpSelector_Stop,
  99.     kISpSelector_GetSize,
  100.     kISpSelector_HandleEvent,
  101.     kISpSelector_Show,
  102.     kISpSelector_Hide,
  103.     kISpSelector_BeginConfiguration,
  104.     kISpSelector_EndConfiguration,
  105.     kISpSelector_GetIcon,
  106.     kISpSelector_GetState,
  107.     kISpSelector_SetState,
  108.     kISpSelector_Dirty,
  109.     kISpSelector_SetActive,
  110.     kISpSelector_DialogItemHit,
  111.     kISpSelector_Tickle,            // 1.03 and later
  112.     kISpSelector_InterruptTickle,
  113.     kISpSelector_Draw,
  114.     kISpSelector_Click,
  115.     kISpSelector_ADBReInit            // 1.2 and later
  116. };
  117.  
  118.  
  119. /*
  120.  *
  121.  * typedefs for the function pointers the metahandler may return 
  122.  *
  123.  */
  124.  
  125. /* a generic driver function pointer */
  126. typedef OSStatus (* ISpDriverFunctionPtr_Generic)(UInt32 refCon, ...);
  127.  
  128. /* the meta handler pointer */
  129. typedef ISpDriverFunctionPtr_Generic (* ISpDriverFunctionPtr_MetaHandler)(UInt32 refCon, ISpMetaHandlerSelector);
  130.  
  131. /* the pointers you get through the meta handler */
  132. typedef OSStatus (* ISpDriverFunctionPtr_Init)(UInt32 refCon, UInt32 count, ISpNeed needs[], ISpElementReference virtualElements[], 
  133.                 Boolean used[], OSType appCreatorCode, OSType subCreatorCode, 
  134.                 UInt32 reserved, void* reserved2);
  135. typedef OSStatus (* ISpDriverFunctionPtr_Stop)(UInt32 refCon);
  136. typedef OSStatus (* ISpDriverFunctionPtr_GetSize)(UInt32 refCon, Point *minimum, Point *best);
  137. typedef OSStatus (* ISpDriverFunctionPtr_HandleEvent)(UInt32 refCon, EventRecord *theEvent, Boolean *handled);
  138. typedef OSStatus (* ISpDriverFunctionPtr_Show)(UInt32 refCon, DialogPtr theDialog, short dialogItemNumber, Rect *r);
  139. typedef OSStatus (* ISpDriverFunctionPtr_Hide)(UInt32 refCon);
  140. typedef OSStatus (* ISpDriverFunctionPtr_BeginConfiguration)(UInt32 refCon, UInt32 count, ISpNeed needs[]);
  141. typedef OSStatus (* ISpDriverFunctionPtr_EndConfiguration)(UInt32 refCon, Boolean accept);
  142. typedef OSStatus (* ISpDriverFunctionPtr_GetIcon)(UInt32 refCon, short *iconSuiteResourceId);
  143. typedef OSStatus (* ISpDriverFunctionPtr_GetState)(UInt32 refCon, UInt32 buflen, void *buffer, UInt32 *length);
  144. typedef OSStatus (* ISpDriverFunctionPtr_SetState)(UInt32 refCon, UInt32 length, void *buffer);
  145. typedef OSStatus (* ISpDriverFunctionPtr_Dirty)(UInt32 refCon, Boolean *dirty);
  146. typedef OSStatus (* ISpDriverFunctionPtr_SetActive)(UInt32 refCon, Boolean active);
  147. typedef OSStatus (* ISpDriverFunctionPtr_DialogItemHit)(UInt32 refCon, short itemHit);
  148.  
  149. // 1.03 and later
  150. typedef OSStatus (* ISpDriverFunctionPtr_Tickle)(UInt32 refCon);
  151. typedef OSStatus (* ISpDriverFunctionPtr_InterruptTickle)(UInt32 refCon);
  152. typedef OSStatus (* ISpDriverFunctionPtr_Draw)(UInt32 refCon);
  153. typedef OSStatus (* ISpDriverFunctionPtr_Click)(UInt32 refCon, const EventRecord *event);
  154.  
  155. // 1.2 and later
  156. typedef OSStatus (* ISpDriverFunctionPtr_ADBReInit)(UInt32 refCon, Boolean inPostProcess);
  157.  
  158. /* ********************* driver level functions ********************* */
  159.  
  160.  
  161. /*
  162.  *
  163.  * ISpDevice_New
  164.  *
  165.  * This creates a new device from the device definition structure and returns
  166.  * the result into the device reference.
  167.  *
  168.  * Returns Codes
  169.  * paramErr
  170.  * out of memory
  171.  * 
  172.  * Specical Considerations
  173.  * may not be done at interrupt time
  174.  */
  175.  
  176. OSStatus ISpDevice_New(    const ISpDeviceDefinition *inStruct, 
  177.                         ISpDriverFunctionPtr_MetaHandler metaHandler, 
  178.                         UInt32 refCon, 
  179.                         ISpDeviceReference *outReference);
  180.  
  181. /*
  182.  * ISpDevice_Dispose
  183.  *
  184.  * This disposes an existing device.
  185.  *
  186.  * Returns Codes
  187.  * paramErr
  188.  *
  189.  * Special Considerations
  190.  * May not be done at interrupt time
  191.  *
  192.  */
  193.  
  194. OSStatus ISpDevice_Dispose(ISpDeviceReference inReference);
  195.  
  196.  
  197. /*
  198.  *
  199.  * ISpElementDefinitionStruct
  200.  *
  201.  * This is the structure that defines everything static about this
  202.  * element.  For each element on your device you will need to 
  203.  * fill in one of these structures when your driver loads.
  204.  *
  205.  */
  206.  
  207. typedef struct ISpElementDefinitionStruct
  208. {
  209.     ISpDeviceReference device;  /* device this element belongs to */
  210.     UInt32 group;                /* group this element belongs to or 0 */
  211.     
  212.     Str63 theString;         /* a string that is a human readable identifier for this element, internationalization ? */
  213.         
  214.     ISpElementKind kind;        
  215.     ISpElementLabel label;        
  216.     
  217.     void *configInfo;         /* a pointer to the buffer containing the configuration information for this element */
  218.     UInt32 configInfoLength; /* length of that configuration info */
  219.  
  220.     UInt32 dataSize;         /* the size of the data, so we can generate an appropriate buffer */
  221.     
  222.     UInt32 reserved1;
  223.     UInt32 reserved2;
  224.     UInt32 reserved3;
  225. } ISpElementDefinitionStruct;
  226.  
  227. /*
  228.  *
  229.  * ISpElement_New
  230.  *
  231.  * ISpElement_New takes an element definition struct and gives you back a element reference.
  232.  * When you produce data you use that element reference to give the data to the system.
  233.  * 
  234.  * Return Codes
  235.  * paramErr
  236.  * memory error
  237.  *
  238.  * Special Considerations
  239.  * The ISpElement_New function may move or purge memory.  Your application should not call this function 
  240.  * at interrupt time.
  241.  * 
  242.  */
  243.  
  244. OSStatus ISpElement_New(const ISpElementDefinitionStruct *inStruct, ISpElementReference *outElement);
  245.  
  246. /*
  247.  *
  248.  * ISpElement_Dispose
  249.  *
  250.  * ISpElement_Dispose takes an element reference and deletes it.
  251.  * You should call this function when your driver unloads.
  252.  *
  253.  * Return Codes
  254.  * paramErr
  255.  * memory error
  256.  *
  257.  * Special Considerations
  258.  * The ISpElement_Dispose function may move or purge memory.  Your application should not call this function 
  259.  * at interrupt time.
  260.  * 
  261.  */
  262.  
  263. OSStatus ISpElement_Dispose(ISpElementReference inElement);
  264.  
  265. /*
  266.  *
  267.  * ISpElement_PushSimpleData
  268.  *
  269.  * ISpElement_PushSimpleData is the appropriate way to give the system data if your data fits exactly into
  270.  * a 32 bit signed number.  You pass the element reference that goes with the data, the data and the 
  271.  * AbsoluteTime that data was produced.  If UpTime is not available you should fill time.lo with the
  272.  * TickCount time and time.hi with 0.
  273.  *
  274.  * Return Codes
  275.  * paramErr
  276.  *
  277.  */
  278.  
  279. OSStatus ISpElement_PushSimpleData(ISpElementReference inElement, UInt32 data, const AbsoluteTime *time);
  280.  
  281. /*
  282.  *
  283.  * ISpElement_PushComplexData
  284.  *
  285.  * ISpElement_PushComplexData is exactly like ISpElement_PushSimpleData except that it is appropriate for times
  286.  * when your data does not fit into a signed 32 bit integer.
  287.  *
  288.  * Instead it takes the length of your data (which must match the datasize field of your ISpElementDefinitionStruct)
  289.  * and a ptr to the devices state.
  290.  *
  291.  * Return Codes
  292.  * paramErr
  293.  *
  294.  */
  295.  
  296. OSStatus ISpElement_PushComplexData(ISpElementReference inElement, UInt32 buflen, void *state, const AbsoluteTime *time);    
  297.  
  298.  
  299. /*
  300.  *
  301.  *
  302.  * use this to get the time
  303.  *
  304.  *
  305.  */
  306.  
  307. AbsoluteTime ISpUptime(void);
  308.  
  309. #ifdef __cplusplus
  310. }
  311. #endif
  312.  
  313.  
  314.  
  315. #if PRAGMA_ALIGN_SUPPORTED
  316. #pragma options align=reset
  317. #endif
  318.  
  319. #endif /* __INPUTSPROCKETDRIVER__ */
  320.