feat: add support for process to conduct Intel x87 and MMX related task.
[lunaix-os.git] / lunaix-os / includes / lunaix / input.h
1 #ifndef __LUNAIX_INPUT_H
2 #define __LUNAIX_INPUT_H
3
4 #include <lunaix/clock.h>
5 #include <lunaix/device.h>
6 #include <lunaix/ds/llist.h>
7 #include <lunaix/ds/waitq.h>
8 #include <lunaix/types.h>
9
10 // event should propagate further
11 #define INPUT_EVT_NEXT 0
12 // event should be captured here
13 #define INPUT_EVT_CATCH 1
14
15 // key pressed (key-type device)
16 #define PKT_PRESS 0x1
17 // key released (key-type device)
18 #define PKT_RELEASE 0x2
19 // vector (e.g. mice wheel scroll, mice maneuver)
20 #define PKT_VECTOR 0x3
21
22 struct input_evt_pkt
23 {
24     uint32_t pkt_type;  // packet type
25     uint32_t scan_code; // hardware raw code
26     uint32_t sys_code;  // driver translated code
27     time_t timestamp;   // event timestamp
28 };
29
30 struct input_device
31 {
32     struct device* dev_if;            // device interface
33     struct input_evt_pkt current_pkt; // recieved event packet
34     waitq_t readers;                  // reader wait queue
35 };
36
37 typedef int (*input_evt_cb)(struct input_device* dev);
38
39 struct input_evt_chain
40 {
41     struct llist_header chain;
42     input_evt_cb evt_cb;
43 };
44
45 void
46 input_init();
47
48 void
49 input_fire_event(struct input_device* idev, struct input_evt_pkt* pkt);
50
51 void
52 input_add_listener(input_evt_cb listener);
53
54 struct input_device*
55 input_add_device(char* name_fmt, ...);
56
57 #endif /* __LUNAIX_INPUT_H */