Wheel mouse support
PATCH 1/1 Wheel mouse support
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.
hw/pckbd.c renamed from home/volker/qemu/hw/pckbd.c +0 -2
@@ -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 ;
sdl.c renamed from home/volker/qemu/sdl.c +12 -10
@@ -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