comparison 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
comparison
equal deleted inserted replaced
3759:064c178558b7 3760:64f346a83ed3
27 #include "../SDL_pixels_c.h" 27 #include "../SDL_pixels_c.h"
28 28
29 #include "SDL_x11video.h" 29 #include "SDL_x11video.h"
30 //#include "SDL_d3drender.h" 30 //#include "SDL_d3drender.h"
31 //#include "SDL_gdirender.h" 31 //#include "SDL_gdirender.h"
32
33 XDevice **SDL_XDevices;
34 int SDL_NumOfXDevices;
35 XEventClass SDL_XEvents[256];
36 int SDL_NumOfXEvents;
32 37
33 /* Initialization/Query functions */ 38 /* Initialization/Query functions */
34 static int X11_VideoInit(_THIS); 39 static int X11_VideoInit(_THIS);
35 static void X11_VideoQuit(_THIS); 40 static void X11_VideoQuit(_THIS);
36 41
94 } 99 }
95 100
96 static void 101 static void
97 X11_DeleteDevice(SDL_VideoDevice * device) 102 X11_DeleteDevice(SDL_VideoDevice * device)
98 { 103 {
104 int i;
99 SDL_VideoData *data = (SDL_VideoData *) device->driverdata; 105 SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
100
101 if (data->display) { 106 if (data->display) {
102 XCloseDisplay(data->display); 107 XCloseDisplay(data->display);
103 } 108 }
104 SDL_free(data->windowlist); 109 SDL_free(data->windowlist);
105 SDL_free(device->driverdata); 110 SDL_free(device->driverdata);
210 215
211 216
212 int 217 int
213 X11_VideoInit(_THIS) 218 X11_VideoInit(_THIS)
214 { 219 {
220 int i,index=0,c_not_needed;
221 XEventClass xEvent;
215 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 222 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
216 223
217 /* Get the window class name, usually the name of the application */ 224 /* Get the window class name, usually the name of the application */
218 data->classname = get_classname(); 225 data->classname = get_classname();
219 226
238 245
239 if (X11_InitKeyboard(_this) != 0) { 246 if (X11_InitKeyboard(_this) != 0) {
240 return -1; 247 return -1;
241 } 248 }
242 X11_InitMouse(_this); 249 X11_InitMouse(_this);
250 for(i=0;i<SDL_NumOfXDevices;++i)
251 {
252 DeviceKeyPress(SDL_XDevices[i],c_not_needed,xEvent);
253 if (xEvent) SDL_XEvents[index++] = xEvent;
254 DeviceKeyRelease(SDL_XDevices[i],c_not_needed,xEvent);
255 if (xEvent) SDL_XEvents[index++] = xEvent;
256
257 /* focus events */
258 DeviceFocusIn(SDL_XDevices[i],c_not_needed,xEvent);
259 if (xEvent) SDL_XEvents[index++] = xEvent;
260 DeviceFocusOut(SDL_XDevices[i],c_not_needed,xEvent);
261 if (xEvent) SDL_XEvents[index++] = xEvent;
262
263 /* button events */
264 DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent);
265 if (xEvent) SDL_XEvents[index++] = xEvent;
266 DeviceButtonRelease(SDL_XDevices[i],c_not_needed,xEvent);
267 if (xEvent) SDL_XEvents[index++] = xEvent;
268
269 /* proximity events */
270 ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
271 if (xEvent) SDL_XEvents[index++] = xEvent;
272 ProximityOut(SDL_XDevices[i],c_not_needed,xEvent);
273 if (xEvent) SDL_XEvents[index++] = xEvent;
274
275 /* motion events */
276 DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
277 if (xEvent) SDL_XEvents[index++] = xEvent;
278
279 /* device state */
280 DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent);
281 if (xEvent) SDL_XEvents[index++] = xEvent;
282 DeviceMappingNotify(SDL_XDevices[i],
283 c_not_needed,xEvent);
284 if (xEvent) SDL_XEvents[index++] = xEvent;
285 ChangeDeviceNotify(SDL_XDevices[i],c_not_needed,xEvent);
286 if (xEvent) SDL_XEvents[index++] = xEvent;
287
288 #if 0
289 /* this cuts the motion data down - not sure if this is useful */
290 DevicePointerMotionHint(SDL_XDevices[i],
291 c_not_neededINPUTEVENT_DEVICE_POINTER_MOTION_HINT],xEvent);
292 if (xEvent) SDL_XEvents[index++] = xEvent;
293 #endif
294
295 /* button motion */
296 DeviceButtonMotion(SDL_XDevices[i],
297 c_not_needed,xEvent);
298 if (xEvent) SDL_XEvents[index++] = xEvent;
299 DeviceButton1Motion(SDL_XDevices[i],
300 c_not_needed,xEvent);
301 if (xEvent) SDL_XEvents[index++] = xEvent;
302 DeviceButton2Motion(SDL_XDevices[i],
303 c_not_needed,xEvent);
304 if (xEvent) SDL_XEvents[index++] = xEvent;
305 DeviceButton3Motion(SDL_XDevices[i],
306 c_not_needed,xEvent);
307 if (xEvent) SDL_XEvents[index++] = xEvent;
308 DeviceButton4Motion(SDL_XDevices[i],
309 c_not_needed,xEvent);
310 if (xEvent) SDL_XEvents[index++] = xEvent;
311 DeviceButton5Motion(SDL_XDevices[i],
312 c_not_needed,xEvent);
313 if (xEvent) SDL_XEvents[index++] = xEvent;
314 }
315 SDL_NumOfXEvents=index;
243 316
244 return 0; 317 return 0;
245 } 318 }
246 319
247 void 320 void
248 X11_VideoQuit(_THIS) 321 X11_VideoQuit(_THIS)
249 { 322 {
323 int i;
324
250 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 325 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
251 326
252 if (data->classname) { 327 if (data->classname) {
253 SDL_free(data->classname); 328 SDL_free(data->classname);
254 } 329 }
261 data->dpms_enabled); 336 data->dpms_enabled);
262 337
263 X11_QuitModes(_this); 338 X11_QuitModes(_this);
264 X11_QuitKeyboard(_this); 339 X11_QuitKeyboard(_this);
265 X11_QuitMouse(_this); 340 X11_QuitMouse(_this);
341 free(SDL_XDevices);
266 } 342 }
267 343
268 /* vim: set ts=4 sw=4 expandtab: */ 344 /* vim: set ts=4 sw=4 expandtab: */