+ if (device_flags & MOUSE_FLAG_BUTTON1)
+ mouse1_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x01 : 0;
+ if (device_flags & MOUSE_FLAG_BUTTON2)
+ mouse2_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x02 : 0;
+
+ buf[0] = 5; // message type
+ buf[1] = mouse1_down | mouse2_down; // button mask
+ buf[2] = param1 >> 8;
+ buf[3] = param1 & 0xff;
+ buf[4] = param2 >> 8;
+ buf[5] = param2 & 0xff;
+ write(vnc_sock, buf, 6);
+