From 6e15856723c694cdd299b76ba1d2d05ff199fe92 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 4 Jan 2009 18:29:20 +0000 Subject: [PATCH] The core pointer is comprised of merging the inputs of all mice. If there are other mice, they should show up in the device list, and we want to report events from those devices instead of the core events. However, if XInput isn't supported or we can't find other mice in the device list, we'll add the core pointer and interpret normal mouse events. --- src/video/x11/SDL_x11events.c | 31 ++++++++++++++++--------------- src/video/x11/SDL_x11mouse.c | 21 ++++++++++++--------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 096e8705b..1b6d43366 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -280,21 +280,6 @@ X11_DispatchEvent(_THIS) } break; - case MotionNotify: -#ifdef DEBUG_MOTION - printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); -#endif - SDL_SendMouseMotion(0, 0, xevent.xmotion.x, xevent.xmotion.y, 0); - break; - - case ButtonPress: - SDL_SendMouseButton(0, SDL_PRESSED, xevent.xbutton.button); - break; - - case ButtonRelease: - SDL_SendMouseButton(0, SDL_RELEASED, xevent.xbutton.button); - break; - default:{ #if SDL_VIDEO_DRIVER_X11_XINPUT for (i = 0; i < SDL_GetNumMice(); ++i) { @@ -304,6 +289,22 @@ X11_DispatchEvent(_THIS) mouse = SDL_GetMouse(i); data = (X11_MouseData *) mouse->driverdata; if (!data) { + switch (xevent.type) { + case MotionNotify: +#ifdef DEBUG_MOTION + printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); +#endif + SDL_SendMouseMotion(0, 0, xevent.xmotion.x, xevent.xmotion.y, 0); + break; + + case ButtonPress: + SDL_SendMouseButton(0, SDL_PRESSED, xevent.xbutton.button); + break; + + case ButtonRelease: + SDL_SendMouseButton(0, SDL_RELEASED, xevent.xbutton.button); + break; + } continue; } diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 3689abb61..9d162ae2f 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -50,19 +50,14 @@ X11_InitMouse(_THIS) int event_code; XEventClass xEvent; #endif - - SDL_zero(mouse); - SDL_AddMouse(&mouse, "CorePointer", 0, 0, 1); + int num_mice = 0; #if SDL_VIDEO_DRIVER_X11_XINPUT - if (!SDL_X11_HAVE_XINPUT) { - /* should have dynamically loaded, but wasn't available. */ - return; - } - /* we're getting the list of input devices */ n = 0; - DevList = XListInputDevices(display, &n); + if (SDL_X11_HAVE_XINPUT) { + DevList = XListInputDevices(display, &n); + } /* we're aquiring valuators: mice, tablets, etc. */ for (i = 0; i < n; ++i) { @@ -127,6 +122,9 @@ X11_InitMouse(_THIS) } else { SDL_AddMouse(&mouse, DevList[i].name, 0, 0, 1); } + if (DevList[i].use == IsXExtensionPointer) { + ++num_mice; + } break; } /* if it's not class we're interested in, lets go further */ @@ -138,6 +136,11 @@ X11_InitMouse(_THIS) } XFreeDeviceList(DevList); #endif + + if (num_mice == 0) { + SDL_zero(mouse); + SDL_AddMouse(&mouse, "CorePointer", 0, 0, 1); + } } void