Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/bitsy/mouse.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname bitsy/mouse.c 2000/1020
## diff -e /dev/null /n/emeliedump/2000/1020/sys/src/9/bitsy/mouse.c
0a
#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 */
	}
}
.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].