26#ifndef _ULTIBO_MOUSE_H
27#define _ULTIBO_MOUSE_H
38#define MOUSE_NAME_PREFIX "Mouse"
41#define MOUSE_TYPE_NONE 0
42#define MOUSE_TYPE_USB 1
43#define MOUSE_TYPE_PS2 2
44#define MOUSE_TYPE_SERIAL 3
46#define MOUSE_TYPE_MAX 3
49#define MOUSE_STATE_DETACHED 0
50#define MOUSE_STATE_DETACHING 1
51#define MOUSE_STATE_ATTACHING 2
52#define MOUSE_STATE_ATTACHED 3
54#define MOUSE_STATE_MAX 3
57#define MOUSE_FLAG_NONE 0x00000000
58#define MOUSE_FLAG_NON_BLOCK 0x00000001
59#define MOUSE_FLAG_DIRECT_READ 0x00000002
60#define MOUSE_FLAG_SWAP_BUTTONS 0x00000004
61#define MOUSE_FLAG_PEEK_BUFFER 0x00000008
62#define MOUSE_FLAG_SWAP_XY 0x00000010
63#define MOUSE_FLAG_INVERT_X 0x00000020
64#define MOUSE_FLAG_INVERT_Y 0x00000040
65#define MOUSE_FLAG_SWAP_MAX_XY 0x00000080
68#define MOUSE_FLAG_MASK MOUSE_FLAG_NON_BLOCK | MOUSE_FLAG_DIRECT_READ | MOUSE_FLAG_SWAP_BUTTONS | MOUSE_FLAG_SWAP_XY | MOUSE_FLAG_INVERT_X | MOUSE_FLAG_INVERT_Y | MOUSE_FLAG_SWAP_MAX_XY
71#define MOUSE_CONTROL_GET_FLAG 1
72#define MOUSE_CONTROL_SET_FLAG 2
73#define MOUSE_CONTROL_CLEAR_FLAG 3
74#define MOUSE_CONTROL_FLUSH_BUFFER 4
75#define MOUSE_CONTROL_GET_SAMPLE_RATE 5
76#define MOUSE_CONTROL_SET_SAMPLE_RATE 6
77#define MOUSE_CONTROL_GET_MAX_X 7
78#define MOUSE_CONTROL_GET_MAX_Y 8
79#define MOUSE_CONTROL_GET_MAX_WHEEL 9
80#define MOUSE_CONTROL_GET_MAX_BUTTONS 10
81#define MOUSE_CONTROL_GET_ROTATION 11
82#define MOUSE_CONTROL_SET_ROTATION 12
85#define MOUSE_BUFFER_SIZE 512
88#define MOUSE_SAMPLE_RATE 100
91#define MOUSE_LEFT_BUTTON 0x0001
92#define MOUSE_RIGHT_BUTTON 0x0002
93#define MOUSE_MIDDLE_BUTTON 0x0004
94#define MOUSE_SIDE_BUTTON 0x0008
95#define MOUSE_EXTRA_BUTTON 0x0010
96#define MOUSE_TOUCH_BUTTON 0x0020
97#define MOUSE_ABSOLUTE_X 0x0040
98#define MOUSE_ABSOLUTE_Y 0x0080
99#define MOUSE_ABSOLUTE_WHEEL 0x0100
102#define MOUSE_ROTATION_0 FRAMEBUFFER_ROTATION_0
103#define MOUSE_ROTATION_90 FRAMEBUFFER_ROTATION_90
104#define MOUSE_ROTATION_180 FRAMEBUFFER_ROTATION_180
105#define MOUSE_ROTATION_270 FRAMEBUFFER_ROTATION_270
111#define USB_HID_SUBCLASS_NONE 0
112#define USB_HID_SUBCLASS_BOOT 1
115#define USB_HID_BOOT_PROTOCOL_NONE 0
116#define USB_HID_BOOT_PROTOCOL_KEYBOARD 1
117#define USB_HID_BOOT_PROTOCOL_MOUSE 2
120#define USB_HID_DESCRIPTOR_TYPE_HID 0x21
121#define USB_HID_DESCRIPTOR_TYPE_REPORT 0x22
122#define USB_HID_DESCRIPTOR_TYPE_PHYSICAL_DESCRIPTOR 0x23
125#define USB_HID_REQUEST_GET_REPORT 0x01
126#define USB_HID_REQUEST_GET_IDLE 0x02
127#define USB_HID_REQUEST_GET_PROTOCOL 0x03
128#define USB_HID_REQUEST_SET_REPORT 0x09
129#define USB_HID_REQUEST_SET_IDLE 0x0A
130#define USB_HID_REQUEST_SET_PROTOCOL 0x0B
133#define USB_HID_PROTOCOL_BOOT 0
134#define USB_HID_PROTOCOL_REPORT 1
137#define USB_HID_REPORT_INPUT 1
138#define USB_HID_REPORT_OUTPUT 2
139#define USB_HID_REPORT_FEATURE 3
142#define USB_HID_REPORTID_NONE 0
145#define USB_HID_BOOT_LEFT_BUTTON (1 << 0)
146#define USB_HID_BOOT_RIGHT_BUTTON (1 << 1)
147#define USB_HID_BOOT_MIDDLE_BUTTON (1 << 2)
148#define USB_HID_BOOT_SIDE_BUTTON (1 << 3)
149#define USB_HID_BOOT_EXTRA_BUTTON (1 << 4)
152#define USB_HID_BOOT_REPORT_SIZE 8
153#define USB_HID_BOOT_DATA_SIZE 8
235#ifndef _ULTIBO_KEYBOARD_H
struct _DEVICE DEVICE
Definition devices.h:373
#define STDCALL
Definition globaltypes.h:45
#define PACKED
Definition globaltypes.h:48
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
HANDLE SEMAPHORE_HANDLE
Definition globaltypes.h:107
HANDLE MUTEX_HANDLE
Definition globaltypes.h:105
struct _USB_HID_DESCRIPTOR USB_HID_DESCRIPTOR
Definition keyboard.h:248
uint32_t STDCALL mouse_device_register(MOUSE_DEVICE *mouse)
Register a new Mouse device in the Mouse table.
uint32_t STDCALL mouse_device_type_to_string(uint32_t mousetype, char *string, uint32_t len)
MOUSE_DEVICE *STDCALL mouse_device_create_ex(uint32_t size)
Create a new Mouse device entry.
uint32_t STDCALL mouse_device_get_properties(MOUSE_DEVICE *mouse, MOUSE_PROPERTIES *properties)
Get the properties for the specified mouse device.
MOUSE_DEVICE *STDCALL mouse_device_find_by_description(const char *description)
Find a mouse device by description in the mouse table.
uint32_t STDCALL mouse_device_rotation_to_string(uint32_t rotation, char *string, uint32_t len)
Return a string describing the supplied mouse rotation value.
uint32_t STDCALL mouse_flush(void)
Flush the contents of the global mouse buffer.
uint32_t STDCALL mouse_device_destroy(MOUSE_DEVICE *mouse)
Destroy an existing Mouse device entry.
uint32_t STDCALL mouse_insert_data(MOUSE_DEVICE *mouse, MOUSE_DATA *data, BOOL signal)
Insert a TMouseData entry into the mouse buffer (Direct or Global).
uint32_t STDCALL mouse_read(void *buffer, uint32_t size, uint32_t *count)
Read mouse data packets from the global mouse buffer.
struct _MOUSE_PROPERTIES MOUSE_PROPERTIES
Definition mouse.h:181
uint32_t STDCALL mouse_device_update(MOUSE_DEVICE *mouse)
Request the specified mouse device to update the current configuration.
uint32_t STDCALL(* mouse_notification_cb)(DEVICE *device, void *data, uint32_t notification)
Definition mouse.h:198
uint32_t STDCALL mouse_device_state_to_notification(uint32_t state)
Convert a Mouse state value into the notification code for device notifications.
uint32_t STDCALL mouse_peek(void)
Peek at the global mouse buffer to see if any data packets are ready.
uint32_t STDCALL mouse_device_state_to_string(uint32_t mousestate, char *string, uint32_t len)
MOUSE_DEVICE *STDCALL mouse_device_find_by_name(const char *name)
Find a mouse device by name in the mouse table.
uint32_t STDCALL mouse_device_set_state(MOUSE_DEVICE *mouse, uint32_t state)
Set the state of the specified mouse and send a notification.
uint32_t STDCALL(* mouse_device_update_proc)(MOUSE_DEVICE *mouse)
Definition mouse.h:202
uint32_t STDCALL mouse_device_deregister(MOUSE_DEVICE *mouse)
Deregister a Mouse device from the Mouse table.
uint32_t STDCALL mouse_get_count(void)
Get the current mouse count.
uint32_t STDCALL(* mouse_enumerate_cb)(MOUSE_DEVICE *mouse, void *data)
Definition mouse.h:196
MOUSE_DEVICE *STDCALL mouse_device_find(uint32_t mouseid)
Find a mouse device by ID in the mouse table.
#define MOUSE_BUFFER_SIZE
Definition mouse.h:85
MOUSE_DEVICE *STDCALL mouse_device_check(MOUSE_DEVICE *mouse)
Check if the supplied Mouse is in the mouse table.
uint32_t STDCALL mouse_read_ex(void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
Read mouse data packets from the global mouse buffer.
uint32_t STDCALL mouse_device_notification(MOUSE_DEVICE *mouse, mouse_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
Register a notification for mouse device changes.
uint32_t STDCALL(* mouse_device_read_proc)(MOUSE_DEVICE *mouse, void *buffer, uint32_t size, uint32_t *count)
Definition mouse.h:201
uint32_t STDCALL mouse_device_enumerate(mouse_enumerate_cb callback, void *data)
Enumerate all mouse devices in the mouse table.
uint32_t STDCALL mouse_device_control(MOUSE_DEVICE *mouse, int request, size_t argument1, size_t *argument2)
Perform a control request on the specified mouse device.
uint32_t STDCALL(* mouse_device_control_proc)(MOUSE_DEVICE *mouse, int request, size_t argument1, size_t *argument2)
Definition mouse.h:203
uint32_t STDCALL(* mouse_device_get_properties_proc)(MOUSE_DEVICE *mouse, MOUSE_PROPERTIES *properties)
Definition mouse.h:205
MOUSE_DEVICE *STDCALL mouse_device_create(void)
Create a new Mouse device entry.
struct _MOUSE_DATA MOUSE_DATA
Definition mouse.h:157
struct _MOUSE_BUFFER MOUSE_BUFFER
Definition mouse.h:171
struct _MOUSE_DEVICE MOUSE_DEVICE
Definition mouse.h:193
uint32_t STDCALL mouse_write(void *buffer, uint32_t size, uint32_t count)
Write mouse data packets to the global mouse buffer.
uint32_t STDCALL mouse_device_read(MOUSE_DEVICE *mouse, void *buffer, uint32_t size, uint32_t *count)
Read mouse data packets from the buffer of the specified mouse.
uint32_t STDCALL mouse_device_resolve_rotation(uint32_t rotation)
Resolve a value of 0, 90, 180 or 270 to a mouse rotation constant (eg MOUSE_ROTATION_180).
MOUSE_DATA buffer[MOUSE_BUFFER_SIZE]
Definition mouse.h:177
uint32_t start
Index of first buffer ready.
Definition mouse.h:175
uint32_t count
Number of entries ready in buffer.
Definition mouse.h:176
SEMAPHORE_HANDLE wait
Buffer ready semaphore.
Definition mouse.h:174
uint16_t maximumwheel
The maximum Wheel value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_WHEEL,...
Definition mouse.h:166
int16_t offsetx
The X offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLU...
Definition mouse.h:161
uint16_t maximumx
The maximum X value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_X,...
Definition mouse.h:164
uint16_t maximumy
The maximum Y value of the mouse (Only applicable if Buttons includes MOUSE_ABSOLUTE_Y,...
Definition mouse.h:165
uint16_t buttons
The bitmap of current button values (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON).
Definition mouse.h:160
uint16_t reserved
Reserved field (Round structure to 16 bytes).
Definition mouse.h:167
int16_t offsety
The Y offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLU...
Definition mouse.h:162
int16_t offsetwheel
The X offset of the mouse pointer (May be negative, read as absolute if Buttons includes MOUSE_ABSOLU...
Definition mouse.h:163
MUTEX_HANDLE lock
Mouse lock.
Definition mouse.h:220
uint32_t receiveerrors
Definition mouse.h:225
uint32_t mouseid
Unique Id of this Mouse in the Mouse table.
Definition mouse.h:212
MOUSE_PROPERTIES properties
Device properties.
Definition mouse.h:222
uint32_t mousestate
Mouse state (eg MOUSE_STATE_ATTACHED).
Definition mouse.h:213
mouse_device_control_proc devicecontrol
A Device specific DeviceControl method implementing a standard Mouse device interface (Or nil if the ...
Definition mouse.h:217
DEVICE device
The Device entry for this Mouse.
Definition mouse.h:210
MOUSE_DEVICE * next
Next entry in Mouse table.
Definition mouse.h:229
uint32_t receivecount
Definition mouse.h:224
MOUSE_DEVICE * prev
Previous entry in Mouse table.
Definition mouse.h:228
MOUSE_BUFFER buffer
Mouse input buffer.
Definition mouse.h:221
mouse_device_get_properties_proc devicegetproperties
A Device specific DeviceGetProperties method implementing a standard Mouse device interface (Or nil i...
Definition mouse.h:218
mouse_device_update_proc deviceupdate
A Device specific DeviceUpdate method implementing a standard Mouse device interface (Or nil if the d...
Definition mouse.h:216
uint32_t mouserate
Mouse sample rate (Samples per second).
Definition mouse.h:214
uint32_t bufferoverruns
Definition mouse.h:226
mouse_device_read_proc deviceread
A Device specific DeviceRead method implementing a standard Mouse device interface (Or nil if the def...
Definition mouse.h:215
uint32_t maxwheel
Maximum (absolute) wheel value for the mouse device.
Definition mouse.h:188
uint32_t maxx
Maximum (absolute) X value for the mouse device.
Definition mouse.h:186
uint32_t flags
Device flags (eg MOUSE_FLAG_SWAP_BUTTONS).
Definition mouse.h:184
uint32_t maxbuttons
Maximum buttons mask (eg MOUSE_LEFT_BUTTON or MOUSE_RIGHT_BUTTON etc).
Definition mouse.h:189
uint32_t maxy
Maximum (absolute) Y value for the mouse device.
Definition mouse.h:187
uint32_t rotation
Screen Rotation (eg MOUSE_ROTATION_180).
Definition mouse.h:185
Definition keyboard.h:250
uint16_t whiddescriptorlength
Definition keyboard.h:257
uint8_t bnumdescriptors
Definition keyboard.h:255
uint16_t bcdhid
Definition keyboard.h:253
uint8_t bdescriptortype
Definition keyboard.h:252
uint8_t bhiddescriptortype
Definition keyboard.h:256
uint8_t blength
Definition keyboard.h:251
uint8_t bcountrycode
Definition keyboard.h:254