Difference between revisions of "Unit Mouse"

From Ultibo.org
Jump to: navigation, search
 
(32 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
This unit provides both the Mouse device interface and the generic USB HID mouse driver.
+
'''Ultibo Mouse Interface unit'''
 +
 
 +
'''Mouse Devices'''
 +
 
 +
This unit provides the Mouse device interface and mouse API to be used by both drivers and applications.
 +
 +
The API includes functions to create, register, locate, read, write, control and configure each connected mouse device.
 +
 
 +
The API supports a global mouse buffer so multiple devices can feed data into a common buffer as well as a buffer per device to allow each device to be used for a specific purpose. For example an application with two separate displays may choose to have a mouse or pointing device to control each one individually.
  
 
=== Constants ===
 
=== Constants ===
Line 23: Line 31:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse device type constants''' <code> MOUSE_TYPE_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse device type''' <code> MOUSE_TYPE_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 48: Line 56:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse device state constants''' <code> MOUSE_STATE_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse device state''' <code> MOUSE_STATE_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 73: Line 81:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse device flag constants''' <code> MOUSE_FLAG_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse device flag''' <code> MOUSE_FLAG_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 84: Line 92:
 
|-
 
|-
 
| <code>MOUSE_FLAG_DIRECT_READ = $00000002;</code>
 
| <code>MOUSE_FLAG_DIRECT_READ = $00000002;</code>
| If set device writes mouse data to its local buffer and which must be read using MouseDeviceRead
+
| If set device writes mouse data to its local buffer which must be read using MouseDeviceRead
 
|-
 
|-
 
| <code>MOUSE_FLAG_SWAP_BUTTONS = $00000004;</code>
 
| <code>MOUSE_FLAG_SWAP_BUTTONS = $00000004;</code>
Line 91: Line 99:
 
| <code>MOUSE_FLAG_PEEK_BUFFER = $00000008;</code>
 
| <code>MOUSE_FLAG_PEEK_BUFFER = $00000008;</code>
 
| Peek at the buffer to see if any data is available, don't remove it. (Used only in Flags parameter of MouseReadEx)
 
| Peek at the buffer to see if any data is available, don't remove it. (Used only in Flags parameter of MouseReadEx)
 +
|-
 +
| <code>MOUSE_FLAG_SWAP_XY = $00000010;</code>
 +
| If set swap the X and Y coordinates
 +
|-
 +
| <code>MOUSE_FLAG_INVERT_X = $00000020;</code>
 +
| If set invert the X coordinate
 +
|-
 +
| <code>MOUSE_FLAG_INVERT_Y = $00000040;</code>
 +
| If set invert the Y coordinate
 +
|-
 +
| <code>MOUSE_FLAG_SWAP_MAX_XY = $00000080;</code>
 +
| If set swap the maximum X and Y values
 
|-
 
|-
 
|colspan="2"|&nbsp;
 
|colspan="2"|&nbsp;
Line 96: Line 116:
 
|colspan="2"|''Flags supported by MOUSE_CONTROL_GET/SET/CLEAR_FLAG''
 
|colspan="2"|''Flags supported by MOUSE_CONTROL_GET/SET/CLEAR_FLAG''
 
|-
 
|-
| <code>MOUSE_FLAG_MASK = MOUSE_FLAG_NON_BLOCK or MOUSE_FLAG_DIRECT_READ or MOUSE_FLAG_SWAP_BUTTONS;</code>
+
|colspan="2"|<code>MOUSE_FLAG_MASK = MOUSE_FLAG_NON_BLOCK or MOUSE_FLAG_DIRECT_READ or MOUSE_FLAG_SWAP_BUTTONS or MOUSE_FLAG_SWAP_XY or MOUSE_FLAG_INVERT_X or MOUSE_FLAG_INVERT_Y or MOUSE_FLAG_SWAP_MAX_XY;</code>
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
Line 103: Line 122:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse device control code constants''' <code> MOUSE_CONTROL_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse device control code''' <code> MOUSE_CONTROL_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 118: Line 137:
 
| <code>MOUSE_CONTROL_FLUSH_BUFFER = 4;</code>
 
| <code>MOUSE_CONTROL_FLUSH_BUFFER = 4;</code>
 
| Flush Buffer
 
| Flush Buffer
 +
|-
 +
| <code>MOUSE_CONTROL_GET_SAMPLE_RATE = 5;</code>
 +
| Get Sample Rate
 +
|-
 +
| <code>MOUSE_CONTROL_SET_SAMPLE_RATE = 6;</code>
 +
| Set Sample Rate
 +
|-
 +
| <code>MOUSE_CONTROL_GET_MAX_X = 7;</code>
 +
| Get Maximum X value (Only applies to Absolute X values)
 +
|-
 +
| <code>MOUSE_CONTROL_GET_MAX_Y = 8;</code>
 +
| Get Maximum Y value (Only applies to Absolute Y values)
 +
|-
 +
| <code>MOUSE_CONTROL_GET_MAX_WHEEL = 9;</code>
 +
| Get Maximum Wheel value (Only applies to Absolute Wheel values)
 +
|-
 +
| <code>MOUSE_CONTROL_GET_MAX_BUTTONS = 10;</code>
 +
| Get Maximum Buttons mask (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON etc)
 +
|-
 +
| <code>MOUSE_CONTROL_GET_ROTATION = 11;</code>
 +
| Get Rotation value (0, 90, 180, 270) (Only where supported by the driver)
 +
|-
 +
| <code>MOUSE_CONTROL_SET_ROTATION = 12;</code>
 +
| Set Rotation value (0, 90, 180, 270) (Only where supported by the driver)
 
|-
 
|-
 
|}
 
|}
Line 123: Line 166:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse buffer size constants''' <code> MOUSE_BUFFER_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse buffer size''' <code> MOUSE_BUFFER_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 134: Line 177:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse data definition constants''' <code> MOUSE_LEFT_*, MOUSE_RIGHT_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse sampling rate''' <code> MOUSE_SAMPLE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MOUSE_SAMPLE_RATE = 100;</code>
 +
| 100 samples/sec
 +
|-
 +
|}
 +
</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;">'''Mouse data definition''' <code> MOUSE_LEFT_*, MOUSE_RIGHT_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 173: Line 227:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Mouse logging constants''' <code> MOUSE_LOG_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Mouse rotation''' <code> MOUSE_ROTATION_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MOUSE_ROTATION_0 = FRAMEBUFFER_ROTATION_0;</code>
 +
| No rotation
 +
|-
 +
| <code>MOUSE_ROTATION_90  = FRAMEBUFFER_ROTATION_90;</code>
 +
| 90 degree rotation
 +
|-
 +
| <code>MOUSE_ROTATION_180 = FRAMEBUFFER_ROTATION_180;</code>
 +
| 180 degree rotation
 +
|-
 +
| <code>MOUSE_ROTATION_270 = FRAMEBUFFER_ROTATION_270;</code>
 +
| 270 degree rotation
 +
|-
 +
|}
 +
</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;">'''Mouse logging''' <code> MOUSE_LOG_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 182: Line 256:
 
| <code>MOUSE_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code>
 
| <code>MOUSE_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code>
 
| Mouse informational messages, such as a device being attached or detached
 
| Mouse informational messages, such as a device being attached or detached
 +
|-
 +
| <code>MOUSE_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code>
 +
| Mouse warning messages
 
|-
 
|-
 
| <code>MOUSE_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code>
 
| <code>MOUSE_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code>
Line 192: Line 269:
 
</div></div>
 
</div></div>
 
<br />
 
<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 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;"
 +
|-
 +
|colspan="2"|Note: The following constants are duplicated with the USBMouse unit for backwards compatibility
 +
|-
 +
|}
 +
</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"|&nbsp;
 +
|-
 +
|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"|&nbsp;
 +
|-
 +
|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"|&nbsp;
 +
|-
 +
|colspan="2"|''HID Request types''
 +
|-
 +
| <code>USB_HID_REQUEST_GET_REPORT = $01;</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_REQUEST_GET_IDLE = $02;</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_REQUEST_GET_PROTOCOL = $03;</code>
 +
| Section 7.2
 +
|-
 +
| <code>USB_HID_REQUEST_SET_REPORT = $09;</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_REQUEST_SET_IDLE = $0A;</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_REQUEST_SET_PROTOCOL = $0B;</code>
 +
| Section 7.2
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|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"|&nbsp;
 +
|-
 +
|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"|&nbsp;
 +
|-
 +
|colspan="2"|''HID Report IDs''
 +
|-
 +
| <code>USB_HID_REPORTID_NONE = 0;</code>
 +
| Section 7.2.1
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|colspan="2"|''HID Boot Protocol Button bits''
 +
|-
 +
| <code>USB_HID_BOOT_LEFT_BUTTON = (1 shl 0);</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_BOOT_RIGHT_BUTTON = (1 shl 1);</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_BOOT_MIDDLE_BUTTON = (1 shl 2);</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_BOOT_SIDE_BUTTON = (1 shl 3);</code>
 +
| &nbsp;
 +
|-
 +
| <code>USB_HID_BOOT_EXTRA_BUTTON = (1 shl 4);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|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 ===
 
----
 
----
  
''To be documented''
+
 
 +
