changeset 3761:e0c95ad1ba87 gsoc2008_manymouse

Major bug fixes
author Szymon Wilczek <kazeuser@gmail.com>
date Thu, 19 Jun 2008 17:24:30 +0000
parents 64f346a83ed3
children f667489e7309
files src/video/x11/SDL_x11events.c src/video/x11/SDL_x11mouse.c src/video/x11/SDL_x11video.c
diffstat 3 files changed, 56 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/x11/SDL_x11events.c	Fri Jun 06 15:23:29 2008 +0000
+++ b/src/video/x11/SDL_x11events.c	Thu Jun 19 17:24:30 2008 +0000
@@ -32,6 +32,10 @@
 //XEventClass *SDL_XEvents;
 //int SDL_numOfEvents;
 
+extern int motion;
+extern int button_pressed;
+extern int button_released;
+
 static void
 X11_DispatchEvent(_THIS)
 {
@@ -39,6 +43,9 @@
     SDL_WindowData *data;
     XEvent xevent;
     int i,z;
+    //extern int motion;
+    //extern int button_pressed;
+    //extern int button_released;
 
     SDL_zero(xevent);           /* valgrind fix. --ryan. */
     XNextEvent(videodata->display, &xevent);
@@ -171,34 +178,6 @@
         }
         break;
 
-        /* Mouse motion? */
-    case 103:{ //MotionNotify
-#ifdef DEBUG_MOTION
-            printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
-#endif
-			XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
-            SDL_SendMouseMotion(move->deviceid, 0, move->x,
-                                move->y,move->axis_data[2]);
-        }
-        break;
-    /*case MotionNotify:{
-
-        /* Mouse button press? */
-    case 101:{//ButtonPress
-			XDeviceButtonPressedEvent* pressed=(XDeviceButtonPressedEvent*)&xevent;
-            SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
-                                pressed->button);
-        }
-        break;
-
-        /* Mouse button release? */
-    case 102:{//ButtonRelease
-			XDeviceButtonReleasedEvent* released=(XDeviceButtonReleasedEvent*)&xevent;
-            SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
-                                released->button);
-        }
-        break;
-
         /* Key press? */
     case KeyPress:{
             KeyCode keycode = xevent.xkey.keycode;
@@ -310,14 +289,44 @@
         break;
 
     default:{
+            if(xevent.type==motion)//MotionNotify
+            {
+#ifdef DEBUG_MOTION
+                printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
+#endif
+			    XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
+                SDL_SendMouseMotion(move->deviceid, 0, move->x,
+                                move->y,move->axis_data[2]);
+            }
+    /*
+
+        Mouse button press? */
+            else if(xevent.type==button_pressed)//ButtonPress
+            {
+			    XDeviceButtonPressedEvent* pressed=(XDeviceButtonPressedEvent*)&xevent;
+                SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
+                                pressed->button);
+            }
+
+        /* Mouse button release? */
+            else if(xevent.type==button_released)//ButtonRelease
+            {
+			    XDeviceButtonReleasedEvent* released=(XDeviceButtonReleasedEvent*)&xevent;
+                SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
+                                released->button);
+            }
+            else
+            {
 #ifdef DEBUG_XEVENTS
-            printf("Unhandled event %d\n", xevent.type);
+                printf("Unhandled event %d\n", xevent.type);
 #endif
+            }
         }
         break;
     }
 }
 
+
 /* Ack!  XPending() actually performs a blocking read if no events available */
 int
 X11_Pending(Display * display)
--- a/src/video/x11/SDL_x11mouse.c	Fri Jun 06 15:23:29 2008 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Thu Jun 19 17:24:30 2008 +0000
@@ -37,7 +37,7 @@
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    
     DevList=XListInputDevices(data->display, &numOfDevices);
-
+    SDL_XDevices=(XDevice**) SDL_malloc(sizeof(XDevice));
     for(i=0;i<numOfDevices;++i)
     {
         if((DevList[i].use!=IsXPointer && DevList[i].use!=IsXKeyboard))
--- a/src/video/x11/SDL_x11video.c	Fri Jun 06 15:23:29 2008 +0000
+++ b/src/video/x11/SDL_x11video.c	Thu Jun 19 17:24:30 2008 +0000
@@ -34,6 +34,7 @@
 int SDL_NumOfXDevices;
 XEventClass SDL_XEvents[256];
 int SDL_NumOfXEvents;
+int motion, button_pressed, button_released;
 
 /* Initialization/Query functions */
 static int X11_VideoInit(_THIS);
@@ -262,9 +263,17 @@
 
 	/* button events */
 	DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent) SDL_XEvents[index++] = xEvent;
+	if (xEvent) 
+    {
+        SDL_XEvents[index++] = xEvent;
+        button_pressed=c_not_needed;
+    }
 	DeviceButtonRelease(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent) SDL_XEvents[index++] = xEvent;
+	if (xEvent)
+    {
+        SDL_XEvents[index++] = xEvent;
+        button_released=c_not_needed;
+    }
 
 	/* proximity events */
 	ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
@@ -274,7 +283,12 @@
 
 	/* motion events */
 	DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent) SDL_XEvents[index++] = xEvent;
+	if (xEvent) 
+    {
+        SDL_XEvents[index++] = xEvent;
+        motion=c_not_needed;
+        //printf("motion: %d", c_not_needed);
+    }
 
 	/* device state */
 	DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent);