Difference between revisions of "Unit HID"

From Ultibo.org
Jump to: navigation, search
Line 31: Line 31:
 
----
 
----
  
''To be documented''
+
 
 +
'''HID descriptor'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDDescriptor = ^THIDDescriptor;</code>
 +
 
 +
<code>THIDDescriptor = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|See Section 6.2.1
 +
|-
 +
| <code>bLength:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>bDescriptorType:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>bcdHID:Word;</code>
 +
| &nbsp;
 +
|-
 +
| <code>bCountryCode:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>bNumDescriptors:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>bHIDDescriptorType:Byte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>wHIDDescriptorLength:Word;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|Note: Up to two optional bHIDDescriptorType/wHIDDescriptorLength pairs after the Report descriptor details
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID report descriptor'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>PHIDReportDescriptor = Pointer;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|See Section 6.2.2
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID physical descriptor'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDPhysicalDescriptor = ^THIDPhysicalDescriptor;</code>
 +
 
 +
<code>THIDPhysicalDescriptor = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|See Section 6.2.3
 +
|-
 +
| <code>bDesignator:Byte;</code>
 +
| Indicates which part of the body affects the item
 +
|-
 +
| <code>bFlags:Byte;</code>
 +
| Bits specifying flags (7..5 Qualifier / 4..0 Effort)
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID physical descriptor set0'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDPhysicalDescriptorSet0 = ^THIDPhysicalDescriptorSet0;</code>
 +
 
 +
<code>THIDPhysicalDescriptorSet0 = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>bNumber:Byte;</code>
 +
| Number of Physical Descriptor sets not including Physical Descriptor set 0
 +
|-
 +
| <code>wLength:Word;</code>
 +
| Length of each Physical descriptor set
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID physical descriptor set'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDPhysicalDescriptorSet = ^THIDPhysicalDescriptorSet;</code>
 +
 
 +
<code>THIDPhysicalDescriptorSet = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>bPhysicalInfo:Byte;</code>
 +
| Bits specifying physical information (7..5 Bias / 4..0 Preference)
 +
|-
 +
| <code>wPhysicalDescriptor:array[0..0] of THIDPhysicalDescriptor;</code>
 +
| Physical descriptor data
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID state'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDState = ^THIDState;</code>
 +
 
 +
<code>THIDState = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Local State
 +
|-
 +
| <code>Usage:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UsageCount:LongWord;</code>
 +
| Provides UsageMinimum/UsageMaximum
 +
|-
 +
| <code>DesignatorIndex:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>DesignatorCount:LongWord;</code>
 +
| Provides DesignatorMinimum/DesignatorMaximum
 +
|-
 +
| <code>StringIndex:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>StringCount:LongWord;</code>
 +
| Provides StringMinimum/StringMaximum
 +
|-
 +
| <code>Delimiter:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|Global State
 +
|-
 +
| <code>UsagePage:Word;</code>
 +
| &nbsp;
 +
|-
 +
| <code>LogicalMinimum:LongInt;</code>
 +
| &nbsp;
 +
|-
 +
| <code>LogicalMaximum:LongInt;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PhysicalMinimum:LongInt;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PhysicalMaximum:LongInt;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UnitType:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UnitExponent:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReportSize:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReportId:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReportCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID stack'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDStack = ^THIDStack;</code>
 +
 
 +
<code>THIDStack = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>State:PHIDState;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Next:PHIDStack;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID usages'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDUsages = ^THIDUsages;</code>
 +
 
 +
<code>THIDUsages = array[0..0] of PHIDUsage;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID usage'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDUsage = ^THIDUsage;</code>
 +
 
 +
<code>THIDUsage = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Page:Word;</code>
 +
| The usage page this usage refers to
 +
|-
 +
| <code>Usage:Word;</code>
 +
| The usage within the usage page
 +
|-
 +
| <code>Count:Word;</code>
 +
| The total number of sequential usages where Usage represents the minimum value or 1 for a single usage (Usage range is from Usage to Usage + Count - 1)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Index:LongWord;</code>
 +
| The index of this usage in the report (First usage is 0)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>StringIndex:LongWord;</code>
 +
| The string index for this usage
 +
|-
 +
| <code>StringCount:LongWord;</code>
 +
| The total number of sequential string index values where string index represents the minimum value or 1 for a single string
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>DesignatorIndex:LongWord; {The designator index for this usage</code>
 +
| &nbsp;
 +
|-
 +
| <code>DesignatorCount:LongWord;</code>
 +
| The total number of sequential designator index values where designator index represents the minimum value or 1 for a single designator
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>LogicalMinimum:LongInt;</code>
 +
| The logical minimum value for this usage
 +
|-
 +
| <code>LogicalMaximum:LongInt;</code>
 +
| The logical maximum value for this usage
 +
|-
 +
| <code>PhysicalMinimum:LongInt;</code>
 +
| The physical minimum value for this usage (in Units)
 +
|-
 +
| <code>PhysicalMaximum:LongInt;</code>
 +
| The physical maximum value for this usage (in Units)
 +
|-
 +
| <code>UnitType:LongWord;</code>
 +
| The unit type for this usage
 +
|-
 +
| <code>UnitExponent:LongWord;</code>
 +
| The unit exponent index for this usage
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Aliases:PHIDUsages;</code>
 +
| The list of aliased usages for this control (See Delimiters in Section 6.2.2.8)
 +
|-
 +
| <code>AliasCount:LongWord;</code>
 +
| The number of aliased usages contained for this control
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Report:PHIDReport;</code>
 +
| The report this usage belongs to
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID reports'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDReports = ^THIDReports;</code>
 +
 
 +
<code>THIDReports = array[0..0] of PHIDReport;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID report'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDReport = ^THIDReport;</code>
 +
 
 +
<code>THIDReport = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Id:Byte;</code>
 +
| The Id of this report
 +
|-
 +
| <code>Kind:Byte;</code>
 +
| The type of report (Input, Output or Feature) (eg HID_REPORT_INPUT)
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| The main item flags for this report (eg HID_MAIN_ITEM_VARIABLE)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| The number of bits per field in this report
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| The number of fields in this report
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Index:LongWord;</code>
 +
| The index of this report in the collection (First report is 0)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Usages:PHIDUsages;</code>
 +
| The list of usages contained in this report
 +
|-
 +
| <code>UsageCount:LongWord;</code>
 +
| The number of usages contained in this report
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Collection:PHIDCollection;</code>
 +
| The collection this report belongs to
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID collections'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDCollections = ^THIDCollections;</code>
 +
 
 +
<code>THIDCollections = array[0..0] of PHIDCollection;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID collection'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDCollection = ^THIDCollection;</code>
 +
 
 +
<code>THIDCollection = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Page:Word;</code>
 +
| The usage page this collection refers to (eg HID_PAGE_GENERIC_DESKTOP)
 +
|-
 +
| <code>Usage:Word;</code>
 +
| The usage within the usage page (eg HID_DESKTOP_MOUSE)
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| The main item flags for this collection (eg HID_MAIN_COLLECTION_APPLICATION)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Start:LongWord;</code>
 +
| The first byte of this collection in the report descriptor
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Reports:PHIDReports;</code>
 +
| The list of reports contained in this collection
 +
|-
 +
| <code>ReportCount:LongWord;</code>
 +
| The number of reports contained in this collection
 +
|-
 +
| <code>Collections:PHIDCollections;</code>
 +
| The list of collections contained in this collection
 +
|-
 +
| <code>CollectionCount:LongWord;</code>
 +
| The number of collections contained in this collection
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Parent:PHIDCollection;</code>
 +
| The parent collection or nil if this is a top level collection
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Device:PHIDDevice;</code>
 +
| The device this collection belongs to
 +
|-
 +
| <code>Consumer:PHIDConsumer;</code>
 +
| The consumer which is bound to this collection (or nil if not bound)
 +
|-
 +
| <code>PrivateData:Pointer;</code>
 +
| Private data for the consumer of this collection
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID device enumeration callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceEnumerate = function(Device:PHIDDevice;Data:Pointer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device notification callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device get idle'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetIdle = function(Device:PHIDDevice; var Duration:Word; ReportId:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device set idle'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceSetIdle = function(Device:PHIDDevice; Duration:Word; ReportId:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device get report'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetReport = function(Device:PHIDDevice; ReportType,ReportId:Byte; ReportData:Pointer; ReportSize:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device set report'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceSetReport = function(Device:PHIDDevice; ReportType,ReportId:Byte; ReportData:Pointer; ReportSize:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device allocate report'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceAllocateReport = function(Device:PHIDDevice; Collection:PHIDCollection; ReportId:Byte; ReportSize:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device release report'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceReleaseReport = function(Device:PHIDDevice; ReportId:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device submit report'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceSubmitReport = function(Device:PHIDDevice; ReportId:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''HID device cancel report'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceCancelReport = function(Device:PHIDDevice; ReportId:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device get protocol'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetProtocol = function(Device:PHIDDevice; var Protocol:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device set protocol'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceSetProtocol = function(Device:PHIDDevice; Protocol:Byte):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device get interval'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetInterval = function(Device:PHIDDevice; var Interval:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device set interval'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceSetInterval = function(Device:PHIDDevice; Interval:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device get report descriptor'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetReportDescriptor = function(Device:PHIDDevice; Descriptor:PHIDReportDescriptor; Size:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device get physical descriptor set0'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetPhysicalDescriptorSet0 = function(Device:PHIDDevice; Descriptor:PHIDPhysicalDescriptorSet0):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''HID device get physical descriptor set'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceGetPhysicalDescriptorSet = function(Device:PHIDDevice; Descriptor:PHIDPhysicalDescriptorSet; Index:Byte; Size:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID device'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDDevice = ^THIDDevice;</code>
 +
 
 +
<code>THIDDevice = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Device Properties''
 +
|-
 +
| <code>Device:TDevice;</code>
 +
| The Device entry for this HID
 +
|-
 +
|colspan="2"|''HID Properties''
 +
|-
 +
| <code>HIDId:LongWord;</code>
 +
| Unique Id of this HID in the HID device table
 +
|-
 +
| <code>HIDState:LongWord;</code>
 +
| HID device state (eg HID_STATE_ATTACHED)
 +
|-
 +
| <code>Consumer:PHIDConsumer;</code>
 +
| The consumer which is bound to this device (or nil if not bound)
 +
|-
 +
| <code>DeviceGetIdle:THIDDeviceGetIdle;</code>
 +
| A device specific GetIdle method (If supported by provider)
 +
|-
 +
| <code>DeviceSetIdle:THIDDeviceSetIdle;</code>
 +
| A device specific SetIdle method (If supported by provider)
 +
|-
 +
| <code>DeviceGetReport:THIDDeviceGetReport;</code>
 +
| A device specific GetReport method (If supported by provider)
 +
|-
 +
| <code>DeviceSetReport:THIDDeviceSetReport;</code>
 +
| A device specific SetReport method (If supported by provider)
 +
|-
 +
| <code>DeviceAllocateReport:THIDDeviceAllocateReport;</code>
 +
| A device specific AllocateReport method (If supported by provider)
 +
|-
 +
| <code>DeviceReleaseReport:THIDDeviceReleaseReport;</code>
 +
| A device specific ReleaseReport method (If supported by provider)
 +
|-
 +
| <code>DeviceSubmitReport:THIDDeviceSubmitReport;</code>
 +
| A device specific SubmitReport method (If supported by provider)
 +
|-
 +
| <code>DeviceCancelReport:THIDDeviceCancelReport;</code>
 +
| A device specific CancelReport method (If supported by provider)
 +
|-
 +
| <code>DeviceGetProtocol:THIDDeviceGetProtocol;</code>
 +
| A device specific GetProtocol method (If supported by provider)
 +
|-
 +
| <code>DeviceSetProtocol:THIDDeviceSetProtocol;</code>
 +
| A device specific SetProtocol method (If supported by provider)
 +
|-
 +
| <code>DeviceGetInterval:THIDDeviceGetInterval;</code>
 +
| A device specific GetInterval method (If supported by provider)
 +
|-
 +
| <code>DeviceSetInterval:THIDDeviceSetInterval;</code>
 +
| A device specific SetInterval method (If supported by provider)
 +
|-
 +
| <code>DeviceGetReportDescriptor:THIDDeviceGetReportDescriptor;</code>
 +
| A device specific GetReportDescriptor method (If supported by provider)
 +
|-
 +
| <code>DeviceGetPhysicalDescriptorSet0:THIDDeviceGetPhysicalDescriptorSet0;</code>
 +
| A device specific GetPhysicalDescriptorSet0 method (If supported by provider)
 +
|-
 +
| <code>DeviceGetPhysicalDescriptorSet:THIDDeviceGetPhysicalDescriptorSet;</code>
 +
| A device specific GetPhysicalDescriptorSet method (If supported by provider)
 +
|-
 +
|colspan="2"|''Driver Properties''
 +
|-
 +
| <code>Lock:TMutexHandle;</code>
 +
| HID device lock
 +
|-
 +
| <code>PrivateData:Pointer;</code>
 +
| Private data for the consumer of this HID device (If applicable)
 +
|-
 +
| <code>Collections:PHIDCollections;</code>
 +
| The parsed report descriptor with collections, reports and usages
 +
|-
 +
| <code>CollectionCount:LongWord;</code>
 +
| The number of top level collections contained in the report descriptor
 +
|-
 +
| <code>Descriptor:PHIDReportDescriptor;</code>
 +
| The raw report descriptor obtained from the device
 +
|-
 +
| <code>DescriptorSize:LongWord;</code>
 +
| The size of the data pointed to by Descriptor
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| <code>ReceiveCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReceiveErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PHIDDevice;</code>
 +
| Previous entry in Device table
 +
|-
 +
| <code>Next:PHIDDevice;</code>
 +
| Next entry in Device table
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID consumer enumeration callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDConsumerEnumerate = function(Consumer:PHIDConsumer; Data:Pointer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''HID device bind'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceBind = function(Device:PHIDDevice):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''HID device unbind'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDDeviceUnbind = function(Device:PHIDDevice):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID collection bind'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDCollectionBind = function(Device:PHIDDevice; Collection:PHIDCollection):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID collection unbind'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDCollectionUnbind = function(Device:PHIDDevice; Collection:PHIDCollection):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID report receive'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>THIDReportReceive = function(Collection:PHIDCollection; ReportId:Byte; ReportData:Pointer; ReportSize:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''HID consumer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDConsumer = ^THIDConsumer;</code>
 +
 
 +
<code>THIDConsumer = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Driver Properties''
 +
|-
 +
| <code>Driver:TDriver;</code>
 +
| The Driver entry for this HID Consumer
 +
|-
 +
|colspan="2"|''Consumer Properties''
 +
|-
 +
| <code>DeviceBind:THIDDeviceBind;</code>
 +
| A Device Bind method to be called when a HID device bind is requested by a provider (Optional)
 +
|-
 +
| <code>DeviceUnbind:THIDDeviceUnbind;</code>
 +
| A Device Ubind method to be called when a HID device unbind is requested by a provider (Optional)
 +
|-
 +
| <code>CollectionBind:THIDCollectionBind;</code>
 +
| A Collection Bind method to be called when a HID collection bind is requested by a provider (Mandatory)
 +
|-
 +
| <code>CollectionUnbind:THIDCollectionUnbind;</code>
 +
| A Collection Unbind method to be called when a HID collection unbind is requested by a provider (Mandatory)
 +
|-
 +
| <code>ReportReceive:THIDReportReceive;</code>
 +
| A Report Receive method to be called when a HID input report is received by a provider (Mandatory)
 +
|-
 +
|colspan="2"|''Interface Properties''
 +
|-
 +
| <code>Lock:TMutexHandle;</code>
 +
| Consumer lock
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PHIDConsumer;</code>
 +
| Previous entry in Consumer table
 +
|-
 +
| <code>Next:PHIDConsumer;</code>
 +
| Next entry in Consumer table
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID report field'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDField = ^THIDField;</code>
 +
 
 +
<code>THIDField = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Page:Word;</code>
 +
| The usage page of this field
 +
|-
 +
| <code>Usage:Word;</code>
 +
| The usage within the usage page
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| The total number of sequential usages where Usage represents the minimum value or 1 for a single usage (Usage range is from Usage to Usage + Count - 1)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| The flags for this field
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| The length in bytes of this field within the input, output or feature report
 +
|-
 +
| <code>Bits:LongWord;</code>
 +
| The length in bits of this field within the input, output or feature report
 +
|-
 +
| <code>Offset:LongWord;</code>
 +
| The byte offset of this field within the input, output or feature report
 +
|-
 +
| <code>Shift:LongWord;</code>
 +
| The number shift bits to access this field in the input, output or feature report
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Minimum:LongInt;</code>
 +
| The minimum value for this field (either in logical or physical units)
 +
|-
 +
| <code>Maximum:LongInt;</code>
 +
| The maximum value for this field (either in logical or physical units)
 +
|-
 +
| <code>Multiplier:Double;</code>
 +
| The conversion multiplier for this field from logical to physical units
 +
|-
 +
| <code>Resolution:Double;</code>
 +
| The unit resolution for this field in counts per physical unit
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Next:PHIDField;</code>
 +
| The next field in the list
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''HID report definition'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHIDDefinition = ^THIDDefinition;</code>
 +
 
 +
<code>THIDDefinition = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Id:Byte;</code>
 +
| The Id of this report
 +
|-
 +
| <code>Kind:Byte;</code>
 +
| The type of this report (Input, Output or Feature)
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| The total length of this input, output or feature report in bytes (Including the Id byte)
 +
|-
 +
| <code>Fields:PHIDField;</code>
 +
| Linked list of fields in this input, output or feature report
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Next:PHIDDefinition;</code>
 +
| The next definition in the list
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===

Revision as of 23:04, 27 October 2022

Return to Unit Reference


Description


Ultibo Human Interface Device (HID) Interface unit

The Human Interface Device (HID) class is intended to provide a flexible model that allows a wide range of control types to be expressed using a standard set of tags in a report descriptor that each device provides during initialization.

HID devices can represent common items such as mice, keyboards, touchscreens, gamepads and joysticks but can also appear as controls within many other types of devices.

A headset for example will primarily be an audio device but the volume and mute buttons can be defined using the HID standard and easily recognized by software without requiring a custom driver for each and every device.

The Ultibo HID implementation creates an intermediate device layer that is mostly agnostic to both the bus type being used by an underlying provider (such as USB) and the devices recognized by HID consumers such as mice and keyboards.

A provider such as USB HID locates devices from the provider specific bus and creates HID devices to represent them along with obtaining report descriptors and other information.

These HID devices are then passed to registered HID consumers (drivers) to determine if they recognize the collections, reports and usages described by the device. A consumer can accept a device and bind to it during this process and create its own devices to represent the functionality described by the HID device.

While HID itself is intended to be bus agnostic this implementation is based heavily on the USB HID standards as those are the most widely adopted at this time. It is anticipated that HID adoption will expand over time to include a range other bus types, Bluetooth is already using HID and there are existing implementations of HID over I2C, SPI and PCI.

Expanding the Ultibo HID support to other bus types simply requires a new HID provider for that bus to be written along with any necessary changes or extensions to the HID layer itself.

Constants


To be documented

Type definitions



HID descriptor

[Expand]

PHIDDescriptor = ^THIDDescriptor;

THIDDescriptor = packed record

HID report descriptor

[Expand]

PHIDReportDescriptor = Pointer;

HID physical descriptor

[Expand]

PHIDPhysicalDescriptor = ^THIDPhysicalDescriptor;

THIDPhysicalDescriptor = packed record

HID physical descriptor set0

[Expand]

PHIDPhysicalDescriptorSet0 = ^THIDPhysicalDescriptorSet0;

THIDPhysicalDescriptorSet0 = packed record

HID physical descriptor set

[Expand]

PHIDPhysicalDescriptorSet = ^THIDPhysicalDescriptorSet;

THIDPhysicalDescriptorSet = packed record

HID state

[Expand]

PHIDState = ^THIDState;

THIDState = record

HID stack

[Expand]

PHIDStack = ^THIDStack;

THIDStack = record

HID usages

[Expand]

PHIDUsages = ^THIDUsages;

THIDUsages = array[0..0] of PHIDUsage;

HID usage

[Expand]

PHIDUsage = ^THIDUsage;

THIDUsage = record

HID reports

[Expand]

PHIDReports = ^THIDReports;

THIDReports = array[0..0] of PHIDReport;

HID report

[Expand]

PHIDReport = ^THIDReport;

THIDReport = record

HID collections

[Expand]

PHIDCollections = ^THIDCollections;

THIDCollections = array[0..0] of PHIDCollection;

HID collection

[Expand]

PHIDCollection = ^THIDCollection;

THIDCollection = record

HID device enumeration callback

THIDDeviceEnumerate = function(Device:PHIDDevice;Data:Pointer):LongWord;

HID device notification callback

THIDDeviceNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;

HID device get idle

THIDDeviceGetIdle = function(Device:PHIDDevice; var Duration:Word; ReportId:Byte):LongWord;

HID device set idle

THIDDeviceSetIdle = function(Device:PHIDDevice; Duration:Word; ReportId:Byte):LongWord;

HID device get report

THIDDeviceGetReport = function(Device:PHIDDevice; ReportType,ReportId:Byte; ReportData:Pointer; ReportSize:LongWord):LongWord;

HID device set report

THIDDeviceSetReport = function(Device:PHIDDevice; ReportType,ReportId:Byte; ReportData:Pointer; ReportSize:LongWord):LongWord;

HID device allocate report

THIDDeviceAllocateReport = function(Device:PHIDDevice; Collection:PHIDCollection; ReportId:Byte; ReportSize:LongWord):LongWord;

HID device release report

THIDDeviceReleaseReport = function(Device:PHIDDevice; ReportId:Byte):LongWord;

HID device submit report

THIDDeviceSubmitReport = function(Device:PHIDDevice; ReportId:Byte):LongWord;

HID device cancel report

THIDDeviceCancelReport = function(Device:PHIDDevice; ReportId:Byte):LongWord;

HID device get protocol

THIDDeviceGetProtocol = function(Device:PHIDDevice; var Protocol:Byte):LongWord;

HID device set protocol

THIDDeviceSetProtocol = function(Device:PHIDDevice; Protocol:Byte):LongWord;

HID device get interval

THIDDeviceGetInterval = function(Device:PHIDDevice; var Interval:LongWord):LongWord;

HID device set interval

THIDDeviceSetInterval = function(Device:PHIDDevice; Interval:LongWord):LongWord;

HID device get report descriptor

THIDDeviceGetReportDescriptor = function(Device:PHIDDevice; Descriptor:PHIDReportDescriptor; Size:LongWord):LongWord;

HID device get physical descriptor set0

THIDDeviceGetPhysicalDescriptorSet0 = function(Device:PHIDDevice; Descriptor:PHIDPhysicalDescriptorSet0):LongWord;

HID device get physical descriptor set

THIDDeviceGetPhysicalDescriptorSet = function(Device:PHIDDevice; Descriptor:PHIDPhysicalDescriptorSet; Index:Byte; Size:LongWord):LongWord;

HID device

[Expand]

PHIDDevice = ^THIDDevice;

THIDDevice = record

HID consumer enumeration callback

THIDConsumerEnumerate = function(Consumer:PHIDConsumer; Data:Pointer):LongWord;

HID device bind

THIDDeviceBind = function(Device:PHIDDevice):LongWord;

HID device unbind

THIDDeviceUnbind = function(Device:PHIDDevice):LongWord;

HID collection bind

THIDCollectionBind = function(Device:PHIDDevice; Collection:PHIDCollection):LongWord;

HID collection unbind

THIDCollectionUnbind = function(Device:PHIDDevice; Collection:PHIDCollection):LongWord;

HID report receive

THIDReportReceive = function(Collection:PHIDCollection; ReportId:Byte; ReportData:Pointer; ReportSize:LongWord):LongWord;

HID consumer

[Expand]

PHIDConsumer = ^THIDConsumer;

THIDConsumer = record

HID report field

[Expand]

PHIDField = ^THIDField;

THIDField = record

HID report definition

[Expand]

PHIDDefinition = ^THIDDefinition;

THIDDefinition = record


Public variables



HID logging

HID_DEFAULT_LOG_LEVEL:LongWord = HID_LOG_LEVEL_DEBUG; Minimum level for HID messages. Only messages with level greater than or equal to this will be printed.
HID_LOG_ENABLED:Boolean;


Function declarations


To be documented


Return to Unit Reference