X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fmouse.cc;fp=src%2Fmouse.cc;h=c46181037f39ae95f93a81856443e91fc3a91643;hb=8a92836b3af157fd47c657cfe546887e5f5683a8;hp=0000000000000000000000000000000000000000;hpb=fb1f0ff6ab479c68cbac5c2d55de5c2beb229efd;p=winnie diff --git a/src/mouse.cc b/src/mouse.cc new file mode 100644 index 0000000..c461810 --- /dev/null +++ b/src/mouse.cc @@ -0,0 +1,50 @@ +#include "mouse.h" +#include "geom.h" + +static int dev_fd = -1; // file descriptor for /dev/psaux +static Rect bounds; +static int pointer_x, pointer_y; + +bool init_mouse() +{ + // TODO open /dev/psaux (see O_NONBLOCK comment below) + return true; +} + +void destroy_mouse() +{ + // TODO close /dev/psaux +} + +void set_mouse_bounds(const Rect &rect) +{ + bounds = rect; +} + +int get_mouse_fd() +{ + return dev_fd; +} + +void process_mouse_event() +{ + /* TODO: + * - read all pending events from mouse fd (use O_NONBLOCK so that + * read will return -1 when there are no more events instead of blocking). + * - process each event and update the pointer and button state + * - send each pointer move and button press/release to the tompost window + * with the pointer on it. + */ +} + +void get_pointer_pos(int *x, int *y) +{ + *x = pointer_x; + *y = pointer_y; +} + +int get_button_state(int bn) +{ + // TODO + return 0; +}