diff --git a/cocoa.m b/cocoa.m
index 56c789a..c247833 100644
--- a/cocoa.m
+++ b/cocoa.m
@@ -47,9 +47,9 @@
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 #define COCOA_MOUSE_EVENT \
         if (isTabletEnabled) { \
-            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \
+            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, 0, buttons); \
         } else if (isMouseGrabed) { \
-            kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, buttons); \
+            kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, 0, buttons); \
         } else { \
             [NSApp sendEvent:event]; \
         }
@@ -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);
+                kbd_mouse_event(0, 0, -[event deltaY], 0, 0);
             } else {
                 [NSApp sendEvent:event];
             }
diff --git a/console.h b/console.h
index 6def115..7ec693d 100644
--- a/console.h
+++ b/console.h
@@ -21,7 +21,7 @@
 
 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
 typedef void QEMUPutLEDEvent(void *opaque, int ledstate);
-typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
+typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int dw, int buttons_state);
 
 typedef struct QEMUPutMouseEntry {
     QEMUPutMouseEvent *qemu_put_mouse_event;
@@ -53,7 +53,7 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
 
 void kbd_put_keycode(int keycode);
 void kbd_put_ledstate(int ledstate);
-void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
+void kbd_mouse_event(int dx, int dy, int dz, int dw, int buttons_state);
 
 /* Does the current mouse generate absolute events */
 int kbd_mouse_is_absolute(void);
diff --git a/hw/adb.c b/hw/adb.c
index 4fb7a62..88be567 100644
--- a/hw/adb.c
+++ b/hw/adb.c
@@ -318,7 +318,8 @@ typedef struct MouseState {
 } MouseState;
 
 static void adb_mouse_event(void *opaque,
-                            int dx1, int dy1, int dz1, int buttons_state)
+                            int dx1, int dy1, int dz1, int dw1,
+                            int buttons_state)
 {
     ADBDevice *d = opaque;
     MouseState *s = d->opaque;
diff --git a/hw/ads7846.c b/hw/ads7846.c
index 184b3dd..544db09 100644
--- a/hw/ads7846.c
+++ b/hw/ads7846.c
@@ -86,7 +86,7 @@ static uint32_t ads7846_transfer(SSISlave *dev, uint32_t value)
 }
 
 static void ads7846_ts_event(void *opaque,
-                int x, int y, int z, int buttons_state)
+                int x, int y, int z, int w, int buttons_state)
 {
     ADS7846State *s = opaque;
 
diff --git a/hw/escc.c b/hw/escc.c
index 6d2fd36..c7b420d 100644
--- a/hw/escc.c
+++ b/hw/escc.c
@@ -827,7 +827,8 @@ static void handle_kbd_command(ChannelState *s, int val)
 }
 
 static void sunmouse_event(void *opaque,
-                               int dx, int dy, int dz, int buttons_state)
+                               int dx, int dy, int dz, int dw,
+                               int buttons_state)
 {
     ChannelState *s = opaque;
     int ch;
diff --git a/hw/msmouse.c b/hw/msmouse.c
index 05f893c..f1bfd0d 100644
--- a/hw/msmouse.c
+++ b/hw/msmouse.c
@@ -31,7 +31,7 @@
 #define MSMOUSE_HI2(n) (((n) & 0xc0) >> 6)
 
 static void msmouse_event(void *opaque,
-                          int dx, int dy, int dz, int buttons_state)
+                          int dx, int dy, int dz, int dw, int buttons_state)
 {
     CharDriverState *chr = (CharDriverState *)opaque;
 
diff --git a/hw/ps2.c b/hw/ps2.c
index f0b206a..db5605d 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -330,7 +330,7 @@ static void ps2_mouse_send_packet(PS2MouseState *s)
 }
 
 static void ps2_mouse_event(void *opaque,
-                            int dx, int dy, int dz, int buttons_state)
+                            int dx, int dy, int dz, int dw, int buttons_state)
 {
     PS2MouseState *s = opaque;
 
@@ -361,7 +361,7 @@ static void ps2_mouse_event(void *opaque,
 
 void ps2_mouse_fake_event(void *opaque)
 {
-    ps2_mouse_event(opaque, 1, 0, 0, 0);
+    ps2_mouse_event(opaque, 1, 0, 0, 0, 0);
 }
 
 void ps2_write_mouse(void *opaque, int val)
diff --git a/hw/syborg_pointer.c b/hw/syborg_pointer.c
index 563d730..04aa55b 100644
--- a/hw/syborg_pointer.c
+++ b/hw/syborg_pointer.c
@@ -122,7 +122,7 @@ static CPUWriteMemoryFunc * const syborg_pointer_writefn[] = {
    syborg_pointer_write
 };
 
-static void syborg_pointer_event(void *opaque, int dx, int dy, int dz,
+static void syborg_pointer_event(void *opaque, int dx, int dy, int dz, int dw,
                                  int buttons_state)
 {
     SyborgPointerState *s = (SyborgPointerState *)opaque;
diff --git a/hw/tsc2005.c b/hw/tsc2005.c
index b75cc86..6bf991d 100644
--- a/hw/tsc2005.c
+++ b/hw/tsc2005.c
@@ -412,7 +412,7 @@ static void tsc2005_timer_tick(void *opaque)
 }
 
 static void tsc2005_touchscreen_event(void *opaque,
-                int x, int y, int z, int buttons_state)
+                int x, int y, int z, int dw, int buttons_state)
 {
     TSC2005State *s = opaque;
     int p = s->pressure;
diff --git a/hw/tsc210x.c b/hw/tsc210x.c
index e851ca1..c97aaf2 100644
--- a/hw/tsc210x.c
+++ b/hw/tsc210x.c
@@ -968,7 +968,7 @@ static void tsc210x_timer_tick(void *opaque)
 }
 
 static void tsc210x_touchscreen_event(void *opaque,
-                int x, int y, int z, int buttons_state)
+                int x, int y, int z, int w, int buttons_state)
 {
     TSC210xState *s = opaque;
     int p = s->pressure;
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 476fcfd..deb4731 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -414,7 +414,8 @@ static void usb_hid_changed(USBHIDState *hs)
 }
 
 static void usb_mouse_event(void *opaque,
-                            int dx1, int dy1, int dz1, int buttons_state)
+                            int dx1, int dy1, int dz1, int dw1,
+                            int buttons_state)
 {
     USBHIDState *hs = opaque;
     USBMouseState *s = &hs->ptr;
@@ -428,7 +429,7 @@ static void usb_mouse_event(void *opaque,
 }
 
 static void usb_tablet_event(void *opaque,
-			     int x, int y, int dz, int buttons_state)
+			     int x, int y, int dz, int dw, int buttons_state)
 {
     USBHIDState *hs = opaque;
     USBMouseState *s = &hs->ptr;
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index fe052eb..b14e58b 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -119,7 +119,8 @@ static const uint8_t qemu_wacom_config_descriptor[] = {
 };
 
 static void usb_mouse_event(void *opaque,
-                            int dx1, int dy1, int dz1, int buttons_state)
+                            int dx1, int dy1, int dz1, int dw1,
+                            int buttons_state)
 {
     USBWacomState *s = opaque;
 
@@ -131,7 +132,7 @@ static void usb_mouse_event(void *opaque,
 }
 
 static void usb_wacom_event(void *opaque,
-                            int x, int y, int dz, int buttons_state)
+                            int x, int y, int dz, int dw, int buttons_state)
 {
     USBWacomState *s = opaque;
 
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index bb6e605..b619170 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -67,7 +67,8 @@ static uint32_t vmmouse_get_status(VMMouseState *s)
     return (s->status << 16) | s->nb_queue;
 }
 
