hidpi.odin 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // +build windows
  2. package sys_windows
  3. import "core:c"
  4. HIDD_CONFIGURATION :: struct {
  5. cookie: PVOID,
  6. size: ULONG,
  7. RingBufferSize: ULONG,
  8. }
  9. PHIDD_CONFIGURATION :: ^HIDD_CONFIGURATION
  10. HIDD_ATTRIBUTES :: struct {
  11. Size: ULONG,
  12. VendorID: USHORT,
  13. ProductID: USHORT,
  14. VersionNumber: USHORT,
  15. }
  16. PHIDD_ATTRIBUTES :: ^HIDD_ATTRIBUTES
  17. HIDP_CAPS :: struct {
  18. Usage: USAGE,
  19. UsagePage: USAGE,
  20. InputReportByteLength: USHORT,
  21. OutputReportByteLength: USHORT,
  22. FeatureReportByteLength: USHORT,
  23. Reserved: [17]USHORT,
  24. NumberLinkCollectionNodes: USHORT,
  25. NumberInputButtonCaps: USHORT,
  26. NumberInputValueCaps: USHORT,
  27. NumberInputDataIndices: USHORT,
  28. NumberOutputButtonCaps: USHORT,
  29. NumberOutputValueCaps: USHORT,
  30. NumberOutputDataIndices: USHORT,
  31. NumberFeatureButtonCaps: USHORT,
  32. NumberFeatureValueCaps: USHORT,
  33. NumberFeatureDataIndices: USHORT,
  34. }
  35. PHIDP_CAPS :: ^HIDP_CAPS
  36. HIDP_BUTTON_CAPS :: struct {
  37. UsagePage: USAGE,
  38. ReportID: UCHAR,
  39. IsAlias: BOOLEAN,
  40. BitField: USHORT,
  41. LinkCollection: USHORT,
  42. LinkUsage: USAGE,
  43. LinkUsagePage: USAGE,
  44. IsRange: BOOLEAN,
  45. IsStringRange: BOOLEAN,
  46. IsDesignatorRange: BOOLEAN,
  47. IsAbsolute: BOOLEAN,
  48. ReportCount: USHORT,
  49. Reserved2: USHORT,
  50. Reserved: [9]ULONG,
  51. using _: struct #raw_union {
  52. Range: struct {
  53. UsageMin: USAGE,
  54. UsageMax: USAGE,
  55. StringMin: USHORT,
  56. StringMax: USHORT,
  57. DesignatorMin: USHORT,
  58. DesignatorMax: USHORT,
  59. DataIndexMin: USHORT,
  60. DataIndexMax: USHORT,
  61. },
  62. NotRange: struct {
  63. Usage: USAGE,
  64. Reserved1: USAGE,
  65. StringIndex: USHORT,
  66. Reserved2: USHORT,
  67. DesignatorIndex: USHORT,
  68. Reserved3: USHORT,
  69. DataIndex: USHORT,
  70. Reserved4: USHORT,
  71. },
  72. },
  73. }
  74. PHIDP_BUTTON_CAPS :: ^HIDP_BUTTON_CAPS
  75. HIDP_VALUE_CAPS :: struct {
  76. UsagePage: USAGE,
  77. ReportID: UCHAR,
  78. IsAlias: BOOLEAN,
  79. BitField: USHORT,
  80. LinkCollection: USHORT,
  81. LinkUsage: USAGE,
  82. LinkUsagePage: USAGE,
  83. IsRange: BOOLEAN,
  84. IsStringRange: BOOLEAN,
  85. IsDesignatorRange: BOOLEAN,
  86. IsAbsolute: BOOLEAN,
  87. HasNull: BOOLEAN,
  88. Reserved: UCHAR,
  89. BitSize: USHORT,
  90. ReportCount: USHORT,
  91. Reserved2: [5]USHORT,
  92. UnitsExp: ULONG,
  93. Units: ULONG,
  94. LogicalMin: LONG,
  95. LogicalMax: LONG,
  96. PhysicalMin: LONG,
  97. PhysicalMax: LONG,
  98. using _: struct #raw_union {
  99. Range: struct {
  100. UsageMin: USAGE,
  101. UsageMax: USAGE,
  102. StringMin: USHORT,
  103. StringMax: USHORT,
  104. DesignatorMin: USHORT,
  105. DesignatorMax: USHORT,
  106. DataIndexMin: USHORT,
  107. DataIndexMax: USHORT,
  108. },
  109. NotRange: struct {
  110. Usage: USAGE,
  111. Reserved1: USAGE,
  112. StringIndex: USHORT,
  113. Reserved2: USHORT,
  114. DesignatorIndex: USHORT,
  115. Reserved3: USHORT,
  116. DataIndex: USHORT,
  117. Reserved4: USHORT,
  118. },
  119. },
  120. }
  121. PHIDP_VALUE_CAPS :: ^HIDP_VALUE_CAPS
  122. HIDP_DATA :: struct {
  123. DataIndex: USHORT,
  124. Reserved: USHORT,
  125. using _ : struct #raw_union {
  126. RawValue: ULONG,
  127. On: BOOLEAN,
  128. },
  129. }
  130. PHIDP_DATA :: ^HIDP_DATA
  131. HIDP_LINK_COLLECTION_NODE :: struct {
  132. LinkUsage: USAGE,
  133. LinkUsagePage: USAGE,
  134. Parent: USHORT,
  135. NumberOfChildren: USHORT,
  136. NextSibling: USHORT,
  137. FirstChild: USHORT,
  138. CollectionType: [8]ULONG,
  139. IsAlias: [1]ULONG,
  140. Reserved: [23]ULONG,
  141. UserContext: PVOID,
  142. }
  143. PHIDP_LINK_COLLECTION_NODE :: ^HIDP_LINK_COLLECTION_NODE
  144. HIDP_PREPARSED_DATA :: rawptr
  145. PHIDP_PREPARSED_DATA :: ^HIDP_PREPARSED_DATA
  146. HIDP_REPORT_TYPE :: enum c.int {
  147. Input,
  148. Output,
  149. Feature,
  150. }
  151. HIDP_STATUS_SUCCESS : NTSTATUS : 0x110000
  152. HIDP_STATUS_NULL : NTSTATUS : -2146369535 //0x80110001
  153. HIDP_STATUS_INVALID_PREPARSED_DATA : NTSTATUS : -1072627711 //0xC0110001
  154. HIDP_STATUS_INVALID_REPORT_TYPE : NTSTATUS : -1072627710 //0xC0110002
  155. HIDP_STATUS_INVALID_REPORT_LENGTH : NTSTATUS : -1072627709 //0xC0110003
  156. HIDP_STATUS_USAGE_NOT_FOUND : NTSTATUS : -1072627708 //0xC0110004
  157. HIDP_STATUS_VALUE_OUT_OF_RANGE : NTSTATUS : -1072627707 //0xC0110005
  158. HIDP_STATUS_BAD_LOG_PHY_VALUES : NTSTATUS : -1072627706 //0xC0100006
  159. HIDP_STATUS_BUFFER_TOO_SMALL : NTSTATUS : -1072627705 //0xC0110007
  160. HIDP_STATUS_INTERNAL_ERROR : NTSTATUS : -1072627704 //0xC0110008
  161. HIDP_STATUS_I8042_TRANS_UNKNOWN : NTSTATUS : -1072627703 //0xC0110009
  162. HIDP_STATUS_INCOMPATIBLE_REPORT_ID : NTSTATUS : -1072627702 //0xC011000A
  163. HIDP_STATUS_NOT_VALUE_ARRAY : NTSTATUS : -1072627701 //0xC011000B
  164. HIDP_STATUS_IS_VALUE_ARRAY : NTSTATUS : -1072627700 //0xC011000C
  165. HIDP_STATUS_DATA_INDEX_NOT_FOUND : NTSTATUS : -1072627699 //0xC011000D
  166. HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE : NTSTATUS : -1072627698 //0xC011000E
  167. HIDP_STATUS_BUTTON_NOT_PRESSED : NTSTATUS : -1072627697 //0xC011000F
  168. HIDP_STATUS_REPORT_DOES_NOT_EXIST : NTSTATUS : -1072627696 //0xC0110010
  169. HIDP_STATUS_NOT_IMPLEMENTED : NTSTATUS : -1072627680 //0xC0110020
  170. HIDP_STATUS_NOT_BUTTON_ARRAY : NTSTATUS : -1072627679 //0xC0110021
  171. HIDP_STATUS_I8242_TRANS_UNKNOWN :: HIDP_STATUS_I8042_TRANS_UNKNOWN
  172. foreign import hid "system:hid.lib"
  173. @(default_calling_convention="system")
  174. foreign hid {
  175. HidP_GetCaps :: proc(PreparsedData: PHIDP_PREPARSED_DATA, Capabilities: PHIDP_CAPS) -> NTSTATUS ---
  176. HidP_GetButtonCaps :: proc(ReportType: HIDP_REPORT_TYPE, ButtonCaps: PHIDP_BUTTON_CAPS, ButtonCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS ---
  177. HidP_GetValueCaps :: proc(ReportType: HIDP_REPORT_TYPE, ValueCaps: PHIDP_VALUE_CAPS, ValueCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS ---
  178. HidP_GetUsages :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, UsageList: PUSAGE, UsageLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS ---
  179. HidP_GetUsageValue :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, Usage: USAGE, UsageValue: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS ---
  180. HidP_GetData :: proc(ReportType: HIDP_REPORT_TYPE, DataList: PHIDP_DATA, DataLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS ---
  181. HidP_GetLinkCollectionNodes :: proc(LinkCollectionNodes: PHIDP_LINK_COLLECTION_NODE, LinkCollectionNodesLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS ---
  182. HidD_GetAttributes :: proc(HidDeviceObject: HANDLE, Attributes: PHIDD_ATTRIBUTES) -> BOOLEAN ---
  183. HidD_GetHidGuid :: proc(HidGuid: LPGUID) ---
  184. HidD_GetPreparsedData :: proc(HidDeviceObject: HANDLE, PreparsedData: ^PHIDP_PREPARSED_DATA) -> BOOLEAN ---
  185. HidD_FreePreparsedData :: proc(PreparsedData: PHIDP_PREPARSED_DATA) -> BOOLEAN ---
  186. HidD_FlushQueue :: proc(HidDeviceObject: HANDLE) -> BOOLEAN ---
  187. HidD_GetConfiguration :: proc(HidDeviceObject: HANDLE, Configuration: PHIDD_CONFIGURATION, ConfigurationLength: ULONG) -> BOOLEAN ---
  188. HidD_SetConfiguration :: proc(HidDeviceObject: HANDLE, Configuration: PHIDD_CONFIGURATION, ConfigurationLength: ULONG) -> BOOLEAN ---
  189. HidD_GetFeature :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN ---
  190. HidD_SetFeature :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN ---
  191. HidD_GetInputReport :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN ---
  192. HidD_SetOutputReport :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN ---
  193. HidD_GetNumInputBuffers :: proc(HidDeviceObject: HANDLE, NumberBuffers: PULONG) -> BOOLEAN ---
  194. HidD_SetNumInputBuffers :: proc(HidDeviceObject: HANDLE, NumberBuffers: ULONG) -> BOOLEAN ---
  195. HidD_GetPhysicalDescriptor :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN ---
  196. HidD_GetManufacturerString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN ---
  197. HidD_GetProductString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN ---
  198. HidD_GetIndexedString :: proc(HidDeviceObject: HANDLE, StringIndex: ULONG, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN ---
  199. HidD_GetSerialNumberString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN ---
  200. HidD_GetMsGenreDescriptor :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN ---
  201. }