'''Mouse data'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMouseData = ^TMouseData;</code>
 +
 
 +
<code>TMouseData = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Buttons:Word;</code>
 +
| The bitmap of current button values (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON)
 +
|-
 +
| <code>OffsetX:SmallInt;</code>
 +
| The X offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLUTE_X)
 +
|-
 +
| <code>OffsetY:SmallInt;</code>
 +
| The Y offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLUTE_Y)
 +
|-
 +
| <code>OffsetWheel:SmallInt;</code>
 +
| The X offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLUTE_WHEEL)
 +
|-
 +
| <code>MaximumX:Word;</code>
 +
| The maximum X value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_X, otherwise must be 0)
 +
|-
 +
| <code>MaximumY:Word;</code>
 +
| The maximum Y value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_Y, otherwise must be 0)
 +
|-
 +
| <code>MaximumWheel:Word;</code>
 +
| The maximum Wheel value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_WHEEL, otherwise must be 0)
 +
|-
 +
| <code>Reserved:Word;</code>
 +
| Reserved field (Round structure to 16 bytes)
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''Mouse buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMouseBuffer = ^TMouseBuffer;</code>
 +
 
 +
<code>TMouseBuffer = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Wait:TSemaphoreHandle;</code>
 +
| Buffer ready semaphore
 +
|-
 +
| <code>Start:LongWord;</code>
 +
| Index of first buffer ready
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Number of entries ready in buffer
 +
|-
 +
| <code>Buffer:array[0..(MOUSE_BUFFER_SIZE - 1)] of TMouseData; </code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Mouse properties'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMouseProperties = ^TMouseProperties;</code>
 +
 
 +
<code>TMouseProperties = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Device flags (eg MOUSE_FLAG_SWAP_BUTTONS)
 +
|-
 +
| <code>Rotation:LongWord;</code>
 +
| Screen Rotation (eg MOUSE_ROTATION_180)
 +
|-
 +
| <code>MaxX:LongWord;</code>
 +
| Maximum (absolute) X value for the mouse device
 +
|-
 +
| <code>MaxY:LongWord;</code>
 +
| Maximum (absolute) Y value for the mouse device
 +
|-
 +
| <code>MaxWheel:LongWord;</code>
 +
| Maximum (absolute) wheel value for the mouse device
 +
|-
 +
| <code>MaxButtons:LongWord;</code>
 +
| Maximum buttons mask (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON etc)
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Mouse enumeration callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMouseEnumerate = function(Mouse:PMouseDevice; Data:Pointer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mouse notification callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMouseNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''Mouse device read'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMouseDeviceRead = function(Mouse:PMouseDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mouse device update'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMouseDeviceUpdate = function(Mouse:PMouseDevice):LongWord; stdcall;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mouse device control'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMouseDeviceControl = function(Mouse:PMouseDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mouse device get properties'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMouseDeviceGetProperties = function(Mouse:PMouseDevice; Properties:PMouseProperties):LongWord; stdcall;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mouse device types'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMouseDevice = ^TMouseDevice;</code>
 +
 
 +
<code>TMouseDevice = 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 Mouse
 +
|-
 +
|colspan="2"|''Mouse Properties''
 +
|-
 +
| <code>MouseId:LongWord;</code>
 +
| Unique Id of this Mouse in the Mouse table
 +
|-
 +
| <code>MouseState:LongWord;</code>
 +
| Mouse state (eg MOUSE_STATE_ATTACHED)
 +
|-
 +
| <code>MouseRate:LongWord;</code>
 +
| Mouse sample rate (Samples per second)
 +
|-
 +
| <code>DeviceRead:TMouseDeviceRead;</code>
 +
| A Device specific DeviceRead method implementing a standard Mouse device interface (Or nil if the default method is suitable)
 +
|-
 +
| <code>DeviceUpdate:TMouseDeviceUpdate;</code>
 +
| A Device specific DeviceUpdate method implementing a standard Mouse device interface (Or nil if the default method is suitable)
 +
|-
 +
| <code>DeviceControl:TMouseDeviceControl;</code>
 +
| A Device specific DeviceControl method implementing a standard Mouse device interface (Or nil if the default method is suitable)
 +
|-
 +
| <code>DeviceGetProperties:TMouseDeviceGetProperties;</code>
 +
| A Device specific DeviceGetProperties method implementing a standard Mouse device interface (Or nil if the default method is suitable)
 +
|-
 +
|colspan="2"|''Driver Properties''
 +
|-
 +
| <code>Lock:TMutexHandle;</code>
 +
| Mouse lock
 +
|-
 +
| <code>Buffer:TMouseBuffer;</code>
 +
| Mouse input buffer
 +
|-
 +
| <code>Properties:TMouseProperties;</code>
 +
| Device properties
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| <code>ReceiveCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReceiveErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>BufferOverruns:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PMouseDevice;</code>
 +
| Previous entry in Mouse table
 +
|-
 +
| <code>Next:PMouseDevice;</code>
 +
| Next entry in Mouse table
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''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%;"|&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>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
 
 +
'''Mouse logging'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>MOUSE_DEFAULT_LOG_LEVEL:LongWord = MOUSE_LOG_LEVEL_DEBUG;</code>
 +
| style="width: 40%;"|Minimum level for Mouse messages. Only messages with level greater than or equal to this will be printed.
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>MOUSE_LOG_ENABLED:Boolean;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
<br />
  
 
=== Function declarations ===
 
=== Function declarations ===
Line 211: Line 685:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseInit;</pre>
 
<pre style="border: 0; padding-bottom:0px;">procedure MouseInit;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the mouse unit, device table and USB mouse driver</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the mouse unit and device table</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Called only during system startup
 
| Called only during system startup
 
|-
 
|-
Line 230: Line 704:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure
 
| ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure
 
|-
 
|-
Line 237: Line 711:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MouseRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read mouse data packets from the global mouse buffer</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read mouse data packets from the global mouse buffer</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the mouse data packets to
 
| Pointer to a buffer to copy the mouse data packets to
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
|-
 
|-
! '''Count'''
+
! Count
| The number of mouse data packets copied to the buffer
+
| The number of mouse data packets copied to the bufferm
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 263: Line 737:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the mouse data packets to
 
| Pointer to a buffer to copy the mouse data packets to
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags for the behaviour of the read (eg MOUSE_FLAG_NON_BLOCK)
 
| The flags for the behaviour of the read (eg MOUSE_FLAG_NON_BLOCK)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of mouse data packets copied to the buffer
 
