qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Brad Jorsch <anomie@users.sourceforge.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/5] Pass hwheel events from the front-ends
Date: Tue,  4 May 2010 12:56:39 -0400	[thread overview]
Message-ID: <1272992201-26911-4-git-send-email-anomie@users.sourceforge.net> (raw)
In-Reply-To: <1272992201-26911-1-git-send-email-anomie@users.sourceforge.net>

SDL seems to report hwheel events as SDL_BUTTON_X1 and SDL_BUTTON_X2.
VNC I am guessing is similar, and online docs indicate that Cocoa
reports hwheel deltas in deltaX for NSScrollWheel.

Signed-off-by: Brad Jorsch <anomie@users.sourceforge.net>
---
 cocoa.m |    2 +-
 sdl.c   |   12 ++++++++++--
 vnc.c   |   11 ++++++++---
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/cocoa.m b/cocoa.m
index c247833..afc1b5f 100644
--- a/cocoa.m
+++ b/cocoa.m
@@ -649,7 +649,7 @@ static int cocoa_keycode_to_qemu(int keycode)
             break;
         case NSScrollWheel:
             if (isTabletEnabled || isMouseGrabed) {
-                kbd_mouse_event(0, 0, -[event deltaY], 0, 0);
+                kbd_mouse_event(0, 0, -[event deltaY], -[event deltaX], 0);
             } else {
                 [NSApp sendEvent:event];
             }
diff --git a/sdl.c b/sdl.c
index 616a7eb..f6fabf1 100644
--- a/sdl.c
+++ b/sdl.c
@@ -700,8 +700,9 @@ static void sdl_refresh(DisplayState *ds)
                         sdl_grab_start();
                     }
                 } else {
-                    int dz;
+                    int dz, dw;
                     dz = 0;
+                    dw = 0;
                     if (ev->type == SDL_MOUSEBUTTONDOWN) {
                         buttonstate |= SDL_BUTTON(bev->button);
                     } else {
@@ -714,7 +715,14 @@ static void sdl_refresh(DisplayState *ds)
                         dz = 1;
                     }
 #endif
-                    sdl_send_mouse_event(0, 0, dz, 0, bev->x, bev->y,
+#ifdef SDL_BUTTON_X1
+                    if (bev->button == SDL_BUTTON_X1 && ev->type == SDL_MOUSEBUTTONDOWN) {
+                        dw = -1;
+                    } else if (bev->button == SDL_BUTTON_X2 && ev->type == SDL_MOUSEBUTTONDOWN) {
+                        dw = 1;
+                    }
+#endif
+                    sdl_send_mouse_event(0, 0, dz, dw, bev->x, bev->y,
                                          buttonstate);
                 }
             }
diff --git a/vnc.c b/vnc.c
index 332c14a..c193963 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1275,6 +1275,7 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y)
 {
     int buttons = 0;
     int dz = 0;
+    int dw = 0;
 
     if (button_mask & 0x01)
         buttons |= MOUSE_EVENT_LBUTTON;
@@ -1286,23 +1287,27 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y)
         dz = -1;
     if (button_mask & 0x10)
         dz = 1;
+    if (button_mask & 0x20)
+        dw = -1;
+    if (button_mask & 0x40)
+        dw = 1;
 
     if (vs->absolute) {
         kbd_mouse_event(ds_get_width(vs->ds) > 1 ?
                           x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000,
                         ds_get_height(vs->ds) > 1 ?
                           y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000,
-                        dz, 0, buttons);
+                        dz, dw, buttons);
     } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) {
         x -= 0x7FFF;
         y -= 0x7FFF;
 
-        kbd_mouse_event(x, y, dz, 0, buttons);
+        kbd_mouse_event(x, y, dz, dw, buttons);
     } else {
         if (vs->last_x != -1)
             kbd_mouse_event(x - vs->last_x,
                             y - vs->last_y,
-                            dz, 0, buttons);
+                            dz, dw, buttons);
         vs->last_x = x;
         vs->last_y = y;
     }
-- 
1.7.1

  parent reply	other threads:[~2010-05-04 16:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04 16:56 [Qemu-devel] [RFC] [PATCH 0/5] Add horizontal wheel support to mice, where possible Brad Jorsch
2010-05-04 16:56 ` [Qemu-devel] [PATCH 1/5] Add function parameters for hwheel Brad Jorsch
2010-05-04 16:56 ` [Qemu-devel] [PATCH 2/5] Add hwheel to monitor mouse_move Brad Jorsch
2010-05-04 16:56 ` Brad Jorsch [this message]
2010-05-04 16:56 ` [Qemu-devel] [PATCH 4/5] Add a horizontal wheel to the USB mouse and tablet Brad Jorsch
2010-05-04 16:56 ` [Qemu-devel] [PATCH 5/5] Add a horizontal wheel to the exps/2 mouse Brad Jorsch
2010-06-02 13:30 ` [Qemu-devel] [RFC] [PATCH 0/5] Add horizontal wheel support to mice, where possible Anthony Liguori
2010-06-02 16:14   ` Brad Jorsch

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=1272992201-26911-4-git-send-email-anomie@users.sourceforge.net \
    --to=anomie@users.sourceforge.net \
    --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).