buttons = mb.status;
buttons = mb.status & BUTSTATMASK;
void rpc_mouse_io(void){	int dy = 0, dx = 0;	struct mousebufrec mb;	static int buttons = 0;	int was_mouse = 0;	xEvent x_event;	/* Try the mouse */	while (read(private.mouse_fd, &mb, sizeof(mb)) > 0)	{		/* Was it an ioctl acknowledge ? */		if (mb.status & IOC_ACK)			continue;		/* It was the mouse */		was_mouse = 1;		/* Get the time of the event as near as possible */		x_event.u.keyButtonPointer.time = TVTOMILLI(mb.event_time);;		/* Process the mouse event */		dx += mb.x;		dy -= mb.y;		/* Have the buttons changed ? */		if (buttons != mb.status) {			if(LEFTB(buttons) != LEFTB(mb.status)){				x_event.u.u.detail = 1;	/* leftmost */				x_event.u.u.type = LEFTB(mb.status) ?				    ButtonRelease : ButtonPress;				mieqEnqueue(&x_event);			}			if(MIDDLEB(buttons) != MIDDLEB(mb.status)){				x_event.u.u.detail = 2;	/* middle */				x_event.u.u.type = MIDDLEB(mb.status) ?				    ButtonRelease : ButtonPress;				mieqEnqueue(&x_event);			}			if(RIGHTB(buttons) != RIGHTB(mb.status)){				x_event.u.u.detail = 3;	/* right */				x_event.u.u.type = RIGHTB(mb.status) ?				    ButtonRelease : ButtonPress;				mieqEnqueue(&x_event);			}			buttons = mb.status;		}	}	/* Once we have processed all the pending mouse events ... */	if (was_mouse) {		DeviceIntPtr device = (DeviceIntPtr)LookupPointerDevice();		dx = mouse_accel(device, dx);		dy = mouse_accel(device, dy);		if (dy || dx)			miPointerDeltaCursor(dx, dy,			    x_event.u.keyButtonPointer.time);	}}