Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
9.2 KiB

  1. /*******************************************************************************
  2. **
  3. ** MODULE: "DT.H".
  4. **
  5. **
  6. ** DESCRIPTION: Include file for DT.C.
  7. **
  8. **
  9. ** AUTHOR: Daniel Dean, John Pierce.
  10. **
  11. **
  12. **
  13. ** CREATED:
  14. **
  15. **
  16. **
  17. **
  18. ** (C) C O P Y R I G H T D A N I E L D E A N 1 9 9 6.
  19. *******************************************************************************/
  20. #ifndef __DT_H__
  21. #define __DT_H__
  22. #define SUCCESS 0
  23. #define FAILURE 1
  24. #define EXITERROR -1
  25. #define IDM_PAGES (WM_USER + 2371)
  26. #define APPCLASS "DT"
  27. #define APPTITLE "HID Report Descriptor Tool"
  28. #define MAIN_ICON "DT"
  29. #define BACKGROUND_BRUSH COLOR_MENU+1//RGB(128,128,128)
  30. #define DEBUGSTOP _asm int 3
  31. #define WM_RESTORE (WM_USER +1763)
  32. LRESULT WINAPI WndProc(HWND, UINT, WPARAM, LPARAM);
  33. #define ITEM(x, y) (x | y)
  34. #define ITEM_SIZE_MASK 0x3
  35. #define ITEM_TAG_MASK 0xFC
  36. #define MAX_DESC_ENTRY 64 // Max characters for a descriptor entry in the list box
  37. // Entity item tags
  38. #define COLLECTION 0xA0
  39. #define END_COLLECTION 0xC0
  40. #define INPUT 0x80
  41. #define OUTPUT 0x90
  42. #define FEATURE 0xB0
  43. // Entity Attribute item tags
  44. #define USAGE_PAGE 0x04
  45. #define LOGICAL_EXTENT_MIN 0x14
  46. #define LOGICAL_EXTENT_MAX 0x24
  47. #define PHYSICAL_EXTENT_MIN 0x34
  48. #define PHYSICAL_EXTENT_MAX 0x44
  49. #define UNIT_EXPONENT 0x54
  50. #define UNIT 0x64
  51. #define REPORT_SIZE 0x74
  52. #define REPORT_ID 0x84
  53. #define REPORT_COUNT 0x94
  54. #define PUSH 0xA4
  55. #define POP 0xB4
  56. // Control attribute item tags
  57. #define USAGE 0x08
  58. #define USAGE_MIN 0x18
  59. #define USAGE_MAX 0x28
  60. #define DESIGNATOR_INDEX 0x38
  61. #define DESIGNATOR_MIN 0x48
  62. #define DESIGNATOR_MAX 0x58
  63. #define STRING_INDEX 0x68
  64. #define STRING_MIN 0x78
  65. #define STRING_MAX 0x88
  66. #define SET_DELIMITER 0xA9
  67. // A bogus item tag
  68. #define UNDEFINED_TAG 0xFF
  69. // Bit masks
  70. #define DATA_SIZE_MASK 0x03
  71. // Flag used by AddString() to indicate we insert at index gotten
  72. // from LB_GETCURSEL
  73. #define DONT_CARE -1
  74. //
  75. // ID's for popup memnu
  76. #define IDM_INSERT 0x9000
  77. #define IDM_ADD 0x9001
  78. #define IDM_DELETE 0x9002
  79. //
  80. // Structure created in the GetXXXVal() functions below and stored
  81. // in the ITEMDATA area for the list box member associated with the
  82. // hex representation of a Descriptor Entity.
  83. typedef struct tagItemStruct{
  84. BYTE bTag; // the built up tag
  85. BYTE bParam[4]; // up to 4 bytes of parameter info
  86. }ITEM_INFO,* PITEM_INFO;
  87. typedef struct tagDeviceInfo{
  88. ULONG nDeviceID; // Number appended to device string in reg
  89. ULONG hDevice; // Handle of the device
  90. }DEVICEINFO,*PDEVICEINFO;
  91. //
  92. // Maximum data bytes in a packet
  93. #define MAX_DATA 10
  94. //
  95. // Structure defining a packet sent to the SendData IOCTL
  96. //
  97. typedef struct tagSendData{
  98. ULONG hDevice;
  99. BYTE bData[MAX_DATA];
  100. }SENDDATA_PACKET, *PSENDDATA_PACKET;
  101. typedef struct _LAVAConfigIndexInfo{
  102. WORD wStartOffset;
  103. WORD wHIDLen;
  104. WORD wReportLen;
  105. WORD wPhysicalLen;
  106. } LAVA_CONFIG,*PLAVA_CONFIG;
  107. //
  108. // Globals
  109. //
  110. #ifdef DEFINE_GLOBALS
  111. HANDLE ghInst = NULL;
  112. HWND ghWnd = NULL;
  113. PCHAR szEntity[] = {"USAGE", // 0
  114. "USAGE_PAGE", // 1
  115. "USAGE_MINIMUM", // 2
  116. "USAGE_MAXIMUM", // 3
  117. "DESIGNATOR_INDEX", // 4
  118. "DESIGNATOR_MINIMUM", // 5
  119. "DESIGNATOR_MAXIMUM", // 6
  120. "STRING_INDEX", // 7
  121. "STRING_MINIMUM", // 8
  122. "STRING_MAXIMUM", // 9
  123. "COLLECTION", // 10
  124. "END_COLLECTION", // 11
  125. "INPUT", // 12
  126. "OUTPUT", // 13
  127. "FEATURE", // 14
  128. "LOGICAL_MINIMUM", // 15
  129. "LOGICAL_MAXIMUM", // 16
  130. "PHYSICAL_MINIMUM", // 17
  131. "PHYSICAL_MAXIMUM", // 18
  132. "UNIT_EXPONENT", // 19
  133. "UNIT", // 20
  134. "REPORT_SIZE", // 21
  135. "REPORT_ID", // 22
  136. "REPORT_COUNT", // 23
  137. "PUSH", // 24
  138. "POP", // 25
  139. "SET_DELIMITER", // 26
  140. "UNDEFINED_TAG"}; // 27
  141. UCHAR Entity[] = {USAGE,
  142. USAGE_PAGE,
  143. USAGE_MIN,
  144. USAGE_MAX,
  145. DESIGNATOR_INDEX,
  146. DESIGNATOR_MIN,
  147. DESIGNATOR_MAX,
  148. STRING_INDEX,
  149. STRING_MIN,
  150. STRING_MAX,
  151. COLLECTION,
  152. END_COLLECTION,
  153. INPUT,
  154. OUTPUT,
  155. FEATURE,
  156. LOGICAL_EXTENT_MIN,
  157. LOGICAL_EXTENT_MAX,
  158. PHYSICAL_EXTENT_MIN,
  159. PHYSICAL_EXTENT_MAX,
  160. UNIT_EXPONENT,
  161. UNIT,
  162. REPORT_SIZE,
  163. REPORT_ID,
  164. REPORT_COUNT,
  165. PUSH,
  166. POP,
  167. SET_DELIMITER,
  168. UNDEFINED_TAG};
  169. #define ENTITY_INDEX 27
  170. UINT gEditVal=0; // Value returned from EditBox
  171. BYTE gCollectionVal=0; // Value returned from Collection dialog
  172. WORD gUnitVal=0; // Value returned from Unit dialog
  173. BYTE gExpVal=0; // Value returned from Exponent dialog
  174. BYTE gUsagePageVal=0; // Value returned from UsagePage dialog
  175. BYTE gSetDelimiterVal=0; // Value returned from GetSetDelimiter dialog
  176. WORD gMainItemVal=0; // Value returned from Input dialog
  177. int gfInsert = FALSE; // Flag to tell whether we insert ot add strings
  178. // to the ListBoxes
  179. WORD gwReportDescLen=0; // Length in bytes of the ReportDescriptor;
  180. #else
  181. extern HANDLE ghInst;
  182. extern HWND ghWnd;
  183. extern PCHAR szEntity[];
  184. extern UCHAR Entity[];
  185. extern int gEditVal;
  186. extern BYTE gCollectionVal;
  187. extern WORD gUnitVal;
  188. extern BYTE gExpVal;
  189. extern BYTE gUsagePageVal;
  190. extern BYTE gSetDelimiterVal;
  191. extern WORD gMainItemVal;
  192. extern int gfInsert;
  193. extern WORD gwReportDescLen;
  194. #endif
  195. ////////////////////////////////////////////////////////////////////////////////
  196. //
  197. // Function Proto's
  198. //
  199. LPARAM WINAPI WindowProc(HWND hWnd, UINT Message, UINT uParam, LPARAM lParam);
  200. LPARAM WMCommand(HWND hWnd, UINT Message, UINT uParam, LPARAM lParam);
  201. LPARAM WMSysCommand(HWND hWnd, UINT Message, UINT uParam, LPARAM lParam);
  202. LPARAM WMCreate(HWND hWnd, UINT uParam);
  203. LPARAM WMClose(HWND hWnd);
  204. LPARAM WMSize(HWND hWnd, LPARAM lParam);
  205. int SendHIDDescriptor(PUCHAR pHID, PULONG pSize, DWORD *pDevID, ULONG *pDevHandle);
  206. ULONG SendHIDData(SENDDATA_PACKET *pPacket, ULONG SizeIn, DWORD *pSizeOut) ;
  207. ULONG KillHIDDevice(SENDDATA_PACKET *pPacket);
  208. LPARAM WMPaint(HWND hWnd, UINT Message, UINT uParam, LPARAM lParam);
  209. INT WMKey(HWND hWnd, UINT Message, UINT uParam, LPARAM lParam);
  210. VOID MoveEntityItems(VOID);
  211. BOOL WindowRegistration(HANDLE hInstance, HANDLE hPrevInstance);
  212. BOOL WINAPI SendDataDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  213. LPARAM WINAPI ListBoxWindowProc(HWND hWnd, UINT Message, UINT uParam, LPARAM lParam);
  214. void DoFileOpen(HANDLE);
  215. void DoFileSave(HANDLE);
  216. void DoFilePrint(HANDLE);
  217. void WriteLavaConfigFile(HANDLE,UINT);
  218. void DoCopyDescriptor(HANDLE hWnd);
  219. void DoParseDescriptor(HANDLE hWnd);
  220. // Dialog box proc proto's
  221. BOOL CALLBACK EditBoxDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  222. BOOL CALLBACK CollectionDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  223. BOOL CALLBACK MainItemDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  224. BOOL CALLBACK UnitDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  225. BOOL CALLBACK ExponentDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  226. BOOL CALLBACK UsagePageDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  227. BOOL CALLBACK SetDelimiterDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  228. LRESULT AddString(HANDLE hListBox,char * szString);
  229. void GetBogusVal( HANDLE,int);
  230. void GetUsageVal( HANDLE,int );
  231. void GetUsagePageVal( HANDLE,int );
  232. void GetInputFromEditBoxSigned( HANDLE,int );
  233. void GetInputFromEditBoxUnSigned( HANDLE,int );
  234. void GetCollectionVal( HANDLE,int );
  235. void GetEndCollectionVal( HANDLE,int );
  236. void GetInputVal( HANDLE,int );
  237. void GetOutputVal( HANDLE,int );
  238. void GetFeatVal( HANDLE,int );
  239. void GetExponentVal( HANDLE,int );
  240. void GetUnitsVal( HANDLE,int );
  241. void GetPushVal( HANDLE,int );
  242. void GetPopVal( HANDLE,int );
  243. void GetSetDelimiterVal( HANDLE hDescListBox, int nEntity);
  244. #endif// __DT_H__