Unit Mouse
From Ultibo.org
Return to Unit Reference
Description
This unit provides both the Mouse device interface and the generic USB HID mouse driver.
Constants
To be documented
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
procedure MouseInit;
Description: Initialize the mouse unit, device table and USB mouse driver
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;
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 buffer |
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 MouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):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 (Dependant on request code) |
Argument2 | The second argument for the operation (Dependant on request code) |
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 | To be documented |
---|
function SysConsoleShowMouse(X,Y:LongWord; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleShowMouse function
Note | To be documented |
---|
function SysConsoleReadMouse(var X,Y,Buttons:LongWord; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadMouse function
Note | To be documented |
---|
USB mouse functions
function USBMouseDeviceRead(Mouse:PMouseDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Implementation of MouseDeviceRead API for USB Mouse
Note | To be documented |
---|
function USBMouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
Description: Implementation of MouseDeviceControl API for USB Mouse
Note | To be documented |
---|
function USBMouseDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Bind the Mouse driver to a USB device if it is suitable
Device | The USB device to attempt to bind to |
---|---|
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 |
function USBMouseDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Unbind the Mouse driver from a USB device
Device | The USB device to unbind from |
---|---|
Interface | 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);
Description: Called (by a Worker thread) to process a completed USB request from a USB mouse IN interrupt endpoint
Request | The USB request which has completed |
---|
procedure USBMouseReportComplete(Request:PUSBRequest);
Description: Called when a USB request from a USB mouse IN interrupt endpoint completes
Request | The USB request which has completed |
---|---|
Note | Request is passed to worker thread for processing to prevent blocking the USB completion |
Mouse helper functions
function MouseGetCount:LongWord; inline;
Description: Get the current mouse count
Note | To be documented |
---|
function MouseDeviceCheck(Mouse:PMouseDevice):PMouseDevice;
Description: Check if the supplied Mouse is in the mouse table
Note | To be documented |
---|
function MouseDeviceTypeToString(MouseType:LongWord):String;
Description: To be documented
Note | To be documented |
---|
function MouseDeviceStateToString(MouseState:LongWord):String;
Description: To be documented
Note | To be documented |
---|
function MouseDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Mouse state value into the notification code for device notifications
Note | To be documented |
---|
procedure MouseLog(Level:LongWord; Mouse:PMouseDevice; const AText:String);
Description: To be documented
Note | To be documented |
---|
procedure MouseLogInfo(Mouse:PMouseDevice; const AText:String);
Description: To be documented
Note | To be documented |
---|
procedure MouseLogError(Mouse:PMouseDevice; const AText:String);
Description: To be documented
Note | To be documented |
---|
procedure MouseLogDebug(Mouse:PMouseDevice; const AText:String);
Description: To be documented
Note | To be documented |
---|
USB mouse helper functions
function USBMouseDeviceSetProtocol(Mouse:PUSBMouseDevice; Protocol:Byte):LongWord;
Description: Set the report protocol for a USB mouse device
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 |
Return to Unit Reference