comparison src/video/x11/SDL_x11events.c @ 3761:e0c95ad1ba87 gsoc2008_manymouse

Major bug fixes
author Szymon Wilczek <kazeuser@gmail.com>
date Thu, 19 Jun 2008 17:24:30 +0000
parents 64f346a83ed3
children 81ea7d9a6624
comparison
equal deleted inserted replaced
3760:64f346a83ed3 3761:e0c95ad1ba87
30 #include "../../events/SDL_events_c.h" 30 #include "../../events/SDL_events_c.h"
31 31
32 //XEventClass *SDL_XEvents; 32 //XEventClass *SDL_XEvents;
33 //int SDL_numOfEvents; 33 //int SDL_numOfEvents;
34 34
35 extern int motion;
36 extern int button_pressed;
37 extern int button_released;
38
35 static void 39 static void
36 X11_DispatchEvent(_THIS) 40 X11_DispatchEvent(_THIS)
37 { 41 {
38 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 42 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
39 SDL_WindowData *data; 43 SDL_WindowData *data;
40 XEvent xevent; 44 XEvent xevent;
41 int i,z; 45 int i,z;
46 //extern int motion;
47 //extern int button_pressed;
48 //extern int button_released;
42 49
43 SDL_zero(xevent); /* valgrind fix. --ryan. */ 50 SDL_zero(xevent); /* valgrind fix. --ryan. */
44 XNextEvent(videodata->display, &xevent); 51 XNextEvent(videodata->display, &xevent);
45 52
46 /* filter events catchs XIM events and sends them to the correct 53 /* filter events catchs XIM events and sends them to the correct
166 case MappingNotify:{ 173 case MappingNotify:{
167 #ifdef DEBUG_XEVENTS 174 #ifdef DEBUG_XEVENTS
168 printf("MappingNotify!\n"); 175 printf("MappingNotify!\n");
169 #endif 176 #endif
170 X11_UpdateKeymap(_this); 177 X11_UpdateKeymap(_this);
171 }
172 break;
173
174 /* Mouse motion? */
175 case 103:{ //MotionNotify
176 #ifdef DEBUG_MOTION
177 printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
178 #endif
179 XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
180 SDL_SendMouseMotion(move->deviceid, 0, move->x,
181 move->y,move->axis_data[2]);
182 }
183 break;
184 /*case MotionNotify:{
185
186 /* Mouse button press? */
187 case 101:{//ButtonPress
188 XDeviceButtonPressedEvent* pressed=(XDeviceButtonPressedEvent*)&xevent;
189 SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
190 pressed->button);
191 }
192 break;
193
194 /* Mouse button release? */
195 case 102:{//ButtonRelease
196 XDeviceButtonReleasedEvent* released=(XDeviceButtonReleasedEvent*)&xevent;
197 SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
198 released->button);
199 } 178 }
200 break; 179 break;
201 180
202 /* Key press? */ 181 /* Key press? */
203 case KeyPress:{ 182 case KeyPress:{
308 0); 287 0);
309 } 288 }
310 break; 289 break;
311 290
312 default:{ 291 default:{
313 #ifdef DEBUG_XEVENTS 292 if(xevent.type==motion)//MotionNotify
314 printf("Unhandled event %d\n", xevent.type); 293 {
315 #endif 294 #ifdef DEBUG_MOTION
316 } 295 printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
317 break; 296 #endif
318 } 297 XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
319 } 298 SDL_SendMouseMotion(move->deviceid, 0, move->x,
299 move->y,move->axis_data[2]);
300 }
301 /*
302
303 Mouse button press? */
304 else if(xevent.type==button_pressed)//ButtonPress
305 {
306 XDeviceButtonPressedEvent* pressed=(XDeviceButtonPressedEvent*)&xevent;
307 SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
308 pressed->button);
309 }
310
311 /* Mouse button release? */
312 else if(xevent.type==button_released)//ButtonRelease
313 {
314 XDeviceButtonReleasedEvent* released=(XDeviceButtonReleasedEvent*)&xevent;
315 SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
316 released->button);
317 }
318 else
319 {
320 #ifdef DEBUG_XEVENTS
321 printf("Unhandled event %d\n", xevent.type);
322 #endif
323 }
324 }
325 break;
326 }
327 }
328
320 329
321 /* Ack! XPending() actually performs a blocking read if no events available */ 330 /* Ack! XPending() actually performs a blocking read if no events available */
322 int 331 int
323 X11_Pending(Display * display) 332 X11_Pending(Display * display)
324 { 333 {