Leaked source code of windows server 2003
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.

2426 lines
69 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dihid.h
  6. * Content: DirectInput internal include file for HID
  7. *
  8. ***************************************************************************/
  9. #ifdef HID_SUPPORT
  10. #ifndef _DIHID_H
  11. #define _DIHID_H
  12. #ifndef HID_USAGE_PAGE_PID
  13. #define HID_USAGE_PAGE_PID ( (USAGE) 0x0000f )
  14. #endif
  15. #ifndef HID_USAGE_PAGE_VENDOR
  16. #define HID_USAGE_PAGE_VENDOR ( (USAGE) 0xff00 )
  17. #endif
  18. /*****************************************************************************
  19. *
  20. * @doc INTERNAL
  21. *
  22. * @struct HIDDEVICEINFO |
  23. *
  24. * Records information about a single hid device.
  25. *
  26. * @field DIOBJECTSTATICDATA | osd |
  27. *
  28. * Standard information that identifies the device crudely.
  29. *
  30. * The <e DIOBJECTSTATICDATA.dwDevType> field contains the
  31. * device type code, used by
  32. * <f CDIDEnum_Next>.
  33. *
  34. * If the device is a HID mouse, then the remaining fields
  35. * are commandeered as follows:
  36. *
  37. * The <e DIOBJECTSTATICDATA.pcguid> field is the number
  38. * of buttons on the mouse.
  39. *
  40. * The <e DIOBJECTSTATICDATA.CreateDcb> field is the number
  41. * of axes on the mouse.
  42. *
  43. * See <f DIHid_ProbeMouse> for an explanation of why we
  44. * need to do this.
  45. *
  46. * @field PSP_DEVICE_INTERFACE_DETAIL_DATA | pdidd |
  47. *
  48. * Pointer to name for device to be used in <f CreateFile>.
  49. *
  50. * @field HKEY | hk |
  51. *
  52. * Registry key that contains configuration information.
  53. * Sadly, we must keep it open because there is no way to
  54. * obtain the name of the key, and the only way to open the
  55. * key is inside an enumeration.
  56. *
  57. * @field HKEY | hkOld |
  58. *
  59. * Registry key that contains configuration information.
  60. * This key was originally used in Win2k Gold. It is to
  61. * maintain compatibiltiy with Win2k Gold.
  62. *
  63. * @field LPTSTR | ptszId |
  64. *
  65. * Cached device ID that allows us to access other information
  66. * about the device.
  67. *
  68. * @field GUID | guid |
  69. *
  70. * The instance GUID for the device.
  71. *
  72. * @field GUID | guidProduct |
  73. *
  74. * The product GUID for the device.
  75. *
  76. * @field WORD | ProductID |
  77. *
  78. * The PID for the device
  79. *
  80. * @field WORD | VendorID |
  81. *
  82. * The VID for the device
  83. *
  84. *****************************************************************************/
  85. typedef struct HIDDEVICEINFO
  86. {
  87. DIOBJECTSTATICDATA osd;
  88. PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd;
  89. HKEY hk;
  90. HKEY hkOld;
  91. LPTSTR ptszId;
  92. GUID guid;
  93. GUID guidProduct;
  94. int idJoy;
  95. WORD ProductID;
  96. WORD VendorID;
  97. BOOL fAttached;
  98. } HIDDEVICEINFO, *PHIDDEVICEINFO;
  99. /*****************************************************************************
  100. *
  101. * @doc INTERNAL
  102. *
  103. * @struct HIDDEVICELIST |
  104. *
  105. * Records information about all the HID devices.
  106. *
  107. * @field int | chdi |
  108. *
  109. * Number of items in the list that are in use.
  110. *
  111. * @field int | chdiAlloc |
  112. *
  113. * Number of items allocated in the list.
  114. *
  115. * @field HIDDEVICEINFO | rghdi[0] |
  116. *
  117. * Variable-size array of device information structures.
  118. *
  119. *****************************************************************************/
  120. typedef struct HIDDEVICELIST
  121. {
  122. int chdi;
  123. int chdiAlloc;
  124. int idMaxJoy;
  125. HIDDEVICEINFO rghdi[0];
  126. } HIDDEVICELIST, *PHIDDEVICELIST;
  127. extern PHIDDEVICELIST g_phdl;
  128. #define cbHdlChdi(chdi) FIELD_OFFSET(HIDDEVICELIST, rghdi[chdi])
  129. /*
  130. * We choose our starting point at 64 devices, since
  131. * that's the maximum number of USB devices supported. This
  132. * avoids needless reallocs.
  133. */
  134. #define chdiMax 64
  135. #define chdiInit 16
  136. /*
  137. * Tag for unused translation of object instance
  138. */
  139. #define NOREGTRANSLATION (0x80000000)
  140. /*
  141. * VID/PID definitions used to handle analog devices
  142. */
  143. #define MSFT_SYSTEM_VID (0x45E)
  144. #define MSFT_SYSTEM_PID (0x100)
  145. #define ANALOG_ID_ROOT TEXT("VID_045E&PID_01")
  146. /*
  147. * VID/PID template so that upper case hex is always used
  148. */
  149. #define VID_PID_TEMPLATE TEXT("VID_%04X&PID_%04X")
  150. /*
  151. * Size of string in characters generated using VID_PID_TEMPLATE
  152. */
  153. #define cbszVIDPID cA( VID_PID_TEMPLATE )
  154. /*****************************************************************************
  155. *
  156. * diextdll.c - Imports from optional external DLLs
  157. *
  158. * It is very important that HidD_GetHidGuid be the very last one.
  159. *
  160. *****************************************************************************/
  161. #ifdef STATIC_DLLUSAGE
  162. #define ExtDll_Init()
  163. #else
  164. void EXTERNAL ExtDll_Init(void);
  165. #endif
  166. void EXTERNAL ExtDll_Term(void);
  167. /*****************************************************************************
  168. *
  169. * @doc INTERNAL
  170. *
  171. * @struct MANUALIMPORT |
  172. *
  173. * Records a single manual import. If it hasn't
  174. * yet been resolved, then the <e MANUALIMPORT.ptsz>
  175. * points to the procedure name. If it has been resolved
  176. * successfully, then <e MANUALIMPORT.pfn> points to
  177. * the resolved address. If it has not been resolved
  178. * successfully, then <e MANUALIMPORT.pfn> is garbage.
  179. *
  180. * @field LPCSTR | psz |
  181. *
  182. * Procdure name. Note that this is always an ANSI string.
  183. *
  184. * @field FARPROC | pfn |
  185. *
  186. * Procedure address.
  187. *
  188. *****************************************************************************/
  189. typedef union MANUALIMPORT
  190. {
  191. FARPROC pfn; /* Procedure address */
  192. } MANUALIMPORT, *PMANUALIMPORT;
  193. #ifndef STATIC_DLLUSAGE
  194. #ifndef WINNT
  195. /*****************************************************************************
  196. *
  197. * CFGMGR32
  198. *
  199. * Note that this must match the CFGMGR32 section in diextdll.c
  200. *
  201. *****************************************************************************/
  202. typedef union CFGMGR32
  203. {
  204. MANUALIMPORT rgmi[6]; /* number of functions we import */
  205. struct
  206. {
  207. CONFIGRET ( WINAPI * _CM_Get_Child)
  208. (
  209. OUT PDEVINST pdnDevInst,
  210. IN DEVINST dnDevInst,
  211. IN ULONG ulFlags
  212. );
  213. CONFIGRET ( WINAPI * _CM_Get_Sibling)
  214. (
  215. OUT PDEVINST pdnDevInst,
  216. IN DEVINST DevInst,
  217. IN ULONG ulFlags
  218. );
  219. CONFIGRET ( WINAPI * _CM_Get_Parent)
  220. (
  221. OUT PDEVINST pdnDevInst,
  222. IN DEVINST dnDevInst,
  223. IN ULONG ulFlags
  224. );
  225. CONFIGRET ( WINAPI * _CM_Get_DevNode_Registry_Property)
  226. (
  227. IN DEVINST dnDevInst,
  228. IN ULONG ulProperty,
  229. OUT PULONG pulRegDataType, OPTIONAL
  230. OUT PVOID Buffer, OPTIONAL
  231. IN OUT PULONG pulLength,
  232. IN ULONG ulFlags
  233. );
  234. CONFIGRET ( WINAPI * _CM_Set_DevNode_Registry_Property)
  235. (
  236. IN DEVINST dnDevInst,
  237. IN ULONG ulProperty,
  238. IN PVOID Buffer, OPTIONAL
  239. IN ULONG ulLength,
  240. IN ULONG ulFlags
  241. );
  242. CONFIGRET( WINAPI * _CM_Get_Device_ID)
  243. (
  244. IN DEVINST dnDevInst,
  245. OUT PTCHAR Buffer,
  246. IN ULONG BufferLen,
  247. IN ULONG ulFlags
  248. );
  249. };
  250. } CFGMGR32, *PFGMGR32;
  251. extern CFGMGR32 g_cfgmgr32;
  252. #undef CM_Get_Child
  253. #undef CM_Get_Sibling
  254. #undef CM_Get_Parent
  255. #undef CM_Get_DevNode_Registry_Property
  256. #undef CM_Set_DevNode_Registry_Property
  257. #undef CM_Get_Device_ID
  258. #define CM_Get_Child \
  259. g_cfgmgr32._CM_Get_Child
  260. #define CM_Get_Sibling \
  261. g_cfgmgr32._CM_Get_Sibling
  262. #define CM_Get_Parent \
  263. g_cfgmgr32._CM_Get_Parent
  264. #define CM_Get_DevNode_Registry_Property \
  265. g_cfgmgr32._CM_Get_DevNode_Registry_Property
  266. #define CM_Set_DevNode_Registry_Property \
  267. g_cfgmgr32._CM_Set_DevNode_Registry_Property
  268. #define CM_Get_Device_ID \
  269. g_cfgmgr32._CM_Get_Device_ID
  270. #endif //#ifndef WINNT
  271. /*****************************************************************************
  272. *
  273. * SETUPAPI
  274. *
  275. * Note that this must match the SETUPAPI section in diextdll.c
  276. *
  277. *****************************************************************************/
  278. typedef union SETUPAPI
  279. {
  280. #ifdef WINNT
  281. MANUALIMPORT rgmi[18]; /* number of functions we import */
  282. #else
  283. MANUALIMPORT rgmi[12]; /* number of functions we import */
  284. #endif
  285. struct
  286. {
  287. HDEVINFO (WINAPI *_SetupDiGetClassDevs)
  288. (
  289. IN LPGUID ClassGuid, OPTIONAL
  290. IN LPCTSTR Enumerator, OPTIONAL
  291. IN HWND hwndParent, OPTIONAL
  292. IN DWORD Flags
  293. );
  294. BOOL (WINAPI *_SetupDiDestroyDeviceInfoList)
  295. (
  296. IN HDEVINFO DeviceInfoSet
  297. );
  298. BOOL (WINAPI *_SetupDiGetDeviceInterfaceDetail)
  299. (
  300. IN HDEVINFO DeviceInfoSet,
  301. IN PSP_DEVICE_INTERFACE_DATA pdid,
  302. OUT PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd, OPTIONAL
  303. IN DWORD cbDidd,
  304. OUT PDWORD RequiredSize, OPTIONAL
  305. OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  306. );
  307. BOOL (WINAPI *_SetupDiEnumDeviceInterfaces)
  308. (
  309. IN HDEVINFO DeviceInfoSet,
  310. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  311. IN LPGUID InterfaceClassGuid,
  312. IN DWORD MemberIndex,
  313. OUT PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData
  314. );
  315. HKEY (WINAPI *_SetupDiCreateDeviceInterfaceRegKey)
  316. (
  317. IN HDEVINFO hdev,
  318. IN PSP_DEVICE_INTERFACE_DATA pdid,
  319. IN DWORD Reserved,
  320. IN REGSAM samDesired,
  321. IN HINF InfHandle, OPTIONAL
  322. IN PCSTR InfSectionName OPTIONAL
  323. );
  324. BOOL (WINAPI *_SetupDiCallClassInstaller)
  325. (
  326. IN DI_FUNCTION InstallFunction,
  327. IN HDEVINFO DeviceInfoSet,
  328. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  329. );
  330. BOOL (WINAPI *_SetupDiGetDeviceRegistryProperty)
  331. (
  332. IN HDEVINFO DeviceInfoSet,
  333. IN PSP_DEVINFO_DATA DeviceInfoData,
  334. IN DWORD Property,
  335. OUT PDWORD PropertyRegDataType, OPTIONAL
  336. OUT PBYTE PropertyBuffer,
  337. IN DWORD PropertyBufferSize,
  338. OUT PDWORD RequiredSize OPTIONAL
  339. );
  340. BOOL (WINAPI *_SetupDiSetDeviceRegistryProperty)
  341. (
  342. IN HDEVINFO DeviceInfoSet,
  343. IN OUT PSP_DEVINFO_DATA DeviceInfoData,
  344. IN DWORD Property,
  345. IN CONST BYTE* PropertyBuffer,
  346. IN DWORD PropertyBufferSize
  347. );
  348. BOOL (WINAPI *_SetupDiGetDeviceInstanceId)
  349. (
  350. IN HDEVINFO DeviceInfoSet,
  351. IN PSP_DEVINFO_DATA DeviceInfoData,
  352. OUT PTSTR DeviceInstanceId,
  353. IN DWORD DeviceInstanceIdSize,
  354. OUT PDWORD RequiredSize OPTIONAL
  355. );
  356. BOOL (WINAPI *_SetupDiOpenDeviceInfo)
  357. (
  358. IN HDEVINFO DeviceInfoSet,
  359. IN LPCTSTR DeviceInstanceId,
  360. IN HWND hwndParent, OPTIONAL
  361. IN DWORD OpenFlags,
  362. OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  363. );
  364. HDEVINFO (WINAPI *_SetupDiCreateDeviceInfoList)
  365. (
  366. IN LPGUID ClassGuid, OPTIONAL
  367. IN HWND hwndParent OPTIONAL
  368. );
  369. HKEY (WINAPI *_SetupDiOpenDevRegKey)
  370. (
  371. IN HDEVINFO DeviceInfoSet,
  372. IN PSP_DEVINFO_DATA DeviceInfoData,
  373. IN DWORD Scope,
  374. IN DWORD HwProfile,
  375. IN DWORD KeyType,
  376. IN REGSAM samDesired
  377. );
  378. #ifdef WINNT
  379. CONFIGRET ( WINAPI * _CM_Get_Child)
  380. (
  381. OUT PDEVINST pdnDevInst,
  382. IN DEVINST dnDevInst,
  383. IN ULONG ulFlags
  384. );
  385. CONFIGRET ( WINAPI * _CM_Get_Sibling)
  386. (
  387. OUT PDEVINST pdnDevInst,
  388. IN DEVINST DevInst,
  389. IN ULONG ulFlags
  390. );
  391. CONFIGRET ( WINAPI * _CM_Get_Parent)
  392. (
  393. OUT PDEVINST pdnDevInst,
  394. IN DEVINST dnDevInst,
  395. IN ULONG ulFlags
  396. );
  397. CONFIGRET ( WINAPI * _CM_Get_DevNode_Registry_Property)
  398. (
  399. IN DEVINST dnDevInst,
  400. IN ULONG ulProperty,
  401. OUT PULONG pulRegDataType, OPTIONAL
  402. OUT PVOID Buffer, OPTIONAL
  403. IN OUT PULONG pulLength,
  404. IN ULONG ulFlags
  405. );
  406. CONFIGRET ( WINAPI * _CM_Set_DevNode_Registry_Property)
  407. (
  408. IN DEVINST dnDevInst,
  409. IN ULONG ulProperty,
  410. IN PVOID Buffer, OPTIONAL
  411. IN ULONG ulLength,
  412. IN ULONG ulFlags
  413. );
  414. CONFIGRET( WINAPI * _CM_Get_Device_ID)
  415. (
  416. IN DEVINST dnDevInst,
  417. OUT PTCHAR Buffer,
  418. IN ULONG BufferLen,
  419. IN ULONG ulFlags
  420. );
  421. #endif //#ifdef WINNT
  422. };
  423. } SETUPAPI, *PSETUPAPI;
  424. extern SETUPAPI g_setupapi;
  425. #undef SetupDiGetClassDevs
  426. #undef SetupDiDestroyDeviceInfoList
  427. #undef SetupDiGetDeviceInterfaceDetail
  428. #undef SetupDiEnumDeviceInterfaces
  429. #undef SetupDiCreateDeviceInterfaceRegKey
  430. #undef SetupDiCallClassInstaller
  431. #undef SetupDiGetDeviceRegistryProperty
  432. #undef SetupDiSetDeviceRegistryProperty
  433. #undef SetupDiGetDeviceInstanceId
  434. #undef SetupDiOpenDeviceInfo
  435. #undef SetupDiCreateDeviceInfoList
  436. #undef SetupDiOpenDevRegKey
  437. #define SetupDiGetClassDevs \
  438. g_setupapi._SetupDiGetClassDevs
  439. #define SetupDiDestroyDeviceInfoList \
  440. g_setupapi._SetupDiDestroyDeviceInfoList
  441. #define SetupDiGetDeviceInterfaceDetail \
  442. g_setupapi._SetupDiGetDeviceInterfaceDetail
  443. #define SetupDiEnumDeviceInterfaces \
  444. g_setupapi._SetupDiEnumDeviceInterfaces
  445. #define SetupDiCreateDeviceInterfaceRegKey \
  446. g_setupapi._SetupDiCreateDeviceInterfaceRegKey
  447. #define SetupDiCallClassInstaller \
  448. g_setupapi._SetupDiCallClassInstaller
  449. #define SetupDiGetDeviceRegistryProperty \
  450. g_setupapi._SetupDiGetDeviceRegistryProperty
  451. #define SetupDiSetDeviceRegistryProperty \
  452. g_setupapi._SetupDiSetDeviceRegistryProperty
  453. #define SetupDiGetDeviceInstanceId \
  454. g_setupapi._SetupDiGetDeviceInstanceId
  455. #define SetupDiOpenDeviceInfo \
  456. g_setupapi._SetupDiOpenDeviceInfo
  457. #define SetupDiCreateDeviceInfoList \
  458. g_setupapi._SetupDiCreateDeviceInfoList
  459. #define SetupDiOpenDevRegKey \
  460. g_setupapi._SetupDiOpenDevRegKey
  461. #ifdef WINNT
  462. #undef CM_Get_Child
  463. #undef CM_Get_Sibling
  464. #undef CM_Get_Parent
  465. #undef CM_Get_DevNode_Registry_Property
  466. #undef CM_Set_DevNode_Registry_Property
  467. #undef CM_Get_Device_ID
  468. #define CM_Get_Child \
  469. g_setupapi._CM_Get_Child
  470. #define CM_Get_Sibling \
  471. g_setupapi._CM_Get_Sibling
  472. #define CM_Get_Parent \
  473. g_setupapi._CM_Get_Parent
  474. #define CM_Get_DevNode_Registry_Property \
  475. g_setupapi._CM_Get_DevNode_Registry_Property
  476. #define CM_Set_DevNode_Registry_Property \
  477. g_setupapi._CM_Set_DevNode_Registry_Property
  478. #define CM_Get_Device_ID \
  479. g_setupapi._CM_Get_Device_ID
  480. #endif //#ifdef WINNT
  481. /*****************************************************************************
  482. *
  483. * HIDDLL
  484. *
  485. * Note that this must match the HID section in diextdll.c
  486. *
  487. *****************************************************************************/
  488. typedef union HIDDLL
  489. {
  490. MANUALIMPORT rgmi[21]; /* number of functions we import */
  491. struct
  492. {
  493. void (__stdcall *_HidD_GetHidGuid)
  494. (
  495. OUT LPGUID HidGuid
  496. );
  497. BOOLEAN (__stdcall *_HidD_GetPreparsedData)
  498. (
  499. IN HANDLE HidDeviceObject,
  500. OUT PHIDP_PREPARSED_DATA * PreparsedData
  501. );
  502. BOOLEAN (__stdcall *_HidD_FreePreparsedData)
  503. (
  504. IN PHIDP_PREPARSED_DATA PreparsedData
  505. );
  506. BOOLEAN (__stdcall *_HidD_FlushQueue)
  507. (
  508. IN HANDLE HidDeviceObject
  509. );
  510. BOOLEAN (__stdcall *_HidD_GetAttributes)
  511. (
  512. IN HANDLE HidDeviceObject,
  513. OUT PHIDD_ATTRIBUTES Attributes
  514. );
  515. BOOLEAN (__stdcall *_HidD_GetFeature)
  516. (
  517. IN HANDLE HidDeviceObject,
  518. OUT PVOID ReportBuffer,
  519. IN ULONG ReportBufferLength
  520. );
  521. BOOLEAN (__stdcall *_HidD_SetFeature)
  522. (
  523. IN HANDLE HidDeviceObject,
  524. IN PVOID ReportBuffer,
  525. IN ULONG ReportBufferLength
  526. );
  527. BOOLEAN (__stdcall *_HidD_GetProductString)
  528. (
  529. IN HANDLE HidDeviceObject,
  530. OUT PVOID Buffer,
  531. IN ULONG BufferLength
  532. );
  533. BOOLEAN (__stdcall *_HidD_GetInputReport)
  534. (
  535. IN HANDLE HidDeviceObject,
  536. OUT PVOID ReportBuffer,
  537. IN ULONG ReportBufferLength
  538. );
  539. NTSTATUS (__stdcall *_HidP_GetCaps)
  540. (
  541. IN PHIDP_PREPARSED_DATA PreparsedData,
  542. OUT PHIDP_CAPS Capabilities
  543. );
  544. NTSTATUS (__stdcall *_HidP_GetButtonCaps)
  545. (
  546. IN HIDP_REPORT_TYPE ReportType,
  547. OUT PHIDP_BUTTON_CAPS ButtonCaps,
  548. IN OUT PUSHORT ButtonCapsLength,
  549. IN PHIDP_PREPARSED_DATA PreparsedData
  550. );
  551. NTSTATUS (__stdcall *_HidP_GetValueCaps)
  552. (
  553. IN HIDP_REPORT_TYPE ReportType,
  554. OUT PHIDP_VALUE_CAPS ValueCaps,
  555. IN OUT PUSHORT ValueCapsLength,
  556. IN PHIDP_PREPARSED_DATA PreparsedData
  557. );
  558. NTSTATUS (__stdcall *_HidP_GetLinkCollectionNodes)
  559. (
  560. OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
  561. IN OUT PULONG LinkCollectionNodesLength,
  562. IN PHIDP_PREPARSED_DATA PreparsedData
  563. );
  564. ULONG (__stdcall *_HidP_MaxDataListLength)
  565. (
  566. IN HIDP_REPORT_TYPE ReportType,
  567. IN PHIDP_PREPARSED_DATA PreparsedData
  568. );
  569. NTSTATUS (__stdcall *_HidP_GetUsagesEx)
  570. (
  571. IN HIDP_REPORT_TYPE ReportType,
  572. IN USHORT LinkCollection,
  573. OUT PUSAGE_AND_PAGE ButtonList,
  574. IN OUT ULONG * UsageLength,
  575. IN PHIDP_PREPARSED_DATA PreparsedData,
  576. IN PCHAR Report,
  577. IN ULONG ReportLength
  578. );
  579. NTSTATUS (__stdcall *_HidP_GetScaledUsageValue)
  580. (
  581. IN HIDP_REPORT_TYPE ReportType,
  582. IN USAGE UsagePage,
  583. IN USHORT LinkCollection,
  584. IN USAGE Usage,
  585. OUT PLONG UsageValue,
  586. IN PHIDP_PREPARSED_DATA PreparsedData,
  587. IN PCHAR Report,
  588. IN ULONG ReportLength
  589. );
  590. NTSTATUS (__stdcall *_HidP_GetData)
  591. (
  592. IN HIDP_REPORT_TYPE ReportType,
  593. OUT PHIDP_DATA DataList,
  594. IN OUT PULONG DataLength,
  595. IN PHIDP_PREPARSED_DATA PreparsedData,
  596. IN PCHAR Report,
  597. IN ULONG ReportLength
  598. );
  599. NTSTATUS (__stdcall *_HidP_SetData)
  600. (
  601. IN HIDP_REPORT_TYPE ReportType,
  602. IN PHIDP_DATA DataList,
  603. IN OUT PULONG DataLength,
  604. IN PHIDP_PREPARSED_DATA PreparsedData,
  605. IN OUT PCHAR Report,
  606. IN ULONG ReportLength
  607. );
  608. NTSTATUS (__stdcall *_HidP_GetUsageValue)
  609. (
  610. IN HIDP_REPORT_TYPE ReportType,
  611. IN USAGE UsagePage,
  612. IN USHORT LinkCollection,
  613. IN USAGE Usage,
  614. OUT PULONG UsageValue,
  615. IN PHIDP_PREPARSED_DATA PreparsedData,
  616. IN PCHAR Report,
  617. IN ULONG ReportLength
  618. );
  619. ULONG (__stdcall *_HidP_MaxUsageListLength)
  620. (
  621. IN HIDP_REPORT_TYPE ReportType,
  622. IN USAGE UsagePage,
  623. IN PHIDP_PREPARSED_DATA PreparsedData
  624. );
  625. NTSTATUS (__stdcall *_HidP_GetSpecificButtonCaps)
  626. (
  627. IN HIDP_REPORT_TYPE ReportType,
  628. IN USAGE UsagePage, // Optional (0 => ignore)
  629. IN USHORT LinkCollection, // Optional (0 => ignore)
  630. IN USAGE Usage, // Optional (0 => ignore)
  631. OUT PHIDP_BUTTON_CAPS ButtonCaps,
  632. IN OUT PUSHORT ButtonCapsLength,
  633. IN PHIDP_PREPARSED_DATA PreparsedData
  634. );
  635. };
  636. } HIDDLL, *PHIDDLL;
  637. extern HIDDLL g_hiddll;
  638. #undef HidD_GetHidGuid
  639. #undef HidD_GetPreparsedData
  640. #undef HidD_FreePreparsedData
  641. #undef HidD_FlushQueue
  642. #undef HidD_GetAttributes
  643. #undef HidD_GetFeature
  644. #undef HidD_SetFeature
  645. #undef HidD_GetProductString
  646. #undef HidD_GetInputReport
  647. #undef HidP_GetCaps
  648. #undef HidP_GetButtonCaps
  649. #undef HidP_GetValueCaps
  650. #undef HidP_GetLinkCollectionNodes
  651. #undef HidP_MaxDataListLength
  652. #undef HidP_GetUsagesEx
  653. #undef HidP_GetScaledUsageValue
  654. #undef HidP_GetData
  655. #undef HidP_SetData
  656. #undef HidP_GetUsageValue
  657. #undef HidP_MaxUsageListLength
  658. #undef HidP_GetSpecificButtonCaps
  659. #define HidD_GetHidGuid \
  660. g_hiddll._HidD_GetHidGuid
  661. #define HidD_GetPreparsedData \
  662. g_hiddll._HidD_GetPreparsedData
  663. #define HidD_FreePreparsedData \
  664. g_hiddll._HidD_FreePreparsedData
  665. #define HidD_FlushQueue \
  666. g_hiddll._HidD_FlushQueue
  667. #define HidD_GetAttributes \
  668. g_hiddll._HidD_GetAttributes \
  669. #define HidD_GetFeature \
  670. g_hiddll._HidD_GetFeature \
  671. #define HidD_SetFeature \
  672. g_hiddll._HidD_SetFeature \
  673. #define HidD_GetProductString \
  674. g_hiddll._HidD_GetProductString \
  675. #define HidD_GetInputReport \
  676. g_hiddll._HidD_GetInputReport \
  677. #define HidP_GetCaps \
  678. g_hiddll._HidP_GetCaps
  679. #define HidP_GetButtonCaps \
  680. g_hiddll._HidP_GetButtonCaps
  681. #define HidP_GetValueCaps \
  682. g_hiddll._HidP_GetValueCaps
  683. #define HidP_GetLinkCollectionNodes \
  684. g_hiddll._HidP_GetLinkCollectionNodes
  685. #define HidP_MaxDataListLength \
  686. g_hiddll._HidP_MaxDataListLength \
  687. #define HidP_GetUsagesEx \
  688. g_hiddll._HidP_GetUsagesEx \
  689. #define HidP_GetScaledUsageValue \
  690. g_hiddll._HidP_GetScaledUsageValue \
  691. #define HidP_GetData \
  692. g_hiddll._HidP_GetData \
  693. #define HidP_SetData \
  694. g_hiddll._HidP_SetData \
  695. #define HidP_GetUsageValue \
  696. g_hiddll._HidP_GetUsageValue \
  697. #define HidP_MaxUsageListLength \
  698. g_hiddll._HidP_MaxUsageListLength \
  699. #define HidP_GetSpecificButtonCaps \
  700. g_hiddll._HidP_GetSpecificButtonCaps \
  701. /*****************************************************************************
  702. *
  703. * WINMMDLL
  704. *
  705. * Note that this must match the WINMM section in diextdll.c
  706. *
  707. *****************************************************************************/
  708. typedef union WINMMDLL
  709. {
  710. MANUALIMPORT rgmi[4]; /* number of functions we import */
  711. struct
  712. {
  713. MMRESULT ( WINAPI * _joyGetDevCaps)
  714. (
  715. IN UINT uJoyID,
  716. OUT LPJOYCAPS pjc,
  717. IN UINT cbjc
  718. );
  719. MMRESULT ( WINAPI * _joyGetPosEx)
  720. (
  721. IN UINT uJoyID,
  722. OUT LPJOYINFOEX pji
  723. );
  724. MMRESULT ( WINAPI * _joyGetPos)
  725. (
  726. IN UINT uJoyID,
  727. OUT LPJOYINFO pji
  728. );
  729. UINT ( WINAPI * _joyConfigChanged)
  730. (
  731. IN DWORD dwFlags
  732. );
  733. };
  734. } WINMMDLL, *PWINMMDLL;
  735. extern WINMMDLL g_winmmdll;
  736. #undef joyGetDevCaps
  737. #undef joyGetPosEx
  738. #undef joyGetPos
  739. #undef joyConfigChanged
  740. #define joyGetDevCaps \
  741. g_winmmdll._joyGetDevCaps
  742. #define joyGetPosEx \
  743. g_winmmdll._joyGetPosEx
  744. #define joyGetPos \
  745. g_winmmdll._joyGetPos
  746. #define joyConfigChanged \
  747. g_winmmdll._joyConfigChanged
  748. /*****************************************************************************
  749. *
  750. * USER32
  751. *
  752. * Note that this must match the USER32 section in diextdll.c
  753. *
  754. *****************************************************************************/
  755. #ifdef USE_WM_INPUT
  756. typedef union USER32
  757. {
  758. MANUALIMPORT rgmi[2]; /* number of functions we import */
  759. struct
  760. {
  761. BOOL ( WINAPI * _RegisterRawInputDevices)
  762. (
  763. PCRAWINPUTDEVICE pRawInputDevices,
  764. UINT uiNumDevices,
  765. UINT cbSize
  766. );
  767. UINT ( WINAPI * _GetRawInputData)
  768. (
  769. HRAWINPUT hRawInput,
  770. UINT uiCommand,
  771. LPVOID pData,
  772. PUINT pcbSize,
  773. UINT cbSizeHeader
  774. );
  775. };
  776. } USER32, *PUSER32;
  777. extern USER32 g_user32;
  778. #undef RegisterRawInputDevices
  779. #undef GetRawInputData
  780. #define RegisterRawInputDevices \
  781. g_user32._RegisterRawInputDevices
  782. #define GetRawInputData \
  783. g_user32._GetRawInputData
  784. #endif
  785. /*****************************************************************************
  786. *
  787. * Dummy functions
  788. *
  789. * These functions are used only when some DLLs can't be loaded.
  790. *
  791. *****************************************************************************/
  792. //cfgmgr32.dll
  793. CONFIGRET WINAPI DIDummy_CM_Get_Child
  794. (
  795. OUT PDEVINST pdnDevInst,
  796. IN DEVINST dnDevInst,
  797. IN ULONG ulFlags
  798. );
  799. CONFIGRET WINAPI DIDummy_CM_Get_Sibling
  800. (
  801. OUT PDEVINST pdnDevInst,
  802. IN DEVINST DevInst,
  803. IN ULONG ulFlags
  804. );
  805. CONFIGRET WINAPI DIDummy_CM_Get_Parent
  806. (
  807. OUT PDEVINST pdnDevInst,
  808. IN DEVINST dnDevInst,
  809. IN ULONG ulFlags
  810. );
  811. CONFIGRET WINAPI DIDummy_CM_Get_DevNode_Registry_Property
  812. (
  813. IN DEVINST dnDevInst,
  814. IN ULONG ulProperty,
  815. OUT PULONG pulRegDataType, OPTIONAL
  816. OUT PVOID Buffer, OPTIONAL
  817. IN OUT PULONG pulLength,
  818. IN ULONG ulFlags
  819. );
  820. CONFIGRET WINAPI DIDummy_CM_Set_DevNode_Registry_Property
  821. (
  822. IN DEVINST dnDevInst,
  823. IN ULONG ulProperty,
  824. IN PVOID Buffer, OPTIONAL
  825. IN ULONG ulLength,
  826. IN ULONG ulFlags
  827. );
  828. CONFIGRET WINAPI DIDummy_CM_Get_Device_ID
  829. (
  830. IN DEVINST dnDevInst,
  831. OUT PTCHAR Buffer,
  832. IN ULONG BufferLen,
  833. IN ULONG ulFlags
  834. );
  835. //Setupapi.dll
  836. HDEVINFO WINAPI DIDummy_SetupDiGetClassDevs
  837. (
  838. IN LPGUID ClassGuid, OPTIONAL
  839. IN LPCTSTR Enumerator, OPTIONAL
  840. IN HWND hwndParent, OPTIONAL
  841. IN DWORD Flags
  842. );
  843. BOOL WINAPI DIDummy_SetupDiDestroyDeviceInfoList
  844. (
  845. IN HDEVINFO DeviceInfoSet
  846. );
  847. BOOL WINAPI DIDummy_SetupDiGetDeviceInterfaceDetail
  848. (
  849. IN HDEVINFO DeviceInfoSet,
  850. IN PSP_DEVICE_INTERFACE_DATA pdid,
  851. OUT PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd, OPTIONAL
  852. IN DWORD cbDidd,
  853. OUT PDWORD RequiredSize, OPTIONAL
  854. OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  855. );
  856. BOOL WINAPI DIDummy_SetupDiEnumDeviceInterfaces
  857. (
  858. IN HDEVINFO DeviceInfoSet,
  859. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  860. IN LPGUID InterfaceClassGuid,
  861. IN DWORD MemberIndex,
  862. OUT PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData
  863. );
  864. HKEY WINAPI DIDummy_SetupDiCreateDeviceInterfaceRegKey
  865. (
  866. IN HDEVINFO hdev,
  867. IN PSP_DEVICE_INTERFACE_DATA pdid,
  868. IN DWORD Reserved,
  869. IN REGSAM samDesired,
  870. IN HINF InfHandle, OPTIONAL
  871. IN PCSTR InfSectionName OPTIONAL
  872. );
  873. BOOL WINAPI DIDummy_SetupDiCallClassInstaller
  874. (
  875. IN DI_FUNCTION InstallFunction,
  876. IN HDEVINFO DeviceInfoSet,
  877. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  878. );
  879. BOOL WINAPI DIDummy_SetupDiGetDeviceRegistryProperty
  880. (
  881. IN HDEVINFO DeviceInfoSet,
  882. IN PSP_DEVINFO_DATA DeviceInfoData,
  883. IN DWORD Property,
  884. OUT PDWORD PropertyRegDataType, OPTIONAL
  885. OUT PBYTE PropertyBuffer,
  886. IN DWORD PropertyBufferSize,
  887. OUT PDWORD RequiredSize OPTIONAL
  888. );
  889. BOOL WINAPI DIDummy_SetupDiSetDeviceRegistryProperty
  890. (
  891. IN HDEVINFO DeviceInfoSet,
  892. IN OUT PSP_DEVINFO_DATA DeviceInfoData,
  893. IN DWORD Property,
  894. IN CONST BYTE* PropertyBuffer,
  895. IN DWORD PropertyBufferSize
  896. );
  897. BOOL WINAPI DIDummy_SetupDiGetDeviceInstanceId
  898. (
  899. IN HDEVINFO DeviceInfoSet,
  900. IN PSP_DEVINFO_DATA DeviceInfoData,
  901. OUT PTSTR DeviceInstanceId,
  902. IN DWORD DeviceInstanceIdSize,
  903. OUT PDWORD RequiredSize OPTIONAL
  904. );
  905. BOOL WINAPI DIDummy_SetupDiOpenDeviceInfo
  906. (
  907. IN HDEVINFO DeviceInfoSet,
  908. IN LPCTSTR DeviceInstanceId,
  909. IN HWND hwndParent, OPTIONAL
  910. IN DWORD OpenFlags,
  911. OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  912. );
  913. HDEVINFO WINAPI DIDummy_SetupDiCreateDeviceInfoList
  914. (
  915. IN LPGUID ClassGuid, OPTIONAL
  916. IN HWND hwndParent OPTIONAL
  917. );
  918. HKEY WINAPI DIDummy_SetupDiOpenDevRegKey
  919. (
  920. IN HDEVINFO DeviceInfoSet,
  921. IN PSP_DEVINFO_DATA DeviceInfoData,
  922. IN DWORD Scope,
  923. IN DWORD HwProfile,
  924. IN DWORD KeyType,
  925. IN REGSAM samDesired
  926. );
  927. // hid.dll
  928. void __stdcall DIDummy_HidD_GetHidGuid
  929. (
  930. OUT LPGUID HidGuid
  931. );
  932. BOOLEAN __stdcall DIDummy_HidD_GetPreparsedData
  933. (
  934. IN HANDLE HidDeviceObject,
  935. OUT PHIDP_PREPARSED_DATA * PreparsedData
  936. );
  937. BOOLEAN __stdcall DIDummy_HidD_FreePreparsedData
  938. (
  939. IN PHIDP_PREPARSED_DATA PreparsedData
  940. );
  941. BOOLEAN __stdcall DIDummy_HidD_FlushQueue
  942. (
  943. IN HANDLE HidDeviceObject
  944. );
  945. BOOLEAN __stdcall DIDummy_HidD_GetAttributes
  946. (
  947. IN HANDLE HidDeviceObject,
  948. OUT PHIDD_ATTRIBUTES Attributes
  949. );
  950. BOOLEAN __stdcall DIDummy_HidD_GetFeature
  951. (
  952. IN HANDLE HidDeviceObject,
  953. OUT PVOID ReportBuffer,
  954. IN ULONG ReportBufferLength
  955. );
  956. BOOLEAN __stdcall DIDummy_HidD_SetFeature
  957. (
  958. IN HANDLE HidDeviceObject,
  959. IN PVOID ReportBuffer,
  960. IN ULONG ReportBufferLength
  961. );
  962. BOOLEAN __stdcall DIDummy_HidD_GetProductString
  963. (
  964. IN HANDLE HidDeviceObject,
  965. OUT PVOID Buffer,
  966. IN ULONG BufferLength
  967. );
  968. BOOLEAN __stdcall DIDummy_HidD_GetInputReport
  969. (
  970. IN HANDLE HidDeviceObject,
  971. OUT PVOID ReportBuffer,
  972. IN ULONG ReportBufferLength
  973. );
  974. NTSTATUS __stdcall DIDummy_HidP_GetCaps
  975. (
  976. IN PHIDP_PREPARSED_DATA PreparsedData,
  977. OUT PHIDP_CAPS Capabilities
  978. );
  979. NTSTATUS __stdcall DIDummy_HidP_GetButtonCaps
  980. (
  981. IN HIDP_REPORT_TYPE ReportType,
  982. OUT PHIDP_BUTTON_CAPS ButtonCaps,
  983. IN OUT PUSHORT ButtonCapsLength,
  984. IN PHIDP_PREPARSED_DATA PreparsedData
  985. );
  986. NTSTATUS __stdcall DIDummy_HidP_GetValueCaps
  987. (
  988. IN HIDP_REPORT_TYPE ReportType,
  989. OUT PHIDP_VALUE_CAPS ValueCaps,
  990. IN OUT PUSHORT ValueCapsLength,
  991. IN PHIDP_PREPARSED_DATA PreparsedData
  992. );
  993. NTSTATUS __stdcall DIDummy_HidP_GetLinkCollectionNodes
  994. (
  995. OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
  996. IN OUT PULONG LinkCollectionNodesLength,
  997. IN PHIDP_PREPARSED_DATA PreparsedData
  998. );
  999. ULONG __stdcall DIDummy_HidP_MaxDataListLength
  1000. (
  1001. IN HIDP_REPORT_TYPE ReportType,
  1002. IN PHIDP_PREPARSED_DATA PreparsedData
  1003. );
  1004. NTSTATUS __stdcall DIDummy_HidP_GetUsagesEx //unused
  1005. (
  1006. IN HIDP_REPORT_TYPE ReportType,
  1007. IN USHORT LinkCollection,
  1008. OUT PUSAGE_AND_PAGE ButtonList,
  1009. IN OUT ULONG * UsageLength,
  1010. IN PHIDP_PREPARSED_DATA PreparsedData,
  1011. IN PCHAR Report,
  1012. IN ULONG ReportLength
  1013. );
  1014. NTSTATUS __stdcall DIDummy_HidP_GetScaledUsageValue //unused
  1015. (
  1016. IN HIDP_REPORT_TYPE ReportType,
  1017. IN USAGE UsagePage,
  1018. IN USHORT LinkCollection,
  1019. IN USAGE Usage,
  1020. OUT PLONG UsageValue,
  1021. IN PHIDP_PREPARSED_DATA PreparsedData,
  1022. IN PCHAR Report,
  1023. IN ULONG ReportLength
  1024. );
  1025. NTSTATUS __stdcall DIDummy_HidP_GetData
  1026. (
  1027. IN HIDP_REPORT_TYPE ReportType,
  1028. OUT PHIDP_DATA DataList,
  1029. IN OUT PULONG DataLength,
  1030. IN PHIDP_PREPARSED_DATA PreparsedData,
  1031. IN PCHAR Report,
  1032. IN ULONG ReportLength
  1033. );
  1034. NTSTATUS __stdcall DIDummy_HidP_SetData
  1035. (
  1036. IN HIDP_REPORT_TYPE ReportType,
  1037. IN PHIDP_DATA DataList,
  1038. IN OUT PULONG DataLength,
  1039. IN PHIDP_PREPARSED_DATA PreparsedData,
  1040. IN OUT PCHAR Report,
  1041. IN ULONG ReportLength
  1042. );
  1043. NTSTATUS __stdcall DIDummy_HidP_GetUsageValue
  1044. (
  1045. IN HIDP_REPORT_TYPE ReportType,
  1046. IN USAGE UsagePage,
  1047. IN USHORT LinkCollection,
  1048. IN USAGE Usage,
  1049. OUT PULONG UsageValue,
  1050. IN PHIDP_PREPARSED_DATA PreparsedData,
  1051. IN PCHAR Report,
  1052. IN ULONG ReportLength
  1053. );
  1054. ULONG __stdcall DIDummy_HidP_MaxUsageListLength
  1055. (
  1056. IN HIDP_REPORT_TYPE ReportType,
  1057. IN USAGE UsagePage,
  1058. IN PHIDP_PREPARSED_DATA PreparsedData
  1059. );
  1060. NTSTATUS __stdcall DIDummy_HidP_GetSpecificButtonCaps
  1061. (
  1062. IN HIDP_REPORT_TYPE ReportType,
  1063. IN USAGE UsagePage,
  1064. IN USHORT LinkCollection,
  1065. IN USAGE Usage,
  1066. OUT PHIDP_BUTTON_CAPS ButtonCaps,
  1067. IN OUT PUSHORT ButtonCapsLength,
  1068. IN PHIDP_PREPARSED_DATA PreparsedData
  1069. );
  1070. NTSTATUS __stdcall DIDummy_HidP_TranslateUsagesToI8042ScanCodes
  1071. (
  1072. IN PUSAGE ChangedUsageList, // Those usages that changed
  1073. IN ULONG UsageListLength,
  1074. IN HIDP_KEYBOARD_DIRECTION KeyAction,
  1075. IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
  1076. IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
  1077. IN PVOID InsertCodesContext
  1078. );
  1079. // winmm.dll
  1080. MMRESULT WINAPI DIDummy_joyGetDevCaps
  1081. (
  1082. IN UINT uJoyID,
  1083. OUT LPJOYCAPS pjc,
  1084. IN UINT cbjc
  1085. );
  1086. MMRESULT WINAPI DIDummy_joyGetPosEx
  1087. (
  1088. IN UINT uJoyID,
  1089. OUT LPJOYINFOEX pji
  1090. );
  1091. MMRESULT WINAPI DIDummy_joyGetPos
  1092. (
  1093. IN UINT uJoyID,
  1094. OUT LPJOYINFO pji
  1095. );
  1096. UINT WINAPI DIDummy_joyConfigChanged
  1097. (
  1098. IN DWORD dwFlags
  1099. );
  1100. MMRESULT WINAPI DIDummy_mmioClose
  1101. (
  1102. IN HMMIO hmmio,
  1103. IN UINT fuClose
  1104. );
  1105. HMMIO WINAPI DIDummy_mmioOpenA
  1106. (
  1107. IN OUT LPSTR pszFileName,
  1108. IN OUT LPMMIOINFO pmmioinfo,
  1109. IN DWORD fdwOpen
  1110. );
  1111. MMRESULT WINAPI DIDummy_mmioDescend
  1112. (
  1113. IN HMMIO hmmio,
  1114. IN OUT LPMMCKINFO pmmcki,
  1115. IN const MMCKINFO FAR* pmmckiParent,
  1116. IN UINT fuDescend
  1117. );
  1118. MMRESULT WINAPI DIDummy_mmioCreateChunk
  1119. (
  1120. IN HMMIO hmmio,
  1121. IN LPMMCKINFO pmmcki,
  1122. IN UINT fuCreate
  1123. );
  1124. LONG WINAPI DIDummy_mmioRead
  1125. (
  1126. IN HMMIO hmmio,
  1127. OUT HPSTR pch,
  1128. IN LONG cch
  1129. );
  1130. LONG WINAPI DIDummy_mmioWrite
  1131. (
  1132. IN HMMIO hmmio,
  1133. IN const char _huge* pch,
  1134. IN LONG cch
  1135. );
  1136. MMRESULT WINAPI DIDummy_mmioAscend
  1137. (
  1138. IN HMMIO hmmio,
  1139. IN LPMMCKINFO pmmcki,
  1140. IN UINT fuAscend
  1141. );
  1142. // user32.dll
  1143. #ifdef USE_WM_INPUT
  1144. BOOL WINAPI DIDummy_RegisterRawInputDevices
  1145. (
  1146. PCRAWINPUTDEVICE pRawInputDevices,
  1147. UINT uiNumDevices,
  1148. UINT cbSize
  1149. );
  1150. UINT WINAPI DIDummy_GetRawInputData
  1151. (
  1152. HRAWINPUT hRawInput,
  1153. UINT uiCommand,
  1154. LPVOID pData,
  1155. PUINT pcbSize,
  1156. UINT cbSizeHeader
  1157. );
  1158. #endif // #ifdef USE_WM_INPUT
  1159. #endif /* STATIC_DLLUSAGE */
  1160. /*****************************************************************************
  1161. *
  1162. * dihidenm.c - HID enumeration functions.
  1163. *
  1164. *****************************************************************************/
  1165. extern TCHAR g_tszIdLastRemoved[MAX_PATH]; //in dihidenm.c
  1166. extern DWORD g_tmLastRemoved; //in dihinenm.c
  1167. STDMETHODIMP hresFindHIDInstanceGUID(PCGUID pguid, CREATEDCB *pcdcb);
  1168. STDMETHODIMP hresFindHIDDeviceInterface(LPCTSTR ptszPath, LPGUID pguidOut);
  1169. PHIDDEVICEINFO EXTERNAL phdiFindHIDInstanceGUID(PCGUID pguid);
  1170. PHIDDEVICEINFO EXTERNAL phdiFindHIDDeviceInterface(LPCTSTR ptszPath);
  1171. void EXTERNAL DIHid_BuildHidList(BOOL fForce);
  1172. void EXTERNAL DIHid_EmptyHidList(void);
  1173. BOOL EXTERNAL
  1174. DIHid_GetDevicePath(HDEVINFO hdev,
  1175. PSP_DEVICE_INTERFACE_DATA pdid,
  1176. PSP_DEVICE_INTERFACE_DETAIL_DATA *ppdidd,
  1177. PSP_DEVINFO_DATA pdinf);
  1178. BOOL EXTERNAL
  1179. DIHid_GetDeviceInstanceId(HDEVINFO hdev,
  1180. PSP_DEVINFO_DATA pdinf,
  1181. LPTSTR *pptszId);
  1182. BOOL EXTERNAL
  1183. DIHid_GetInstanceGUID(HKEY hk, LPGUID pguid);
  1184. /*****************************************************************************
  1185. *
  1186. * diguid.c - GUID generation
  1187. *
  1188. *****************************************************************************/
  1189. void EXTERNAL DICreateGuid(LPGUID pguid);
  1190. void EXTERNAL DICreateStaticGuid(LPGUID pguid, WORD pid, WORD vid);
  1191. /*****************************************************************************
  1192. *
  1193. * dihid.c
  1194. *
  1195. *****************************************************************************/
  1196. /*****************************************************************************
  1197. *
  1198. * We will just use the HID item index as our DirectInput
  1199. * internal ID number, which is in turn an index into the
  1200. * <t DIOBJECTDATAFORMAT> array.
  1201. *
  1202. * Keyboard support requires a translation table.
  1203. * Other devices also a translation table so that the external
  1204. * instance numbers can be made compatible with legacy ones and
  1205. * so that secondary aliases can be separated from primary ones.
  1206. *
  1207. * Since HID restarts the item index counter at zero for
  1208. * each of input, feature, and output, we need to do some
  1209. * adjustment so there aren't any collisions. So we
  1210. * shift the features to start after the inputs, and the
  1211. * outputs to start after the features.
  1212. *
  1213. * The <e CHid.rgdwBase> array contains the amount by which
  1214. * each group of HID item indexes has been shifted.
  1215. *
  1216. *****************************************************************************/
  1217. /*****************************************************************************
  1218. *
  1219. * @doc INTERNAL
  1220. *
  1221. * @func BOOL | HidP_IsValidReportType |
  1222. *
  1223. * For debugging only. Check if a value is a valid
  1224. * <t HIDP_REPORT_TYPE>.
  1225. *
  1226. * Note that we also create a "fake" report type in which
  1227. * to record our collections.
  1228. *
  1229. * @field HIDP_REPORT_TYPE | type |
  1230. *
  1231. * One of the values
  1232. * <c HidP_Input>,
  1233. * <c HidP_Output>,
  1234. * or
  1235. * <c HidP_Feature>. Hopefully.
  1236. *
  1237. *****************************************************************************/
  1238. #define HidP_Max (HidP_Feature + 1)
  1239. #define HidP_Coll HidP_Max
  1240. #define HidP_MaxColl (HidP_Coll + 1)
  1241. BOOL INLINE
  1242. HidP_IsValidReportType(HIDP_REPORT_TYPE type)
  1243. {
  1244. CAssertF(HidP_Input == 0);
  1245. CAssertF(HidP_Output == 1);
  1246. CAssertF(HidP_Feature == 2);
  1247. return type < HidP_Max;
  1248. }
  1249. /*****************************************************************************
  1250. *
  1251. * There are three (overlapping) classes of HID reports.
  1252. *
  1253. * InputLike - HidP_Input and HidP_Feature
  1254. * OutputLike - HidP_Output and HidP_Feature
  1255. * NothingLike - HidP_Coll
  1256. *
  1257. *****************************************************************************/
  1258. BOOL INLINE
  1259. HidP_IsInputLike(HIDP_REPORT_TYPE type)
  1260. {
  1261. return type == HidP_Input || type == HidP_Feature;
  1262. }
  1263. BOOL INLINE
  1264. HidP_IsOutputLike(HIDP_REPORT_TYPE type)
  1265. {
  1266. return type == HidP_Output || type == HidP_Feature;
  1267. }
  1268. /*****************************************************************************
  1269. *
  1270. * @doc INTERNAL
  1271. *
  1272. * @struct LMINMAX |
  1273. *
  1274. * Min and max, that's all. These are kept in structures
  1275. * to make logical-to-physical and physical-to-logical
  1276. * translations less gross.
  1277. *
  1278. * @field LONG | Min |
  1279. *
  1280. * The minimum value.
  1281. *
  1282. * @field LONG | Max |
  1283. *
  1284. * The maximum value.
  1285. *
  1286. *****************************************************************************/
  1287. typedef struct LMINMAX
  1288. {
  1289. LONG Min;
  1290. LONG Max;
  1291. } LMINMAX, *PLMINMAX;
  1292. typedef const LMINMAX *PCLMINMAX;
  1293. /*****************************************************************************
  1294. *
  1295. * @doc INTERNAL
  1296. *
  1297. * @struct HIDGROUPCAPS |
  1298. *
  1299. * This structure unifies the various HID caps structures
  1300. * <t HIDP_BUTTON_CAPS> and
  1301. * <t HIDP_VALUE_CAPS>.
  1302. *
  1303. * @field HIDP_REPORT_TYPE | type |
  1304. *
  1305. * One of the values
  1306. * <c HidP_Input>,
  1307. * <c HidP_Output>,
  1308. * or
  1309. * <c HidP_Feature>.
  1310. *
  1311. * @field UINT | cObj |
  1312. *
  1313. * Number of objects in this group.
  1314. *
  1315. * @field USAGE | UsagePage |
  1316. *
  1317. * Usage page for all usages in the group.
  1318. *
  1319. * @field USAGE | UsageMin |
  1320. *
  1321. * First usage described by this group. The remaining
  1322. * items are numbered consecutively starting from
  1323. * this value.
  1324. *
  1325. * @field USHORT | StringMin |
  1326. *
  1327. * String for first usage described by this group.
  1328. * The remaining strings are numbered consecutively
  1329. * starting from this value, unless the string maximum
  1330. * is reached, in which case all subsequent objects
  1331. * share that last string.
  1332. *
  1333. * @field USHORT | StringMax |
  1334. *
  1335. * Last string.
  1336. *
  1337. * @field USHORT | DesignatorMin |
  1338. *
  1339. * Designator for first usage described by this group.
  1340. * The remaining designators are numbered consecutively
  1341. * starting from this value, unless the designator maximum
  1342. * is reached, in which case all subsequent objects
  1343. * share that last designator.
  1344. *
  1345. * @field USHORT | DesignatorMax |
  1346. *
  1347. * Last designator.
  1348. *
  1349. * @field USHORT | DataIndexMin |
  1350. *
  1351. * Data index for the first usage described by this group.
  1352. * The remaining data index values are numbered consecutively
  1353. * starting from this value.
  1354. *
  1355. * @field USHORT | usGranularity |
  1356. *
  1357. * If object is a POV or wheel, then contains device granularity.
  1358. *
  1359. * @field LONG | lMask |
  1360. *
  1361. * Mask bits used for sign extension. For example, if the
  1362. * value is 8-bits, the mask will be 0xFFFFFF80, indicating
  1363. * that bit 7 (0x00000080) is extended to fill the remainder
  1364. * of the value.
  1365. *
  1366. * This field is used only by values.
  1367. *
  1368. * @field USHORT | BitSize |
  1369. *
  1370. * Number of bits devoted to this value, including the sign bit.
  1371. *
  1372. * ISSUE-2001/03/29-timgill structure field probably not used anywhere.
  1373. *
  1374. * @field USHORT | LinkCollection |
  1375. *
  1376. * HID link collection number.
  1377. *
  1378. * @field LMINMAX | Logical |
  1379. *
  1380. * Logical minimum and maximum values.
  1381. * These are the extremes of raw values
  1382. * that can validly be received from the device.
  1383. *
  1384. * This field is used only by values.
  1385. *
  1386. * @field LMINMAX | Physical |
  1387. *
  1388. * Physical minimum and maximum values.
  1389. * This is the "actual" value
  1390. * that the logical minimum and maximum value corresponds to.
  1391. *
  1392. * This field is used only by values, and is consulted
  1393. * only when converting between DirectInput calibration
  1394. * (which uses logical values) and VJOYD calibration
  1395. * (which uses physical values).
  1396. *
  1397. * @field LONG | Null |
  1398. *
  1399. * The null value to be used for output.
  1400. *
  1401. * This field is used only by values.
  1402. *
  1403. * @field ULONG | Units |
  1404. *
  1405. * The HID units descriptor, if any.
  1406. *
  1407. * @field WORD | Exponent |
  1408. *
  1409. * The HID unit exponent, if any.
  1410. *
  1411. * @field WORD | wReportId |
  1412. *
  1413. * HID report Id
  1414. *
  1415. * @field BOOL | IsAbsolute |
  1416. *
  1417. * Nonzero if the group describes absolute axes.
  1418. *
  1419. * This field is used only by values.
  1420. *
  1421. * @field BOOL | IsValue |
  1422. *
  1423. * Nonzero if the group describes a HID value.
  1424. *
  1425. * Note that an analog pushbutton is reported by
  1426. * DirectInput as a <c DIDFT_BUTTON>, but is
  1427. * handled internally as a HID value.
  1428. *
  1429. * @field BOOL | IsAlias |
  1430. *
  1431. * Nonzero if the group describes an alias.
  1432. *
  1433. * @field BOOL | IsSigned |
  1434. *
  1435. * The return data is signed.
  1436. *
  1437. * @field BOOL | IsPolledPOV |
  1438. *
  1439. * Nonzero if the axis is a polled POV.
  1440. *
  1441. * @devnote New for DX6.1a
  1442. *
  1443. *****************************************************************************/
  1444. #define HIDGROUPCAPS_SIGNATURE 0x47444948 /* HIDG */
  1445. typedef struct HIDGROUPCAPS
  1446. {
  1447. D(DWORD dwSignature;)
  1448. HIDP_REPORT_TYPE type;
  1449. UINT cObj;
  1450. USAGE UsagePage;
  1451. USAGE UsageMin;
  1452. USHORT StringMin, StringMax;
  1453. USHORT DesignatorMin, DesignatorMax;
  1454. USHORT DataIndexMin;
  1455. USHORT usGranularity;
  1456. LONG lMask;
  1457. USHORT BitSize;
  1458. USHORT LinkCollection;
  1459. LMINMAX Logical;
  1460. LMINMAX Physical;
  1461. LONG Null;
  1462. ULONG Units;
  1463. WORD Exponent;
  1464. WORD wReportId;
  1465. BOOL fReportDisabled;
  1466. BOOL Reserved;
  1467. BOOL IsAbsolute;
  1468. BOOL IsValue;
  1469. BOOL IsAlias;
  1470. BOOL IsSigned;
  1471. #ifdef WINNT
  1472. BOOL IsPolledPOV;
  1473. #endif
  1474. } HIDGROUPCAPS, *PHIDGROUPCAPS;
  1475. /*****************************************************************************
  1476. *
  1477. * @doc INTERNAL
  1478. *
  1479. * @struct HIDOBJCAPS |
  1480. *
  1481. * This structure contains various cached pointers for each
  1482. * object on the device, allowing us to get at things like
  1483. * the group caps and the calibration information.
  1484. *
  1485. * @field PHIDGROUPCAPS | pcaps |
  1486. *
  1487. * The <t PHIDGROUPCAPS> for the group the object belongs to.
  1488. *
  1489. * @field PJOYRANGECONVERT | pjrc |
  1490. *
  1491. * If non-NULL, then points to the range conversion information
  1492. * for the object.
  1493. *
  1494. * @field int | idata |
  1495. *
  1496. * Index into the <t HIDP_DATA> array for the corresponding
  1497. * output/feature report,
  1498. * or <c -1> if the item is not in the output/feature report.
  1499. *
  1500. *****************************************************************************/
  1501. typedef struct HIDOBJCAPS
  1502. {
  1503. PHIDGROUPCAPS pcaps;
  1504. PJOYRANGECONVERT pjrc;
  1505. int idata;
  1506. } HIDOBJCAPS, *PHIDOBJCAPS;
  1507. /*****************************************************************************
  1508. *
  1509. * @doc INTERNAL
  1510. *
  1511. * @struct HIDREPORTINFO |
  1512. *
  1513. * This structure contains information that is used for
  1514. * parsing HID reports.
  1515. *
  1516. * @field PHIDP_DATA | rgdata |
  1517. *
  1518. * Array used when parsing reports via
  1519. * <f HidP_GetData> or <f HidP_SetData>. This MUST be aligned
  1520. * correctly on some architechtures.
  1521. *
  1522. * @field PV | pvReport |
  1523. *
  1524. * The report itself.
  1525. *
  1526. * @field int | cdataMax |
  1527. *
  1528. * Number of elements in the <e HIDREPORTINFO.rgdata> array.
  1529. *
  1530. * @field int | cdataUsed |
  1531. *
  1532. * Number of elements in the <e HIDREPORTINFO.rgdata> array
  1533. * that are actually in use.
  1534. *
  1535. * @field ULONG | cbReport |
  1536. *
  1537. * Number of bytes in the report.
  1538. *
  1539. * @field BOOL | fNeedClear |
  1540. *
  1541. * Nonzero if the report needs to be zero'd out because we
  1542. * deleted something (most likely a button) from it.
  1543. * The only way to delete an item from a report is to zero
  1544. * out the entire report and then re-add everything back in.
  1545. *
  1546. * @field BOOL | fChanged |
  1547. *
  1548. * Nonzero if an element in the report has changed.
  1549. *
  1550. *****************************************************************************/
  1551. typedef struct HIDREPORTINFO
  1552. {
  1553. PHIDP_DATA rgdata;
  1554. PV pvReport;
  1555. int cdataMax;
  1556. int cdataUsed;
  1557. ULONG cbReport;
  1558. BOOL fNeedClear;
  1559. BOOL fChanged;
  1560. } HIDREPORTINFO, *PHIDREPORTINFO;
  1561. /*****************************************************************************
  1562. *
  1563. * @doc INTERNAL
  1564. *
  1565. * @struct CHid |
  1566. *
  1567. * The <i IDirectInputDeviceCallback> object for HID devices.
  1568. *
  1569. * @field IDirectInputDeviceCalllback | didc |
  1570. *
  1571. * The object (containing vtbl).
  1572. *
  1573. * @field PV | pvGroup2 |
  1574. *
  1575. * Pointer to group 2 memory. This field is a union with the
  1576. * pointer to the first chunk of memory in the second memory group.
  1577. *
  1578. * @field HIDREPORTINFO | hriIn |
  1579. *
  1580. * HID input report parsing and state.
  1581. *
  1582. * This memory is the first chunk of group 2.
  1583. *
  1584. * @field HIDREPORTINFO | hriOut |
  1585. *
  1586. * HID output report parsing and state.
  1587. *
  1588. * @field HIDREPORTINFO | hriFea |
  1589. *
  1590. * HID feature report parsing and state.
  1591. *
  1592. * @field PV | pvPhys |
  1593. *
  1594. * Pointer to physical device status information updated
  1595. * asynchronously by the data collection thread.
  1596. *
  1597. * @field PV | pvStage |
  1598. *
  1599. * Staging area used when the HID report is parsed.
  1600. *
  1601. * This memory is the last chunk of group 2.
  1602. *
  1603. * @field DWORD | cbPhys |
  1604. *
  1605. * Size of the physical device state.
  1606. *
  1607. * @field VXDINSTANCE * | pvi |
  1608. *
  1609. * The DirectInput instance handle.
  1610. *
  1611. * HID devices always run through ring 3, which is misleadingly
  1612. * called "emulation".
  1613. *
  1614. * @field DWORD | dwDevType |
  1615. *
  1616. * Device type code.
  1617. *
  1618. * @field LPTSTR | ptszId |
  1619. *
  1620. * Setupapi device instance ID. Used to obtain things
  1621. * like manufacturer name.
  1622. *
  1623. * @field LPTSTR | ptszPath |
  1624. *
  1625. * Path to the device, for <f CreateFile>.
  1626. *
  1627. * @field UINT | dwAxes |
  1628. *
  1629. * Number of axes on the device.
  1630. *
  1631. * @field UINT | dwButtons |
  1632. *
  1633. * Number of buttons on the device.
  1634. *
  1635. * @field UINT | dwPOVs |
  1636. *
  1637. * Number of POV controllers on the device.
  1638. *
  1639. * @field HANDLE | hdev |
  1640. *
  1641. * Handle to the device itself. This field is valid only
  1642. * while the device is acquired.
  1643. *
  1644. * @field HANDLE | hdevEm |
  1645. *
  1646. * <f DuplicateHandle> of the <e CHid.hdev> which is used
  1647. * by the worker thread. We need to keep this separate from
  1648. * the main copy to avoid race conditions between the main
  1649. * thread and the worker thread.
  1650. *
  1651. * @field HKEY | hkInstType |
  1652. *
  1653. * Per-instance registry key that contains additional configuration
  1654. * information, equivalent to the joystick Type key.
  1655. *
  1656. * @field DWORD | rgdwBase[HidP_MaxColl] |
  1657. *
  1658. * Array of base indices for the three HID usage classes:
  1659. * <c HidP_Input>, <c HidP_Output>, and <c HidP_Feature>.
  1660. * We hide the <c HidP_Collection> base index here, too.
  1661. *
  1662. * @field PHIDOBJCAPS | rghoc |
  1663. *
  1664. * Pointer to array of
  1665. * <t PHIDOBJCAPS>, one for each object on the device,
  1666. * each of which in turn contains info about a single object.
  1667. *
  1668. * This memory is allocated as part of the
  1669. * df.rgodf in the <t DIDATAFORMAT> structure
  1670. * hence should not be freed separately.
  1671. *
  1672. * @field DIDATAFORMAT | df |
  1673. *
  1674. * The dynamically-generated data format based on the
  1675. * usages on the HID device.
  1676. *
  1677. * @field DWORD | ibButtonData |
  1678. *
  1679. * The location of the button data inside the data format.
  1680. *
  1681. * @field DWORD | cbButtonData |
  1682. *
  1683. * The number of bytes of button data inside the data format.
  1684. *
  1685. * @field PBYTE * | rgpbButtonMasks |
  1686. *
  1687. * Pointer to a an array of pointers to byte strings to mask
  1688. * the buttons relevant to a report.
  1689. *
  1690. * @field PHIDP_PREPARSED_DATA | ppd |
  1691. *
  1692. * Preparsed data generated by the HID subsystem.
  1693. *
  1694. * @field PHIDGROUPCAPS | rgcaps |
  1695. *
  1696. * Array of <t HIDGROUPCAPS> structures used to keep
  1697. * track of the various buttons, groups, and collections.
  1698. *
  1699. * @field UINT | ccaps |
  1700. *
  1701. * Number of caps structures in the <e CHid.rgcaps> array.
  1702. *
  1703. * @field HIDP_CAPS | caps |
  1704. *
  1705. * Cached HID caps.
  1706. *
  1707. * @field OVERLAPPED | o |
  1708. *
  1709. * Overlapped I/O structure used by worker thread
  1710. * for reading.
  1711. *
  1712. * @field PJOYRANGECONVERT | pjrcNext |
  1713. *
  1714. * Pointer to the first <t JOYRANGECONVERT> structure
  1715. * (in a preallocated array) which has
  1716. * yet to be used.
  1717. * This structure is used for logical-to-physical
  1718. * range conversion (a.k.a. calibration).
  1719. *
  1720. * This memory is allocated as part of the
  1721. * df.rgodf in the <t DIDATAFORMAT> structure
  1722. * hence should not be freed separately.
  1723. *
  1724. * This field is used during device initialization to
  1725. * parcel out the <t JOYRANGECONVERT>s. Afterwards,
  1726. * the field is <c NULL> if we did not create any
  1727. * conversion structures (hence do not need to subclass
  1728. * the cooperative window to catch recalibrations).
  1729. *
  1730. * @field PINT | rgiobj |
  1731. *
  1732. * This points to an array which maps DirectInput instance
  1733. * values (DIDFT_GETINSTANCE) into object indices.
  1734. *
  1735. * @field PINT | rgipov |
  1736. *
  1737. * If we are not a keyboard, then this is the first element in
  1738. * the above array which maps povs.
  1739. *
  1740. * @field PINT | rgiaxis |
  1741. *
  1742. * If we are not a keyboard, then this is the first element in
  1743. * the above array which maps axes.
  1744. *
  1745. * @field PINT | rgicoll |
  1746. *
  1747. * If we are not a keyboard, then this is the first element in
  1748. * the above array which maps collections.
  1749. * //ISSUE-2001/03/29-timgill need to document keyboard case behaviour
  1750. *
  1751. * @field UINT | uiInstanceMax |
  1752. *
  1753. * The number of elements in the above
  1754. * <f rgiobj> array.
  1755. *
  1756. * @field int | idJoy |
  1757. *
  1758. * Joystick identifier for <f joyGetPosEx> and friends for
  1759. * legacy access.
  1760. *
  1761. * This value starts out as -1, to meant that
  1762. * the corresponding legacy joystick is unknown.
  1763. * If we do something that requires the matched legacy
  1764. * joystick to be found, we check if the current value
  1765. * is still valid. If not (either it is -1 or the cached
  1766. * value is stale), then we go hunt for the correct value.
  1767. *
  1768. * @field HKEY | hkType |
  1769. *
  1770. * The joystick type key opened with <c MAXIMUM_ALLOWED> access.
  1771. * This is not per-instance; multiple instances of the same
  1772. * hardware share this key.
  1773. *
  1774. * @field USHORT | VendorID |
  1775. *
  1776. * HID vendor ID for this device.
  1777. *
  1778. * @field USHORT | ProductID |
  1779. *
  1780. * HID product ID for this device.
  1781. *
  1782. * @field HWND | hwnd |
  1783. *
  1784. * The window which we have subclassed in order to watch
  1785. * for recalibration messages.
  1786. *
  1787. * @field BOOL | IsPolledInput |
  1788. *
  1789. * Nonzero if the device has to be polled for Input data.
  1790. *
  1791. * @field BOOL | fPIDdevice |
  1792. *
  1793. * Set to true if the device is found to support PID.
  1794. *
  1795. * @field WORD | wMaxReportId |
  1796. *
  1797. * The maximum (number) of ReportId used by the HID device.
  1798. *
  1799. * @field PUCHAR | pEnableReportId |
  1800. *
  1801. * Pointer to (wMaxReportId) bytes. If a reportID needs to be
  1802. * polled in order to get features / set Output, then that element
  1803. * of this array is set to 0x1.
  1804. *
  1805. * @field BOOL | fEnableInputReport |
  1806. *
  1807. * True if Input report should be enabled for this device.
  1808. *
  1809. * @field BOOL | fFlags2Checked |
  1810. *
  1811. * True after we check the registry for Flags2 for disabling
  1812. * input reports.
  1813. *
  1814. * @comm
  1815. *
  1816. * It is the caller's responsibility to serialize access as
  1817. * necessary.
  1818. *
  1819. *****************************************************************************/
  1820. typedef struct CHid
  1821. {
  1822. /* Supported interfaces */
  1823. IDirectInputDeviceCallback dcb;
  1824. union
  1825. {
  1826. PV pvGroup2;
  1827. HIDREPORTINFO hriIn;
  1828. };
  1829. HIDREPORTINFO hriOut;
  1830. HIDREPORTINFO hriFea;
  1831. PV pvPhys;
  1832. PV pvStage;
  1833. DWORD cbPhys;
  1834. VXDINSTANCE *pvi;
  1835. DWORD dwDevType;
  1836. UINT dwAxes;
  1837. UINT dwButtons;
  1838. UINT dwPOVs;
  1839. UINT dwCollections;
  1840. HANDLE hdev;
  1841. HANDLE hdevEm;
  1842. DWORD rgdwBase[HidP_MaxColl];
  1843. PHIDOBJCAPS rghoc;
  1844. DIDATAFORMAT df;
  1845. DWORD ibButtonData;
  1846. DWORD cbButtonData;
  1847. PBYTE *rgpbButtonMasks;
  1848. PHIDP_PREPARSED_DATA ppd;
  1849. PHIDGROUPCAPS rgcaps;
  1850. PJOYRANGECONVERT pjrcNext;
  1851. HIDP_CAPS caps;
  1852. ED ed;
  1853. OVERLAPPED o;
  1854. DWORD dwStartRead;
  1855. DWORD dwStopRead;
  1856. PINT rgiobj;
  1857. PINT rgipov;
  1858. PINT rgiaxis;
  1859. PINT rgicoll;
  1860. UINT uiInstanceMax;
  1861. LPTSTR ptszId;
  1862. LPTSTR ptszPath;
  1863. HKEY hkInstType;
  1864. UINT ccaps;
  1865. int idJoy;
  1866. HKEY hkType;
  1867. USHORT VendorID;
  1868. USHORT ProductID;
  1869. #define FAILED_POLL_THRESHOLD (0x4)
  1870. HWND hwnd;
  1871. BOOL IsPolledInput;
  1872. BOOL fPIDdevice;
  1873. WORD wMaxReportId[HidP_Max];
  1874. PUCHAR pEnableReportId[HidP_Max];
  1875. DWORD dwVersion;
  1876. #if (DIRECTINPUT_VERSION > 0x061A)
  1877. DIAPPHACKS diHacks;
  1878. #endif
  1879. BOOL fEnableInputReport;
  1880. BOOL fFlags2Checked;
  1881. } CHid, CHID, *PCHID;
  1882. /*****************************************************************************
  1883. *
  1884. * @doc INTERNAL
  1885. *
  1886. * @func PCHID | pchidFromPo |
  1887. *
  1888. * Given an interior pointer to an <t OVERLAPPED>, retrieve
  1889. * a pointer to the parent <t CHid>.
  1890. *
  1891. * @parm LPOVERLAPPED | po |
  1892. *
  1893. * The pointer to convert.
  1894. *
  1895. *****************************************************************************/
  1896. PCHID INLINE
  1897. pchidFromPo(LPOVERLAPPED po)
  1898. {
  1899. return pvSubPvCb(po, FIELD_OFFSET(CHid, o));
  1900. }
  1901. /*****************************************************************************
  1902. *
  1903. * @doc INTERNAL
  1904. *
  1905. * @func PCHID | pchidFromPed |
  1906. *
  1907. * Given an interior pointer to a <t CEd>, retrieve
  1908. * a pointer to the parent <t CHid>.
  1909. *
  1910. * @parm PED | ped |
  1911. *
  1912. * The pointer to convert.
  1913. *
  1914. *****************************************************************************/
  1915. PCHID INLINE
  1916. pchidFromPed(PED ped)
  1917. {
  1918. return pvSubPvCb(ped, FIELD_OFFSET(CHid, ed));
  1919. }
  1920. /*****************************************************************************
  1921. *
  1922. * @doc INTERNAL
  1923. *
  1924. * @func PCHID | pchidFromPem |
  1925. *
  1926. * Given a <t CEm>, wander back to the
  1927. * <t CHid> that spawned it.
  1928. *
  1929. * @parm PEM | pem |
  1930. *
  1931. * The pointer at which to start.
  1932. *
  1933. *****************************************************************************/
  1934. PCHID INLINE
  1935. pchidFromPem(PEM pem)
  1936. {
  1937. PCHID pchid = pchidFromPed(pem->ped);
  1938. AssertF(pemFromPvi(pchid->pvi) == pem);
  1939. return pchid;
  1940. }
  1941. /*****************************************************************************
  1942. *
  1943. * @doc INTERNAL
  1944. *
  1945. * @method UINT | CHid | ObjFromType |
  1946. *
  1947. * Given a <p dwType>, extract the instance number
  1948. * and (if necessary) convert it to an object index.
  1949. * Note, the instance number will always be of the primary instance
  1950. * not an alias.
  1951. *
  1952. * @parm PCHID | this |
  1953. *
  1954. * HID device object.
  1955. *
  1956. * @parm DWORD | dwType |
  1957. *
  1958. * The type code to convert.
  1959. *
  1960. * @returns
  1961. *
  1962. * The object index, or an out-of-range value.
  1963. *
  1964. *****************************************************************************/
  1965. UINT INLINE
  1966. CHid_ObjFromType(PCHID this, DWORD dwType)
  1967. {
  1968. UINT uiObj = DIDFT_GETINSTANCE(dwType);
  1969. // ISSUE-2001/03/29-timgill Range checks may be unnecessary
  1970. // MarcAnd can we ever get the out of range value?
  1971. // if so, can we really run with it?
  1972. // if not, can these range checks be converted into Asserts?
  1973. /*
  1974. * The range checking makes use of the fact that the translation
  1975. * tables are taken from a contiguous memory allocation and that
  1976. * aliased collections are not distinguished.
  1977. */
  1978. if(this->rgiobj)
  1979. {
  1980. switch( DIDFT_GETTYPE(dwType) )
  1981. {
  1982. case DIDFT_RELAXIS:
  1983. case DIDFT_ABSAXIS:
  1984. if( &this->rgiaxis[uiObj] < this->rgicoll )
  1985. {
  1986. uiObj = this->rgiaxis[uiObj];
  1987. } else
  1988. {
  1989. uiObj = 0xFFFFFFFF;
  1990. }
  1991. break;
  1992. case DIDFT_PSHBUTTON:
  1993. case DIDFT_TGLBUTTON:
  1994. /*
  1995. * If it is keyboard, this->rgiobj == this->rgipov (see CHid_MungeKeyboard).
  1996. * So, we can't test &this->rgiobj[uiObj] < this->rgipov.
  1997. */
  1998. if( (GET_DIDEVICE_TYPE(this->dwDevType) == DIDEVTYPE_KEYBOARD &&
  1999. uiObj < this->uiInstanceMax ) ||
  2000. &this->rgiobj[uiObj] < this->rgipov )
  2001. {
  2002. uiObj = this->rgiobj[uiObj];
  2003. } else
  2004. {
  2005. uiObj = 0xFFFFFFFF;
  2006. }
  2007. break;
  2008. case DIDFT_POV:
  2009. if( &this->rgipov[uiObj] < this->rgiaxis )
  2010. {
  2011. uiObj = this->rgipov[uiObj];
  2012. } else
  2013. {
  2014. uiObj = 0xFFFFFFFF;
  2015. }
  2016. break;
  2017. case (DIDFT_COLLECTION | DIDFT_NODATA):
  2018. if( &this->rgicoll[uiObj] <= &this->rgiobj[this->uiInstanceMax] )
  2019. {
  2020. uiObj = this->rgicoll[uiObj];
  2021. } else
  2022. {
  2023. uiObj = 0xFFFFFFFF;
  2024. }
  2025. break;
  2026. case DIDFT_NODATA:
  2027. /*
  2028. * So far, this TYPE only shows up on Keyboard (HID_USAGE_PAGE_LED).
  2029. */
  2030. if( GET_DIDEVICE_TYPE(this->dwDevType) == DIDEVTYPE_KEYBOARD &&
  2031. uiObj < this->uiInstanceMax )
  2032. {
  2033. uiObj = this->rgiobj[uiObj];
  2034. }
  2035. break;
  2036. default:
  2037. /*
  2038. * Hopefully this is just a vendor defined object but squirt
  2039. * in debug as these may cause problems.
  2040. */
  2041. SquirtSqflPtszV(sqflHidParse | sqflVerbose,
  2042. TEXT("CHid_ObjFromType: dwType 0x%08x not converted"),
  2043. dwType );
  2044. break;
  2045. }
  2046. }
  2047. else
  2048. {
  2049. SquirtSqflPtszV(sqflHidParse | sqflError,
  2050. TEXT("CHid_ObjFromType: Translation array missing") );
  2051. }
  2052. return uiObj;
  2053. }
  2054. LONG EXTERNAL
  2055. CHid_CoordinateTransform(PLMINMAX Dst, PLMINMAX Src, LONG lVal);
  2056. void EXTERNAL
  2057. CHid_UpdateVjoydCalibration(PCHID this, UINT iobj);
  2058. void EXTERNAL
  2059. CHid_UpdateCalibrationFromVjoyd(PCHID this, UINT iobj, LPDIOBJECTCALIBRATION pCal);
  2060. /*****************************************************************************
  2061. *
  2062. * dihidini.c - Device callback initialization stuff
  2063. *
  2064. *****************************************************************************/
  2065. #define INITBUTTONFLAG 0x10000000
  2066. HRESULT EXTERNAL CHid_InitParseData(PCHID this);
  2067. HRESULT EXTERNAL CHid_Init(PCHID this, REFGUID rguid);
  2068. HANDLE EXTERNAL CHid_OpenDevicePath(PCHID this, DWORD dwAttributes );
  2069. UINT EXTERNAL CHid_LoadCalibrations(PCHID this);
  2070. BOOL EXTERNAL CHid_IsPolledDevice( HANDLE hdev );
  2071. /*****************************************************************************
  2072. *
  2073. * dihiddat.c - HID data parsing/management
  2074. *
  2075. *****************************************************************************/
  2076. typedef HRESULT (FAR PASCAL * SENDHIDREPORT)(PCHID this, PHIDREPORTINFO phri);
  2077. void EXTERNAL CHid_ResetDeviceData(PCHID this, PHIDREPORTINFO phri,
  2078. HIDP_REPORT_TYPE type);
  2079. HRESULT EXTERNAL CHid_AddDeviceData(PCHID this, UINT uiObj, DWORD dwData);
  2080. STDMETHODIMP CHid_PrepareDeviceData(PCHID this, PHIDREPORTINFO phri);
  2081. STDMETHODIMP CHid_SendHIDReport(PCHID this, PHIDREPORTINFO phri,
  2082. HIDP_REPORT_TYPE type, SENDHIDREPORT SendHIDReport);
  2083. NTSTATUS EXTERNAL
  2084. CHid_ParseData(PCHID this, HIDP_REPORT_TYPE type, PHIDREPORTINFO phri);
  2085. HRESULT EXTERNAL
  2086. DIHid_GetRegistryProperty(LPTSTR ptszId, DWORD dwProperty, LPDIPROPHEADER pdiph);
  2087. /*****************************************************************************
  2088. *
  2089. * diemh.c - HID "emulation"
  2090. *
  2091. *****************************************************************************/
  2092. void EXTERNAL CEm_HID_Sync(PLLTHREADSTATE plts, PEM pem);
  2093. BOOL EXTERNAL CEm_HID_IssueRead( PCHID pchid );
  2094. #else //No HID Support
  2095. #define DIHid_BuildHidList(fForce)
  2096. #define hresFindHIDDeviceInterface(ptszPath, pguidOut) ( E_FAIL )
  2097. #endif /* _DIHID_H */
  2098. #endif /* HID_SUPPORT */