# HG changeset patch # User Szymon Wilczek # Date 1217698849 0 # Node ID 9087a84cba511e91ed4b277474df89717cf5aed1 # Parent 8cc36a399a12903c240f442d9f1f98b34947b08f First comments and code upgrades in X11 diff -r 8cc36a399a12 -r 9087a84cba51 src/video/x11/SDL_x11events.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, diff -r 8cc36a399a12 -r 9087a84cba51 src/video/x11/SDL_x11mouse.c --- 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;iclass==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(); } diff -r 8cc36a399a12 -r 9087a84cba51 src/video/x11/SDL_x11video.c --- 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