src/SDL_compat.c
changeset 2152 003c1b5b07da
parent 2130 3ee59c43d784
child 2153 760c1bd2d625
--- 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;
         }