-static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_state)
+static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int dw,
+                                int buttons_state)
 {
     VMMouseState *s = opaque;
     int buttons = 0;
diff --git a/hw/xenfb.c b/hw/xenfb.c
index 422cd53..0d83810 100644
--- a/hw/xenfb.c
+++ b/hw/xenfb.c
@@ -320,7 +320,7 @@ static void xenfb_key_event(void *opaque, int scancode)
  * the button state.
  */
 static void xenfb_mouse_event(void *opaque,
-			      int dx, int dy, int dz, int button_state)
+			      int dx, int dy, int dz, int dz2, int button_state)
 {
     struct XenInput *xenfb = opaque;
     int dw = ds_get_width(xenfb->c.ds);
diff --git a/input.c b/input.c
index 8f0941e..ea7c246 100644
--- a/input.c
+++ b/input.c
@@ -137,7 +137,7 @@ void kbd_put_ledstate(int ledstate)
     }
 }
 
-void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
+void kbd_mouse_event(int dx, int dy, int dz, int dw, int buttons_state)
 {
     QEMUPutMouseEntry *entry;
     QEMUPutMouseEvent *mouse_event;
@@ -160,10 +160,10 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
             else
                 width = graphic_width - 1;
             mouse_event(mouse_event_opaque,
-                        width - dy, dx, dz, buttons_state);
+                        width - dy, dx, dz, dw, buttons_state);
         } else
             mouse_event(mouse_event_opaque,
-                        dx, dy, dz, buttons_state);
+                        dx, dy, dz, dw, buttons_state);
     }
 }
 
