diff src/video/x11/SDL_x11mouse.c @ 2763:6fc50bdd88c0

Some cleanups on the new XInput code. One or two things got moved around, but largely this is hooked up correctly in the Unix configure system now: it can be dynamically loaded and fallback gracefully if not available, or libXi can be directly linked to libSDL. XInput support can be --disable'd from the configure script, too (defaults to enabled). Please note that while the framework is in place to gracefully fallback, the current state of the source requires XInput. We'll need to adjust a few things still to correct this.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 17 Sep 2008 08:20:57 +0000
parents 44e49d3fa6cf
children f55c87ae336b
line wrap: on
line diff
--- a/src/video/x11/SDL_x11mouse.c	Mon Sep 15 20:48:51 2008 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Wed Sep 17 08:20:57 2008 +0000
@@ -20,22 +20,25 @@
     slouken@libsdl.org
 */
 #include "SDL_config.h"
-
 #include "SDL_x11video.h"
-
 #include "../../events/SDL_mouse_c.h"
 
 void
 X11_InitMouse(_THIS)
 {
-    extern XDevice **SDL_XDevices;
+#if SDL_VIDEO_DRIVER_X11_XINPUT
     XDevice **newDevices;
     int i, j, index = 0, numOfDevices;
-    extern int SDL_NumOfXDevices;
     XDeviceInfo *DevList;
     XAnyClassPtr deviceClass;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
+    SDL_XDevices = NULL;
+    SDL_NumOfXDevices = 0;
+
+    if (!SDL_X11_HAVE_XINPUT)
+        return;  /* should have dynamically loaded, but wasn't available. */
+
     /* we're getting the list of input devices */
     DevList = XListInputDevices(data->display, &numOfDevices);
     SDL_XDevices = (XDevice **) SDL_malloc(sizeof(XDevice));
@@ -92,6 +95,7 @@
     XFreeDeviceList(DevList);
 
     SDL_NumOfXDevices = index;
+#endif
 }
 
 void
@@ -99,6 +103,8 @@
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
+    /* !!! FIXME: use XCloseDevice()? Or maybe handle under SDL_MouseQuit()? */
+
     /* let's delete all of the mice */
     SDL_MouseQuit();
 }