PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
mouse.h
Go to the documentation of this file.
1#ifndef _SYS_MOUSE_H
2#define _SYS_MOUSE_H 1
3
4#include <stdint.h>
5
6#if defined(__cplusplus)
7extern "C"
8{
9#endif
10
11#include "_internal/clock_t.h"
12
13/**
14 * @brief Mouse device header.
15 * @ingroup libstd
16 * @defgroup libstd_sys_mouse Mouse device
17 *
18 * The `sys/mouse.h` header defines structs and constants used by mouse devices for example `/dev/mouse/ps2`. The
19 * primary way to use a mouse device is to open it and then read from it to retrieve `mouse_event_t` structures.
20 *
21 * @{
22 */
23
24/**
25 * @brief Mouse buttons enum.
26 *
27 * The `mouse_buttons_t` enum is used to store the state of mouse buttons.
28 *
29 */
30typedef enum
31{
32 MOUSE_NONE = 0, ///< None
33 MOUSE_RIGHT = (1 << 0), ///< Right mouse button
34 MOUSE_MIDDLE = (1 << 1), ///< Middle mouse button
35 MOUSE_LEFT = (1 << 2) ///< Left mouse button
37
38/**
39 * @brief Mouse event structure.
40 *
41 * The `mouse_event_t` structure can be read from mouse files, for example `/dev/mouse/ps2`. Mouse files will block
42 * until a mouse event happens, mouse files will never return partial events.
43 */
44typedef struct
45{
46 clock_t time; ///< Clock ticks since boot when the event happened
47 mouse_buttons_t buttons; ///< Which buttons were held down durring the event
48 int64_t deltaX; ///< Change in X coordinate
49 int64_t deltaY; ///< Change in Y coordinate
51
52#if defined(__cplusplus)
53}
54#endif
55
56#endif
57
58/** @} */
mouse_buttons_t
Mouse buttons enum.
Definition mouse.h:31
@ MOUSE_RIGHT
Right mouse button.
Definition mouse.h:33
@ MOUSE_NONE
None.
Definition mouse.h:32
@ MOUSE_MIDDLE
Middle mouse button.
Definition mouse.h:34
@ MOUSE_LEFT
Left mouse button.
Definition mouse.h:35
__UINT64_TYPE__ clock_t
A nanosecond time.
Definition clock_t.h:13
__INT64_TYPE__ int64_t
Definition stdint.h:16
Mouse event structure.
Definition mouse.h:45
mouse_buttons_t buttons
Which buttons were held down durring the event.
Definition mouse.h:47
clock_t time
Clock ticks since boot when the event happened.
Definition mouse.h:46
int64_t deltaY
Change in Y coordinate.
Definition mouse.h:49
int64_t deltaX
Change in X coordinate.
Definition mouse.h:48