From: Peter Dinda Date: Fri, 12 Apr 2013 23:03:17 +0000 (-0500) Subject: Revised mouse-related host events, graphics console, and userland support; mouse... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=33e6f079afd41e2897ee382886c46ce12f374729 Revised mouse-related host events, graphics console, and userland support; mouse packet generation --- diff --git a/linux_module/iface-graphics-console.c b/linux_module/iface-graphics-console.c index d47819c..748c8b3 100644 --- a/linux_module/iface-graphics-console.c +++ b/linux_module/iface-graphics-console.c @@ -269,16 +269,20 @@ static int palacios_graphics_console_key(struct v3_guest * guest, 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; } @@ -432,8 +436,7 @@ static int fb_input(struct v3_guest * guest, } 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"); } diff --git a/linux_module/iface-graphics-console.h b/linux_module/iface-graphics-console.h index aef5330..040aa36 100644 --- a/linux_module/iface-graphics-console.h +++ b/linux_module/iface-graphics-console.h @@ -23,8 +23,10 @@ struct v3_fb_query_response { // 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 }; diff --git a/linux_usr/v3_fb.c b/linux_usr/v3_fb.c index 69240ec..5c95e16 100644 --- a/linux_usr/v3_fb.c +++ b/linux_usr/v3_fb.c @@ -6,8 +6,12 @@ #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 @@ -36,14 +40,16 @@ int v3_send_key(int fd, uint8_t scan_code) } -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"); diff --git a/linux_usr/v3_fb.h b/linux_usr/v3_fb.h index 4c93c57..7920ff7 100644 --- a/linux_usr/v3_fb.h +++ b/linux_usr/v3_fb.h @@ -26,7 +26,10 @@ EXTERNC int v3_get_fb_data(int fd, struct v3_frame_buffer_spec *spec, void *data 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 diff --git a/palacios/include/palacios/vmm_host_events.h b/palacios/include/palacios/vmm_host_events.h index 21d4c01..d2fb211 100644 --- a/palacios/include/palacios/vmm_host_events.h +++ b/palacios/include/palacios/vmm_host_events.h @@ -22,12 +22,18 @@ 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 { diff --git a/palacios/src/devices/keyboard.c b/palacios/src/devices/keyboard.c index 3a8e58a..10f3732 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -434,16 +434,35 @@ static int mouse_event_handler(struct v3_vm_info * vm, 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; }