|
PatchworkOS
19e446b
A non-POSIX operating system.
|
Mouse driver abstraction. More...
Mouse driver abstraction.
Mouse devices are exposed as a /dev/mouse/[id]/ directory, containing the below files.
A read-only file that contains the driver defined name of the mouse device.
A readable and pollable file that provides a stream of mouse events represented as integer values suffixed with a single character indicating the type of the event.
The ´xandycharacters indicate movement in the X and Y directions respectively, the_and^represent a button press and release respectively, and thez` character represents a scroll event.
Buttons are represented as their button number starting from 1 where 1 is the left button, 2 is the right button, and 3 is the middle button.
The below example shows a press of the left mouse button, moving the mouse 10 units in the X direction and -5 units in the Y direction, releasing the left mouse button, and then scrolling 3 units.
If no events are available to read, the read call will block until an event is available unless the file is opened in non-blocking mode in which case the read will fail with EAGAIN.
scan() is used with "%u%c" the scan() call does not require any "ungets". Data Structures | |
| struct | mouse_client_t |
| Keyboard event client structure. More... | |
| struct | mouse_t |
| Mouse structure. More... | |
Macros | |
| #define | MOUSE_CLIENT_BUFFER_SIZE 512 |
| Size of the mouse client buffer. | |
Functions | |
| mouse_t * | mouse_new (const char *name) |
| Allocate and initialize a mouse structure. | |
| void | mouse_free (mouse_t *mouse) |
| Free and deinitialize a mouse structure. | |
| void | mouse_press (mouse_t *mouse, uint32_t button) |
| Push a mouse button press event to the mouse event queue. | |
| void | mouse_release (mouse_t *mouse, uint32_t button) |
| Push a mouse button release event to the mouse event queue. | |
| void | mouse_move_x (mouse_t *mouse, int64_t delta) |
| Push a mouse movement in the X direction to the mouse event queue. | |
| void | mouse_move_y (mouse_t *mouse, int64_t delta) |
| Push a mouse movement in the Y direction to the mouse event queue. | |
| void | mouse_scroll (mouse_t *mouse, int64_t delta) |
| Push a mouse scroll event to the mouse event queue. | |
| #define MOUSE_CLIENT_BUFFER_SIZE 512 |
| mouse_t * mouse_new | ( | const char * | name | ) |
Allocate and initialize a mouse structure.
Will make the mouse available under /dev/mouse/[id].
| name | Driver specified name of the mouse device. |
NULL and errno is set. Definition at line 144 of file mouse.c.
| void mouse_free | ( | mouse_t * | mouse | ) |