diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/9/bitsy/mouse.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/9/bitsy/mouse.c')
-rwxr-xr-x | sys/src/9/bitsy/mouse.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/sys/src/9/bitsy/mouse.c b/sys/src/9/bitsy/mouse.c new file mode 100755 index 000000000..f26607022 --- /dev/null +++ b/sys/src/9/bitsy/mouse.c @@ -0,0 +1,63 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "../port/error.h" +#include "io.h" + +#define Image IMAGE +#include <draw.h> +#include <memdraw.h> +#include <cursor.h> +#include "screen.h" + +enum { + Button1 = 0x1; + Button2 = 0x2; + Button3 = 0x4; +}; + +int buttons; +Point position; + +static void +mousevent(void) { + static int curbuttons; + static Point curposition; + + if (buttons == curbuttons && eqpt(position, curposition)) + return; + + /* generate a mouse event */ + curbuttons = buttons; + curposition = position; +} + +void +buttonevent(int event) { + switch (event) { + case 0x02: + /* Button 2 down */ + buttons |= Button2; + mousevent(); + break; + case 0x82: + /* Button 2 up */ + buttons &= ~Button2; + mousevent(); + break; + case 0x03: + /* Button 3 down */ + buttons |= Button3; + mousevent(); + break; + case 0x83: + /* Button 3 up */ + buttons &= ~Button3; + mousevent(); + break; + default: + /* other buttons */ + } +} |