annotate src/video/x11/SDL_x11mouse.c @ 3772:9087a84cba51 gsoc2008_manymouse

First comments and code upgrades in X11
author Szymon Wilczek <kazeuser@gmail.com>
date Sat, 02 Aug 2008 17:40:49 +0000
parents 24db5d326f57
children e5011833348a
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
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
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
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_x11video.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "../../events/SDL_mouse_c.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 X11_InitMouse(_THIS)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 {
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
31 extern XDevice **SDL_XDevices;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
32 XDevice **newDevices;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
33 int i,j,index=0, numOfDevices;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
34 extern int SDL_NumOfXDevices;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
35 XDeviceInfo *DevList;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
36 XAnyClassPtr deviceClass;
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
38
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
39 /*we're getting the list of input devices*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
40 DevList=XListInputDevices(data->display, &numOfDevices);
3761
e0c95ad1ba87 Major bug fixes
Szymon Wilczek <kazeuser@gmail.com>
parents: 3760
diff changeset
41 SDL_XDevices=(XDevice**) SDL_malloc(sizeof(XDevice));
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
42
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
43 /*we're aquiring valuators:mices, tablets, etc.*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
44 for(i=0;i<numOfDevices;++i)
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
45 {
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
46 /*if it's the core pointer or core keyborard we don't want it*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
47 if((DevList[i].use!=IsXPointer && DevList[i].use!=IsXKeyboard))
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
48 {
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
49 /*we have to check all of the device classes*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
50 deviceClass=DevList[i].inputclassinfo;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
51 for(j=0;j<DevList[i].num_classes;++j)
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
52 {
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
53 if(deviceClass->class==ValuatorClass)/*bingo;)*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
54 {
3766
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
55 XValuatorInfo* valInfo;
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
56 SDL_Mouse mouse;
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
57
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
58 newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
59 if(!newDevices)
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
60 {
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
61 SDL_OutOfMemory();
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
62 return -1;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
63 }
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
64 SDL_XDevices=newDevices;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
65 SDL_XDevices[index]=XOpenDevice(data->display,DevList[i].id);
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
66 SDL_zero(mouse);
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
67
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
68 /*the id of the device differs from its index
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
69 *so we're assigning the index of a device to it's id*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
70 SDL_SetIndexId(DevList[i].id,index);
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
71 /*lets get the device parameters*/
3766
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
72 valInfo=(XValuatorInfo*)deviceClass;
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
73 /*if the device reports pressure, lets check it parameteres*/
3766
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
74 if(valInfo->num_axes>2)
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
75 {
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
76 data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,valInfo->axes[2].max_value,valInfo->axes[2].min_value);
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
77 }
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
78 else
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
79 {
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
80 data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,0,0);
24db5d326f57 Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents: 3761
diff changeset
81 }
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
82 break;
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
83 }
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
84 /*if it's not class we're interested in, lets go further*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
85 deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
86 }
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
87 }
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
88 }
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
89 XFreeDeviceList(DevList);
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
90
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
91 SDL_NumOfXDevices=index;
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 X11_QuitMouse(_THIS)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
3772
9087a84cba51 First comments and code upgrades in X11
Szymon Wilczek <kazeuser@gmail.com>
parents: 3766
diff changeset
99 /*Lets delete all of the mice*/
3760
64f346a83ed3 http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents: 1950
diff changeset
100 SDL_MouseQuit();
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 /* vi: set ts=4 sw=4 expandtab: */