-rw-r--r-- | qt/qt-2.3.9.patch/qte239-qwsmouse.patch | 301 |
1 files changed, 301 insertions, 0 deletions
diff --git a/qt/qt-2.3.9.patch/qte239-qwsmouse.patch b/qt/qt-2.3.9.patch/qte239-qwsmouse.patch new file mode 100644 index 0000000..865516e --- a/dev/null +++ b/qt/qt-2.3.9.patch/qte239-qwsmouse.patch | |||
@@ -0,0 +1,301 @@ | |||
1 | # | ||
2 | # Patch managed by http://www.holgerschurig.de/patcher.html | ||
3 | # | ||
4 | |||
5 | --- qt-2.3.9-snapshot-20041211/src/kernel/qwsmouse_qws.cpp~tslib.patch | ||
6 | +++ qt-2.3.9-snapshot-20041211/src/kernel/qwsmouse_qws.cpp | ||
7 | @@ -7,6 +7,14 @@ | ||
8 | ** | ||
9 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | ||
10 | ** | ||
11 | +** Portions Copyright (C) 2003 Texas Instruments, Inc. | ||
12 | +** Rights to said portions for use under the GPL and QPL licenses | ||
13 | +** are hereby granted to Trolltech AS. | ||
14 | +** | ||
15 | +** Portions Copyright (C) 2004 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
16 | +** Rights to said portions for use under the GPL and QPL licenses | ||
17 | +** are hereby granted to Trolltech AS. | ||
18 | +** | ||
19 | ** This file is part of the kernel module of the Qt GUI Toolkit. | ||
20 | ** | ||
21 | ** This file may be distributed and/or modified under the terms of the | ||
22 | @@ -60,6 +68,10 @@ | ||
23 | #include <linux/tpanel.h> | ||
24 | #endif | ||
25 | |||
26 | +#ifdef QWS_TSLIB | ||
27 | +#include <tslib.h> | ||
28 | +#endif | ||
29 | + | ||
30 | //#define QT_QWS_K2 | ||
31 | |||
32 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_K2) | ||
33 | @@ -1124,6 +1136,221 @@ | ||
34 | return sent; | ||
35 | } | ||
36 | |||
37 | + | ||
38 | +class QTSLibHandler : public QCalibratedMouseHandler | ||
39 | +{ | ||
40 | + Q_OBJECT | ||
41 | +public: | ||
42 | + QTSLibHandler(); | ||
43 | + ~QTSLibHandler(); | ||
44 | + | ||
45 | + virtual void clearCalibration(); | ||
46 | + virtual void calibrate( QWSPointerCalibrationData * ); | ||
47 | + | ||
48 | + static int sortByX( const void*, const void* ); | ||
49 | + static int sortByY( const void*, const void* ); | ||
50 | +private: | ||
51 | + void openTs(); | ||
52 | + void closeTs(); | ||
53 | + void interpolateSample(); | ||
54 | + | ||
55 | +private: | ||
56 | + bool raw : 1; | ||
57 | +#ifdef QWS_TSLIB | ||
58 | + struct tsdev *ts; | ||
59 | +#endif | ||
60 | + QSocketNotifier *m_notify; | ||
61 | + | ||
62 | +private slots: | ||
63 | + void readMouseData(); | ||
64 | +}; | ||
65 | + | ||
66 | +QTSLibHandler::QTSLibHandler() | ||
67 | + : raw(false), m_notify(0l) | ||
68 | +{ | ||
69 | + openTs(); | ||
70 | +} | ||
71 | + | ||
72 | +QTSLibHandler::~QTSLibHandler() | ||
73 | +{ | ||
74 | + closeTs(); | ||
75 | +} | ||
76 | + | ||
77 | +void QTSLibHandler::openTs() | ||
78 | +{ | ||
79 | +#ifdef QWS_TSLIB | ||
80 | + char *tsdevice; | ||
81 | + | ||
82 | + if( ( tsdevice = getenv( "TSLIB_TSDEVICE" ) ) != NULL ) { | ||
83 | + ts = ts_open( tsdevice, 1 ); | ||
84 | + } else { | ||
85 | + ts = ts_open( "/dev/ts", 1 ); | ||
86 | + } | ||
87 | + | ||
88 | + if (!ts) { | ||
89 | + qWarning( "Cannot open touchscreen (%s)", strerror( errno ) ); | ||
90 | + return; | ||
91 | + } | ||
92 | + | ||
93 | + if (ts_config( ts )) { | ||
94 | + qWarning( "Cannot configure touchscreen (%s)", strerror( errno ) ); | ||
95 | + return; | ||
96 | + } | ||
97 | + | ||
98 | + | ||
99 | + m_notify = new QSocketNotifier( ts_fd(ts), QSocketNotifier::Read, this ); | ||
100 | + connect( m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); | ||
101 | +#endif | ||
102 | +} | ||
103 | + | ||
104 | +void QTSLibHandler::closeTs() | ||
105 | +{ | ||
106 | +#ifdef QWS_TSLIB | ||
107 | + if (ts) | ||
108 | + ts_close(ts); | ||
109 | + | ||
110 | + delete m_notify; | ||
111 | + m_notify = 0; ts = 0; | ||
112 | + raw = false; | ||
113 | +#endif | ||
114 | + | ||
115 | +} | ||
116 | + | ||
117 | +void QTSLibHandler::clearCalibration() | ||
118 | +{ | ||
119 | + raw = true; | ||
120 | +} | ||
121 | + | ||
122 | + | ||
123 | +void QTSLibHandler::calibrate( QWSPointerCalibrationData *cd ) | ||
124 | +{ | ||
125 | + QPoint dev_tl = cd->devPoints[ QWSPointerCalibrationData::TopLeft ]; | ||
126 | + QPoint dev_br = cd->devPoints[ QWSPointerCalibrationData::BottomRight ]; | ||
127 | + QPoint screen_tl = cd->screenPoints[ QWSPointerCalibrationData::TopLeft ]; | ||
128 | + QPoint screen_br = cd->screenPoints[ QWSPointerCalibrationData::BottomRight ]; | ||
129 | + int a, b, c, d, e, f, s; | ||
130 | + | ||
131 | + s = 1 << 16; | ||
132 | + | ||
133 | + a = s * (screen_tl.x() - screen_br.x() ) / (dev_tl.x() - dev_br.x()); | ||
134 | + b = 0; | ||
135 | + c = s * screen_tl.x() - a * dev_tl.x(); | ||
136 | + | ||
137 | + d = 0; | ||
138 | + e = s * (screen_tl.y() - screen_br.y() ) / (dev_tl.y() - dev_br.y()); | ||
139 | + f = s * screen_tl.y() - e * dev_tl.y(); | ||
140 | + | ||
141 | + QString calFile = "/etc/pointercal"; | ||
142 | +#ifndef QT_NO_TEXTSTREAM | ||
143 | + QFile file( calFile ); | ||
144 | + if ( file.open( IO_WriteOnly ) ) { | ||
145 | + QTextStream t( &file ); | ||
146 | + t << a << " " << b << " " << c << " "; | ||
147 | + t << d << " " << e << " " << f << " " << s; | ||
148 | + file.flush(); closeTs(); | ||
149 | + openTs(); | ||
150 | + } else | ||
151 | +#endif | ||
152 | + { | ||
153 | + qDebug( "Could not save calibration: %s", calFile.latin1() ); | ||
154 | + } | ||
155 | +} | ||
156 | + | ||
157 | +void QTSLibHandler::readMouseData() | ||
158 | +{ | ||
159 | +#ifdef QWS_TSLIB | ||
160 | + if(!qt_screen) | ||
161 | + return; | ||
162 | + | ||
163 | + /* | ||
164 | + * After clear Calibration | ||
165 | + * we're in raw mode and do some easy median | ||
166 | + * search. | ||
167 | + */ | ||
168 | + if (raw ) | ||
169 | + return interpolateSample(); | ||
170 | + | ||
171 | + static struct ts_sample sample; | ||
172 | + static int ret; | ||
173 | + | ||
174 | + /* | ||
175 | + * Ok. We need to see if we can read more than one event | ||
176 | + * We do this not to lose an update. | ||
177 | + */ | ||
178 | + while ( true ) { | ||
179 | + if ((ret = ts_read(ts, &sample, 1)) != 1 ) | ||
180 | + return; | ||
181 | + | ||
182 | + | ||
183 | + QPoint pos( sample.x, sample.y ); | ||
184 | + emit mouseChanged( pos, sample.pressure != 0 ? 1 : 0 ); | ||
185 | + } | ||
186 | +#endif | ||
187 | +} | ||
188 | + | ||
189 | + | ||
190 | +/* | ||
191 | + * Lets take all down events and then sort them | ||
192 | + * and take the event in the middle. | ||
193 | + * | ||
194 | + * inspired by testutils.c | ||
195 | + */ | ||
196 | +void QTSLibHandler::interpolateSample() { | ||
197 | + static struct ts_sample samples[25]; | ||
198 | + int index = 0; | ||
199 | + int ret; | ||
200 | + | ||
201 | + do { | ||
202 | + /* fill only the last sample again */ | ||
203 | + if ( index >= 25 ) | ||
204 | + index = 24; | ||
205 | + | ||
206 | + /* we're opened non-blocking */ | ||
207 | + if((ret= ts_read_raw(ts, &samples[index], 1 ) ) != 1 ) { | ||
208 | + /* no event yet, so try again */ | ||
209 | + if (ret==-1 ) { | ||
210 | + index--; | ||
211 | + continue; | ||
212 | + } | ||
213 | + } | ||
214 | + }while (samples[index++].pressure != 0); | ||
215 | + | ||
216 | + /* | ||
217 | + * index is maximal 25 and we at least one sample | ||
218 | + */ | ||
219 | + if( index >= 25 ) | ||
220 | + index = 24; | ||
221 | + int x, y; | ||
222 | + | ||
223 | + /* | ||
224 | + * now let us use the median value | ||
225 | + * even index does not have an item in the middle | ||
226 | + * so let us take the average of n/2 and (n/2)-1 as the middle | ||
227 | + */ | ||
228 | + int m = index/2; | ||
229 | + ::qsort(samples, index, sizeof(ts_sample), QTSLibHandler::sortByX); | ||
230 | + x = (index % 2 ) ? samples[m].x : | ||
231 | + ( samples[m-1].x + samples[m].x )/2; | ||
232 | + | ||
233 | + ::qsort(samples, index, sizeof(ts_sample), QTSLibHandler::sortByY); | ||
234 | + y = (index % 2 ) ? samples[m].y : | ||
235 | + ( samples[m-1].y + samples[m].y )/2; | ||
236 | + | ||
237 | + emit mouseChanged( QPoint(x, y), 1 ); | ||
238 | + emit mouseChanged( QPoint(0, 0), 0 ); | ||
239 | +} | ||
240 | + | ||
241 | +int QTSLibHandler::sortByX( const void* one, const void* two) { | ||
242 | + return reinterpret_cast<const struct ts_sample*>(one)->x - | ||
243 | + reinterpret_cast<const struct ts_sample*>(two)->x; | ||
244 | +} | ||
245 | + | ||
246 | +int QTSLibHandler::sortByY( const void* one, const void* two) { | ||
247 | + return reinterpret_cast<const struct ts_sample*>(one)->y - | ||
248 | + reinterpret_cast<const struct ts_sample*>(two)->y; | ||
249 | +} | ||
250 | + | ||
251 | + | ||
252 | /* | ||
253 | * Handler for /dev/tpanel Linux kernel driver | ||
254 | */ | ||
255 | @@ -1731,7 +1958,9 @@ | ||
256 | |||
257 | case TPanel: | ||
258 | #if defined(QWS_CUSTOMTOUCHPANEL) | ||
259 | - handler = new QCustomTPanelHandlerPrivate(mouseProtocol,mouseDev); | ||
260 | + handler = new QCustomTPanelHandlerPrivate(mouseProtocol,mouseDev); | ||
261 | +#elif defined(QWS_TSLIB) | ||
262 | + handler = new QTSLibHandler(); | ||
263 | #elif defined(QT_QWS_YOPY) | ||
264 | handler = new QYopyTPanelHandlerPrivate(mouseProtocol,mouseDev); | ||
265 | #elif defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_K2) | ||
266 | --- qt-2.3.9-snapshot-20041211/configure~tslib.patch | ||
267 | +++ qt-2.3.9-snapshot-20041211/configure | ||
268 | @@ -406,6 +406,9 @@ | ||
269 | -kde) | ||
270 | KDE=yes | ||
271 | ;; | ||
272 | + -tslib) | ||
273 | + TSLIB=YES | ||
274 | + ;; | ||
275 | -no-g++-exceptions) | ||
276 | GPLUSPLUS_EXCEPTIONS=no | ||
277 | ;; | ||
278 | @@ -1290,6 +1293,9 @@ | ||
279 | set to point to a KDE 2 installation. | ||
280 | See http://www.kde.org | ||
281 | |||
282 | + -tslib ............. Use the TSLib (touchscreen access library) mouse handler | ||
283 | + by default, instead of the normal device default. | ||
284 | + | ||
285 | -no-g++-exceptions . Disable exceptions on platforms using the GNU C++ | ||
286 | compiler by using the -fno-exceptions flag. | ||
287 | |||
288 | @@ -1353,6 +1359,13 @@ | ||
289 | [ "x$SM" = "xno" ] && QT_CXX="${QT_CXX} -DQT_NO_SM_SUPPORT" | ||
290 | [ "x$XFT" = "xyes" ] && QT_CXX="${QT_CXX} -DQT_XFT" | ||
291 | [ "x$XFT" = "xno" ] && QT_CXX="${QT_CXX} -DQT_NO_XKB" | ||
292 | + | ||
293 | +if [ "x$TSLIB" = "xyes" ] | ||
294 | +then | ||
295 | + QT_CXX="${QT_CXX} -DQWS_TSLIB" | ||
296 | + QT_LIBS="${QT_LIBS} -lts" | ||
297 | +fi | ||
298 | + | ||
299 | if [ "x$THREAD" = "xyes" ] | ||
300 | then | ||
301 | cat >src-mt.mk <<EOF | ||