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