c46181037f39ae95f93a81856443e91fc3a91643
[winnie] / src / mouse.cc
1 #include "mouse.h"
2 #include "geom.h"
3
4 static int dev_fd = -1; // file descriptor for /dev/psaux
5 static Rect bounds;
6 static int pointer_x, pointer_y;
7
8 bool init_mouse()
9 {
10         // TODO open /dev/psaux (see O_NONBLOCK comment below)
11         return true;
12 }
13
14 void destroy_mouse()
15 {
16         // TODO close /dev/psaux
17 }
18
19 void set_mouse_bounds(const Rect &rect)
20 {
21         bounds = rect;
22 }
23
24 int get_mouse_fd()
25 {
26         return dev_fd;
27 }
28
29 void process_mouse_event()
30 {
31         /* TODO:
32          * - read all pending events from mouse fd (use O_NONBLOCK so that
33          *   read will return -1 when there are no more events instead of blocking).
34          * - process each event and update the pointer and button state
35          * - send each pointer move and button press/release to the tompost window
36          *   with the pointer on it.
37          */
38 }
39
40 void get_pointer_pos(int *x, int *y)
41 {
42         *x = pointer_x;
43         *y = pointer_y;
44 }
45
46 int get_button_state(int bn)
47 {
48         // TODO
49         return 0;
50 }