| The number of mouse data packets copied to the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 287: Line 761:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the mouse data packets from
 
| Pointer to a buffer to copy the mouse data packets from
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of mouse data packets to copy from the buffer
 
| The number of mouse data packets to copy from the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 308: Line 782:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 320: Line 794:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to read from
 
| The mouse device to read from
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the mouse data packets to
 
| Pointer to a buffer to copy the mouse data packets to
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
| The size of the buffer in bytes (Must be at least TMouseData or greater)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of mouse data packets copied to the buffer
 
| The number of mouse data packets copied to the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 339: Line 813:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceUpdate(Mouse:PMouseDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Request the specified mouse device to update the current configuration</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Mouse
 +
| The mouse device to update
 +
|-
 +
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 +
|-
 +
! Note
 +
| Items updated can include rotation, maximum X, Y and wheel and flags (If supported)
 +
|-
 +
|}
 +
</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 MouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a control request on the specified mouse device</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a control request on the specified mouse device</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to control
 
| The mouse device to control
 
|-
 
|-
! '''Request'''
+
! Request
 
| The request code for the operation (eg MOUSE_CONTROL_GET_FLAG)
 
| The request code for the operation (eg MOUSE_CONTROL_GET_FLAG)
 
|-
 
|-
! '''Argument1'''
+
! Argument1
 
| The first argument for the operation (Dependent on request code)
 
| The first argument for the operation (Dependent on request code)
 
|-
 
|-
! '''Argument2'''
+
! Argument2
 
| The second argument for the operation (Dependent on request code)
 
| The second argument for the operation (Dependent on request code)
 
|-
 
|-
! '''Return'''
+
! Return
 +
| ERROR_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;">function MouseDeviceGetProperties(Mouse:PMouseDevice; Properties:PMouseProperties):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified 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 mouse device to get properties from
 +
|-
 +
! Properties
 +
| Pointer to a TMouseProperties structure to fill in
 +
|-
 +
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 368: Line 878:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse to set the state for
 
| The mouse to set the state for
 
|-
 
|-
! '''State'''
+
! State
 
| The new state to set and notify
 
| The new state to set and notify
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 386: Line 896:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to new Mouse device entry or nil if mouse could not be created
 
| Pointer to new Mouse device entry or nil if mouse could not be created
 
|-
 
|-
Line 398: Line 908:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Size'''
+
! Size
 
| Size in bytes to allocate for new mouse (Including the mouse device entry)
 
| Size in bytes to allocate for new mouse (Including the mouse device entry)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to new Mouse device entry or nil if mouse could not be created
 
| Pointer to new Mouse device entry or nil if mouse could not be created
 
|-
 
|-
Line 413: Line 923:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to destroy
 
| The mouse device to destroy
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 428: Line 938:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to register
 
| The mouse device to register
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 443: Line 953:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to deregister
 
| The mouse device to deregister
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 458: Line 968:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''MouseId'''
+
! MouseId
 
| The ID number of the mouse to find
 
| The ID number of the mouse to find
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to mouse device entry or nil if not found
 
| Pointer to mouse device entry or nil if not found
 
|-
 
|-
Line 473: Line 983:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Name'''
+
! Name
 
| The name of the mouse to find (eg Mouse0)
 
| The name of the mouse to find (eg Mouse0)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to mouse device entry or nil if not found
 
| Pointer to mouse device entry or nil if not found
 
|-
 
|-
Line 488: Line 998:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Description'''
+
! Description
 
| The description of the mouse to find (eg USB HID Mouse)
 
| The description of the mouse to find (eg USB HID Mouse)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to mouse device entry or nil if not found
 
| Pointer to mouse device entry or nil if not found
 
|-
 
|-
Line 503: Line 1,013:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The callback function to call for each mouse in the table
 
| The callback function to call for each mouse in the table
 
|-
 
|-
! '''Data'''
+
! Data
 
| A private data pointer to pass to callback for each mouse in the table
 
| A private data pointer to pass to callback for each mouse in the table
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 521: Line 1,031:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to notify changes for (Optional, pass nil for all mice)
 
| The mouse device to notify changes for (Optional, pass nil for all mice)
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The function to call when a notification event occurs
 
| The function to call when a notification event occurs
 
|-
 
|-
! '''Data'''
+
! Data
 
| A private data pointer to pass to callback when a notification event occurs
 
| A private data pointer to pass to callback when a notification event occurs
 
|-
 
|-
! '''Notification'''
+
! Notification
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 
|-
 
|-
Line 548: Line 1,058:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 560: Line 1,070:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 572: Line 1,082:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 579: Line 1,089:
 
<br />
 
<br />
  
'''USB mouse functions'''
+
'''Mouse helper functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 USBMouseDeviceRead(Mouse:PMouseDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MouseGetCount:LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of MouseDeviceRead API for USB Mouse</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current mouse count</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 594: Line 1,104:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 USBMouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceCheck(Mouse:PMouseDevice):PMouseDevice;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of MouseDeviceControl API for USB Mouse</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied Mouse is in the mouse table</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 606: Line 1,116:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceTypeToString(MouseType:LongWord):String;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Bind the Mouse driver to a USB device if it is suitable</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Device'''
+
! Note
| The USB device to attempt to bind to
+
| None documented
|-
+
! '''Interface'''
+
| 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
+
 
