author | sandman <sandman> | 2002-08-04 02:25:54 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-04 02:25:54 (UTC) |
commit | 8fd0780faa16abbcf7db9220af1bc333ae484ec8 (patch) (unidiff) | |
tree | ffacd596daa0ab07890f185510275667649d55db /libopie/odevice.cpp | |
parent | 549df674d7af9fe1347751e6a63d6ed8249d2503 (diff) | |
download | opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.zip opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.tar.gz opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.tar.bz2 |
1) Fixes for suspend/resume (improved it for iPAQ, shouldn't have changed
anything for Z) -- It seems that this also fixes the 70% CPU load
problem (needs more testing/feedback though)
2) the launcher now creates a /var/run/opie.pid file containing its pid
3) the launcher catches SIGTERM and kills all its child processes
-rw-r--r-- | libopie/odevice.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index bc8014a..057c344 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,514 +1,576 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | ||
21 | |||
20 | #include <qfile.h> | 22 | #include <qfile.h> |
21 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
22 | #include <qpe/sound.h> | 24 | #include <qpe/sound.h> |
23 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
24 | 26 | ||
25 | 27 | ||
26 | #include "odevice.h" | 28 | #include "odevice.h" |
27 | 29 | ||
28 | 30 | ||
29 | class ODeviceData { | 31 | class ODeviceData { |
30 | public: | 32 | public: |
31 | QString m_vendorstr; | 33 | QString m_vendorstr; |
32 | OVendor m_vendor; | 34 | OVendor m_vendor; |
33 | 35 | ||
34 | QString m_modelstr; | 36 | QString m_modelstr; |
35 | OModel m_model; | 37 | OModel m_model; |
36 | 38 | ||
37 | QString m_systemstr; | 39 | QString m_systemstr; |
38 | OSystem m_system; | 40 | OSystem m_system; |
39 | 41 | ||
40 | QString m_sysverstr; | 42 | QString m_sysverstr; |
41 | 43 | ||
42 | OLedState m_leds [4]; // just for convenience ... | 44 | OLedState m_leds [4]; // just for convenience ... |
43 | }; | 45 | }; |
44 | 46 | ||
45 | class ODeviceIPAQ : public ODevice { | 47 | class ODeviceIPAQ : public ODevice { |
46 | protected: | 48 | protected: |
47 | virtual void init ( ); | 49 | virtual void init ( ); |
48 | 50 | ||
49 | public: | 51 | public: |
52 | virtual bool suspend ( ); | ||
53 | |||
50 | virtual void alarmSound ( ); | 54 | virtual void alarmSound ( ); |
51 | 55 | ||
52 | virtual uint hasLeds ( ) const; | 56 | virtual uint hasLeds ( ) const; |
53 | virtual OLedState led ( uint which ) const; | 57 | virtual OLedState led ( uint which ) const; |
54 | virtual bool setLed ( uint which, OLedState st ); | 58 | virtual bool setLed ( uint which, OLedState st ); |
59 | |||
60 | private: | ||
61 | static void tstp_sighandler ( int ); | ||
55 | }; | 62 | }; |
56 | 63 | ||
57 | class ODeviceZaurus : public ODevice { | 64 | class ODeviceZaurus : public ODevice { |
58 | protected: | 65 | protected: |
59 | virtual void init ( ); | 66 | virtual void init ( ); |
60 | 67 | ||
61 | public: | 68 | public: |
62 | virtual void alarmSound ( ); | 69 | virtual void alarmSound ( ); |
63 | virtual void keySound ( ); | 70 | virtual void keySound ( ); |
64 | virtual void touchSound ( ); | 71 | virtual void touchSound ( ); |
65 | 72 | ||
66 | virtual uint hasLeds ( ) const; | 73 | virtual uint hasLeds ( ) const; |
67 | virtual OLedState led ( uint which ) const; | 74 | virtual OLedState led ( uint which ) const; |
68 | virtual bool setLed ( uint which, OLedState st ); | 75 | virtual bool setLed ( uint which, OLedState st ); |
69 | 76 | ||
70 | protected: | 77 | protected: |
71 | virtual void buzzer ( int snd ); | 78 | virtual void buzzer ( int snd ); |
72 | }; | 79 | }; |
73 | 80 | ||
74 | 81 | ||
75 | 82 | ||
76 | 83 | ||
77 | ODevice *ODevice::inst ( ) | 84 | ODevice *ODevice::inst ( ) |
78 | { | 85 | { |
79 | static ODevice *dev = 0; | 86 | static ODevice *dev = 0; |
80 | 87 | ||
81 | if ( !dev ) { | 88 | if ( !dev ) { |
82 | if ( QFile::exists ( "/proc/hal/model" )) | 89 | if ( QFile::exists ( "/proc/hal/model" )) |
83 | dev = new ODeviceIPAQ ( ); | 90 | dev = new ODeviceIPAQ ( ); |
84 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 91 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
85 | dev = new ODeviceZaurus ( ); | 92 | dev = new ODeviceZaurus ( ); |
86 | else | 93 | else |
87 | dev = new ODevice ( ); | 94 | dev = new ODevice ( ); |
88 | 95 | ||
89 | dev-> init ( ); | 96 | dev-> init ( ); |
90 | } | 97 | } |
91 | return dev; | 98 | return dev; |
92 | } | 99 | } |
93 | 100 | ||
94 | ODevice::ODevice ( ) | 101 | ODevice::ODevice ( ) |
95 | { | 102 | { |
96 | d = new ODeviceData; | 103 | d = new ODeviceData; |
97 | 104 | ||
98 | d-> m_modelstr = "Unknown"; | 105 | d-> m_modelstr = "Unknown"; |
99 | d-> m_model = OMODEL_Unknown; | 106 | d-> m_model = OMODEL_Unknown; |
100 | d-> m_vendorstr = "Unkown"; | 107 | d-> m_vendorstr = "Unkown"; |
101 | d-> m_vendor = OVENDOR_Unknown; | 108 | d-> m_vendor = OVENDOR_Unknown; |
102 | d-> m_systemstr = "Unkown"; | 109 | d-> m_systemstr = "Unkown"; |
103 | d-> m_system = OSYSTEM_Unknown; | 110 | d-> m_system = OSYSTEM_Unknown; |
104 | d-> m_sysverstr = "0.0"; | 111 | d-> m_sysverstr = "0.0"; |
105 | } | 112 | } |
106 | 113 | ||
107 | void ODevice::init ( ) | 114 | void ODevice::init ( ) |
108 | { | 115 | { |
109 | } | 116 | } |
110 | 117 | ||
111 | ODevice::~ODevice ( ) | 118 | ODevice::~ODevice ( ) |
112 | { | 119 | { |
113 | delete d; | 120 | delete d; |
114 | } | 121 | } |
115 | 122 | ||
123 | bool ODevice::suspend ( ) | ||
124 | { | ||
125 | int rc = ::system ( "apm --suspend" ); | ||
126 | |||
127 | if (( rc == 127 ) || ( rc == -1 )) | ||
128 | return false; | ||
129 | else | ||
130 | return true; | ||
131 | } | ||
132 | |||
116 | QString ODevice::vendorString ( ) | 133 | QString ODevice::vendorString ( ) |
117 | { | 134 | { |
118 | return d-> m_vendorstr; | 135 | return d-> m_vendorstr; |
119 | } | 136 | } |
120 | 137 | ||
121 | OVendor ODevice::vendor ( ) | 138 | OVendor ODevice::vendor ( ) |
122 | { | 139 | { |
123 | return d-> m_vendor; | 140 | return d-> m_vendor; |
124 | } | 141 | } |
125 | 142 | ||
126 | QString ODevice::modelString ( ) | 143 | QString ODevice::modelString ( ) |
127 | { | 144 | { |
128 | return d-> m_modelstr; | 145 | return d-> m_modelstr; |
129 | } | 146 | } |
130 | 147 | ||
131 | OModel ODevice::model ( ) | 148 | OModel ODevice::model ( ) |
132 | { | 149 | { |
133 | return d-> m_model; | 150 | return d-> m_model; |
134 | } | 151 | } |
135 | 152 | ||
136 | QString ODevice::systemString ( ) | 153 | QString ODevice::systemString ( ) |
137 | { | 154 | { |
138 | return d-> m_systemstr; | 155 | return d-> m_systemstr; |
139 | } | 156 | } |
140 | 157 | ||
141 | OSystem ODevice::system ( ) | 158 | OSystem ODevice::system ( ) |
142 | { | 159 | { |
143 | return d-> m_system; | 160 | return d-> m_system; |
144 | } | 161 | } |
145 | 162 | ||
146 | QString ODevice::systemVersionString ( ) | 163 | QString ODevice::systemVersionString ( ) |
147 | { | 164 | { |
148 | return d-> m_sysverstr; | 165 | return d-> m_sysverstr; |
149 | } | 166 | } |
150 | 167 | ||
151 | void ODevice::alarmSound ( ) | 168 | void ODevice::alarmSound ( ) |
152 | { | 169 | { |
153 | #ifndef QT_QWS_EBX | 170 | #ifndef QT_QWS_EBX |
154 | #ifndef QT_NO_SOUND | 171 | #ifndef QT_NO_SOUND |
155 | static Sound snd ( "alarm" ); | 172 | static Sound snd ( "alarm" ); |
156 | 173 | ||
157 | if ( snd. isFinished ( )) | 174 | if ( snd. isFinished ( )) |
158 | snd. play ( ); | 175 | snd. play ( ); |
159 | #endif | 176 | #endif |
160 | #endif | 177 | #endif |
161 | } | 178 | } |
162 | 179 | ||
163 | void ODevice::keySound ( ) | 180 | void ODevice::keySound ( ) |
164 | { | 181 | { |
165 | #ifndef QT_QWS_EBX | 182 | #ifndef QT_QWS_EBX |
166 | #ifndef QT_NO_SOUND | 183 | #ifndef QT_NO_SOUND |
167 | static Sound snd ( "keysound" ); | 184 | static Sound snd ( "keysound" ); |
168 | 185 | ||
169 | if ( snd. isFinished ( )) | 186 | if ( snd. isFinished ( )) |
170 | snd. play ( ); | 187 | snd. play ( ); |
171 | #endif | 188 | #endif |
172 | #endif | 189 | #endif |
173 | } | 190 | } |
174 | 191 | ||
175 | void ODevice::touchSound ( ) | 192 | void ODevice::touchSound ( ) |
176 | { | 193 | { |
177 | 194 | ||
178 | #ifndef QT_QWS_EBX | 195 | #ifndef QT_QWS_EBX |
179 | #ifndef QT_NO_SOUND | 196 | #ifndef QT_NO_SOUND |
180 | static Sound snd ( "touchsound" ); | 197 | static Sound snd ( "touchsound" ); |
181 | //qDebug("touchSound"); | 198 | //qDebug("touchSound"); |
182 | if ( snd. isFinished ( )) { | 199 | if ( snd. isFinished ( )) { |
183 | snd. play ( ); | 200 | snd. play ( ); |
184 | // qDebug("sound should play"); | 201 | // qDebug("sound should play"); |
185 | } | 202 | } |
186 | #endif | 203 | #endif |
187 | #endif | 204 | #endif |
188 | } | 205 | } |
189 | 206 | ||
190 | uint ODevice::hasLeds ( ) const | 207 | uint ODevice::hasLeds ( ) const |
191 | { | 208 | { |
192 | return 0; | 209 | return 0; |
193 | } | 210 | } |
194 | 211 | ||
195 | OLedState ODevice::led ( uint /*which*/ ) const | 212 | OLedState ODevice::led ( uint /*which*/ ) const |
196 | { | 213 | { |
197 | return OLED_Off; | 214 | return OLED_Off; |
198 | } | 215 | } |
199 | 216 | ||
200 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) | 217 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) |
201 | { | 218 | { |
202 | return false; | 219 | return false; |
203 | } | 220 | } |
204 | 221 | ||
205 | 222 | ||
206 | 223 | ||
207 | 224 | ||
208 | //#if defined( QT_QWS_IPAQ ) // IPAQ | 225 | //#if defined( QT_QWS_IPAQ ) // IPAQ |
209 | 226 | ||
210 | 227 | ||
211 | void ODeviceIPAQ::init ( ) | 228 | void ODeviceIPAQ::init ( ) |
212 | { | 229 | { |
213 | d-> m_vendorstr = "HP"; | 230 | d-> m_vendorstr = "HP"; |
214 | d-> m_vendor = OVENDOR_HP; | 231 | d-> m_vendor = OVENDOR_HP; |
215 | 232 | ||
216 | QFile f ( "/proc/hal/model" ); | 233 | QFile f ( "/proc/hal/model" ); |
217 | 234 | ||
218 | if ( f. open ( IO_ReadOnly )) { | 235 | if ( f. open ( IO_ReadOnly )) { |
219 | QTextStream ts ( &f ); | 236 | QTextStream ts ( &f ); |
220 | 237 | ||
221 | d-> m_modelstr = "H" + ts. readLine ( ); | 238 | d-> m_modelstr = "H" + ts. readLine ( ); |
222 | 239 | ||
223 | if ( d-> m_modelstr == "H3100" ) | 240 | if ( d-> m_modelstr == "H3100" ) |
224 | d-> m_model = OMODEL_iPAQ_H31xx; | 241 | d-> m_model = OMODEL_iPAQ_H31xx; |
225 | else if ( d-> m_modelstr == "H3600" ) | 242 | else if ( d-> m_modelstr == "H3600" ) |
226 | d-> m_model = OMODEL_iPAQ_H36xx; | 243 | d-> m_model = OMODEL_iPAQ_H36xx; |
227 | else if ( d-> m_modelstr == "H3700" ) | 244 | else if ( d-> m_modelstr == "H3700" ) |
228 | d-> m_model = OMODEL_iPAQ_H37xx; | 245 | d-> m_model = OMODEL_iPAQ_H37xx; |
229 | else if ( d-> m_modelstr == "H3800" ) | 246 | else if ( d-> m_modelstr == "H3800" ) |
230 | d-> m_model = OMODEL_iPAQ_H38xx; | 247 | d-> m_model = OMODEL_iPAQ_H38xx; |
231 | else | 248 | else |
232 | d-> m_model = OMODEL_Unknown; | 249 | d-> m_model = OMODEL_Unknown; |
233 | 250 | ||
234 | f. close ( ); | 251 | f. close ( ); |
235 | } | 252 | } |
236 | 253 | ||
237 | f. setName ( "/etc/familiar-version" ); | 254 | f. setName ( "/etc/familiar-version" ); |
238 | if ( f. open ( IO_ReadOnly )) { | 255 | if ( f. open ( IO_ReadOnly )) { |
239 | d-> m_systemstr = "Familiar"; | 256 | d-> m_systemstr = "Familiar"; |
240 | d-> m_system = OSYSTEM_Familiar; | 257 | d-> m_system = OSYSTEM_Familiar; |
241 | 258 | ||
242 | QTextStream ts ( &f ); | 259 | QTextStream ts ( &f ); |
243 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 260 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
244 | 261 | ||
245 | f. close ( ); | 262 | f. close ( ); |
246 | } | 263 | } |
247 | 264 | ||
248 | d-> m_leds [0] = OLED_Off; | 265 | d-> m_leds [0] = OLED_Off; |
249 | } | 266 | } |
250 | 267 | ||
251 | #include <unistd.h> | 268 | #include <unistd.h> |
252 | #include <fcntl.h> | 269 | #include <fcntl.h> |
253 | #include <sys/ioctl.h> | 270 | #include <sys/ioctl.h> |
271 | #include <signal.h> | ||
272 | #include <sys/time.h> | ||
254 | #include <linux/soundcard.h> | 273 | #include <linux/soundcard.h> |
255 | #include <qapplication.h> | 274 | #include <qapplication.h> |
256 | #include <qpe/config.h> | 275 | #include <qpe/config.h> |
257 | 276 | ||
258 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
259 | 278 | ||
260 | typedef struct h3600_ts_led { | 279 | typedef struct h3600_ts_led { |
261 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
262 | unsigned char TotalTime; /* Units of 5 seconds */ | 281 | unsigned char TotalTime; /* Units of 5 seconds */ |
263 | unsigned char OnTime; /* units of 100m/s */ | 282 | unsigned char OnTime; /* units of 100m/s */ |
264 | unsigned char OffTime; /* units of 100m/s */ | 283 | unsigned char OffTime; /* units of 100m/s */ |
265 | } LED_IN; | 284 | } LED_IN; |
266 | 285 | ||
267 | 286 | ||
268 | // #define IOC_H3600_TS_MAGIC 'f' | 287 | // #define IOC_H3600_TS_MAGIC 'f' |
269 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) | 288 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) |
270 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( | 289 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( |
271 | 290 | ||
272 | 291 | ||
292 | //#include <linux/apm_bios.h> | ||
293 | |||
294 | //#define APM_IOC_SUSPEND _IO('A',2) | ||
295 | |||
296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) | ||
297 | |||
298 | |||
299 | void ODeviceIPAQ::tstp_sighandler ( int ) | ||
300 | { | ||
301 | } | ||
302 | |||
303 | |||
304 | bool ODeviceIPAQ::suspend ( ) | ||
305 | { | ||
306 | int fd; | ||
307 | bool res = false; | ||
308 | |||
309 | if (( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) { | ||
310 | struct timeval tvs, tvn; | ||
311 | |||
312 | ::signal ( SIGTSTP, tstp_sighandler ); | ||
313 | ::gettimeofday ( &tvs, 0 ); | ||
314 | |||
315 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); | ||
316 | ::close ( fd ); | ||
317 | |||
318 | if ( res ) { | ||
319 | ::kill ( -::getpid ( ), SIGTSTP ); | ||
320 | |||
321 | do { | ||
322 | ::usleep ( 200 * 1000 ); | ||
323 | ::gettimeofday ( &tvn, 0 ); | ||
324 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | ||
325 | |||
326 | ::kill ( -::getpid ( ), SIGCONT ); | ||
327 | } | ||
328 | |||
329 | ::signal ( SIGTSTP, SIG_DFL ); | ||
330 | } | ||
331 | return res; | ||
332 | } | ||
333 | |||
334 | |||
273 | void ODeviceIPAQ::alarmSound ( ) | 335 | void ODeviceIPAQ::alarmSound ( ) |
274 | { | 336 | { |
275 | #if defined( QT_QWS_IPAQ ) // IPAQ | 337 | #if defined( QT_QWS_IPAQ ) // IPAQ |
276 | #ifndef QT_NO_SOUND | 338 | #ifndef QT_NO_SOUND |
277 | static Sound snd ( "alarm" ); | 339 | static Sound snd ( "alarm" ); |
278 | int fd; | 340 | int fd; |
279 | int vol; | 341 | int vol; |
280 | bool vol_reset = false; | 342 | bool vol_reset = false; |
281 | 343 | ||
282 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 344 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
283 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 345 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
284 | 346 | ||
285 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 347 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
286 | Config cfg ( "qpe" ); | 348 | Config cfg ( "qpe" ); |
287 | cfg. setGroup ( "Volume" ); | 349 | cfg. setGroup ( "Volume" ); |
288 | 350 | ||
289 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 351 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
290 | if ( volalarm < 0 ) | 352 | if ( volalarm < 0 ) |
291 | volalarm = 0; | 353 | volalarm = 0; |
292 | else if ( volalarm > 100 ) | 354 | else if ( volalarm > 100 ) |
293 | volalarm = 100; | 355 | volalarm = 100; |
294 | volalarm |= ( volalarm << 8 ); | 356 | volalarm |= ( volalarm << 8 ); |
295 | 357 | ||
296 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 358 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
297 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 359 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
298 | vol_reset = true; | 360 | vol_reset = true; |
299 | } | 361 | } |
300 | } | 362 | } |
301 | } | 363 | } |
302 | 364 | ||
303 | snd. play ( ); | 365 | snd. play ( ); |
304 | while ( !snd. isFinished ( )) | 366 | while ( !snd. isFinished ( )) |
305 | qApp-> processEvents ( ); | 367 | qApp-> processEvents ( ); |
306 | 368 | ||
307 | if ( fd >= 0 ) { | 369 | if ( fd >= 0 ) { |
308 | if ( vol_reset ) | 370 | if ( vol_reset ) |
309 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 371 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
310 | ::close ( fd ); | 372 | ::close ( fd ); |
311 | } | 373 | } |
312 | #endif | 374 | #endif |
313 | #endif | 375 | #endif |
314 | } | 376 | } |
315 | 377 | ||
316 | uint ODeviceIPAQ::hasLeds ( ) const | 378 | uint ODeviceIPAQ::hasLeds ( ) const |
317 | { | 379 | { |
318 | return 1; | 380 | return 1; |
319 | } | 381 | } |
320 | 382 | ||
321 | OLedState ODeviceIPAQ::led ( uint which ) const | 383 | OLedState ODeviceIPAQ::led ( uint which ) const |
322 | { | 384 | { |
323 | if ( which == 0 ) | 385 | if ( which == 0 ) |
324 | return d-> m_leds [0]; | 386 | return d-> m_leds [0]; |
325 | else | 387 | else |
326 | return OLED_Off; | 388 | return OLED_Off; |
327 | } | 389 | } |
328 | 390 | ||
329 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) | 391 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) |
330 | { | 392 | { |
331 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); | 393 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); |
332 | 394 | ||
333 | if ( which == 0 ) { | 395 | if ( which == 0 ) { |
334 | if ( fd >= 0 ) { | 396 | if ( fd >= 0 ) { |
335 | struct h3600_ts_led leds; | 397 | struct h3600_ts_led leds; |
336 | ::memset ( &leds, 0, sizeof( leds )); | 398 | ::memset ( &leds, 0, sizeof( leds )); |
337 | leds. TotalTime = 0; | 399 | leds. TotalTime = 0; |
338 | leds. OnTime = 0; | 400 | leds. OnTime = 0; |
339 | leds. OffTime = 1; | 401 | leds. OffTime = 1; |
340 | leds. OffOnBlink = 2; | 402 | leds. OffOnBlink = 2; |
341 | 403 | ||
342 | switch ( st ) { | 404 | switch ( st ) { |
343 | case OLED_Off : leds. OffOnBlink = 0; break; | 405 | case OLED_Off : leds. OffOnBlink = 0; break; |
344 | case OLED_On : leds. OffOnBlink = 1; break; | 406 | case OLED_On : leds. OffOnBlink = 1; break; |
345 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 407 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
346 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 408 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
347 | } | 409 | } |
348 | 410 | ||
349 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 411 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
350 | d-> m_leds [0] = st; | 412 | d-> m_leds [0] = st; |
351 | return true; | 413 | return true; |
352 | } | 414 | } |
353 | } | 415 | } |
354 | } | 416 | } |
355 | return false; | 417 | return false; |
356 | } | 418 | } |
357 | 419 | ||
358 | 420 | ||
359 | //#endif | 421 | //#endif |
360 | 422 | ||
361 | 423 | ||
362 | 424 | ||
363 | 425 | ||
364 | 426 | ||
365 | //#if defined( QT_QWS_EBX ) // Zaurus | 427 | //#if defined( QT_QWS_EBX ) // Zaurus |
366 | 428 | ||
367 | void ODeviceZaurus::init ( ) | 429 | void ODeviceZaurus::init ( ) |
368 | { | 430 | { |
369 | d-> m_modelstr = "Zaurus SL5000"; | 431 | d-> m_modelstr = "Zaurus SL5000"; |
370 | d-> m_model = OMODEL_Zaurus_SL5000; | 432 | d-> m_model = OMODEL_Zaurus_SL5000; |
371 | d-> m_vendorstr = "Sharp"; | 433 | d-> m_vendorstr = "Sharp"; |
372 | d-> m_vendor = OVENDOR_Sharp; | 434 | d-> m_vendor = OVENDOR_Sharp; |
373 | 435 | ||
374 | QFile f ( "/proc/filesystems" ); | 436 | QFile f ( "/proc/filesystems" ); |
375 | 437 | ||
376 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 438 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
377 | d-> m_systemstr = "OpenZaurus"; | 439 | d-> m_systemstr = "OpenZaurus"; |
378 | d-> m_system = OSYSTEM_OpenZaurus; | 440 | d-> m_system = OSYSTEM_OpenZaurus; |
379 | 441 | ||
380 | f. close ( ); | 442 | f. close ( ); |
381 | } | 443 | } |
382 | else { | 444 | else { |
383 | d-> m_systemstr = "Zaurus"; | 445 | d-> m_systemstr = "Zaurus"; |
384 | d-> m_system = OSYSTEM_Zaurus; | 446 | d-> m_system = OSYSTEM_Zaurus; |
385 | } | 447 | } |
386 | 448 | ||
387 | d-> m_leds [0] = OLED_Off; | 449 | d-> m_leds [0] = OLED_Off; |
388 | } | 450 | } |
389 | 451 | ||
390 | #include <unistd.h> | 452 | #include <unistd.h> |
391 | #include <fcntl.h> | 453 | #include <fcntl.h> |
392 | #include <sys/ioctl.h> | 454 | #include <sys/ioctl.h> |
393 | 455 | ||
394 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 456 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
395 | 457 | ||
396 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 458 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
397 | 459 | ||
398 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 460 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
399 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 461 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
400 | 462 | ||
401 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 463 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
402 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 464 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
403 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 465 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
404 | 466 | ||
405 | /* --- for SHARP_BUZZER device --- */ | 467 | /* --- for SHARP_BUZZER device --- */ |
406 | 468 | ||
407 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 469 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
408 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 470 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
409 | 471 | ||
410 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 472 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
411 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 473 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
412 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 474 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
413 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 475 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
414 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 476 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
415 | 477 | ||
416 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 478 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
417 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 479 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
418 | 480 | ||
419 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 481 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
420 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 482 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
421 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 483 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
422 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 484 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
423 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 485 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
424 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 486 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
425 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 487 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
426 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 488 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
427 | 489 | ||
428 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 490 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
429 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 491 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
430 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 492 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
431 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 493 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
432 | // | 494 | // |
433 | 495 | ||
434 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 496 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
435 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 497 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
436 | 498 | ||
437 | typedef struct sharp_led_status { | 499 | typedef struct sharp_led_status { |
438 | int which; /* select which LED status is wanted. */ | 500 | int which; /* select which LED status is wanted. */ |
439 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 501 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
440 | } sharp_led_status; | 502 | } sharp_led_status; |
441 | 503 | ||
442 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 504 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
443 | 505 | ||
444 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 506 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
445 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 507 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
446 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 508 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
447 | 509 | ||
448 | 510 | ||
449 | 511 | ||
450 | void ODeviceZaurus::buzzer ( int sound ) | 512 | void ODeviceZaurus::buzzer ( int sound ) |
451 | { | 513 | { |
452 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 514 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
453 | 515 | ||
454 | if ( fd >= 0 ) | 516 | if ( fd >= 0 ) |
455 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 517 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
456 | } | 518 | } |
457 | 519 | ||
458 | 520 | ||
459 | void ODeviceZaurus::alarmSound ( ) | 521 | void ODeviceZaurus::alarmSound ( ) |
460 | { | 522 | { |
461 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 523 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
462 | } | 524 | } |
463 | 525 | ||
464 | void ODeviceZaurus::touchSound ( ) | 526 | void ODeviceZaurus::touchSound ( ) |
465 | { | 527 | { |
466 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 528 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
467 | } | 529 | } |
468 | 530 | ||
469 | void ODeviceZaurus::keySound ( ) | 531 | void ODeviceZaurus::keySound ( ) |
470 | { | 532 | { |
471 | buzzer ( SHARP_BUZ_KEYSOUND ); | 533 | buzzer ( SHARP_BUZ_KEYSOUND ); |
472 | } | 534 | } |
473 | 535 | ||
474 | 536 | ||
475 | uint ODeviceZaurus::hasLeds ( ) const | 537 | uint ODeviceZaurus::hasLeds ( ) const |
476 | { | 538 | { |
477 | return 1; | 539 | return 1; |
478 | } | 540 | } |
479 | 541 | ||
480 | OLedState ODeviceZaurus::led ( uint which ) const | 542 | OLedState ODeviceZaurus::led ( uint which ) const |
481 | { | 543 | { |
482 | if ( which == 0 ) | 544 | if ( which == 0 ) |
483 | return d-> m_leds [0]; | 545 | return d-> m_leds [0]; |
484 | else | 546 | else |
485 | return OLED_Off; | 547 | return OLED_Off; |
486 | } | 548 | } |
487 | 549 | ||
488 | bool ODeviceZaurus::setLed ( uint which, OLedState st ) | 550 | bool ODeviceZaurus::setLed ( uint which, OLedState st ) |
489 | { | 551 | { |
490 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 552 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
491 | 553 | ||
492 | if ( which == 0 ) { | 554 | if ( which == 0 ) { |
493 | if ( fd >= 0 ) { | 555 | if ( fd >= 0 ) { |
494 | struct sharp_led_status leds; | 556 | struct sharp_led_status leds; |
495 | ::memset ( &leds, 0, sizeof( leds )); | 557 | ::memset ( &leds, 0, sizeof( leds )); |
496 | leds. which = SHARP_LED_MAIL_EXISTS; | 558 | leds. which = SHARP_LED_MAIL_EXISTS; |
497 | 559 | ||
498 | switch ( st ) { | 560 | switch ( st ) { |
499 | case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 561 | case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
500 | case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 562 | case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
501 | case OLED_BlinkSlow: | 563 | case OLED_BlinkSlow: |
502 | case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 564 | case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
503 | } | 565 | } |
504 | 566 | ||
505 | if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { | 567 | if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { |
506 | d-> m_leds [0] = st; | 568 | d-> m_leds [0] = st; |
507 | return true; | 569 | return true; |
508 | } | 570 | } |
509 | } | 571 | } |
510 | } | 572 | } |
511 | return false; | 573 | return false; |
512 | } | 574 | } |
513 | 575 | ||
514 | //#endif | 576 | //#endif |