static int palacios_graphics_console_mouse(struct v3_guest * guest,
struct palacios_graphics_console *cons,
- uint8_t x, uint8_t y, uint8_t buttons)
+ uint8_t sx, uint8_t dx,
+ uint8_t sy, uint8_t dy,
+ uint8_t buttons)
{
- /*
+
struct v3_mouse_event e;
- e.data[0]=x;
- e.data[1]=y;
- e.data[2]=buttons; // These three are completely wrong, of course - ignoring mouse for now
- */
- // mouse delivery is broken, so don't do it.
- // v3_deliver_mouse_event(guest->v3_ctx,&e);
+
+ e.sx=sx;
+ e.dx=dx;
+ e.sy=sy;
+ e.dy=dy;
+ e.buttons=buttons;
+
+ v3_deliver_mouse_event(guest->v3_ctx,&e);
return 0;
}
}
if ((inp.data_type == V3_FB_MOUSE) || (inp.data_type == V3_FB_BOTH)) {
- rc |= palacios_graphics_console_mouse(guest, cons, inp.mouse_data[0],
- inp.mouse_data[1], inp.mouse_data[2]);
+ rc |= palacios_graphics_console_mouse(guest, cons, inp.sx, inp.dx, inp.sy, inp.dy, inp.buttons);
//DEBUG("palacios: mouse delivered to palacios\n");
}
// This is what userland sends down for input events
struct v3_fb_input {
enum { V3_FB_KEY, V3_FB_MOUSE, V3_FB_BOTH} data_type;
- uint8_t scan_code;
- uint8_t mouse_data[3];
+ uint8_t scan_code; // kbd scan code
+ uint8_t sx, dx; // mouse horizontal sign and dx
+ uint8_t sy, dy; // mouse vertical sign and dy
+ uint8_t buttons; // mouse buttons
};
#define V3_VM_FB_INPUT 256+1
struct v3_fb_input {
enum { V3_FB_KEY, V3_FB_MOUSE, V3_FB_BOTH} data_type;
- uint8_t scan_code;
- uint8_t mouse_data[3];
+ uint8_t scan_code;
+ uint8_t sx; // sign bit for deltax
+ uint8_t dx; // deltax
+ uint8_t sy; // sign bit for deltay
+ uint8_t dy; // deltay
+ uint8_t buttons; // button state
};
#define V3_VM_FB_QUERY 256+2
}
-int v3_send_mouse(int fd, uint8_t mx, uint8_t my, uint8_t button)
+int v3_send_mouse(int fd, uint8_t sx, uint8_t dx, uint8_t sy, uint8_t dy, uint8_t buttons)
{
struct v3_fb_input e;
e.data_type=V3_FB_MOUSE;
- e.mouse_data[0]=mx;
- e.mouse_data[1]=my;
- e.mouse_data[2]=button;
+ e.sx=sx;
+ e.dx=dx;
+ e.sy=sy;
+ e.dy=dy;
+ e.buttons=buttons;
if (ioctl(fd,V3_VM_FB_INPUT,&e)<0) {
perror("v3_send_mouse");
EXTERNC int v3_send_key(int fd, uint8_t scan_code);
-EXTERNC int v3_send_mouse(int fd, uint8_t mx, uint8_t my, uint8_t button);
+EXTERNC int v3_send_mouse(int fd,
+ uint8_t sx, uint8_t dx, // dx sign and dx
+ uint8_t sy, uint8_t dy, // dy sign and dy
+ uint8_t buttons); // button state
struct v3_keyboard_event {
+ // A keyboard event is a PS/2 scancode and status reg
unsigned char status;
unsigned char scan_code;
};
struct v3_mouse_event {
- unsigned char data[3];
+ // A mouse event is a PS/2 mouse packet
+ unsigned char sx; // sign bit for deltax
+ unsigned char dx; // deltax
+ unsigned char sy; // sign bit for deltay
+ unsigned char dy; // deltay
+ unsigned char buttons; // button state
};
struct v3_timer_event {
switch (kbd->mouse_state) {
case STREAM:
-
+ // packet is 3 bytes of form
+ // YO | XO | YS | XS | 1 | MIDDLE | RIGHT | LEFT
+ // DX
+ // YY
if (kbd->cmd.mouse_disable == 0) {
- push_to_output_queue(kbd, evt->data[0], DATA, MOUSE);
- push_to_output_queue(kbd, evt->data[1], DATA, MOUSE);
- push_to_output_queue(kbd, evt->data[2], DATA, MOUSE);
+ uint8_t h;
+ // YO=0
+ // XO=0
+ // bit 3 set
+ h=0x08;
+ // YS bit
+ h |= (!!(evt->sy)) << 5;
+ // XS bit
+ h |= (!!(evt->sx)) << 4;
+ // buttons
+ h |= (evt->buttons) & 0x7;
+ // header byte
+ push_to_output_queue(kbd, h, DATA, MOUSE);
+ // dx
+ push_to_output_queue(kbd, evt->dx, DATA, MOUSE);
+ // dy
+ push_to_output_queue(kbd, evt->dy, DATA, MOUSE);
+ } else {
+ PrintDebug(vm,VCORE_NONE, "Ignoring mouse event because mouse is disabled\n");
}
break;
default:
- PrintError(vm, VCORE_NONE, "Invalid mouse state\n");
- ret = -1;
+ PrintDebug(vm, VCORE_NONE, "Ignoring mouse event due to mouse not being in stream mode\n");
+ ret = 0;
break;
}