Difference between revisions of "Unit USBMOUSE"
(One intermediate revision by the same user not shown) | |||
Line 12: | Line 12: | ||
To use this driver in place of the default HID Mouse driver set the following configuration variables in your application during system initialization. | To use this driver in place of the default HID Mouse driver set the following configuration variables in your application during system initialization. | ||
− | |||
HID_REGISTER_MOUSE := False; | HID_REGISTER_MOUSE := False; | ||
USB_MOUSE_REGISTER_DRIVER := True; | USB_MOUSE_REGISTER_DRIVER := True; | ||
− | |||
This driver does not recognize devices that do not report themselves as boot mice, does not correctly recognize the wheel on many devices and is known to be incompatible with the touch pad included in some portable wireless keyboards. | This driver does not recognize devices that do not report themselves as boot mice, does not correctly recognize the wheel on many devices and is known to be incompatible with the touch pad included in some portable wireless keyboards. | ||
Line 21: | Line 19: | ||
---- | ---- | ||
− | '' | + | |
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''USB mouse specific constants''' <code> USBMOUSE_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>USBMOUSE_DRIVER_NAME = 'USB Mouse Driver (HID boot protocol)';</code> | ||
+ | | Name of USB mouse driver | ||
+ | |- | ||
+ | | <code>USBMOUSE_MOUSE_DESCRIPTION = 'USB HID Mouse';</code> | ||
+ | | Description of USB mouse device | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''USB HID types''' <code> USB_HID_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''HID Interface Subclass types (See USB HID v1.11 specification)'' | ||
+ | |- | ||
+ | | <code>USB_HID_SUBCLASS_NONE = 0;</code> | ||
+ | | Section 4.2 | ||
+ | |- | ||
+ | | <code>USB_HID_SUBCLASS_BOOT = 1;</code> | ||
+ | | Section 4.2 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Interface Protocol types (See USB HID v1.11 specification)'' | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_PROTOCOL_NONE = 0;</code> | ||
+ | | Section 4.3 | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_PROTOCOL_KEYBOARD = 1;</code> | ||
+ | | Section 4.3 | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_PROTOCOL_MOUSE = 2;</code> | ||
+ | | Section 4.3 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Class Descriptor Types (See USB HID v1.11 specification)'' | ||
+ | |- | ||
+ | | <code>USB_HID_DESCRIPTOR_TYPE_HID = $21;</code> | ||
+ | | Section 7.1 | ||
+ | |- | ||
+ | | <code>USB_HID_DESCRIPTOR_TYPE_REPORT = $22;</code> | ||
+ | | Section 7.1 | ||
+ | |- | ||
+ | | <code>USB_HID_DESCRIPTOR_TYPE_PHYSICAL_DESCRIPTOR = $23;</code> | ||
+ | | Section 7.1 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Request types'' | ||
+ | |- | ||
+ | | <code>USB_HID_REQUEST_GET_REPORT = $01;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_REQUEST_GET_IDLE = $02;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_REQUEST_GET_PROTOCOL = $03;</code> | ||
+ | | Section 7.2 | ||
+ | |- | ||
+ | | <code>USB_HID_REQUEST_SET_REPORT = $09;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_REQUEST_SET_IDLE = $0A;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_REQUEST_SET_PROTOCOL = $0B;</code> | ||
+ | | Section 7.2 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Protocol types'' | ||
+ | |- | ||
+ | | <code>USB_HID_PROTOCOL_BOOT = 0;</code> | ||
+ | | Section 7.2.5 | ||
+ | |- | ||
+ | | <code>USB_HID_PROTOCOL_REPORT = 1;</code> | ||
+ | | Section 7.2.5 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Report types'' | ||
+ | |- | ||
+ | | <code>USB_HID_REPORT_INPUT = 1;</code> | ||
+ | | Section 7.2.1 | ||
+ | |- | ||
+ | | <code>USB_HID_REPORT_OUTPUT = 2;</code> | ||
+ | | Section 7.2.1 | ||
+ | |- | ||
+ | | <code>USB_HID_REPORT_FEATURE = 3;</code> | ||
+ | | Section 7.2.1 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Report IDs'' | ||
+ | |- | ||
+ | | <code>USB_HID_REPORTID_NONE = 0;</code> | ||
+ | | Section 7.2.1 | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Boot Protocol Button bits'' | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_LEFT_BUTTON = (1 shl 0);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_RIGHT_BUTTON = (1 shl 1);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_MIDDLE_BUTTON = (1 shl 2);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_SIDE_BUTTON = (1 shl 3);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_EXTRA_BUTTON = (1 shl 4);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|''HID Boot Protocol Report data'' | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_REPORT_SIZE = 3;</code> | ||
+ | | Appendix B of HID Device Class Definition 1.11 | ||
+ | |- | ||
+ | | <code>USB_HID_BOOT_DATA_SIZE = 8;</code> | ||
+ | | Allocate more than the minimum to allow for extra data | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Type definitions === | === Type definitions === | ||
---- | ---- | ||
− | '' | + | |
+ | '''USB HID descriptor''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PUSBHIDDescriptor = ^TUSBHIDDescriptor;</code> | ||
+ | |||
+ | <code>TUSBHIDDescriptor = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>bLength:Byte;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>bDescriptorType:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bcdHID:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bCountryCode:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bNumDescriptors:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bHIDDescriptorType:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>wHIDDescriptorLength:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|Note: Up to two optional bHIDDescriptorType/wHIDDescriptorLength pairs after the Report descriptor details | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''USB mouse device''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PUSBMouseDevice = ^TUSBMouseDevice;</code> | ||
+ | |||
+ | <code>TUSBMouseDevice = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''Mouse Properties'' | ||
+ | |- | ||
+ | | <code>Mouse:TMouseDevice;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''USB Properties'' | ||
+ | |- | ||
+ | | <code>HIDInterface:PUSBInterface;</code> | ||
+ | | USB HID Mouse Interface | ||
+ | |- | ||
+ | | <code>ReportRequest:PUSBRequest;</code> | ||
+ | | USB request for mouse report data | ||
+ | |- | ||
+ | | <code>ReportEndpoint:PUSBEndpointDescriptor;</code> | ||
+ | | USB Mouse Interrupt IN Endpoint | ||
+ | |- | ||
+ | | <code>HIDDescriptor:PUSBHIDDescriptor;</code> | ||
+ | | USB HID Descriptor for mouse | ||
+ | |- | ||
+ | | <code>ReportDescriptor:Pointer;</code> | ||
+ | | USB HID Report Descriptor for mouse | ||
+ | |- | ||
+ | | <code>PendingCount:LongWord;</code> | ||
+ | | Number of USB requests pending for this mouse | ||
+ | |- | ||
+ | | <code>WaiterThread:TThreadId;</code> | ||
+ | | Thread waiting for pending requests to complete (for mouse detachment) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
---- | ---- | ||
− | '' | + | ''None defined'' |
=== Function declarations === | === Function declarations === | ||
---- | ---- | ||
− | |||
+ | |||
+ | '''Initialization functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure USBMouseInit;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the USB mouse driver</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Called only during system startup | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''USB mouse functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function USBMouseDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Bind the Mouse driver to a USB device if it is suitable</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Device | ||
+ | | The USB device to attempt to bind to | ||
+ | |- | ||
+ | ! Interrface | ||
+ | | The USB interface to attempt to bind to (or nil for whole device) | ||
+ | |- | ||
+ | ! Return | ||
+ | | USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure. | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function USBMouseDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Unbind the Mouse driver from a USB device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Device | ||
+ | | The USB device to unbind from | ||
+ | |- | ||
+ | ! Interrface | ||
+ | | The USB interface to unbind from (or nil for whole device) | ||
+ | |- | ||
+ | ! Return | ||
+ | | USB_STATUS_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure USBMouseReportWorker(Request:PUSBRequest);</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Called (by a Worker thread) to process a completed USB request from a USB mouse IN interrupt endpoint</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Request | ||
+ | | The USB request which has completed | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure USBMouseReportComplete(Request:PUSBRequest);</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Called when a USB request from a USB mouse IN interrupt endpoint completes</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Request | ||
+ | | The USB request which has completed | ||
+ | |- | ||
+ | ! Note | ||
+ | | Request is passed to worker thread for processing to prevent blocking the USB completion | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''USB mouse helper functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function USBMouseCheckDevice(Device:PUSBDevice):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied USB device is suitable for detection as a HID Mouse Device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Device | ||
+ | | The USB device to check | ||
+ | |- | ||
+ | ! Return | ||
+ | | True if the device is suitable or False if it is not | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function USBMouseDeviceSetProtocol(Mouse:PUSBMouseDevice; Protocol:Byte):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the report protocol for a USB mouse device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Mouse | ||
+ | | The USB mouse device to set the report protocol for | ||
+ | |- | ||
+ | ! Protocol | ||
+ | | The report protocol to set (eg USB_HID_PROTOCOL_BOOT) | ||
+ | |- | ||
+ | ! Return | ||
+ | | USB_STATUS_SUCCESS if completed or another USB error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function USBMouseDeviceGetHIDDescriptor(Mouse:PUSBMouseDevice; Descriptor:PUSBHIDDescriptor):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the HID Descriptor for a USB mouse device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Mouse | ||
+ | | The USB mouse device to get the descriptor for | ||
+ | |- | ||
+ | ! Descriptor | ||
+ | | Pointer to a USB HID Descriptor structure for the returned data | ||
+ | |- | ||
+ | ! Return | ||
+ | | USB_STATUS_SUCCESS if completed or another USB error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function USBMouseDeviceGetReportDescriptor(Mouse:PUSBMouseDevice; Descriptor:Pointer; Size:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the Report Descriptor for a USB mouse device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Mouse | ||
+ | | The USB mouse device to get the descriptor for | ||
+ | |- | ||
+ | ! Descriptor | ||
+ | | Pointer to a buffer to return the USB Report Descriptor | ||
+ | |- | ||
+ | ! Size | ||
+ | | The size in bytes of the buffer pointed to by Descriptor | ||
+ | |- | ||
+ | ! Return | ||
+ | | USB_STATUS_SUCCESS if completed or another USB error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
Return to [[Unit_Reference|Unit Reference]] | Return to [[Unit_Reference|Unit Reference]] |
Latest revision as of 04:02, 16 November 2022
Return to Unit Reference
Description
Ultibo USB Mouse Driver unit
USB Mouse Devices
The USB mouse driver in this unit uses HID Boot Protocol only and has been replaced by the HIDMouse unit which provides complete HID Report Protocol support for USB mice. It is retained here for legacy uses and backwards compatibility only.
To use this driver in place of the default HID Mouse driver set the following configuration variables in your application during system initialization.
HID_REGISTER_MOUSE := False; USB_MOUSE_REGISTER_DRIVER := True;
This driver does not recognize devices that do not report themselves as boot mice, does not correctly recognize the wheel on many devices and is known to be incompatible with the touch pad included in some portable wireless keyboards.
Constants
USBMOUSE_*
USBMOUSE_DRIVER_NAME = 'USB Mouse Driver (HID boot protocol)';
|
Name of USB mouse driver |
USBMOUSE_MOUSE_DESCRIPTION = 'USB HID Mouse';
|
Description of USB mouse device |
USB_HID_*
HID Interface Subclass types (See USB HID v1.11 specification) | |
USB_HID_SUBCLASS_NONE = 0;
|
Section 4.2 |
USB_HID_SUBCLASS_BOOT = 1;
|
Section 4.2 |
HID Interface Protocol types (See USB HID v1.11 specification) | |
USB_HID_BOOT_PROTOCOL_NONE = 0;
|
Section 4.3 |
USB_HID_BOOT_PROTOCOL_KEYBOARD = 1;
|
Section 4.3 |
USB_HID_BOOT_PROTOCOL_MOUSE = 2;
|
Section 4.3 |
HID Class Descriptor Types (See USB HID v1.11 specification) | |
USB_HID_DESCRIPTOR_TYPE_HID = $21;
|
Section 7.1 |
USB_HID_DESCRIPTOR_TYPE_REPORT = $22;
|
Section 7.1 |
USB_HID_DESCRIPTOR_TYPE_PHYSICAL_DESCRIPTOR = $23;
|
Section 7.1 |
HID Request types | |
USB_HID_REQUEST_GET_REPORT = $01;
|
|
USB_HID_REQUEST_GET_IDLE = $02;
|
|
USB_HID_REQUEST_GET_PROTOCOL = $03;
|
Section 7.2 |
USB_HID_REQUEST_SET_REPORT = $09;
|
|
USB_HID_REQUEST_SET_IDLE = $0A;
|
|
USB_HID_REQUEST_SET_PROTOCOL = $0B;
|
Section 7.2 |
HID Protocol types | |
USB_HID_PROTOCOL_BOOT = 0;
|
Section 7.2.5 |
USB_HID_PROTOCOL_REPORT = 1;
|
Section 7.2.5 |
HID Report types | |
USB_HID_REPORT_INPUT = 1;
|
Section 7.2.1 |
USB_HID_REPORT_OUTPUT = 2;
|
Section 7.2.1 |
USB_HID_REPORT_FEATURE = 3;
|
Section 7.2.1 |
HID Report IDs | |
USB_HID_REPORTID_NONE = 0;
|
Section 7.2.1 |
HID Boot Protocol Button bits | |
USB_HID_BOOT_LEFT_BUTTON = (1 shl 0);
|
|
USB_HID_BOOT_RIGHT_BUTTON = (1 shl 1);
|
|
USB_HID_BOOT_MIDDLE_BUTTON = (1 shl 2);
|
|
USB_HID_BOOT_SIDE_BUTTON = (1 shl 3);
|
|
USB_HID_BOOT_EXTRA_BUTTON = (1 shl 4);
|
|
HID Boot Protocol Report data | |
USB_HID_BOOT_REPORT_SIZE = 3;
|
Appendix B of HID Device Class Definition 1.11 |
USB_HID_BOOT_DATA_SIZE = 8;
|
Allocate more than the minimum to allow for extra data |
Type definitions
USB HID descriptor
PUSBHIDDescriptor = ^TUSBHIDDescriptor;
TUSBHIDDescriptor = packed record
bLength:Byte;
|
|
bDescriptorType:Byte;
|
|
bcdHID:Word;
|
|
bCountryCode:Byte;
|
|
bNumDescriptors:Byte;
|
|
bHIDDescriptorType:Byte;
|
|
wHIDDescriptorLength:Word;
|
|
Note: Up to two optional bHIDDescriptorType/wHIDDescriptorLength pairs after the Report descriptor details |
USB mouse device
PUSBMouseDevice = ^TUSBMouseDevice;
TUSBMouseDevice = record
Mouse Properties | |
Mouse:TMouseDevice;
|
|
USB Properties | |
HIDInterface:PUSBInterface;
|
USB HID Mouse Interface |
ReportRequest:PUSBRequest;
|
USB request for mouse report data |
ReportEndpoint:PUSBEndpointDescriptor;
|
USB Mouse Interrupt IN Endpoint |
HIDDescriptor:PUSBHIDDescriptor;
|
USB HID Descriptor for mouse |
ReportDescriptor:Pointer;
|
USB HID Report Descriptor for mouse |
PendingCount:LongWord;
|
Number of USB requests pending for this mouse |
WaiterThread:TThreadId;
|
Thread waiting for pending requests to complete (for mouse detachment) |
Public variables
None defined
Function declarations
Initialization functions
procedure USBMouseInit;
Note | Called only during system startup |
---|
USB mouse functions
function USBMouseDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Device | The USB device to attempt to bind to |
---|---|
Interrface | The USB interface to attempt to bind to (or nil for whole device) |
Return | USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure. |
function USBMouseDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Device | The USB device to unbind from |
---|---|
Interrface | The USB interface to unbind from (or nil for whole device) |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
procedure USBMouseReportWorker(Request:PUSBRequest);
Request | The USB request which has completed |
---|
procedure USBMouseReportComplete(Request:PUSBRequest);
Request | The USB request which has completed |
---|---|
Note | Request is passed to worker thread for processing to prevent blocking the USB completion |
USB mouse helper functions
function USBMouseCheckDevice(Device:PUSBDevice):Boolean;
Device | The USB device to check |
---|---|
Return | True if the device is suitable or False if it is not |
function USBMouseDeviceSetProtocol(Mouse:PUSBMouseDevice; Protocol:Byte):LongWord;
Mouse | The USB mouse device to set the report protocol for |
---|---|
Protocol | The report protocol to set (eg USB_HID_PROTOCOL_BOOT) |
Return | USB_STATUS_SUCCESS if completed or another USB error code on failure |
function USBMouseDeviceGetHIDDescriptor(Mouse:PUSBMouseDevice; Descriptor:PUSBHIDDescriptor):LongWord;
Mouse | The USB mouse device to get the descriptor for |
---|---|
Descriptor | Pointer to a USB HID Descriptor structure for the returned data |
Return | USB_STATUS_SUCCESS if completed or another USB error code on failure |
function USBMouseDeviceGetReportDescriptor(Mouse:PUSBMouseDevice; Descriptor:Pointer; Size:LongWord):LongWord;
Mouse | The USB mouse device to get the descriptor for |
---|---|
Descriptor | Pointer to a buffer to return the USB Report Descriptor |
Size | The size in bytes of the buffer pointed to by Descriptor |
Return | USB_STATUS_SUCCESS if completed or another USB error code on failure |
Return to Unit Reference