diff src/SDL_compat.c @ 2152:003c1b5b07da

Fixed bug #382 Added horizontal scrolling support
author Sam Lantinga <slouken@libsdl.org>
date Fri, 06 Jul 2007 09:22:18 +0000
parents 3ee59c43d784
children 760c1bd2d625
line wrap: on
line diff
--- a/src/SDL_compat.c	Thu Jul 05 06:35:40 2007 +0000
+++ b/src/SDL_compat.c	Fri Jul 06 09:22:18 2007 +0000
@@ -256,25 +256,42 @@
             SDL_GetMouseState(&x, &y);
             SDL_SelectMouse(selected);
 
-            if (event->wheel.motion > 0) {
-                button = SDL_BUTTON_WHEELUP;
-            } else {
-                button = SDL_BUTTON_WHEELDOWN;
-            }
-
             fake.button.which = event->wheel.windowID;
-            fake.button.button = button;
             fake.button.x = x;
             fake.button.y = y;
             fake.button.windowID = event->wheel.windowID;
 
-            fake.type = SDL_MOUSEBUTTONDOWN;
-            fake.button.state = SDL_PRESSED;
-            SDL_PushEvent(&fake);
+            if (event->wheel.y) {
+                if (event->wheel.y > 0) {
+                    fake.button.button = SDL_BUTTON_WHEELUP;
+                } else {
+                    fake.button.button = SDL_BUTTON_WHEELDOWN;
+                }
+
+                fake.type = SDL_MOUSEBUTTONDOWN;
+                fake.button.state = SDL_PRESSED;
+                SDL_PushEvent(&fake);
 
-            fake.type = SDL_MOUSEBUTTONUP;
-            fake.button.state = SDL_RELEASED;
-            SDL_PushEvent(&fake);
+                fake.type = SDL_MOUSEBUTTONUP;
+                fake.button.state = SDL_RELEASED;
+                SDL_PushEvent(&fake);
+            }
+            if (event->wheel.x) {
+                if (event->wheel.y > 0) {
+                    fake.button.button = SDL_BUTTON_WHEELLEFT;
+                } else {
+                    fake.button.button = SDL_BUTTON_WHEELRIGHT;
+                }
+
+                fake.type = SDL_MOUSEBUTTONDOWN;
+                fake.button.state = SDL_PRESSED;
+                SDL_PushEvent(&fake);
+
+                fake.type = SDL_MOUSEBUTTONUP;
+                fake.button.state = SDL_RELEASED;
+                SDL_PushEvent(&fake);
+            }
+
             break;
         }