home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Mac OS USB DDK_v1.0.1 / Examples / KeyboardModule / KeyboardModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-03  |  2.8 KB  |  96 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        KeyboardModule.h
  3.  
  4.     Contains:    Header file for Keyboard Module
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11. #ifndef __KeyboardModuleH__
  12. #define __KeyboardModuleH__
  13.  
  14. #include <Types.h>
  15. #include <Devices.h>
  16. #include <DriverServices.h>
  17. #include <Processes.h>
  18. #include <USB.h>
  19.  
  20. void     PostUSBKeyToMac(UInt16 rawUSBkey);
  21. void    PostADBKeyToMac(UInt16 virtualKeycode, UInt8 state);
  22.  
  23. void    USBDemoKeyIn(UInt32 refcon, void * theData);
  24. void    InitUSBKeyboard(void);
  25. void     KBDHIDNotification(UInt32 devicetype, UInt8 NewHIDData[], UInt8 OldHIDData[]);
  26.  
  27. Boolean    SetBit(UInt8 *bitmapArray, UInt16 index, Boolean value);
  28.  
  29. static     OSStatus    KeyboardModuleInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  30. static     OSStatus    KeyboardInterfaceInitialize(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  31. static     OSStatus    KeyboardModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc);
  32.  
  33. void    KeyboardModuleInitiateTransaction(USBPB *pb);
  34. void    KeyboardModuleDelay1CompletionProc(USBPB *pb);
  35. void    KeyboardCompletionProc(USBPB *pb);
  36. void    InterfaceEntry(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBDeviceRef device);
  37.  
  38. OSErr     FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc);
  39. void     NotifyRegisteredHIDUser(UInt32 devicetype, UInt8 hidReport[]);
  40.  
  41. #define kKeyboardRetryCount        3
  42. #define kKeyboardModifierBits    8
  43. #define kKeyboardReportKeys        6
  44. #define    kKeyboardOffsetToKeys    2
  45. #define kKeyboardReportSize        8
  46.  
  47. enum driverstages
  48. {
  49.     kUndefined = 0,
  50.     kSetKeyboardLEDs,
  51.     kGetFullConfiguration,
  52.     kFindInterfaceAndSetProtocol,
  53.     kSetIdleRequest,
  54.     kFindAndOpenInterruptPipe,
  55.     kReadInterruptPipe,
  56.     kReturnFromDriver =     0x1000,
  57.     kRetryTransaction =     0x2000,
  58.     kSyncTransaction =         0x4000,
  59.     kCompletionPending =     0x8000
  60. };
  61.  
  62. typedef struct
  63. {
  64.     USBPB                             pb;
  65.     void (*handler)(USBPB             *pb);
  66.  
  67.     USBDeviceRef                    deviceRef;
  68.     USBInterfaceRef                    interfaceRef;
  69.     USBPipeRef                        pipeRef;
  70.     
  71.     USBDeviceDescriptor             deviceDescriptor;
  72.     USBInterfaceDescriptor            interfaceDescriptor;
  73.  
  74.     USBConfigurationDescriptorPtr     pFullConfigDescriptor;
  75.     USBInterfaceDescriptorPtr        pInterfaceDescriptor;
  76.     USBEndPointDescriptorPtr        pEndpointDescriptor;
  77.     
  78.     UInt32                            hidDeviceType;
  79.     UInt8                            hidReport[8];
  80.     UInt8                            oldHIDReport[8];
  81.     UInt8                            padding[8];
  82.     
  83.     Boolean                            sendRawReportFlag;
  84.     Boolean                            hidEmulationInit;
  85.     
  86.     HIDInterruptProcPtr             pSHIMInterruptRoutine;
  87.     HIDInterruptProcPtr             pSavedInterruptRoutine;
  88.     
  89.     UInt32                            interruptRefcon;
  90.     
  91.     SInt32                             retryCount;
  92.     SInt32                            delayLevel;
  93.     SInt32                            transDepth;
  94. } usbKeyboardPBStruct;
  95.  
  96. #endif //__KeyboardModuleH__