Unit Mouse

From Ultibo.org
Jump to: navigation, search

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



[Expand]
Mouse specific constants MOUSE_*


[Expand]
Mouse device type MOUSE_TYPE_*


[Expand]
Mouse device state MOUSE_STATE_*


[Expand]
Mouse device flag MOUSE_FLAG_*


[Expand]
Mouse device control code MOUSE_CONTROL_*


[Expand]
Mouse buffer size MOUSE_BUFFER_*


[Expand]
Mouse sampling rate MOUSE_SAMPLE_*


[Expand]
Mouse data definition MOUSE_LEFT_*, MOUSE_RIGHT_*


[Expand]
Mouse rotation MOUSE_ROTATION_*


[Expand]
Mouse logging MOUSE_LOG_*


[Expand]
USB mouse specific constants USBMOUSE_*


[Expand]
USB HID types USB_HID_*


Type definitions



Mouse data

[Expand]

PMouseData = ^TMouseData;

TMouseData = record

Mouse buffer

[Expand]

PMouseBuffer = ^TMouseBuffer;

TMouseBuffer = record

Mouse properties

[Expand]

PMouseProperties = ^TMouseProperties;

TMouseProperties = record

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

[Expand]

PMouseDevice = ^TMouseDevice;

TMouseDevice = record

USB HID descriptor

[Expand]

PUSBHIDDescriptor = ^TUSBHIDDescriptor;

TUSBHIDDescriptor = packed record


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

[Expand]
procedure MouseInit;
Description: Initialize the mouse unit and device table


Mouse functions

[Expand]
function MousePeek:LongWord;
Description: Peek at the global mouse buffer to see if any data packets are ready


[Expand]
function MouseRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
Description: Read mouse data packets from the global mouse buffer


[Expand]
function MouseReadEx(Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Read mouse data packets from the global mouse buffer


[Expand]
function MouseWrite(Buffer:Pointer; Size,Count:LongWord):LongWord;
Description: Write mouse data packets to the global mouse buffer


[Expand]
function MouseFlush:LongWord;
Description: Flush the contents of the global mouse buffer


[Expand]
function MouseDeviceRead(Mouse:PMouseDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Read mouse data packets from the buffer of the specified mouse


[Expand]
function MouseDeviceUpdate(Mouse:PMouseDevice):LongWord;
Description: Request the specified mouse device to update the current configuration


[Expand]
function MouseDeviceControl(Mouse:PMouseDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: Perform a control request on the specified mouse device


[Expand]
function MouseDeviceGetProperties(Mouse:PMouseDevice; Properties:PMouseProperties):LongWord;
Description: Get the properties for the specified mouse device


[Expand]
function MouseDeviceSetState(Mouse:PMouseDevice; State:LongWord):LongWord;
Description: Set the state of the specified mouse and send a notification


[Expand]
function MouseDeviceCreate:PMouseDevice;
Description: Create a new Mouse device entry


[Expand]
function MouseDeviceCreateEx(Size:LongWord):PMouseDevice;
Description: Create a new Mouse device entry


[Expand]
function MouseDeviceDestroy(Mouse:PMouseDevice):LongWord;
Description: Destroy an existing Mouse device entry


[Expand]
function MouseDeviceRegister(Mouse:PMouseDevice):LongWord;
Description: Register a new Mouse device in the Mouse table


[Expand]
function MouseDeviceDeregister(Mouse:PMouseDevice):LongWord;
Description: Deregister a Mouse device from the Mouse table


[Expand]
function MouseDeviceFind(MouseId:LongWord):PMouseDevice;
Description: Find a mouse device by ID in the mouse table


[Expand]
function MouseDeviceFindByName(const Name:String):PMouseDevice; inline;
Description: Find a mouse device by name in the mouse table


[Expand]
function MouseDeviceFindByDescription(const Description:String):PMouseDevice; inline;
Description: Find a mouse device by description in the mouse table


[Expand]
function MouseDeviceEnumerate(Callback:TMouseEnumerate; Data:Pointer):LongWord;
Description: Enumerate all mouse devices in the mouse table


[Expand]
function MouseDeviceNotification(Mouse:PMouseDevice; Callback:TMouseNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for mouse device changes


RTL console functions

[Expand]
function SysConsoleHideMouse(AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleHideMouse function


[Expand]
function SysConsoleShowMouse(X,Y:LongWord; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleShowMouse function


[Expand]
function SysConsoleReadMouse(var X,Y,Buttons:LongWord; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadMouse function


Mouse helper functions

[Expand]
function MouseGetCount:LongWord;
Description: Get the current mouse count


[Expand]
function MouseDeviceCheck(Mouse:PMouseDevice):PMouseDevice;
Description: Check if the supplied Mouse is in the mouse table


[Expand]
function MouseDeviceTypeToString(MouseType:LongWord):String;
Description: To be documented


[Expand]
function MouseDeviceStateToString(MouseState:LongWord):String;
Description: To be documented


[Expand]
function MouseDeviceRotationToString(Rotation:LongWord):String;
Description: Return a string describing the supplied mouse rotation value


[Expand]
function MouseDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Mouse state value into the notification code for device notifications


[Expand]
function MouseDeviceResolveRotation(ARotation:LongWord):LongWord;
Description: Resolve a value of 0, 90, 180 or 270 to a mouse rotation constant (eg MOUSE_ROTATION_180)


[Expand]
function MouseInsertData(Mouse:PMouseDevice; Data:PMouseData; Signal:Boolean):LongWord;
Description: Insert a TMouseData entry into the mouse buffer (Direct or Global)


[Expand]
procedure MouseLog(Level:LongWord; Mouse:PMouseDevice; const AText:String);
Description: To be documented


[Expand]
procedure MouseLogInfo(Mouse:PMouseDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure MouseLogWarn(Mouse:PMouseDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure MouseLogError(Mouse:PMouseDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure MouseLogDebug(Mouse:PMouseDevice;const AText:String); inline;
Description: To be documented


Return to Unit Reference