Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11touch.c @ 5284:96a22141cf86 tip
Changed output directory of Universal libSDL.a for iOS to respect build configurations. Template generator was updated to reflect these changes as well.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Sat, 12 Feb 2011 21:52:30 -0800 |
parents | b530ef003506 |
children |
rev | line source |
---|---|
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
1 /* |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
5267 | 3 Copyright (C) 1997-2011 Sam Lantinga |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
4 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
9 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
14 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
18 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
21 */ |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
23 #include "SDL_x11video.h" |
4923
1002d074d459
Renamed X11 touch files for consistency
Sam Lantinga <slouken@libsdl.org>
parents:
4683
diff
changeset
|
24 #include "SDL_x11touch.h" |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
25 #include "../../events/SDL_touch_c.h" |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
26 |
4681 | 27 |
28 #ifdef SDL_INPUT_LINUXEV | |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
29 #include <linux/input.h> |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
30 #include <fcntl.h> |
4669 | 31 #endif |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
32 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
33 void |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
34 X11_InitTouch(_THIS) |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
35 { |
4681 | 36 #ifdef SDL_INPUT_LINUXEV |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
37 FILE *fd; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
38 fd = fopen("/proc/bus/input/devices","r"); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
39 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
40 char c; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
41 int i = 0; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
42 char line[256]; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
43 char tstr[256]; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
44 int vendor = -1,product = -1,event = -1; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
45 while(!feof(fd)) { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
46 if(fgets(line,256,fd) <=0) continue; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
47 if(line[0] == '\n') { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
48 if(vendor == 1386){ |
5044
4913042e8572
Removed debug print statements
Sam Lantinga <slouken@libsdl.org>
parents:
4923
diff
changeset
|
49 /*printf("Wacom... Assuming it is a touch device\n");*/ |
4913042e8572
Removed debug print statements
Sam Lantinga <slouken@libsdl.org>
parents:
4923
diff
changeset
|
50 /*sprintf(tstr,"/dev/input/event%i",event);*/ |
4913042e8572
Removed debug print statements
Sam Lantinga <slouken@libsdl.org>
parents:
4923
diff
changeset
|
51 /*printf("At location: %s\n",tstr);*/ |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
52 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
53 SDL_Touch touch; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
54 touch.pressure_max = 0; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
55 touch.pressure_min = 0; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
56 touch.id = event; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
57 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
58 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
59 touch.driverdata = SDL_malloc(sizeof(EventTouchData)); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
60 EventTouchData* data = (EventTouchData*)(touch.driverdata); |
4683
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
61 |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
62 data->x = -1; |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
63 data->y = -1; |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
64 data->pressure = -1; |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
65 data->finger = 0; |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
66 data->up = SDL_FALSE; |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
67 |
15dfe42edbfd
Fixed gestureMulti. Disabled dollar gesture temporarily.
Jim Grandpre <jim.tla@gmail.com>
parents:
4681
diff
changeset
|
68 |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
69 data->eventStream = open(tstr, |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
70 O_RDONLY | O_NONBLOCK); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
71 ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr); |
4646
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
72 |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
73 int abs[5]; |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
74 ioctl(data->eventStream,EVIOCGABS(0),abs); |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
75 touch.x_min = abs[1]; |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
76 touch.x_max = abs[2]; |
4678
f8431f66613d
Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working).
jimtla
parents:
4669
diff
changeset
|
77 touch.native_xres = touch.x_max - touch.x_min; |
4646
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
78 ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs); |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
79 touch.y_min = abs[1]; |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
80 touch.y_max = abs[2]; |
4678
f8431f66613d
Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working).
jimtla
parents:
4669
diff
changeset
|
81 touch.native_yres = touch.y_max - touch.y_min; |
4646
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
82 ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs); |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
83 touch.pressure_min = abs[1]; |
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
84 touch.pressure_max = abs[2]; |
4678
f8431f66613d
Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working).
jimtla
parents:
4669
diff
changeset
|
85 touch.native_pressureres = touch.pressure_max - touch.pressure_min; |
4646
eea1bf53effa
Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents:
4645
diff
changeset
|
86 |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
87 SDL_AddTouch(&touch, tstr); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
88 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
89 vendor = -1; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
90 product = -1; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
91 event = -1; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
92 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
93 else if(line[0] == 'I') { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
94 i = 1; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
95 while(line[i]) { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
96 sscanf(&line[i],"Vendor=%x",&vendor); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
97 sscanf(&line[i],"Product=%x",&product); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
98 i++; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
99 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
100 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
101 else if(line[0] == 'H') { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
102 i = 1; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
103 while(line[i]) { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
104 sscanf(&line[i],"event%d",&event); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
105 i++; |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
106 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
107 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
108 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
109 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
110 close(fd); |
4669 | 111 #endif |
4645
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
112 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
113 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
114 void |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
115 X11_QuitTouch(_THIS) |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
116 { |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
117 SDL_TouchQuit(); |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
118 } |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
119 |
0375d020e7e3
Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
120 /* vi: set ts=4 sw=4 expandtab: */ |