The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file sys/input.h
5
* @brief the events of /dev/input (ABI).
6
*
7
* one event is 12 bytes: a time, a type, a code and a value. the types and
8
* codes are the ones of Linux (linux/input-event-codes.h), so ported
9
* programs know them. a group of events that belong together (a mouse
10
* moving in x and y, and a button) ends with EV_SYN / SYN_REPORT.
11
*
12
* the kernel has a copy in src/kernel/input/input_event.h; the two must
13
* stay the same.
14
*/
15
16
#include <
stdint.h
>
17
18
typedef
struct
19
{
20
uint32_t
time_ms
;
// milliseconds since boot
21
uint16_t
type
;
// EV_
22
uint16_t
code
;
// KEY_, BTN_, REL_ or ABS_
23
int32_t
value
;
// keys: 1 down, 0 up, 2 repeat; REL: a change; ABS: a position
24
}
input_event_t
;
25
26
// event types
27
#define EV_SYN 0x00
28
#define EV_KEY 0x01
29
#define EV_REL 0x02
30
#define EV_ABS 0x03
31
32
// EV_SYN codes
33
#define SYN_REPORT 0
// the end of a group of events
34
#define SYN_DROPPED 3
// the reader was too slow: events were lost before this
35
36
// EV_REL codes
37
#define REL_X 0x00
38
#define REL_Y 0x01
// positive is down
39
#define REL_WHEEL 0x08
// positive is up (away from the user)
40
41
// EV_ABS codes: positions from 0 to INPUT_ABS_MAX across the screen
42
#define ABS_X 0x00
43
#define ABS_Y 0x01
44
#define INPUT_ABS_MAX 32767
45
46
// mouse buttons (EV_KEY)
47
#define BTN_LEFT 0x110
48
#define BTN_RIGHT 0x111
49
#define BTN_MIDDLE 0x112
50
51
// the key codes of a PC keyboard (EV_KEY), as Linux numbers them
52
#define KEY_ESC 1
53
#define KEY_1 2
54
#define KEY_2 3
55
#define KEY_3 4
56
#define KEY_4 5
57
#define KEY_5 6
58
#define KEY_6 7
59
#define KEY_7 8
60
#define KEY_8 9
61
#define KEY_9 10
62
#define KEY_0 11
63
#define KEY_MINUS 12
64
#define KEY_EQUAL 13
65
#define KEY_BACKSPACE 14
66
#define KEY_TAB 15
67
#define KEY_Q 16
68
#define KEY_W 17
69
#define KEY_E 18
70
#define KEY_R 19
71
#define KEY_T 20
72
#define KEY_Y 21
73
#define KEY_U 22
74
#define KEY_I 23
75
#define KEY_O 24
76
#define KEY_P 25
77
#define KEY_LEFTBRACE 26
78
#define KEY_RIGHTBRACE 27
79
#define KEY_ENTER 28
80
#define KEY_LEFTCTRL 29
81
#define KEY_A 30
82
#define KEY_S 31
83
#define KEY_D 32
84
#define KEY_F 33
85
#define KEY_G 34
86
#define KEY_H 35
87
#define KEY_J 36
88
#define KEY_K 37
89
#define KEY_L 38
90
#define KEY_SEMICOLON 39
91
#define KEY_APOSTROPHE 40
92
#define KEY_GRAVE 41
93
#define KEY_LEFTSHIFT 42
94
#define KEY_BACKSLASH 43
95
#define KEY_Z 44
96
#define KEY_X 45
97
#define KEY_C 46
98
#define KEY_V 47
99
#define KEY_B 48
100
#define KEY_N 49
101
#define KEY_M 50
102
#define KEY_COMMA 51
103
#define KEY_DOT 52
104
#define KEY_SLASH 53
105
#define KEY_RIGHTSHIFT 54
106
#define KEY_KPASTERISK 55
107
#define KEY_LEFTALT 56
108
#define KEY_SPACE 57
109
#define KEY_CAPSLOCK 58
110
#define KEY_F1 59
111
#define KEY_F2 60
112
#define KEY_F3 61
113
#define KEY_F4 62
114
#define KEY_F5 63
115
#define KEY_F6 64
116
#define KEY_F7 65
117
#define KEY_F8 66
118
#define KEY_F9 67
119
#define KEY_F10 68
120
#define KEY_NUMLOCK 69
121
#define KEY_SCROLLLOCK 70
122
#define KEY_KP7 71
123
#define KEY_KP8 72
124
#define KEY_KP9 73
125
#define KEY_KPMINUS 74
126
#define KEY_KP4 75
127
#define KEY_KP5 76
128
#define KEY_KP6 77
129
#define KEY_KPPLUS 78
130
#define KEY_KP1 79
131
#define KEY_KP2 80
132
#define KEY_KP3 81
133
#define KEY_KP0 82
134
#define KEY_KPDOT 83
135
#define KEY_102ND 86
136
#define KEY_F11 87
137
#define KEY_F12 88
138
#define KEY_KPENTER 96
139
#define KEY_RIGHTCTRL 97
140
#define KEY_KPSLASH 98
141
#define KEY_SYSRQ 99
142
#define KEY_RIGHTALT 100
143
#define KEY_HOME 102
144
#define KEY_UP 103
145
#define KEY_PAGEUP 104
146
#define KEY_LEFT 105
147
#define KEY_RIGHT 106
148
#define KEY_END 107
149
#define KEY_DOWN 108
150
#define KEY_PAGEDOWN 109
151
#define KEY_INSERT 110
152
#define KEY_DELETE 111
153
#define KEY_LEFTMETA 125
154
#define KEY_RIGHTMETA 126
155
#define KEY_COMPOSE 127
156
157
// ioctl: while a reader holds the grab, key events go only to /dev/input,
158
// not to the text console (the compositor takes the keyboard). int arg: 1
159
// grab, 0 release. closing the reader releases it.
160
#define INPUT_IOC_GRAB 0x40044901u
uint32_t
unsigned int uint32_t
Definition
fb.h:17
stdint.h
integer types of fixed width.
uint16_t
unsigned short uint16_t
Definition
stdint.h:13
int32_t
int int32_t
Definition
stdint.h:14
input_event_t
Definition
input.h:19
input_event_t::code
uint16_t code
Definition
input.h:22
input_event_t::value
int32_t value
Definition
input.h:23
input_event_t::type
uint16_t type
Definition
input.h:21
input_event_t::time_ms
uint32_t time_ms
Definition
input.h:20
src
libc
include
sys
input.h
Generated by
1.18.0