|-
 
|-
 
|}
 
|}
Line 624: Line 1,128:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceStateToString(MouseState:LongWord):String;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Unbind the Mouse driver from a USB device</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Device'''
+
! Note
| The USB device to unbind from
+
| None documented
|-
+
! '''Interface'''
+
| The USB interface to unbind from (or nil for whole device)
+
|-
+
! '''Return'''
+
| USB_STATUS_SUCCESS if completed or another error code on failure
+
 
|-
 
|-
 
|}
 
|}
Line 642: Line 1,140:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceRotationToString(Rotation:LongWord):String;</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 style="font-size: 14px; padding-left: 12px;">'''Description:''' Return a string describing the supplied mouse rotation value</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Request'''
+
! Note
| The USB request which has completed
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 654: Line 1,152:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceStateToNotification(State:LongWord):LongWord;</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 style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a Mouse state value into the notification code for device notifications</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 />
+
 
+
'''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 MouseGetCount:LongWord; inline;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current mouse count</div>
+
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 684: Line 1,164:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseDeviceCheck(Mouse:PMouseDevice):PMouseDevice;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MouseDeviceResolveRotation(ARotation:LongWord):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied Mouse is in the mouse table</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Resolve a value of 0, 90, 180 or 270 to a mouse rotation constant (eg MOUSE_ROTATION_180)</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| None documented
+
| Also accepts passing the mouse rotation constant values directly
 
|-
 
|-
 
|}
 
|}
Line 696: Line 1,176:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseDeviceTypeToString(MouseType:LongWord):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function MouseInsertData(Mouse:PMouseDevice; Data:PMouseData; Signal:Boolean):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Insert a TMouseData entry into the mouse buffer (Direct or Global)</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Mouse
| None documented
+
| The mouse device to insert data for
 
|-
 
|-
|}
+
! Data
</div></div>
+
| The TMouseData entry to insert
<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 MouseDeviceStateToString(MouseState:LongWord):String;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Note'''
+
! Signal
| None documented
+
| If True then signal that new data is available in the buffer
 
|-
 
|-
|}
+
! Return
</div></div>
+
| ERROR_SUCCESS if completed or another error code on failure
<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 MouseDeviceStateToNotification(State:LongWord):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a Mouse state value into the notification code for device notifications</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Note'''
+
! Note
| None documented
+
| Caller must hold the mouse lock
 
|-
 
|-
 
|}
 
|}
Line 737: Line 1,205:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 744: Line 1,212:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseLogInfo(Mouse:PMouseDevice; const AText:String);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MouseLogInfo(Mouse:PMouseDevice; const AText:String); inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 756: Line 1,224:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseLogError(Mouse:PMouseDevice; const AText:String);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MouseLogWarn(Mouse:PMouseDevice; const AText:String); inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 768: Line 1,236:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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 MouseLogDebug(Mouse:PMouseDevice; const AText:String);</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure MouseLogError(Mouse:PMouseDevice; const AText:String); inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 779: Line 1,247:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 
'''USB mouse helper functions'''
 
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<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>
+
<pre style="border: 0; padding-bottom:0px;">procedure MouseLogDebug(Mouse:PMouseDevice;const AText:String); inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the report protocol for a USB mouse device</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Note
| The USB mouse device to set the report protocol for
+
| None documented
|-
+
! '''Protocol'''
+
| The report protocol to set (eg USB_HID_PROTOCOL_BOOT)
+
|-
+
! '''Return'''
+
| USB_STATUS_SUCCESS if completed or another USB error code on failure
+
 
|-
 
|-
 
|}
 
|}

Latest revision as of 03:41, 15 December 2022

Return to Unit Reference


Description


Ultibo Mouse Interface unit

Mouse Devices

This unit provides the Mouse device interface and mouse API to be used by both drivers and applications.

The API includes functions to create, register, locate, read, write, control and configure each connected mouse device.

The API supports a global mouse buffer so multiple devices can feed data into a common buffer as well as a buffer per device to allow each device to be used for a specific purpose. For example an application with two separate displays may choose to have a mouse or pointing device to control each one individually.

Constants



Mouse specific constants MOUSE_*
MOUSE_NAME_PREFIX = 'Mouse'; Name prefix for Mouse Devices


Mouse device type MOUSE_TYPE_*
MOUSE_TYPE_NONE = 0;  
MOUSE_TYPE_USB = 1;  
MOUSE_TYPE_PS2 = 2;  
MOUSE_TYPE_SERIAL = 3;  
 
MOUSE_TYPE_MAX = 3;  


Mouse device state MOUSE_STATE_*
MOUSE_STATE_DETACHED = 0;  
MOUSE_STATE_DETACHING = 1;  
MOUSE_STATE_ATTACHING = 2;  
MOUSE_STATE_ATTACHED = 3;  
 
MOUSE_STATE_MAX = 3;  


Mouse device flag MOUSE_FLAG_*
MOUSE_FLAG_NONE = $00000000;  
MOUSE_FLAG_NON_BLOCK = $00000001; If set device reads are non blocking (Also supported in Flags parameter of MouseReadEx)
MOUSE_FLAG_DIRECT_READ = $00000002; If set device writes mouse data to its local buffer which must be read using MouseDeviceRead
MOUSE_FLAG_SWAP_BUTTONS = $00000004; If set left and right mouse buttons will be swapped in mouse data
MOUSE_FLAG_PEEK_BUFFER = $00000008; Peek at the buffer to see if any data is available, don't remove it. (Used only in Flags parameter of MouseReadEx)
MOUSE_FLAG_SWAP_XY = $00000010; If set swap the X and Y coordinates
MOUSE_FLAG_INVERT_X = $00000020; If set invert the X coordinate
MOUSE_FLAG_INVERT_Y = $00000040; If set invert the Y coordinate
MOUSE_FLAG_SWAP_MAX_XY = $00000080; If set swap the maximum X and Y values
 
Flags supported by MOUSE_CONTROL_GET/SET/CLEAR_FLAG
MOUSE_FLAG_MASK = MOUSE_FLAG_NON_BLOCK or MOUSE_FLAG_DIRECT_READ or MOUSE_FLAG_SWAP_BUTTONS or MOUSE_FLAG_SWAP_XY or MOUSE_FLAG_INVERT_X or MOUSE_FLAG_INVERT_Y or MOUSE_FLAG_SWAP_MAX_XY;


Mouse device control code MOUSE_CONTROL_*
MOUSE_CONTROL_GET_FLAG = 1; Get Flag
MOUSE_CONTROL_SET_FLAG = 2; Set Flag
MOUSE_CONTROL_CLEAR_FLAG = 3; Clear Flag
MOUSE_CONTROL_FLUSH_BUFFER = 4; Flush Buffer
MOUSE_CONTROL_GET_SAMPLE_RATE = 5; Get Sample Rate
MOUSE_CONTROL_SET_SAMPLE_RATE = 6; Set Sample Rate
MOUSE_CONTROL_GET_MAX_X = 7; Get Maximum X value (Only applies to Absolute X values)
MOUSE_CONTROL_GET_MAX_Y = 8; Get Maximum Y value (Only applies to Absolute Y values)
MOUSE_CONTROL_GET_MAX_WHEEL = 9; Get Maximum Wheel value (Only applies to Absolute Wheel values)
MOUSE_CONTROL_GET_MAX_BUTTONS = 10; Get Maximum Buttons mask (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON etc)
MOUSE_CONTROL_GET_ROTATION = 11; Get Rotation value (0, 90, 180, 270) (Only where supported by the driver)
MOUSE_CONTROL_SET_ROTATION = 12; Set Rotation value (0, 90, 180, 270) (Only where supported by the driver)


Mouse buffer size MOUSE_BUFFER_*
MOUSE_BUFFER_SIZE = 512;  


Mouse sampling rate MOUSE_SAMPLE_*
MOUSE_SAMPLE_RATE = 100; 100 samples/sec


Mouse data definition MOUSE_LEFT_*, MOUSE_RIGHT_*
Values for TMouseData.Buttons
 
MOUSE_LEFT_BUTTON = $0001; The Left mouse button is pressed
MOUSE_RIGHT_BUTTON = $0002; The Right mouse button is pressed
MOUSE_MIDDLE_BUTTON = $0004; The Middle mouse button is pressed
MOUSE_SIDE_BUTTON = $0008; The Side mouse button is pressed
MOUSE_EXTRA_BUTTON = $0010; The Extra mouse button is pressed
MOUSE_TOUCH_BUTTON = $0020; The Touch screen is being touched
MOUSE_ABSOLUTE_X = $0040; The OffsetX value is absolute not relative
MOUSE_ABSOLUTE_Y = $0080; The OffsetY value is absolute not relative
MOUSE_ABSOLUTE_WHEEL = $0100; The OffsetWheel value is absolute not relative


Mouse rotation MOUSE_ROTATION_*
MOUSE_ROTATION_0 = FRAMEBUFFER_ROTATION_0; No rotation
MOUSE_ROTATION_90 = FRAMEBUFFER_ROTATION_90; 90 degree rotation
MOUSE_ROTATION_180 = FRAMEBUFFER_ROTATION_180; 180 degree rotation
MOUSE_ROTATION_270 = FRAMEBUFFER_ROTATION_270; 270 degree rotation


Mouse logging MOUSE_LOG_*
MOUSE_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG; Mouse debugging messages
MOUSE_LOG_LEVEL_INFO = LOG_LEVEL_INFO; Mouse informational messages, such as a device being attached or detached
MOUSE_LOG_LEVEL_WARN = LOG_LEVEL_WARN; Mouse warning messages
MOUSE_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR; Mouse error messages
MOUSE_LOG_LEVEL_NONE = LOG_LEVEL_NONE; No Mouse messages


USB mouse specific constants USBMOUSE_*
Note: The following constants are duplicated with the USBMouse unit for backwards compatibility


USB HID types 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



Mouse data

PMouseData = ^TMouseData;

TMouseData = record

Buttons:Word; The bitmap of current button values (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON)
OffsetX:SmallInt; The X offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLUTE_X)
OffsetY:SmallInt; The Y offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLUTE_Y)
OffsetWheel:SmallInt; The X offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLUTE_WHEEL)
MaximumX:Word; The maximum X value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_X, otherwise must be 0)
MaximumY:Word; The maximum Y value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_Y, otherwise must be 0)
MaximumWheel:Word; The maximum Wheel value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_WHEEL, otherwise must be 0)
Reserved:Word; Reserved field (Round structure to 16 bytes)

Mouse buffer

PMouseBuffer = ^TMouseBuffer;

TMouseBuffer = record

Wait:TSemaphoreHandle; Buffer ready semaphore
Start:LongWord; Index of first buffer ready
Count:LongWord; Number of entries ready in buffer
Buffer:array[0..(MOUSE_BUFFER_SIZE - 1)] of TMouseData;  

Mouse properties

PMouseProperties = ^TMouseProperties;

TMouseProperties = record

Flags:LongWord; Device flags (eg MOUSE_FLAG_SWAP_BUTTONS)
Rotation:LongWord; Screen Rotation (eg MOUSE_ROTATION_180)
MaxX:LongWord; Maximum (absolute) X value for the mouse device
MaxY:LongWord; Maximum (absolute) Y value for the mouse device
MaxWheel:LongWord; Maximum (absolute) wheel value for the mouse device
MaxButtons:LongWord; Maximum buttons mask (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON etc)

Mouse enumeration callback

TMouseEnumerate = function(Mouse:PMouseDevice; Data:Pointer):LongWord;

Mouse notification callback

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

Mouse device read

TMouseDeviceRead = function(Mouse:PMouseDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;

Mouse device update

TMouseDeviceUpdate = function(Mouse:PMouseDevice):LongWord; stdcall;

Mouse device control

TMouseDeviceControl = function(Mouse:PMouseDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;

Mouse device get properties

TMouseDeviceGetProperties = function(Mouse:PMouseDevice; Properties:PMouseProperties):LongWord; stdcall;

Mouse device types

PMouseDevice = ^TMouseDevice;

TMouseDevice = record

Device Properties
Device:TDevice; The Device entry for this Mouse
Mouse Properties
MouseId:LongWord; Unique Id of this Mouse in the Mouse table
MouseState:LongWord; Mouse state (eg MOUSE_STATE_ATTACHED)
MouseRate:LongWord; Mouse sample rate (Samples per second)
DeviceRead:TMouseDeviceRead; A Device specific DeviceRead method implementing a standard Mouse device interface (Or nil if the default method is suitable)
DeviceUpdate:TMouseDeviceUpdate; A Device specific DeviceUpdate method implementing a standard Mouse device interface (Or nil if the default method is suitable)
DeviceControl:TMouseDeviceControl; A Device specific DeviceControl method implementing a standard Mouse device interface (Or nil if the default method is suitable)
DeviceGetProperties:TMouseDeviceGetProperties; A Device specific DeviceGetProperties method implementing a standard Mouse device interface (Or nil if the default method is suitable)
Driver Properties
Lock:TMutexHandle; Mouse lock
Buffer:TMouseBuffer; Mouse input buffer
Properties:TMouseProperties; Device properties
Statistics Properties
ReceiveCount:LongWord;  
ReceiveErrors:LongWord;  
BufferOverruns:LongWord;  
Internal Properties
Prev:PMouseDevice; Previous entry in Mouse table
Next:PMouseDevice; Next entry in Mouse table

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


Public variables



Mouse logging

MOUSE_DEFAULT_LOG_LEVEL:LongWord = MOUSE_LOG_LEVEL_DEBUG; Minimum level for Mouse messages. Only messages with level greater than or equal to this will be printed.
MOUSE_LOG_ENABLED:Boolean;


Function declarations



Initialization functions

procedure MouseInit;
Description: Initialize the mouse unit and device table
Note Called only during system startup


Mouse functions

function MousePeek:LongWord;
Description: Peek at the global mouse buffer to see if any data packets are ready
Return ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure


function MouseRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
Description: Read mouse data packets from the global mouse buffer
Buffer Pointer to a buffer to copy the mouse data packets to
Size The size of the buffer in bytes (Must be at least TMouseData or greater)
Count The number of mouse data packets copied to the bufferm
Return ERROR_SUCCESS if completed or another error code on failure


function MouseReadEx(Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Read mouse data packets from the global mouse buffer
Buffer Pointer to a buffer to copy the mouse data packets to
Size The size of the buffer in bytes (Must be at least TMouseData or greater)
Flags The flags for the behaviour of the read (eg MOUSE_FLAG_NON_BLOCK)
Count The number of mouse data packets copied to the buffer
Return ERROR_SUCCESS if completed or another error code on failure


function MouseWrite(Buffer:Pointer; Size,Count:LongWord):LongWord;
Description: Write mouse data packets to the global mouse buffer
Buffer Pointer to a buffer to copy the mouse data packets from
Size The size of the buffer in bytes (Must be at least TMouseData or greater)
Count The number of mouse data packets to copy from the buffer
Return ERROR_SUCCESS if completed or another error code on failure


function MouseFlush:LongWord;
Description: Flush the contents of the global mouse buffer
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceRead(Mouse:PMouseDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Read mouse data packets from the buffer of the specified mouse
Mouse The mouse device to read from
Buffer Pointer to a buffer to copy the mouse data packets to
Size The size of the buffer in bytes (Must be at least TMouseData or greater)
Count The number of mouse data packets copied to the buffer
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceUpdate(Mouse:PMouseDevice):LongWord;
Description: Request the specified mouse device to update the current configuration
Mouse The mouse device to update
Return ERROR_SUCCESS if completed or another error code on failure
Note Items updated can include rotation, maximum X, Y and wheel and flags (If supported)


function MouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: Perform a control request on the specified mouse device
Mouse The mouse device to control
Request The request code for the operation (eg MOUSE_CONTROL_GET_FLAG)
Argument1 The first argument for the operation (Dependent on request code)
Argument2 The second argument for the operation (Dependent on request code)
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceGetProperties(Mouse:PMouseDevice; Properties:PMouseProperties):LongWord;
Description: Get the properties for the specified mouse device
Mouse The mouse device to get properties from
Properties Pointer to a TMouseProperties structure to fill in
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceSetState(Mouse:PMouseDevice; State:LongWord):LongWord;
Description: Set the state of the specified mouse and send a notification
Mouse The mouse to set the state for
State The new state to set and notify
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceCreate:PMouseDevice;
Description: Create a new Mouse device entry
Return Pointer to new Mouse device entry or nil if mouse could not be created


function MouseDeviceCreateEx(Size:LongWord):PMouseDevice;
Description: Create a new Mouse device entry
Size Size in bytes to allocate for new mouse (Including the mouse device entry)
Return Pointer to new Mouse device entry or nil if mouse could not be created


function MouseDeviceDestroy(Mouse:PMouseDevice):LongWord;
Description: Destroy an existing Mouse device entry
Mouse The mouse device to destroy
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceRegister(Mouse:PMouseDevice):LongWord;
Description: Register a new Mouse device in the Mouse table
Mouse The mouse device to register
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceDeregister(Mouse:PMouseDevice):LongWord;
Description: Deregister a Mouse device from the Mouse table
Mouse The mouse device to deregister
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceFind(MouseId:LongWord):PMouseDevice;
Description: Find a mouse device by ID in the mouse table
MouseId The ID number of the mouse to find
Return Pointer to mouse device entry or nil if not found


function MouseDeviceFindByName(const Name:String):PMouseDevice; inline;
Description: Find a mouse device by name in the mouse table
Name The name of the mouse to find (eg Mouse0)
Return Pointer to mouse device entry or nil if not found


function MouseDeviceFindByDescription(const Description:String):PMouseDevice; inline;
Description: Find a mouse device by description in the mouse table
Description The description of the mouse to find (eg USB HID Mouse)
Return Pointer to mouse device entry or nil if not found


function MouseDeviceEnumerate(Callback:TMouseEnumerate; Data:Pointer):LongWord;
Description: Enumerate all mouse devices in the mouse table
Callback The callback function to call for each mouse in the table
Data A private data pointer to pass to callback for each mouse in the table
Return ERROR_SUCCESS if completed or another error code on failure


function MouseDeviceNotification(Mouse:PMouseDevice; Callback:TMouseNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for mouse device changes
Mouse The mouse device to notify changes for (Optional, pass nil for all mice)
Callback The function to call when a notification event occurs
Data A private data pointer to pass to callback when a notification event occurs
Notification The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
Flags The flags to control the notification (eg NOTIFIER_FLAG_WORKER)


RTL console functions

function SysConsoleHideMouse(AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleHideMouse function
Note None documented


function SysConsoleShowMouse(X,Y:LongWord; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleShowMouse function
Note None documented


function SysConsoleReadMouse(var X,Y,Buttons:LongWord; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadMouse function
Note None documented


Mouse helper functions

function MouseGetCount:LongWord;
Description: Get the current mouse count
Note None documented


function MouseDeviceCheck(Mouse:PMouseDevice):PMouseDevice;
Description: Check if the supplied Mouse is in the mouse table
Note None documented


function MouseDeviceTypeToString(MouseType:LongWord):String;
Description: To be documented
Note None documented


function MouseDeviceStateToString(MouseState:LongWord):String;
Description: To be documented
Note None documented


function MouseDeviceRotationToString(Rotation:LongWord):String;
Description: Return a string describing the supplied mouse rotation value
Note None documented


function MouseDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Mouse state value into the notification code for device notifications
Note None documented


function MouseDeviceResolveRotation(ARotation:LongWord):LongWord;
Description: Resolve a value of 0, 90, 180 or 270 to a mouse rotation constant (eg MOUSE_ROTATION_180)
Note Also accepts passing the mouse rotation constant values directly


function MouseInsertData(Mouse:PMouseDevice; Data:PMouseData; Signal:Boolean):LongWord;
Description: Insert a TMouseData entry into the mouse buffer (Direct or Global)
Mouse The mouse device to insert data for
Data The TMouseData entry to insert
Signal If True then signal that new data is available in the buffer
Return ERROR_SUCCESS if completed or another error code on failure
Note Caller must hold the mouse lock


procedure MouseLog(Level:LongWord; Mouse:PMouseDevice; const AText:String);
Description: To be documented
Note None documented


procedure MouseLogInfo(Mouse:PMouseDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure MouseLogWarn(Mouse:PMouseDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure MouseLogError(Mouse:PMouseDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure MouseLogDebug(Mouse:PMouseDevice;const AText:String); inline;
Description: To be documented
Note None documented


Return to Unit Reference