First comments and code upgrades in X11 gsoc2008_manymouse
authorSzymon Wilczek <kazeuser@gmail.com>
Sat, 02 Aug 2008 17:40:49 +0000
branchgsoc2008_manymouse
changeset 3772 9087a84cba51
parent 3771 8cc36a399a12
child 3773 3b5691f85c0d
First comments and code upgrades in X11
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11mouse.c
src/video/x11/SDL_x11video.c
--- a/src/video/x11/SDL_x11events.c	Sat Aug 02 14:02:28 2008 +0000
+++ b/src/video/x11/SDL_x11events.c	Sat Aug 02 17:40:49 2008 +0000
@@ -29,16 +29,11 @@
 #include "SDL_x11video.h"
 #include "../../events/SDL_events_c.h"
 
-//XEventClass *SDL_XEvents;
-//int SDL_numOfEvents;
-
-extern int motion;
-extern int button_pressed;
-extern int button_released;
-extern int proximity_in;
-extern int proximity_out;
-extern int x_max,y_max;
-
+extern int motion;/*the motion event id defined by an XInput function*/
+extern int button_pressed;/*the button_pressed event id defined by an XInput function*/
+extern int button_released;/*the button_released event id defined by an XInput function*/
+extern int proximity_in;/*the proximity in event defined by an XInput function*/
+extern int proximity_out;/*the proximity out event defined by an XInput function*/
 
 static void
 X11_DispatchEvent(_THIS)
@@ -47,9 +42,6 @@
     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);
@@ -67,7 +59,6 @@
     /* Send a SDL_SYSWMEVENT if the application wants them */
     if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
         SDL_SysWMmsg wmmsg;
-
         SDL_VERSION(&wmmsg.version);
         wmmsg.subsystem = SDL_SYSWM_X11;
         wmmsg.event.xevent = xevent;
@@ -127,8 +118,6 @@
                 (xevent.xcrossing.mode != NotifyUngrab) &&
                 (xevent.xcrossing.detail != NotifyInferior)) {
 			    XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
-                //SDL_SendMouseMotion(move->deviceid, 0,
-                //                    move->x, move->y,move->axis_data[2]);
                 SDL_SetMouseFocus(move->deviceid, 0);
             }
         }
@@ -300,8 +289,6 @@
 #endif
                 XWindowAttributes attrib;
                 XGetWindowAttributes(videodata->display, ((XAnyEvent*)&xevent)->window, &attrib);
-                /*x_max=attrib.width;
-                y_max=attrib.height;*/
                 SDL_UpdateCoordinates(attrib.width, attrib.height);
 			    XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
                 SDL_SendMouseMotion(move->deviceid, 0, move->x,
--- a/src/video/x11/SDL_x11mouse.c	Sat Aug 02 14:02:28 2008 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Sat Aug 02 17:40:49 2008 +0000
@@ -35,19 +35,26 @@
     XDeviceInfo *DevList;
     XAnyClassPtr deviceClass;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-   
+
+    /*we're getting the list of input devices*/
     DevList=XListInputDevices(data->display, &numOfDevices);
     SDL_XDevices=(XDevice**) SDL_malloc(sizeof(XDevice));
+
+    /*we're aquiring valuators:mices, tablets, etc.*/
     for(i=0;i<numOfDevices;++i)
     {
+        /*if it's the core pointer or core keyborard we don't want it*/
         if((DevList[i].use!=IsXPointer && DevList[i].use!=IsXKeyboard))
         {
+            /*we have to check all of the device classes*/
             deviceClass=DevList[i].inputclassinfo;
             for(j=0;j<DevList[i].num_classes;++j)
             {
-                if(deviceClass->class==ValuatorClass)
+                if(deviceClass->class==ValuatorClass)/*bingo;)*/
                 {
                     XValuatorInfo* valInfo;
+                    SDL_Mouse mouse;
+
                     newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
                     if(!newDevices)
                     {
@@ -56,10 +63,14 @@
                     }
                     SDL_XDevices=newDevices;
                     SDL_XDevices[index]=XOpenDevice(data->display,DevList[i].id);
-                    SDL_Mouse mouse;
                     SDL_zero(mouse);
+
+                    /*the id of the device differs from its index
+                     *so we're assigning the index of a device to it's id*/
                     SDL_SetIndexId(DevList[i].id,index);
+                    /*lets get the device parameters*/
                     valInfo=(XValuatorInfo*)deviceClass;
+                    /*if the device reports pressure, lets check it parameteres*/
                     if(valInfo->num_axes>2)
                     {
                         data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,valInfo->axes[2].max_value,valInfo->axes[2].min_value);
@@ -70,11 +81,13 @@
                     }
                     break;
                 }
+                /*if it's not class we're interested in, lets go further*/
                 deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);
             }
         }
     }
     XFreeDeviceList(DevList);
+    
     SDL_NumOfXDevices=index;
 }
 
@@ -83,6 +96,7 @@
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
+    /*Lets delete all of the mice*/
     SDL_MouseQuit();
 }
 
--- a/src/video/x11/SDL_x11video.c	Sat Aug 02 14:02:28 2008 +0000
+++ b/src/video/x11/SDL_x11video.c	Sat Aug 02 17:40:49 2008 +0000
@@ -27,14 +27,15 @@
 #include "../SDL_pixels_c.h"
 
 #include "SDL_x11video.h"
-//#include "SDL_d3drender.h"
-//#include "SDL_gdirender.h"
+/*#include "SDL_d3drender.h"
+#include "SDL_gdirender.h"*/
 
 XDevice **SDL_XDevices;
 int SDL_NumOfXDevices;
 XEventClass SDL_XEvents[256];
 int SDL_NumOfXEvents;
-int motion, button_pressed, button_released;
+
+int motion, button_pressed, button_released;/*the definitions of the mice events*/
 int proximity_in, proximity_out;
 
 /* Initialization/Query functions */
@@ -249,6 +250,7 @@
         return -1;
     }
     X11_InitMouse(_this);
+    /*we're generating the table of events that should be recognized*/
     for(i=0;i<SDL_NumOfXDevices;++i)
     {   
         DeviceKeyPress(SDL_XDevices[i],c_not_needed,xEvent);
@@ -256,13 +258,13 @@
 	    DeviceKeyRelease(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent) SDL_XEvents[index++] = xEvent;
 
-	/* focus events */
+	/*focus events*/
 	DeviceFocusIn(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent) SDL_XEvents[index++] = xEvent;
 	DeviceFocusOut(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent) SDL_XEvents[index++] = xEvent;
 
-	/* button events */
+	/*button events*/
 	DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent) 
     {
@@ -276,7 +278,7 @@
         button_released=c_not_needed;
     }
 
-	/* proximity events */
+	/*proximity events*/
 	ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent)
     {
@@ -289,7 +291,7 @@
         SDL_XEvents[index++] = xEvent;
         proximity_out=c_not_needed;
     }
-	/* motion events */
+	/*motion events*/
 	DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent) 
     {
@@ -297,7 +299,7 @@
         motion=c_not_needed;
     }
 
-	/* device state */
+	/*device state*/
 	DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent);
 	if (xEvent) SDL_XEvents[index++] = xEvent;
 	DeviceMappingNotify(SDL_XDevices[i],
@@ -313,7 +315,7 @@
 	if (xEvent) SDL_XEvents[index++] = xEvent;
 #endif
 
-	/* button motion */
+	/*button motion*/
 	DeviceButtonMotion(SDL_XDevices[i],
 			c_not_needed,xEvent);
 	if (xEvent) SDL_XEvents[index++] = xEvent;