diff src/video/x11/SDL_x11video.c @ 2710:44e49d3fa6cf

Final merge of Google Summer of Code 2008 work... Many-mouse and tablet support by Szymon Wilczek, mentored by Ryan C. Gordon Everything concerning the project is noted on the wiki: http://wilku.ravenlord.ws/doku.php?id=start
author Sam Lantinga <slouken@libsdl.org>
date Mon, 25 Aug 2008 06:33:00 +0000
parents 3202e4826c57
children 6fc50bdd88c0
line wrap: on
line diff
--- a/src/video/x11/SDL_x11video.c	Mon Aug 25 05:30:28 2008 +0000
+++ b/src/video/x11/SDL_x11video.c	Mon Aug 25 06:33:00 2008 +0000
@@ -27,8 +27,14 @@
 #include "../SDL_pixels_c.h"
 
 #include "SDL_x11video.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;    /* the definitions of the mice events */
+int proximity_in, proximity_out;
 
 /* Initialization/Query functions */
 static int X11_VideoInit(_THIS);
@@ -97,7 +103,6 @@
 X11_DeleteDevice(SDL_VideoDevice * device)
 {
     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, event_code;
+    XEventClass xEvent;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
     /* Get the window class name, usually the name of the application */
@@ -241,6 +248,42 @@
     }
     X11_InitMouse(_this);
 
+    /* we're generating the table of events that should be recognized */
+    for (i = 0; i < SDL_NumOfXDevices; ++i) {
+        /* button events */
+        DeviceButtonPress(SDL_XDevices[i], event_code, xEvent);
+        if (xEvent) {
+            SDL_XEvents[index++] = xEvent;
+            button_pressed = event_code;
+        }
+        DeviceButtonRelease(SDL_XDevices[i], event_code, xEvent);
+        if (xEvent) {
+            SDL_XEvents[index++] = xEvent;
+            button_released = event_code;
+        }
+
+        /* proximity events */
+        ProximityIn(SDL_XDevices[i], event_code, xEvent);
+        if (xEvent) {
+            SDL_XEvents[index++] = xEvent;
+            proximity_in = event_code;
+        }
+        ProximityOut(SDL_XDevices[i], event_code, xEvent);
+        if (xEvent) {
+            SDL_XEvents[index++] = xEvent;
+            proximity_out = event_code;
+        }
+
+        /* motion events */
+        DeviceMotionNotify(SDL_XDevices[i], event_code, xEvent);
+        if (xEvent) {
+            SDL_XEvents[index++] = xEvent;
+            motion = event_code;
+        }
+
+    }
+    SDL_NumOfXEvents = index;
+
     return 0;
 }
 
@@ -263,6 +306,7 @@
     X11_QuitModes(_this);
     X11_QuitKeyboard(_this);
     X11_QuitMouse(_this);
+    free(SDL_XDevices);
 }
 
 /* vim: set ts=4 sw=4 expandtab: */