[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] Wheel mouse support
From: |
Volker Ruppert |
Subject: |
[Qemu-devel] [PATCH] Wheel mouse support |
Date: |
Mon, 17 Jan 2005 22:22:20 +0100 |
User-agent: |
KMail/1.5.4 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] Wheel mouse support,
Volker Ruppert <=