From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CqeVg-0000qX-H5 for qemu-devel@nongnu.org; Mon, 17 Jan 2005 16:34:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CqeVd-0000od-0g for qemu-devel@nongnu.org; Mon, 17 Jan 2005 16:34:01 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CqeVc-0000mF-0h for qemu-devel@nongnu.org; Mon, 17 Jan 2005 16:34:00 -0500 Received: from [212.227.126.171] (helo=moutng.kundenserver.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CqeFi-0003jO-0r for qemu-devel@nongnu.org; Mon, 17 Jan 2005 16:17:34 -0500 Received: from [212.227.126.206] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1CqeFg-0003JT-00 for qemu-devel@nongnu.org; Mon, 17 Jan 2005 22:17:32 +0100 Received: from [217.237.96.247] (helo=pD9ED60F7.dip0.t-ipconnect.de) by mrelayng.kundenserver.de with asmtp (TLSv1:RC4-MD5:128) (Exim 3.35 #1) id 1CqeFg-000193-00 for qemu-devel@nongnu.org; Mon, 17 Jan 2005 22:17:32 +0100 From: Volker Ruppert Date: Mon, 17 Jan 2005 22:22:20 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200501172222.20459.info@vruppert.de> Subject: [Qemu-devel] [PATCH] Wheel mouse support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi all! Today I found out why the mouse wheel in qemu could not work. The button state returned by SDL_GetRelativeMouseState() always returns 0 if the wheel is scrolled. Since the wheel data is present in the button event, I'm using this information. I have tested the wheel successfully with Win98 and the latest Bochs BIOS. Win98 uses the BIOS function "set sample rate" (INT 15h, AX=C202h) to detect the wheel capabilities. diff -urN /home/volker/qemu/hw/pckbd.c ./hw/pckbd.c --- /home/volker/qemu/hw/pckbd.c 2004-07-10 19:27:05.000000000 +0200 +++ ./hw/pckbd.c 2005-01-17 21:59:56.000000000 +0100 @@ -549,7 +549,6 @@ break; case AUX_SET_SAMPLE: s->mouse_sample_rate = val; -#if 0 /* detect IMPS/2 or IMEX */ switch(s->mouse_detect_state) { default: @@ -576,7 +575,6 @@ s->mouse_detect_state = 0; break; } -#endif kbd_queue(s, AUX_ACK, 1); s->mouse_write_cmd = -1; break; diff -urN /home/volker/qemu/sdl.c ./sdl.c --- /home/volker/qemu/sdl.c 2004-12-12 18:36:50.000000000 +0100 +++ ./sdl.c 2005-01-17 22:03:18.000000000 +0100 @@ -39,6 +39,7 @@ static int gui_fullscreen_initial_grab; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static uint8_t modifiers_state[256]; +static int wheel_data; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -281,7 +282,7 @@ static void sdl_send_mouse_event(void) { - int dx, dy, dz, state, buttons; + int dx, dy, state, buttons; state = SDL_GetRelativeMouseState(&dx, &dy); buttons = 0; if (state & SDL_BUTTON(SDL_BUTTON_LEFT)) @@ -290,15 +291,8 @@ buttons |= MOUSE_EVENT_RBUTTON; if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) buttons |= MOUSE_EVENT_MBUTTON; - /* XXX: test wheel */ - dz = 0; -#ifdef SDL_BUTTON_WHEELUP - if (state & SDL_BUTTON(SDL_BUTTON_WHEELUP)) - dz--; - if (state & SDL_BUTTON(SDL_BUTTON_WHEELDOWN)) - dz++; -#endif - kbd_mouse_event(dx, dy, dz, buttons); + /* XXX: state does not return wheel data */ + kbd_mouse_event(dx, dy, wheel_data, buttons); } static void toggle_full_screen(DisplayState *ds) @@ -330,6 +324,7 @@ vga_update_display(); while (SDL_PollEvent(ev)) { + wheel_data = 0; switch (ev->type) { case SDL_VIDEOEXPOSE: sdl_update(ds, 0, 0, screen->w, screen->h); @@ -440,6 +435,13 @@ sdl_grab_start(); } } else { +#ifdef SDL_BUTTON_WHEELUP + if (bev->button == SDL_BUTTON_WHEELUP) { + wheel_data = -1; + } else if (bev->button == SDL_BUTTON_WHEELDOWN) { + wheel_data = 1; + } +#endif sdl_send_mouse_event(); } } -- Bye Volker