Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11video.c @ 3760:64f346a83ed3 gsoc2008_manymouse
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
author | Szymon Wilczek <kazeuser@gmail.com> |
---|---|
date | Fri, 06 Jun 2008 15:23:29 +0000 |
parents | 3202e4826c57 |
children | e0c95ad1ba87 |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11video.c Fri Jun 06 14:50:56 2008 +0000 +++ b/src/video/x11/SDL_x11video.c Fri Jun 06 15:23:29 2008 +0000 @@ -30,6 +30,11 @@ //#include "SDL_d3drender.h" //#include "SDL_gdirender.h" +XDevice **SDL_XDevices; +int SDL_NumOfXDevices; +XEventClass SDL_XEvents[256]; +int SDL_NumOfXEvents; + /* Initialization/Query functions */ static int X11_VideoInit(_THIS); static void X11_VideoQuit(_THIS); @@ -96,8 +101,8 @@ static void X11_DeleteDevice(SDL_VideoDevice * device) { + int i; SDL_VideoData *data = (SDL_VideoData *) device->driverdata; - if (data->display) { XCloseDisplay(data->display); } @@ -212,6 +217,8 @@ int X11_VideoInit(_THIS) { + int i,index=0,c_not_needed; + XEventClass xEvent; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ @@ -240,6 +247,72 @@ return -1; } X11_InitMouse(_this); + for(i=0;i<SDL_NumOfXDevices;++i) + { + DeviceKeyPress(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceKeyRelease(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + + /* 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 */ + DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceButtonRelease(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + + /* proximity events */ + ProximityIn(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + ProximityOut(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + + /* motion events */ + DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + + /* device state */ + DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceMappingNotify(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + ChangeDeviceNotify(SDL_XDevices[i],c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + +#if 0 + /* this cuts the motion data down - not sure if this is useful */ + DevicePointerMotionHint(SDL_XDevices[i], + c_not_neededINPUTEVENT_DEVICE_POINTER_MOTION_HINT],xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; +#endif + + /* button motion */ + DeviceButtonMotion(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceButton1Motion(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceButton2Motion(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceButton3Motion(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceButton4Motion(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + DeviceButton5Motion(SDL_XDevices[i], + c_not_needed,xEvent); + if (xEvent) SDL_XEvents[index++] = xEvent; + } + SDL_NumOfXEvents=index; return 0; } @@ -247,6 +320,8 @@ void X11_VideoQuit(_THIS) { + int i; + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; if (data->classname) { @@ -263,6 +338,7 @@ X11_QuitModes(_this); X11_QuitKeyboard(_this); X11_QuitMouse(_this); + free(SDL_XDevices); } /* vim: set ts=4 sw=4 expandtab: */