Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11mouse.c @ 4590:1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Fixes involved:
1. Fix handling of alpha channel when SDL_BLENDMODE_NONE is set.
2. Make xrendercolor use floating-point values for color channels and then convert to 16 bit ints.
3. Fix handling of visuals in SDL_x11modes.c so that a 32 bit ARGB visual is used.
4. Fix the background pixel value in SDL_x11window.c so that the window background has an alpha value of 0xFF and not 0.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Fri, 09 Jul 2010 21:36:41 +0530 |
parents | f7b03b6838cb |
children | 3e69e077cb95 |
rev | line source |
---|---|
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #include "SDL_x11video.h" |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
24 #include "SDL_x11mouse.h" |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "../../events/SDL_mouse_c.h" |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
27 #if SDL_VIDEO_DRIVER_X11_XINPUT |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
28 static void |
2942 | 29 X11_FreeMouse(SDL_Mouse * mouse) |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
30 { |
2942 | 31 X11_MouseData *data = (X11_MouseData *) mouse->driverdata; |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
32 |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
33 if (data) { |
2952
79dee7da6ba5
Date: Fri, 02 Jan 2009 00:54:48 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset
|
34 XCloseDevice(data->display, data->device); |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
35 SDL_free(data); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
36 } |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
37 } |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
38 #endif |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
39 |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 void |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 X11_InitMouse(_THIS) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 { |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
43 SDL_Mouse mouse; |
2763
6fc50bdd88c0
Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents:
2710
diff
changeset
|
44 #if SDL_VIDEO_DRIVER_X11_XINPUT |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
45 Display *display = ((SDL_VideoData *) _this->driverdata)->display; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
46 X11_MouseData *data; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
47 int i, j, n; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
48 XDeviceInfo *DevList; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
49 XAnyClassPtr deviceClass; |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
50 int event_code; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
51 XEventClass xEvent; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
52 #endif |
2992
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
53 int num_mice = 0; |
2763
6fc50bdd88c0
Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents:
2710
diff
changeset
|
54 |
3195
08747e24a50f
Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents:
3002
diff
changeset
|
55 SDL_zero(mouse); |
08747e24a50f
Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents:
3002
diff
changeset
|
56 |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
57 #if SDL_VIDEO_DRIVER_X11_XINPUT |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
58 /* we're getting the list of input devices */ |
2962
1e242954330b
Hopefully fixed crash when there are no input devices
Sam Lantinga <slouken@libsdl.org>
parents:
2952
diff
changeset
|
59 n = 0; |
2992
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
60 if (SDL_X11_HAVE_XINPUT) { |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
61 DevList = XListInputDevices(display, &n); |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
62 } |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
63 |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
64 /* we're aquiring valuators: mice, tablets, etc. */ |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
65 for (i = 0; i < n; ++i) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
66 /* if it's the core pointer or core keyborard we don't want it */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
67 if ((DevList[i].use != IsXPointer && DevList[i].use != IsXKeyboard)) { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
68 /* we have to check all of the device classes */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
69 deviceClass = DevList[i].inputclassinfo; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
70 for (j = 0; j < DevList[i].num_classes; ++j) { |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
71 if (deviceClass->class == ValuatorClass) { /* bingo ;) */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
72 XValuatorInfo *valInfo; |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
73 |
2942 | 74 data = (X11_MouseData *) SDL_calloc(1, sizeof(*data)); |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
75 if (!data) { |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
76 continue; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
77 } |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
78 data->display = display; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
79 data->device = XOpenDevice(display, DevList[i].id); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
80 |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
81 /* motion events */ |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
82 DeviceMotionNotify(data->device, event_code, xEvent); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
83 if (xEvent) { |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
84 data->xevents[data->num_xevents++] = xEvent; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
85 data->motion = event_code; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
86 } |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
88 /* button events */ |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
89 DeviceButtonPress(data->device, event_code, xEvent); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
90 if (xEvent) { |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
91 data->xevents[data->num_xevents++] = xEvent; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
92 data->button_pressed = event_code; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
93 } |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
94 DeviceButtonRelease(data->device, event_code, xEvent); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
95 if (xEvent) { |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
96 data->xevents[data->num_xevents++] = xEvent; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
97 data->button_released = event_code; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
98 } |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
99 |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
100 /* proximity events */ |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
101 ProximityIn(data->device, event_code, xEvent); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
102 if (xEvent) { |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
103 data->xevents[data->num_xevents++] = xEvent; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
104 data->proximity_in = event_code; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
105 } |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
106 ProximityOut(data->device, event_code, xEvent); |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
107 if (xEvent) { |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
108 data->xevents[data->num_xevents++] = xEvent; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
109 data->proximity_out = event_code; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
110 } |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
111 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
112 SDL_zero(mouse); |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
113 mouse.id = DevList[i].id; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
114 mouse.FreeMouse = X11_FreeMouse; |
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
115 mouse.driverdata = data; |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
116 |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
117 /* lets get the device parameters */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
118 valInfo = (XValuatorInfo *) deviceClass; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
119 /* if the device reports pressure, lets check it parameteres */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
120 if (valInfo->num_axes > 2) { |
2942 | 121 SDL_AddMouse(&mouse, DevList[i].name, |
122 valInfo->axes[2].max_value, | |
123 valInfo->axes[2].min_value, 1); | |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
124 } else { |
2942 | 125 SDL_AddMouse(&mouse, DevList[i].name, 0, 0, 1); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
126 } |
3002
0deb3e94c251
define this value if it's not in the system headers
Sam Lantinga <slouken@libsdl.org>
parents:
2992
diff
changeset
|
127 #ifndef IsXExtensionPointer |
0deb3e94c251
define this value if it's not in the system headers
Sam Lantinga <slouken@libsdl.org>
parents:
2992
diff
changeset
|
128 #define IsXExtensionPointer 4 |
0deb3e94c251
define this value if it's not in the system headers
Sam Lantinga <slouken@libsdl.org>
parents:
2992
diff
changeset
|
129 #endif |
2992
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
130 if (DevList[i].use == IsXExtensionPointer) { |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
131 ++num_mice; |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
132 } |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
133 break; |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
134 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
135 /* if it's not class we're interested in, lets go further */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
136 deviceClass = |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
137 (XAnyClassPtr) ((char *) deviceClass + |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
138 deviceClass->length); |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
139 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
140 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
141 } |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
142 XFreeDeviceList(DevList); |
2763
6fc50bdd88c0
Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents:
2710
diff
changeset
|
143 #endif |
2992
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
144 |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
145 if (num_mice == 0) { |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
146 SDL_zero(mouse); |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
147 SDL_AddMouse(&mouse, "CorePointer", 0, 0, 1); |
dbff5769d742
The core pointer is comprised of merging the inputs of all mice.
Sam Lantinga <slouken@libsdl.org>
parents:
2962
diff
changeset
|
148 } |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 void |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 X11_QuitMouse(_THIS) |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 { |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
2763
6fc50bdd88c0
Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents:
2710
diff
changeset
|
156 /* !!! FIXME: use XCloseDevice()? Or maybe handle under SDL_MouseQuit()? */ |
6fc50bdd88c0
Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents:
2710
diff
changeset
|
157 |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
158 /* let's delete all of the mice */ |
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1950
diff
changeset
|
159 SDL_MouseQuit(); |
1950
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 } |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
a344e42bce3b
Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 /* vi: set ts=4 sw=4 expandtab: */ |