summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-01 01:48:02 (UTC)
committer llornkcor <llornkcor>2002-07-01 01:48:02 (UTC)
commitd538fa9811906117a3ea68e3d434a1de7f46fc67 (patch) (unidiff)
treee04353bad0cc4edd64d950c4c60d3bfdf45dbed6
parent9c51797971bf5ec9dc6c4d7704b44672aa00741c (diff)
downloadopie-d538fa9811906117a3ea68e3d434a1de7f46fc67.zip
opie-d538fa9811906117a3ea68e3d434a1de7f46fc67.tar.gz
opie-d538fa9811906117a3ea68e3d434a1de7f46fc67.tar.bz2
take out debugs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index dea24a8..9931684 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,368 +1,368 @@
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 <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <qpe/sound.h> 22#include <qpe/sound.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25 25
26#include "odevice.h" 26#include "odevice.h"
27 27
28 28
29class ODeviceData { 29class ODeviceData {
30public: 30public:
31 QString m_vendorstr; 31 QString m_vendorstr;
32 OVendor m_vendor; 32 OVendor m_vendor;
33 33
34 QString m_modelstr; 34 QString m_modelstr;
35 OModel m_model; 35 OModel m_model;
36 36
37 QString m_systemstr; 37 QString m_systemstr;
38 OSystem m_system; 38 OSystem m_system;
39 39
40 OLedState m_leds [4]; // just for convenience ... 40 OLedState m_leds [4]; // just for convenience ...
41}; 41};
42 42
43class ODeviceIPAQ : public ODevice { 43class ODeviceIPAQ : public ODevice {
44protected: 44protected:
45 virtual void init ( ); 45 virtual void init ( );
46 46
47public: 47public:
48 virtual void alarmSound ( ); 48 virtual void alarmSound ( );
49 49
50 virtual uint hasLeds ( ) const; 50 virtual uint hasLeds ( ) const;
51 virtual OLedState led ( uint which ) const; 51 virtual OLedState led ( uint which ) const;
52 virtual bool setLed ( uint which, OLedState st ); 52 virtual bool setLed ( uint which, OLedState st );
53}; 53};
54 54
55class ODeviceZaurus : public ODevice { 55class ODeviceZaurus : public ODevice {
56protected: 56protected:
57 virtual void init ( ); 57 virtual void init ( );
58 58
59 public: 59 public:
60 virtual void alarmSound ( ); 60 virtual void alarmSound ( );
61 virtual void keySound ( ); 61 virtual void keySound ( );
62 virtual void touchSound ( ); 62 virtual void touchSound ( );
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
68protected: 68protected:
69 virtual void buzzer ( int snd ); 69 virtual void buzzer ( int snd );
70}; 70};
71 71
72 72
73 73
74 74
75ODevice *ODevice::inst ( ) 75ODevice *ODevice::inst ( )
76{ 76{
77 static ODevice *dev = 0; 77 static ODevice *dev = 0;
78 78
79 if ( !dev ) { 79 if ( !dev ) {
80 if ( QFile::exists ( "/proc/hal/model" )) 80 if ( QFile::exists ( "/proc/hal/model" ))
81 dev = new ODeviceIPAQ ( ); 81 dev = new ODeviceIPAQ ( );
82 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 82 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
83 dev = new ODeviceZaurus ( ); 83 dev = new ODeviceZaurus ( );
84 else 84 else
85 dev = new ODevice ( ); 85 dev = new ODevice ( );
86 86
87 dev-> init ( ); 87 dev-> init ( );
88 } 88 }
89 return dev; 89 return dev;
90} 90}
91 91
92ODevice::ODevice ( ) 92ODevice::ODevice ( )
93{ 93{
94 d = new ODeviceData; 94 d = new ODeviceData;
95 95
96 d-> m_modelstr = "Unknown"; 96 d-> m_modelstr = "Unknown";
97 d-> m_model = OMODEL_Unknown; 97 d-> m_model = OMODEL_Unknown;
98 d-> m_vendorstr = "Unkown"; 98 d-> m_vendorstr = "Unkown";
99 d-> m_vendor = OVENDOR_Unknown; 99 d-> m_vendor = OVENDOR_Unknown;
100 d-> m_systemstr = "Unkown"; 100 d-> m_systemstr = "Unkown";
101 d-> m_system = OSYSTEM_Unknown; 101 d-> m_system = OSYSTEM_Unknown;
102} 102}
103 103
104void ODevice::init ( ) 104void ODevice::init ( )
105{ 105{
106} 106}
107 107
108ODevice::~ODevice ( ) 108ODevice::~ODevice ( )
109{ 109{
110 delete d; 110 delete d;
111} 111}
112 112
113QString ODevice::vendorString ( ) 113QString ODevice::vendorString ( )
114{ 114{
115 return d-> m_vendorstr; 115 return d-> m_vendorstr;
116} 116}
117 117
118OVendor ODevice::vendor ( ) 118OVendor ODevice::vendor ( )
119{ 119{
120 return d-> m_vendor; 120 return d-> m_vendor;
121} 121}
122 122
123QString ODevice::modelString ( ) 123QString ODevice::modelString ( )
124{ 124{
125 return d-> m_modelstr; 125 return d-> m_modelstr;
126} 126}
127 127
128OModel ODevice::model ( ) 128OModel ODevice::model ( )
129{ 129{
130 return d-> m_model; 130 return d-> m_model;
131} 131}
132 132
133QString ODevice::systemString ( ) 133QString ODevice::systemString ( )
134{ 134{
135 return d-> m_systemstr; 135 return d-> m_systemstr;
136} 136}
137 137
138OSystem ODevice::system ( ) 138OSystem ODevice::system ( )
139{ 139{
140 return d-> m_system; 140 return d-> m_system;
141} 141}
142 142
143void ODevice::alarmSound ( ) 143void ODevice::alarmSound ( )
144{ 144{
145#ifndef QT_QWS_EBX 145#ifndef QT_QWS_EBX
146#ifndef QT_NO_SOUND 146#ifndef QT_NO_SOUND
147 static Sound snd ( "alarm" ); 147 static Sound snd ( "alarm" );
148 148
149 if ( snd. isFinished ( )) 149 if ( snd. isFinished ( ))
150 snd. play ( ); 150 snd. play ( );
151#endif 151#endif
152#endif 152#endif
153} 153}
154 154
155void ODevice::keySound ( ) 155void ODevice::keySound ( )
156{ 156{
157#ifndef QT_QWS_EBX 157#ifndef QT_QWS_EBX
158#ifndef QT_NO_SOUND 158#ifndef QT_NO_SOUND
159 static Sound snd ( "keysound" ); 159 static Sound snd ( "keysound" );
160 160
161 if ( snd. isFinished ( )) 161 if ( snd. isFinished ( ))
162 snd. play ( ); 162 snd. play ( );
163#endif 163#endif
164#endif 164#endif
165} 165}
166 166
167void ODevice::touchSound ( ) 167void ODevice::touchSound ( )
168{ 168{
169 169
170#ifndef QT_QWS_EBX 170#ifndef QT_QWS_EBX
171#ifndef QT_NO_SOUND 171#ifndef QT_NO_SOUND
172 static Sound snd ( "touchsound" ); 172 static Sound snd ( "touchsound" );
173qDebug("touchSound"); 173//qDebug("touchSound");
174 if ( snd. isFinished ( )) { 174 if ( snd. isFinished ( )) {
175 snd. play ( ); 175 snd. play ( );
176 qDebug("sound should play"); 176 // qDebug("sound should play");
177 } 177 }
178#endif 178#endif
179#endif 179#endif
180} 180}
181 181
182uint ODevice::hasLeds ( ) const 182uint ODevice::hasLeds ( ) const
183{ 183{
184 return 0; 184 return 0;
185} 185}
186 186
187OLedState ODevice::led ( uint /*which*/ ) const 187OLedState ODevice::led ( uint /*which*/ ) const
188{ 188{
189 return OLED_Off; 189 return OLED_Off;
190} 190}
191 191
192bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) 192bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ )
193{ 193{
194 return false; 194 return false;
195} 195}
196 196
197 197
198 198
199 199
200//#if defined( QT_QWS_IPAQ ) // IPAQ 200//#if defined( QT_QWS_IPAQ ) // IPAQ
201 201
202 202
203void ODeviceIPAQ::init ( ) 203void ODeviceIPAQ::init ( )
204{ 204{
205 d-> m_vendorstr = "HP"; 205 d-> m_vendorstr = "HP";
206 d-> m_vendor = OVENDOR_HP; 206 d-> m_vendor = OVENDOR_HP;
207 207
208 QFile f ( "/proc/hal/model" ); 208 QFile f ( "/proc/hal/model" );
209 209
210 if ( f. open ( IO_ReadOnly )) { 210 if ( f. open ( IO_ReadOnly )) {
211 QTextStream ts ( &f ); 211 QTextStream ts ( &f );
212 212
213 d-> m_modelstr = "H" + ts. readLine ( ); 213 d-> m_modelstr = "H" + ts. readLine ( );
214 214
215 if ( d-> m_modelstr == "H3100" ) 215 if ( d-> m_modelstr == "H3100" )
216 d-> m_model = OMODEL_iPAQ_H31xx; 216 d-> m_model = OMODEL_iPAQ_H31xx;
217 else if ( d-> m_modelstr == "H3600" ) 217 else if ( d-> m_modelstr == "H3600" )
218 d-> m_model = OMODEL_iPAQ_H36xx; 218 d-> m_model = OMODEL_iPAQ_H36xx;
219 else if ( d-> m_modelstr == "H3700" ) 219 else if ( d-> m_modelstr == "H3700" )
220 d-> m_model = OMODEL_iPAQ_H37xx; 220 d-> m_model = OMODEL_iPAQ_H37xx;
221 else if ( d-> m_modelstr == "H3800" ) 221 else if ( d-> m_modelstr == "H3800" )
222 d-> m_model = OMODEL_iPAQ_H38xx; 222 d-> m_model = OMODEL_iPAQ_H38xx;
223 else 223 else
224 d-> m_model = OMODEL_Unknown; 224 d-> m_model = OMODEL_Unknown;
225 225
226 f. close ( ); 226 f. close ( );
227 } 227 }
228 228
229 if ( QFile::exists ( "/etc/familiar-version" )) { 229 if ( QFile::exists ( "/etc/familiar-version" )) {
230 d-> m_systemstr = "Familiar"; 230 d-> m_systemstr = "Familiar";
231 d-> m_system = OSYSTEM_Familiar; 231 d-> m_system = OSYSTEM_Familiar;
232 } 232 }
233 233
234 d-> m_leds [0] = OLED_Off; 234 d-> m_leds [0] = OLED_Off;
235} 235}
236 236
237#include <unistd.h> 237#include <unistd.h>
238#include <fcntl.h> 238#include <fcntl.h>
239#include <sys/ioctl.h> 239#include <sys/ioctl.h>
240#include <linux/soundcard.h> 240#include <linux/soundcard.h>
241#include <qapplication.h> 241#include <qapplication.h>
242#include <qpe/config.h> 242#include <qpe/config.h>
243 243
244//#include <linux/h3600_ts.h> // including kernel headers is evil ... 244//#include <linux/h3600_ts.h> // including kernel headers is evil ...
245 245
246typedef struct h3600_ts_led { 246typedef struct h3600_ts_led {
247 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 247 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
248 unsigned char TotalTime; /* Units of 5 seconds */ 248 unsigned char TotalTime; /* Units of 5 seconds */
249 unsigned char OnTime; /* units of 100m/s */ 249 unsigned char OnTime; /* units of 100m/s */
250 unsigned char OffTime; /* units of 100m/s */ 250 unsigned char OffTime; /* units of 100m/s */
251} LED_IN; 251} LED_IN;
252 252
253 253
254// #define IOC_H3600_TS_MAGIC 'f' 254// #define IOC_H3600_TS_MAGIC 'f'
255// #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) 255// #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led)
256#define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( 256#define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :(
257 257
258 258
259void ODeviceIPAQ::alarmSound ( ) 259void ODeviceIPAQ::alarmSound ( )
260{ 260{
261#if defined( QT_QWS_IPAQ ) // IPAQ 261#if defined( QT_QWS_IPAQ ) // IPAQ
262#ifndef QT_NO_SOUND 262#ifndef QT_NO_SOUND
263 static Sound snd ( "alarm" ); 263 static Sound snd ( "alarm" );
264 int fd; 264 int fd;
265 int vol; 265 int vol;
266 bool vol_reset = false; 266 bool vol_reset = false;
267 267
268 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || 268 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) ||
269 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { 269 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) {
270 270
271 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 271 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
272 Config cfg ( "qpe" ); 272 Config cfg ( "qpe" );
273 cfg. setGroup ( "Volume" ); 273 cfg. setGroup ( "Volume" );
274 274
275 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 275 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
276 if ( volalarm < 0 ) 276 if ( volalarm < 0 )
277 volalarm = 0; 277 volalarm = 0;
278 else if ( volalarm > 100 ) 278 else if ( volalarm > 100 )
279 volalarm = 100; 279 volalarm = 100;
280 volalarm |= ( volalarm << 8 ); 280 volalarm |= ( volalarm << 8 );
281 281
282 if (( volalarm & 0xff ) > ( vol & 0xff )) { 282 if (( volalarm & 0xff ) > ( vol & 0xff )) {
283 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 283 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
284 vol_reset = true; 284 vol_reset = true;
285 } 285 }
286 } 286 }
287 } 287 }
288 288
289 snd. play ( ); 289 snd. play ( );
290 while ( !snd. isFinished ( )) 290 while ( !snd. isFinished ( ))
291 qApp-> processEvents ( ); 291 qApp-> processEvents ( );
292 292
293 if ( fd >= 0 ) { 293 if ( fd >= 0 ) {
294 if ( vol_reset ) 294 if ( vol_reset )
295 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 295 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
296 ::close ( fd ); 296 ::close ( fd );
297 } 297 }
298#endif 298#endif
299#endif 299#endif
300} 300}
301 301
302uint ODeviceIPAQ::hasLeds ( ) const 302uint ODeviceIPAQ::hasLeds ( ) const
303{ 303{
304 return 1; 304 return 1;
305} 305}
306 306
307OLedState ODeviceIPAQ::led ( uint which ) const 307OLedState ODeviceIPAQ::led ( uint which ) const
308{ 308{
309 if ( which == 0 ) 309 if ( which == 0 )
310 return d-> m_leds [0]; 310 return d-> m_leds [0];
311 else 311 else
312 return OLED_Off; 312 return OLED_Off;
313} 313}
314 314
315bool ODeviceIPAQ::setLed ( uint which, OLedState st ) 315bool ODeviceIPAQ::setLed ( uint which, OLedState st )
316{ 316{
317 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); 317 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK );
318 318
319 if ( which == 0 ) { 319 if ( which == 0 ) {
320 if ( fd >= 0 ) { 320 if ( fd >= 0 ) {
321 struct h3600_ts_led leds; 321 struct h3600_ts_led leds;
322 ::memset ( &leds, 0, sizeof( leds )); 322 ::memset ( &leds, 0, sizeof( leds ));
323 leds. TotalTime = 0; 323 leds. TotalTime = 0;
324 leds. OnTime = 0; 324 leds. OnTime = 0;
325 leds. OffTime = 1; 325 leds. OffTime = 1;
326 leds. OffOnBlink = 2; 326 leds. OffOnBlink = 2;
327 327
328 switch ( st ) { 328 switch ( st ) {
329 case OLED_Off : leds. OffOnBlink = 0; break; 329 case OLED_Off : leds. OffOnBlink = 0; break;
330 case OLED_On : leds. OffOnBlink = 1; break; 330 case OLED_On : leds. OffOnBlink = 1; break;
331 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 331 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
332 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 332 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
333 } 333 }
334 334
335 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 335 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
336 d-> m_leds [0] = st; 336 d-> m_leds [0] = st;
337 return true; 337 return true;
338 } 338 }
339 } 339 }
340 } 340 }
341 return false; 341 return false;
342} 342}
343 343
344 344
345//#endif 345//#endif
346 346
347 347
348 348
349 349
350 350
351//#if defined( QT_QWS_EBX ) // Zaurus 351//#if defined( QT_QWS_EBX ) // Zaurus
352 352
353void ODeviceZaurus::init ( ) 353void ODeviceZaurus::init ( )
354{ 354{
355 d-> m_modelstr = "Zaurus SL5000"; 355 d-> m_modelstr = "Zaurus SL5000";
356 d-> m_model = OMODEL_Zaurus_SL5000; 356 d-> m_model = OMODEL_Zaurus_SL5000;
357 d-> m_vendorstr = "Sharp"; 357 d-> m_vendorstr = "Sharp";
358 d-> m_vendor = OVENDOR_Sharp; 358 d-> m_vendor = OVENDOR_Sharp;
359 359
360 QFile f ( "/proc/filesystems" ); 360 QFile f ( "/proc/filesystems" );
361 361
362 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 362 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
363 d-> m_systemstr = "OpenZaurus"; 363 d-> m_systemstr = "OpenZaurus";
364 d-> m_system = OSYSTEM_OpenZaurus; 364 d-> m_system = OSYSTEM_OpenZaurus;
365 365
366 f. close ( ); 366 f. close ( );
367 } 367 }
368 else { 368 else {