diff --git a/monitor.c b/monitor.c
index 46d0b47..520d48d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1841,14 +1841,14 @@ static void do_mouse_move(Monitor *mon, const QDict *qdict)
     dz = 0;
     if (dz_str)
         dz = strtol(dz_str, NULL, 0);
-    kbd_mouse_event(dx, dy, dz, mouse_button_state);
+    kbd_mouse_event(dx, dy, dz, 0, mouse_button_state);
 }
 
 static void do_mouse_button(Monitor *mon, const QDict *qdict)
 {
     int button_state = qdict_get_int(qdict, "button_state");
     mouse_button_state = button_state;
-    kbd_mouse_event(0, 0, 0, mouse_button_state);
+    kbd_mouse_event(0, 0, 0, 0, mouse_button_state);
 }
 
 static void do_ioport_read(Monitor *mon, const QDict *qdict)
diff --git a/sdl.c b/sdl.c
index 16a48e9..616a7eb 100644
--- a/sdl.c
+++ b/sdl.c
@@ -503,7 +503,8 @@ static void sdl_mouse_mode_change(Notifier *notify)
     }
 }
 
-static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state)
+static void sdl_send_mouse_event(int dx, int dy, int dz, int dw,
+                                 int x, int y, int state)
 {
     int buttons;
     buttons = 0;
@@ -526,7 +527,7 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state
         dy = y;
     }
 
-    kbd_mouse_event(dx, dy, dz, buttons);
+    kbd_mouse_event(dx, dy, dz, dw, buttons);
 }
 
 static void toggle_full_screen(DisplayState *ds)
@@ -684,7 +685,7 @@ static void sdl_refresh(DisplayState *ds)
         case SDL_MOUSEMOTION:
             if (gui_grab || kbd_mouse_is_absolute() ||
                 absolute_enabled) {
-                sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0,
+                sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0, 0,
                        ev->motion.x, ev->motion.y, ev->motion.state);
             }
             break;
@@ -713,7 +714,8 @@ static void sdl_refresh(DisplayState *ds)
                         dz = 1;
                     }
 #endif
-                    sdl_send_mouse_event(0, 0, dz, bev->x, bev->y, buttonstate);
+                    sdl_send_mouse_event(0, 0, dz, 0, bev->x, bev->y,
+                                         buttonstate);
                 }
             }
             break;
diff --git a/vnc.c b/vnc.c
index 5241a6a..332c14a 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1292,17 +1292,17 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y)
                           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, buttons);
+                        dz, 0, buttons);
     } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) {
         x -= 0x7FFF;
         y -= 0x7FFF;
 
-        kbd_mouse_event(x, y, dz, buttons);
+        kbd_mouse_event(x, y, dz, 0, buttons);
     } else {
         if (vs->last_x != -1)
             kbd_mouse_event(x - vs->last_x,
                             y - vs->last_y,
-                            dz, buttons);
+                            dz, 0, buttons);
         vs->last_x = x;
         vs->last_y = y;
     }
