author | sandman <sandman> | 2002-09-06 21:40:14 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-06 21:40:14 (UTC) |
commit | c22872aadda2ba93ddc53e5d5607ad795f147883 (patch) (unidiff) | |
tree | 247c442995fec2e5e2ed9b5826f46a427333a410 /libopie | |
parent | e95e14f056ce6be658a4fd0d4737168431e92d88 (diff) | |
download | opie-c22872aadda2ba93ddc53e5d5607ad795f147883.zip opie-c22872aadda2ba93ddc53e5d5607ad795f147883.tar.gz opie-c22872aadda2ba93ddc53e5d5607ad795f147883.tar.bz2 |
Fix for the new OD_IO macros
-rw-r--r-- | libopie/odevice.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 6e3f114..9871e80 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,457 +1,459 @@ | |||
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 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | #include "odevice.h" | 37 | #include "odevice.h" |
38 | 38 | ||
39 | // _IO and friends are only defined in kernel headers ... | 39 | // _IO and friends are only defined in kernel headers ... |
40 | 40 | ||
41 | #define OD_IO(type,area,number,args) (( type << 30 ) | ( area << 8 ) | ( number ) | ( sizeof( args ) << 16 )) | 41 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
42 | #define OD_IOW(area,number,args) OD_IO(1,area,number,args) | 42 | |
43 | #define OD_IOR(area,number,args) OD_IO(2,area,number,args) | 43 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
44 | #define OD_IORW(area,number,args) OD_IO(3,area,number,args) | 44 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
45 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
46 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
45 | 47 | ||
46 | 48 | ||
47 | class ODeviceData { | 49 | class ODeviceData { |
48 | public: | 50 | public: |
49 | QString m_vendorstr; | 51 | QString m_vendorstr; |
50 | OVendor m_vendor; | 52 | OVendor m_vendor; |
51 | 53 | ||
52 | QString m_modelstr; | 54 | QString m_modelstr; |
53 | OModel m_model; | 55 | OModel m_model; |
54 | 56 | ||
55 | QString m_systemstr; | 57 | QString m_systemstr; |
56 | OSystem m_system; | 58 | OSystem m_system; |
57 | 59 | ||
58 | QString m_sysverstr; | 60 | QString m_sysverstr; |
59 | 61 | ||
60 | OLedState m_leds [4]; // just for convenience ... | 62 | OLedState m_leds [4]; // just for convenience ... |
61 | }; | 63 | }; |
62 | 64 | ||
63 | class ODeviceIPAQ : public ODevice { | 65 | class ODeviceIPAQ : public ODevice { |
64 | protected: | 66 | protected: |
65 | virtual void init ( ); | 67 | virtual void init ( ); |
66 | 68 | ||
67 | public: | 69 | public: |
68 | virtual bool setPowerButtonHandler ( PowerButtonHandler h ); | 70 | virtual bool setPowerButtonHandler ( PowerButtonHandler h ); |
69 | 71 | ||
70 | virtual bool setDisplayBrightness ( int b ); | 72 | virtual bool setDisplayBrightness ( int b ); |
71 | virtual int displayBrightnessResolution ( ) const; | 73 | virtual int displayBrightnessResolution ( ) const; |
72 | 74 | ||
73 | virtual void alarmSound ( ); | 75 | virtual void alarmSound ( ); |
74 | 76 | ||
75 | virtual uint hasLeds ( ) const; | 77 | virtual uint hasLeds ( ) const; |
76 | virtual OLedState led ( uint which ) const; | 78 | virtual OLedState led ( uint which ) const; |
77 | virtual bool setLed ( uint which, OLedState st ); | 79 | virtual bool setLed ( uint which, OLedState st ); |
78 | }; | 80 | }; |
79 | 81 | ||
80 | class ODeviceZaurus : public ODevice { | 82 | class ODeviceZaurus : public ODevice { |
81 | protected: | 83 | protected: |
82 | virtual void init ( ); | 84 | virtual void init ( ); |
83 | 85 | ||
84 | public: | 86 | public: |
85 | virtual bool setPowerButtonHandler ( PowerButtonHandler h ); | 87 | virtual bool setPowerButtonHandler ( PowerButtonHandler h ); |
86 | 88 | ||
87 | virtual bool setDisplayBrightness ( int b ); | 89 | virtual bool setDisplayBrightness ( int b ); |
88 | virtual int displayBrightnessResolution ( ) const; | 90 | virtual int displayBrightnessResolution ( ) const; |
89 | 91 | ||
90 | virtual void alarmSound ( ); | 92 | virtual void alarmSound ( ); |
91 | virtual void keySound ( ); | 93 | virtual void keySound ( ); |
92 | virtual void touchSound ( ); | 94 | virtual void touchSound ( ); |
93 | 95 | ||
94 | virtual uint hasLeds ( ) const; | 96 | virtual uint hasLeds ( ) const; |
95 | virtual OLedState led ( uint which ) const; | 97 | virtual OLedState led ( uint which ) const; |
96 | virtual bool setLed ( uint which, OLedState st ); | 98 | virtual bool setLed ( uint which, OLedState st ); |
97 | 99 | ||
98 | protected: | 100 | protected: |
99 | virtual void buzzer ( int snd ); | 101 | virtual void buzzer ( int snd ); |
100 | }; | 102 | }; |
101 | 103 | ||
102 | 104 | ||
103 | 105 | ||
104 | 106 | ||
105 | ODevice *ODevice::inst ( ) | 107 | ODevice *ODevice::inst ( ) |
106 | { | 108 | { |
107 | static ODevice *dev = 0; | 109 | static ODevice *dev = 0; |
108 | 110 | ||
109 | if ( !dev ) { | 111 | if ( !dev ) { |
110 | if ( QFile::exists ( "/proc/hal/model" )) | 112 | if ( QFile::exists ( "/proc/hal/model" )) |
111 | dev = new ODeviceIPAQ ( ); | 113 | dev = new ODeviceIPAQ ( ); |
112 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 114 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
113 | dev = new ODeviceZaurus ( ); | 115 | dev = new ODeviceZaurus ( ); |
114 | else | 116 | else |
115 | dev = new ODevice ( ); | 117 | dev = new ODevice ( ); |
116 | 118 | ||
117 | dev-> init ( ); | 119 | dev-> init ( ); |
118 | } | 120 | } |
119 | return dev; | 121 | return dev; |
120 | } | 122 | } |
121 | 123 | ||
122 | 124 | ||
123 | /************************************************** | 125 | /************************************************** |
124 | * | 126 | * |
125 | * common | 127 | * common |
126 | * | 128 | * |
127 | **************************************************/ | 129 | **************************************************/ |
128 | 130 | ||
129 | 131 | ||
130 | ODevice::ODevice ( ) | 132 | ODevice::ODevice ( ) |
131 | { | 133 | { |
132 | d = new ODeviceData; | 134 | d = new ODeviceData; |
133 | 135 | ||
134 | d-> m_modelstr = "Unknown"; | 136 | d-> m_modelstr = "Unknown"; |
135 | d-> m_model = OMODEL_Unknown; | 137 | d-> m_model = OMODEL_Unknown; |
136 | d-> m_vendorstr = "Unkown"; | 138 | d-> m_vendorstr = "Unkown"; |
137 | d-> m_vendor = OVENDOR_Unknown; | 139 | d-> m_vendor = OVENDOR_Unknown; |
138 | d-> m_systemstr = "Unkown"; | 140 | d-> m_systemstr = "Unkown"; |
139 | d-> m_system = OSYSTEM_Unknown; | 141 | d-> m_system = OSYSTEM_Unknown; |
140 | d-> m_sysverstr = "0.0"; | 142 | d-> m_sysverstr = "0.0"; |
141 | } | 143 | } |
142 | 144 | ||
143 | void ODevice::init ( ) | 145 | void ODevice::init ( ) |
144 | { | 146 | { |
145 | } | 147 | } |
146 | 148 | ||
147 | ODevice::~ODevice ( ) | 149 | ODevice::~ODevice ( ) |
148 | { | 150 | { |
149 | delete d; | 151 | delete d; |
150 | } | 152 | } |
151 | 153 | ||
152 | bool ODevice::setPowerButtonHandler ( ODevice::PowerButtonHandler ) | 154 | bool ODevice::setPowerButtonHandler ( ODevice::PowerButtonHandler ) |
153 | { | 155 | { |
154 | return false; | 156 | return false; |
155 | } | 157 | } |
156 | 158 | ||
157 | //#include <linux/apm_bios.h> | 159 | //#include <linux/apm_bios.h> |
158 | 160 | ||
159 | #define APM_IOC_SUSPEND OD_IO( 0, 'A', 2, 0 ) | 161 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
160 | 162 | ||
161 | 163 | ||
162 | bool ODevice::suspend ( ) | 164 | bool ODevice::suspend ( ) |
163 | { | 165 | { |
164 | if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices | 166 | if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices |
165 | return false; | 167 | return false; |
166 | 168 | ||
167 | int fd; | 169 | int fd; |
168 | bool res = false; | 170 | bool res = false; |
169 | 171 | ||
170 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 172 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
171 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 173 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
172 | struct timeval tvs, tvn; | 174 | struct timeval tvs, tvn; |
173 | 175 | ||
174 | ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped | 176 | ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped |
175 | ::gettimeofday ( &tvs, 0 ); | 177 | ::gettimeofday ( &tvs, 0 ); |
176 | 178 | ||
177 | ::sync ( ); // flush fs caches | 179 | ::sync ( ); // flush fs caches |
178 | 180 | ||
179 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending | 181 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending |
180 | 182 | ||
181 | if ( res ) { | 183 | if ( res ) { |
182 | ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group | 184 | ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group |
183 | 185 | ||
184 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 186 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
185 | ::usleep ( 200 * 1000 ); | 187 | ::usleep ( 200 * 1000 ); |
186 | ::gettimeofday ( &tvn, 0 ); | 188 | ::gettimeofday ( &tvn, 0 ); |
187 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 189 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
188 | 190 | ||
189 | ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group | 191 | ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group |
190 | } | 192 | } |
191 | 193 | ||
192 | ::close ( fd ); | 194 | ::close ( fd ); |
193 | ::signal ( SIGTSTP, SIG_DFL ); | 195 | ::signal ( SIGTSTP, SIG_DFL ); |
194 | } | 196 | } |
195 | 197 | ||
196 | return res; | 198 | return res; |
197 | } | 199 | } |
198 | 200 | ||
199 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 201 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
200 | 202 | ||
201 | #define FBIOBLANK OD_IO( 0, 'F', 0x11, 0 ) // 0x4611 | 203 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
202 | 204 | ||
203 | /* VESA Blanking Levels */ | 205 | /* VESA Blanking Levels */ |
204 | #define VESA_NO_BLANKING 0 | 206 | #define VESA_NO_BLANKING 0 |
205 | #define VESA_VSYNC_SUSPEND 1 | 207 | #define VESA_VSYNC_SUSPEND 1 |
206 | #define VESA_HSYNC_SUSPEND 2 | 208 | #define VESA_HSYNC_SUSPEND 2 |
207 | #define VESA_POWERDOWN 3 | 209 | #define VESA_POWERDOWN 3 |
208 | 210 | ||
209 | 211 | ||
210 | bool ODevice::setDisplayStatus ( bool on ) | 212 | bool ODevice::setDisplayStatus ( bool on ) |
211 | { | 213 | { |
212 | if ( d-> m_model == OMODEL_Unknown ) | 214 | if ( d-> m_model == OMODEL_Unknown ) |
213 | return false; | 215 | return false; |
214 | 216 | ||
215 | bool res = false; | 217 | bool res = false; |
216 | int fd; | 218 | int fd; |
217 | 219 | ||
218 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 220 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
219 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 221 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
220 | ::close ( fd ); | 222 | ::close ( fd ); |
221 | } | 223 | } |
222 | return res; | 224 | return res; |
223 | } | 225 | } |
224 | 226 | ||
225 | bool ODevice::setDisplayBrightness ( int ) | 227 | bool ODevice::setDisplayBrightness ( int ) |
226 | { | 228 | { |
227 | return false; | 229 | return false; |
228 | } | 230 | } |
229 | 231 | ||
230 | int ODevice::displayBrightnessResolution ( ) const | 232 | int ODevice::displayBrightnessResolution ( ) const |
231 | { | 233 | { |
232 | return 16; | 234 | return 16; |
233 | } | 235 | } |
234 | 236 | ||
235 | QString ODevice::vendorString ( ) | 237 | QString ODevice::vendorString ( ) |
236 | { | 238 | { |
237 | return d-> m_vendorstr; | 239 | return d-> m_vendorstr; |
238 | } | 240 | } |
239 | 241 | ||
240 | OVendor ODevice::vendor ( ) | 242 | OVendor ODevice::vendor ( ) |
241 | { | 243 | { |
242 | return d-> m_vendor; | 244 | return d-> m_vendor; |
243 | } | 245 | } |
244 | 246 | ||
245 | QString ODevice::modelString ( ) | 247 | QString ODevice::modelString ( ) |
246 | { | 248 | { |
247 | return d-> m_modelstr; | 249 | return d-> m_modelstr; |
248 | } | 250 | } |
249 | 251 | ||
250 | OModel ODevice::model ( ) | 252 | OModel ODevice::model ( ) |
251 | { | 253 | { |
252 | return d-> m_model; | 254 | return d-> m_model; |
253 | } | 255 | } |
254 | 256 | ||
255 | QString ODevice::systemString ( ) | 257 | QString ODevice::systemString ( ) |
256 | { | 258 | { |
257 | return d-> m_systemstr; | 259 | return d-> m_systemstr; |
258 | } | 260 | } |
259 | 261 | ||
260 | OSystem ODevice::system ( ) | 262 | OSystem ODevice::system ( ) |
261 | { | 263 | { |
262 | return d-> m_system; | 264 | return d-> m_system; |
263 | } | 265 | } |
264 | 266 | ||
265 | QString ODevice::systemVersionString ( ) | 267 | QString ODevice::systemVersionString ( ) |
266 | { | 268 | { |
267 | return d-> m_sysverstr; | 269 | return d-> m_sysverstr; |
268 | } | 270 | } |
269 | 271 | ||
270 | void ODevice::alarmSound ( ) | 272 | void ODevice::alarmSound ( ) |
271 | { | 273 | { |
272 | #ifndef QT_QWS_EBX | 274 | #ifndef QT_QWS_EBX |
273 | #ifndef QT_NO_SOUND | 275 | #ifndef QT_NO_SOUND |
274 | static Sound snd ( "alarm" ); | 276 | static Sound snd ( "alarm" ); |
275 | 277 | ||
276 | if ( snd. isFinished ( )) | 278 | if ( snd. isFinished ( )) |
277 | snd. play ( ); | 279 | snd. play ( ); |
278 | #endif | 280 | #endif |
279 | #endif | 281 | #endif |
280 | } | 282 | } |
281 | 283 | ||
282 | void ODevice::keySound ( ) | 284 | void ODevice::keySound ( ) |
283 | { | 285 | { |
284 | #ifndef QT_QWS_EBX | 286 | #ifndef QT_QWS_EBX |
285 | #ifndef QT_NO_SOUND | 287 | #ifndef QT_NO_SOUND |
286 | static Sound snd ( "keysound" ); | 288 | static Sound snd ( "keysound" ); |
287 | 289 | ||
288 | if ( snd. isFinished ( )) | 290 | if ( snd. isFinished ( )) |
289 | snd. play ( ); | 291 | snd. play ( ); |
290 | #endif | 292 | #endif |
291 | #endif | 293 | #endif |
292 | } | 294 | } |
293 | 295 | ||
294 | void ODevice::touchSound ( ) | 296 | void ODevice::touchSound ( ) |
295 | { | 297 | { |
296 | 298 | ||
297 | #ifndef QT_QWS_EBX | 299 | #ifndef QT_QWS_EBX |
298 | #ifndef QT_NO_SOUND | 300 | #ifndef QT_NO_SOUND |
299 | static Sound snd ( "touchsound" ); | 301 | static Sound snd ( "touchsound" ); |
300 | 302 | ||
301 | if ( snd. isFinished ( )) | 303 | if ( snd. isFinished ( )) |
302 | snd. play ( ); | 304 | snd. play ( ); |
303 | #endif | 305 | #endif |
304 | #endif | 306 | #endif |
305 | } | 307 | } |
306 | 308 | ||
307 | uint ODevice::hasLeds ( ) const | 309 | uint ODevice::hasLeds ( ) const |
308 | { | 310 | { |
309 | return 0; | 311 | return 0; |
310 | } | 312 | } |
311 | 313 | ||
312 | OLedState ODevice::led ( uint /*which*/ ) const | 314 | OLedState ODevice::led ( uint /*which*/ ) const |
313 | { | 315 | { |
314 | return OLED_Off; | 316 | return OLED_Off; |
315 | } | 317 | } |
316 | 318 | ||
317 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) | 319 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) |
318 | { | 320 | { |
319 | return false; | 321 | return false; |
320 | } | 322 | } |
321 | 323 | ||
322 | 324 | ||
323 | 325 | ||
324 | 326 | ||
325 | /************************************************** | 327 | /************************************************** |
326 | * | 328 | * |
327 | * iPAQ | 329 | * iPAQ |
328 | * | 330 | * |
329 | **************************************************/ | 331 | **************************************************/ |
330 | 332 | ||
331 | void ODeviceIPAQ::init ( ) | 333 | void ODeviceIPAQ::init ( ) |
332 | { | 334 | { |
333 | d-> m_vendorstr = "HP"; | 335 | d-> m_vendorstr = "HP"; |
334 | d-> m_vendor = OVENDOR_HP; | 336 | d-> m_vendor = OVENDOR_HP; |
335 | 337 | ||
336 | QFile f ( "/proc/hal/model" ); | 338 | QFile f ( "/proc/hal/model" ); |
337 | 339 | ||
338 | if ( f. open ( IO_ReadOnly )) { | 340 | if ( f. open ( IO_ReadOnly )) { |
339 | QTextStream ts ( &f ); | 341 | QTextStream ts ( &f ); |
340 | 342 | ||
341 | d-> m_modelstr = "H" + ts. readLine ( ); | 343 | d-> m_modelstr = "H" + ts. readLine ( ); |
342 | 344 | ||
343 | if ( d-> m_modelstr == "H3100" ) | 345 | if ( d-> m_modelstr == "H3100" ) |
344 | d-> m_model = OMODEL_iPAQ_H31xx; | 346 | d-> m_model = OMODEL_iPAQ_H31xx; |
345 | else if ( d-> m_modelstr == "H3600" ) | 347 | else if ( d-> m_modelstr == "H3600" ) |
346 | d-> m_model = OMODEL_iPAQ_H36xx; | 348 | d-> m_model = OMODEL_iPAQ_H36xx; |
347 | else if ( d-> m_modelstr == "H3700" ) | 349 | else if ( d-> m_modelstr == "H3700" ) |
348 | d-> m_model = OMODEL_iPAQ_H37xx; | 350 | d-> m_model = OMODEL_iPAQ_H37xx; |
349 | else if ( d-> m_modelstr == "H3800" ) | 351 | else if ( d-> m_modelstr == "H3800" ) |
350 | d-> m_model = OMODEL_iPAQ_H38xx; | 352 | d-> m_model = OMODEL_iPAQ_H38xx; |
351 | else | 353 | else |
352 | d-> m_model = OMODEL_Unknown; | 354 | d-> m_model = OMODEL_Unknown; |
353 | 355 | ||
354 | f. close ( ); | 356 | f. close ( ); |
355 | } | 357 | } |
356 | 358 | ||
357 | f. setName ( "/etc/familiar-version" ); | 359 | f. setName ( "/etc/familiar-version" ); |
358 | if ( f. open ( IO_ReadOnly )) { | 360 | if ( f. open ( IO_ReadOnly )) { |
359 | d-> m_systemstr = "Familiar"; | 361 | d-> m_systemstr = "Familiar"; |
360 | d-> m_system = OSYSTEM_Familiar; | 362 | d-> m_system = OSYSTEM_Familiar; |
361 | 363 | ||
362 | QTextStream ts ( &f ); | 364 | QTextStream ts ( &f ); |
363 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 365 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
364 | 366 | ||
365 | f. close ( ); | 367 | f. close ( ); |
366 | } | 368 | } |
367 | 369 | ||
368 | d-> m_leds [0] = OLED_Off; | 370 | d-> m_leds [0] = OLED_Off; |
369 | } | 371 | } |
370 | 372 | ||
371 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 373 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
372 | 374 | ||
373 | typedef struct { | 375 | typedef struct { |
374 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 376 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
375 | unsigned char TotalTime; /* Units of 5 seconds */ | 377 | unsigned char TotalTime; /* Units of 5 seconds */ |
376 | unsigned char OnTime; /* units of 100m/s */ | 378 | unsigned char OnTime; /* units of 100m/s */ |
377 | unsigned char OffTime; /* units of 100m/s */ | 379 | unsigned char OffTime; /* units of 100m/s */ |
378 | } LED_IN; | 380 | } LED_IN; |
379 | 381 | ||
380 | typedef struct { | 382 | typedef struct { |
381 | unsigned char mode; | 383 | unsigned char mode; |
382 | unsigned char pwr; | 384 | unsigned char pwr; |
383 | unsigned char brightness; | 385 | unsigned char brightness; |
384 | } FLITE_IN; | 386 | } FLITE_IN; |
385 | 387 | ||
386 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 388 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
387 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 389 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
388 | 390 | ||
389 | 391 | ||
390 | void ODeviceIPAQ::alarmSound ( ) | 392 | void ODeviceIPAQ::alarmSound ( ) |
391 | { | 393 | { |
392 | #if defined( QT_QWS_IPAQ ) // IPAQ | 394 | #if defined( QT_QWS_IPAQ ) // IPAQ |
393 | #ifndef QT_NO_SOUND | 395 | #ifndef QT_NO_SOUND |
394 | static Sound snd ( "alarm" ); | 396 | static Sound snd ( "alarm" ); |
395 | int fd; | 397 | int fd; |
396 | int vol; | 398 | int vol; |
397 | bool vol_reset = false; | 399 | bool vol_reset = false; |
398 | 400 | ||
399 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 401 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
400 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 402 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
401 | 403 | ||
402 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 404 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
403 | Config cfg ( "qpe" ); | 405 | Config cfg ( "qpe" ); |
404 | cfg. setGroup ( "Volume" ); | 406 | cfg. setGroup ( "Volume" ); |
405 | 407 | ||
406 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 408 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
407 | if ( volalarm < 0 ) | 409 | if ( volalarm < 0 ) |
408 | volalarm = 0; | 410 | volalarm = 0; |
409 | else if ( volalarm > 100 ) | 411 | else if ( volalarm > 100 ) |
410 | volalarm = 100; | 412 | volalarm = 100; |
411 | volalarm |= ( volalarm << 8 ); | 413 | volalarm |= ( volalarm << 8 ); |
412 | 414 | ||
413 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 415 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
414 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 416 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
415 | vol_reset = true; | 417 | vol_reset = true; |
416 | } | 418 | } |
417 | } | 419 | } |
418 | } | 420 | } |
419 | 421 | ||
420 | snd. play ( ); | 422 | snd. play ( ); |
421 | while ( !snd. isFinished ( )) | 423 | while ( !snd. isFinished ( )) |
422 | qApp-> processEvents ( ); | 424 | qApp-> processEvents ( ); |
423 | 425 | ||
424 | if ( fd >= 0 ) { | 426 | if ( fd >= 0 ) { |
425 | if ( vol_reset ) | 427 | if ( vol_reset ) |
426 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 428 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
427 | ::close ( fd ); | 429 | ::close ( fd ); |
428 | } | 430 | } |
429 | #endif | 431 | #endif |
430 | #endif | 432 | #endif |
431 | } | 433 | } |
432 | 434 | ||
433 | uint ODeviceIPAQ::hasLeds ( ) const | 435 | uint ODeviceIPAQ::hasLeds ( ) const |
434 | { | 436 | { |
435 | return 1; | 437 | return 1; |
436 | } | 438 | } |
437 | 439 | ||
438 | OLedState ODeviceIPAQ::led ( uint which ) const | 440 | OLedState ODeviceIPAQ::led ( uint which ) const |
439 | { | 441 | { |
440 | if ( which == 0 ) | 442 | if ( which == 0 ) |
441 | return d-> m_leds [0]; | 443 | return d-> m_leds [0]; |
442 | else | 444 | else |
443 | return OLED_Off; | 445 | return OLED_Off; |
444 | } | 446 | } |
445 | 447 | ||
446 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) | 448 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) |
447 | { | 449 | { |
448 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); | 450 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); |
449 | 451 | ||
450 | if ( which == 0 ) { | 452 | if ( which == 0 ) { |
451 | if ( fd >= 0 ) { | 453 | if ( fd >= 0 ) { |
452 | LED_IN leds; | 454 | LED_IN leds; |
453 | ::memset ( &leds, 0, sizeof( leds )); | 455 | ::memset ( &leds, 0, sizeof( leds )); |
454 | leds. TotalTime = 0; | 456 | leds. TotalTime = 0; |
455 | leds. OnTime = 0; | 457 | leds. OnTime = 0; |
456 | leds. OffTime = 1; | 458 | leds. OffTime = 1; |
457 | leds. OffOnBlink = 2; | 459 | leds. OffOnBlink = 2; |