PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
Mouse Abstraction

Mouse driver abstraction. More...

Collaboration diagram for Mouse Abstraction:

Detailed Description

Mouse driver abstraction.

Mouse devices are exposed as a /dev/mouse/[id]/ directory, containing the below files.

name

A read-only file that contains the driver defined name of the mouse device.

events

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.

1_10x-5y1^3z

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.

Note
The format is specified such that if 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_tmouse_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.
 

Macro Definition Documentation

◆ MOUSE_CLIENT_BUFFER_SIZE

#define MOUSE_CLIENT_BUFFER_SIZE   512

Size of the mouse client buffer.

Definition at line 53 of file mouse.h.

Function Documentation

◆ mouse_new()

mouse_t * mouse_new ( const char *  name)

Allocate and initialize a mouse structure.

Will make the mouse available under /dev/mouse/[id].

Parameters
nameDriver specified name of the mouse device.
Returns
On success, the new mouse structure. On failure, NULL and errno is set.

Definition at line 144 of file mouse.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_free()

void mouse_free ( mouse_t mouse)

Free and deinitialize a mouse structure.

Removes the mouse from /dev/mouse/[id].

Parameters
mousePointer to the mouse structure to free.

Definition at line 219 of file mouse.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_press()

void mouse_press ( mouse_t mouse,
uint32_t  button 
)

Push a mouse button press event to the mouse event queue.

Parameters
mousePointer to the mouse structure.
buttonButton to press.

Definition at line 246 of file mouse.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_release()

void mouse_release ( mouse_t mouse,
uint32_t  button 
)

Push a mouse button release event to the mouse event queue.

Parameters
mousePointer to the mouse structure.
buttonButton to release.

Definition at line 264 of file mouse.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_move_x()

void mouse_move_x ( mouse_t mouse,
int64_t  delta 
)

Push a mouse movement in the X direction to the mouse event queue.

Parameters
mousePointer to the mouse structure.
deltaAmount to move in the X direction.

Definition at line 282 of file mouse.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_move_y()

void mouse_move_y ( mouse_t mouse,
int64_t  delta 
)

Push a mouse movement in the Y direction to the mouse event queue.

Parameters
mousePointer to the mouse structure.
deltaAmount to move in the Y direction.

Definition at line 300 of file mouse.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_scroll()

void mouse_scroll ( mouse_t mouse,
int64_t  delta 
)

Push a mouse scroll event to the mouse event queue.

Parameters
mousePointer to the mouse structure.
deltaAmount to scroll.

Definition at line 318 of file mouse.c.

Here is the call graph for this function: