qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Volker Ruppert <info@vruppert.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Wheel mouse support
Date: Mon, 17 Jan 2005 22:22:20 +0100	[thread overview]
Message-ID: <200501172222.20459.info@vruppert.de> (raw)

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

                 reply	other threads:[~2005-01-17 21:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200501172222.20459.info@vruppert.de \
    --to=info@vruppert.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).