comparison src/video/x11/SDL_x11mouse.c @ 2992:dbff5769d742

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.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 04 Jan 2009 18:29:20 +0000
parents 1e242954330b
children 0deb3e94c251
comparison
equal deleted inserted replaced
2991:f4d14219c2aa 2992:dbff5769d742
48 XDeviceInfo *DevList; 48 XDeviceInfo *DevList;
49 XAnyClassPtr deviceClass; 49 XAnyClassPtr deviceClass;
50 int event_code; 50 int event_code;
51 XEventClass xEvent; 51 XEventClass xEvent;
52 #endif 52 #endif
53 53 int num_mice = 0;
54 SDL_zero(mouse);
55 SDL_AddMouse(&mouse, "CorePointer", 0, 0, 1);
56 54
57 #if SDL_VIDEO_DRIVER_X11_XINPUT 55 #if SDL_VIDEO_DRIVER_X11_XINPUT
58 if (!SDL_X11_HAVE_XINPUT) {
59 /* should have dynamically loaded, but wasn't available. */
60 return;
61 }
62
63 /* we're getting the list of input devices */ 56 /* we're getting the list of input devices */
64 n = 0; 57 n = 0;
65 DevList = XListInputDevices(display, &n); 58 if (SDL_X11_HAVE_XINPUT) {
59 DevList = XListInputDevices(display, &n);
60 }
66 61
67 /* we're aquiring valuators: mice, tablets, etc. */ 62 /* we're aquiring valuators: mice, tablets, etc. */
68 for (i = 0; i < n; ++i) { 63 for (i = 0; i < n; ++i) {
69 /* if it's the core pointer or core keyborard we don't want it */ 64 /* if it's the core pointer or core keyborard we don't want it */
70 if ((DevList[i].use != IsXPointer && DevList[i].use != IsXKeyboard)) { 65 if ((DevList[i].use != IsXPointer && DevList[i].use != IsXKeyboard)) {
125 valInfo->axes[2].max_value, 120 valInfo->axes[2].max_value,
126 valInfo->axes[2].min_value, 1); 121 valInfo->axes[2].min_value, 1);
127 } else { 122 } else {
128 SDL_AddMouse(&mouse, DevList[i].name, 0, 0, 1); 123 SDL_AddMouse(&mouse, DevList[i].name, 0, 0, 1);
129 } 124 }
125 if (DevList[i].use == IsXExtensionPointer) {
126 ++num_mice;
127 }
130 break; 128 break;
131 } 129 }
132 /* if it's not class we're interested in, lets go further */ 130 /* if it's not class we're interested in, lets go further */
133 deviceClass = 131 deviceClass =
134 (XAnyClassPtr) ((char *) deviceClass + 132 (XAnyClassPtr) ((char *) deviceClass +
136 } 134 }
137 } 135 }
138 } 136 }
139 XFreeDeviceList(DevList); 137 XFreeDeviceList(DevList);
140 #endif 138 #endif
139
140 if (num_mice == 0) {
141 SDL_zero(mouse);
142 SDL_AddMouse(&mouse, "CorePointer", 0, 0, 1);
143 }
141 } 144 }
142 145
143 void 146 void
144 X11_QuitMouse(_THIS) 147 X11_QuitMouse(_THIS)
145 { 148 {