comparison src/video/x11/SDL_x11mouse.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 a344e42bce3b
children e0c95ad1ba87
comparison
equal deleted inserted replaced
3759:064c178558b7 3760:64f346a83ed3
26 #include "../../events/SDL_mouse_c.h" 26 #include "../../events/SDL_mouse_c.h"
27 27
28 void 28 void
29 X11_InitMouse(_THIS) 29 X11_InitMouse(_THIS)
30 { 30 {
31 extern XDevice **SDL_XDevices;
32 XDevice **newDevices;
33 int i,j,index=0, numOfDevices;
34 extern int SDL_NumOfXDevices;
35 XDeviceInfo *DevList;
36 XAnyClassPtr deviceClass;
31 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 37 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
32 SDL_Mouse mouse; 38
39 DevList=XListInputDevices(data->display, &numOfDevices);
33 40
34 SDL_zero(mouse); 41 for(i=0;i<numOfDevices;++i)
35 data->mouse = SDL_AddMouse(&mouse, -1); 42 {
43 if((DevList[i].use!=IsXPointer && DevList[i].use!=IsXKeyboard))
44 {
45 deviceClass=DevList[i].inputclassinfo;
46 for(j=0;j<DevList[i].num_classes;++j)
47 {
48 if(deviceClass->class==ValuatorClass)
49 {
50 newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
51 if(!newDevices)
52 {
53 SDL_OutOfMemory();
54 return -1;
55 }
56 SDL_XDevices=newDevices;
57 SDL_XDevices[index]=XOpenDevice(data->display,DevList[i].id);
58 SDL_Mouse mouse;
59 SDL_zero(mouse);
60 SDL_SetIndexId(DevList[i].id,index);
61 data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name);
62 break;
63 }
64 deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);
65 }
66 }
67 }
68 XFreeDeviceList(DevList);
69 SDL_NumOfXDevices=index;
36 } 70 }
37 71
38 void 72 void
39 X11_QuitMouse(_THIS) 73 X11_QuitMouse(_THIS)
40 { 74 {
41 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 75 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
42 76
43 SDL_DelMouse(data->mouse); 77 SDL_MouseQuit();
44 } 78 }
45 79
46 /* vi: set ts=4 sw=4 expandtab: */ 80 /* vi: set ts=4 sw=4 expandtab: */