summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorllornkcor <llornkcor>2002-07-01 01:43:24 (UTC)
committer llornkcor <llornkcor>2002-07-01 01:43:24 (UTC)
commit9c51797971bf5ec9dc6c4d7704b44672aa00741c (patch) (unidiff)
treed99933fc446110857580136159c632e4b7ce5e5a /libopie/odevice.cpp
parentc96791c0cb6fe7ddf87ea092ca498caea3ba3bd7 (diff)
downloadopie-9c51797971bf5ec9dc6c4d7704b44672aa00741c.zip
opie-9c51797971bf5ec9dc6c4d7704b44672aa00741c.tar.gz
opie-9c51797971bf5ec9dc6c4d7704b44672aa00741c.tar.bz2
had to add some ifndef QT_QWS_EBX around Sound things for some odd reason. added sharp_buz empty defines for future usage
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp107
1 files changed, 73 insertions, 34 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 61c24f4..dea24a8 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,461 +1,500 @@
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_NO_SOUND 146#ifndef QT_NO_SOUND
146 static Sound snd ( "alarm" ); 147 static Sound snd ( "alarm" );
147 148
148 if ( snd. isFinished ( )) 149 if ( snd. isFinished ( ))
149 snd. play ( ); 150 snd. play ( );
150#endif 151#endif
152#endif
151} 153}
152 154
153void ODevice::keySound ( ) 155void ODevice::keySound ( )
154{ 156{
157#ifndef QT_QWS_EBX
155#ifndef QT_NO_SOUND 158#ifndef QT_NO_SOUND
156 static Sound snd ( "keysound" ); 159 static Sound snd ( "keysound" );
157 160
158 if ( snd. isFinished ( )) 161 if ( snd. isFinished ( ))
159 snd. play ( ); 162 snd. play ( );
160#endif 163#endif
164#endif
161} 165}
162 166
163void ODevice::touchSound ( ) 167void ODevice::touchSound ( )
164{ 168{
169
170#ifndef QT_QWS_EBX
165#ifndef QT_NO_SOUND 171#ifndef QT_NO_SOUND
166 static Sound snd ( "touchsound" ); 172 static Sound snd ( "touchsound" );
167 173qDebug("touchSound");
168 if ( snd. isFinished ( )) 174 if ( snd. isFinished ( )) {
169 snd. play ( ); 175 snd. play ( );
176 qDebug("sound should play");
177 }
178#endif
170#endif 179#endif
171} 180}
172 181
173uint ODevice::hasLeds ( ) const 182uint ODevice::hasLeds ( ) const
174{ 183{
175 return 0; 184 return 0;
176} 185}
177 186
178OLedState ODevice::led ( uint /*which*/ ) const 187OLedState ODevice::led ( uint /*which*/ ) const
179{ 188{
180 return OLED_Off; 189 return OLED_Off;
181} 190}
182 191
183bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) 192bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ )
184{ 193{
185 return false; 194 return false;
186} 195}
187 196
188 197
189 198
190 199
191//#if defined( QT_QWS_IPAQ ) // IPAQ 200//#if defined( QT_QWS_IPAQ ) // IPAQ
192 201
193 202
194void ODeviceIPAQ::init ( ) 203void ODeviceIPAQ::init ( )
195{ 204{
196 d-> m_vendorstr = "HP"; 205 d-> m_vendorstr = "HP";
197 d-> m_vendor = OVENDOR_HP; 206 d-> m_vendor = OVENDOR_HP;
198 207
199 QFile f ( "/proc/hal/model" ); 208 QFile f ( "/proc/hal/model" );
200 209
201 if ( f. open ( IO_ReadOnly )) { 210 if ( f. open ( IO_ReadOnly )) {
202 QTextStream ts ( &f ); 211 QTextStream ts ( &f );
203 212
204 d-> m_modelstr = "H" + ts. readLine ( ); 213 d-> m_modelstr = "H" + ts. readLine ( );
205 214
206 if ( d-> m_modelstr == "H3100" ) 215 if ( d-> m_modelstr == "H3100" )
207 d-> m_model = OMODEL_iPAQ_H31xx; 216 d-> m_model = OMODEL_iPAQ_H31xx;
208 else if ( d-> m_modelstr == "H3600" ) 217 else if ( d-> m_modelstr == "H3600" )
209 d-> m_model = OMODEL_iPAQ_H36xx; 218 d-> m_model = OMODEL_iPAQ_H36xx;
210 else if ( d-> m_modelstr == "H3700" ) 219 else if ( d-> m_modelstr == "H3700" )
211 d-> m_model = OMODEL_iPAQ_H37xx; 220 d-> m_model = OMODEL_iPAQ_H37xx;
212 else if ( d-> m_modelstr == "H3800" ) 221 else if ( d-> m_modelstr == "H3800" )
213 d-> m_model = OMODEL_iPAQ_H38xx; 222 d-> m_model = OMODEL_iPAQ_H38xx;
214 else 223 else
215 d-> m_model = OMODEL_Unknown; 224 d-> m_model = OMODEL_Unknown;
216 225
217 f. close ( ); 226 f. close ( );
218 } 227 }
219 228
220 if ( QFile::exists ( "/etc/familiar-version" )) { 229 if ( QFile::exists ( "/etc/familiar-version" )) {
221 d-> m_systemstr = "Familiar"; 230 d-> m_systemstr = "Familiar";
222 d-> m_system = OSYSTEM_Familiar; 231 d-> m_system = OSYSTEM_Familiar;
223 } 232 }
224 233
225 d-> m_leds [0] = OLED_Off; 234 d-> m_leds [0] = OLED_Off;
226} 235}
227 236
228#include <unistd.h> 237#include <unistd.h>
229#include <fcntl.h> 238#include <fcntl.h>
230#include <sys/ioctl.h> 239#include <sys/ioctl.h>
231#include <linux/soundcard.h> 240#include <linux/soundcard.h>
232#include <qapplication.h> 241#include <qapplication.h>
233#include <qpe/config.h> 242#include <qpe/config.h>
234 243
235//#include <linux/h3600_ts.h> // including kernel headers is evil ... 244//#include <linux/h3600_ts.h> // including kernel headers is evil ...
236 245
237typedef struct h3600_ts_led { 246typedef struct h3600_ts_led {
238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 247 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
239 unsigned char TotalTime; /* Units of 5 seconds */ 248 unsigned char TotalTime; /* Units of 5 seconds */
240 unsigned char OnTime; /* units of 100m/s */ 249 unsigned char OnTime; /* units of 100m/s */
241 unsigned char OffTime; /* units of 100m/s */ 250 unsigned char OffTime; /* units of 100m/s */
242} LED_IN; 251} LED_IN;
243 252
244 253
245// #define IOC_H3600_TS_MAGIC 'f' 254// #define IOC_H3600_TS_MAGIC 'f'
246// #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)
247#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 :(
248 257
249 258
250void ODeviceIPAQ::alarmSound ( ) 259void ODeviceIPAQ::alarmSound ( )
251{ 260{
261#if defined( QT_QWS_IPAQ ) // IPAQ
252#ifndef QT_NO_SOUND 262#ifndef QT_NO_SOUND
253 static Sound snd ( "alarm" ); 263 static Sound snd ( "alarm" );
254 int fd; 264 int fd;
255 int vol; 265 int vol;
256 bool vol_reset = false; 266 bool vol_reset = false;
257 267
258 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || 268 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) ||
259 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { 269 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) {
260 270
261 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 271 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
262 Config cfg ( "qpe" ); 272 Config cfg ( "qpe" );
263 cfg. setGroup ( "Volume" ); 273 cfg. setGroup ( "Volume" );
264 274
265 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 275 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
266 if ( volalarm < 0 ) 276 if ( volalarm < 0 )
267 volalarm = 0; 277 volalarm = 0;
268 else if ( volalarm > 100 ) 278 else if ( volalarm > 100 )
269 volalarm = 100; 279 volalarm = 100;
270 volalarm |= ( volalarm << 8 ); 280 volalarm |= ( volalarm << 8 );
271 281
272 if (( volalarm & 0xff ) > ( vol & 0xff )) { 282 if (( volalarm & 0xff ) > ( vol & 0xff )) {
273 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 283 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
274 vol_reset = true; 284 vol_reset = true;
275 } 285 }
276 } 286 }
277 } 287 }
278 288
279 snd. play ( ); 289 snd. play ( );
280 while ( !snd. isFinished ( )) 290 while ( !snd. isFinished ( ))
281 qApp-> processEvents ( ); 291 qApp-> processEvents ( );
282 292
283 if ( fd >= 0 ) { 293 if ( fd >= 0 ) {
284 if ( vol_reset ) 294 if ( vol_reset )
285 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 295 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
286 ::close ( fd ); 296 ::close ( fd );
287 } 297 }
288#endif 298#endif
299#endif
289} 300}
290 301
291uint ODeviceIPAQ::hasLeds ( ) const 302uint ODeviceIPAQ::hasLeds ( ) const
292{ 303{
293 return 1; 304 return 1;
294} 305}
295 306
296OLedState ODeviceIPAQ::led ( uint which ) const 307OLedState ODeviceIPAQ::led ( uint which ) const
297{ 308{
298 if ( which == 0 ) 309 if ( which == 0 )
299 return d-> m_leds [0]; 310 return d-> m_leds [0];
300 else 311 else
301 return OLED_Off; 312 return OLED_Off;
302} 313}
303 314
304bool ODeviceIPAQ::setLed ( uint which, OLedState st ) 315bool ODeviceIPAQ::setLed ( uint which, OLedState st )
305{ 316{
306 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); 317 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK );
307 318
308 if ( which == 0 ) { 319 if ( which == 0 ) {
309 if ( fd >= 0 ) { 320 if ( fd >= 0 ) {
310 struct h3600_ts_led leds; 321 struct h3600_ts_led leds;
311 ::memset ( &leds, 0, sizeof( leds )); 322 ::memset ( &leds, 0, sizeof( leds ));
312 leds. TotalTime = 0; 323 leds. TotalTime = 0;
313 leds. OnTime = 0; 324 leds. OnTime = 0;
314 leds. OffTime = 1; 325 leds. OffTime = 1;
315 leds. OffOnBlink = 2; 326 leds. OffOnBlink = 2;
316 327
317 switch ( st ) { 328 switch ( st ) {
318 case OLED_Off : leds. OffOnBlink = 0; break; 329 case OLED_Off : leds. OffOnBlink = 0; break;
319 case OLED_On : leds. OffOnBlink = 1; break; 330 case OLED_On : leds. OffOnBlink = 1; break;
320 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 331 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
321 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 332 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
322 } 333 }
323 334
324 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 335 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
325 d-> m_leds [0] = st; 336 d-> m_leds [0] = st;
326 return true; 337 return true;
327 } 338 }
328 } 339 }
329 } 340 }
330 return false; 341 return false;
331} 342}
332 343
333 344
334//#endif 345//#endif
335 346
336 347
337 348
338 349
339 350
340//#if defined( QT_QWS_CUSTOM ) // Zaurus 351//#if defined( QT_QWS_EBX ) // Zaurus
341 352
342void ODeviceZaurus::init ( ) 353void ODeviceZaurus::init ( )
343 { 354{
344 d-> m_modelstr = "Zaurus SL5000"; 355 d-> m_modelstr = "Zaurus SL5000";
345 d-> m_model = OMODEL_Zaurus_SL5000; 356 d-> m_model = OMODEL_Zaurus_SL5000;
346 d-> m_vendorstr = "Sharp"; 357 d-> m_vendorstr = "Sharp";
347 d-> m_vendor = OVENDOR_Sharp; 358 d-> m_vendor = OVENDOR_Sharp;
348 359
349 QFile f ( "/proc/filesystems" ); 360 QFile f ( "/proc/filesystems" );
350 361
351 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 )) {
352 d-> m_systemstr = "OpenZaurus"; 363 d-> m_systemstr = "OpenZaurus";
353 d-> m_system = OSYSTEM_OpenZaurus; 364 d-> m_system = OSYSTEM_OpenZaurus;
354 365
355 f. close ( ); 366 f. close ( );
356 } 367 }
357 else { 368 else {
358 d-> m_systemstr = "Zaurus"; 369 d-> m_systemstr = "Zaurus";
359 d-> m_system = OSYSTEM_Zaurus; 370 d-> m_system = OSYSTEM_Zaurus;
360 } 371 }
361 372
362 d-> m_leds [0] = OLED_Off; 373 d-> m_leds [0] = OLED_Off;
363} 374}
364 375
365#include <unistd.h> 376#include <unistd.h>
366#include <fcntl.h> 377#include <fcntl.h>
367#include <sys/ioctl.h> 378#include <sys/ioctl.h>
368 379
369//#include <asm/sharp_char.h> // including kernel headers is evil ... 380//#include <asm/sharp_char.h> // including kernel headers is evil ...
370 381
371#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 382#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
372 383
373 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 384 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
374#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 385#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
375 386
376#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 387#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
377#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 388#define SHARP_BUZ_KEYSOUND 2 /* key sound */
378#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 389#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
379 390
391/* --- for SHARP_BUZZER device --- */
392
393 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
394//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
395
396#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
397#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
398#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
399#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
400#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
401
402//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
403//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
404
405//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
406//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
407//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
408//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
409//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
410//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
411//#define SHARP_PDA_APPSTART 9 /* application start */
412//#define SHARP_PDA_APPQUIT 10 /* application ends */
413
414//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
415//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
416//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
417//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
418//
380 419
381 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 420 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
382#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 421#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
383 422
384typedef struct sharp_led_status { 423typedef struct sharp_led_status {
385 int which; /* select which LED status is wanted. */ 424 int which; /* select which LED status is wanted. */
386 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 425 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
387} sharp_led_status; 426} sharp_led_status;
388 427
389#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 428#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
390 429
391#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 430#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
392#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 431#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
393#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 432#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
394 433
395 434
396 435
397void ODeviceZaurus::buzzer ( int sound ) 436void ODeviceZaurus::buzzer ( int sound )
398{ 437{
399 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 438 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
400 439
401 if ( fd >= 0 ) 440 if ( fd >= 0 )
402 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 441 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
403} 442}
404 443
405 444
406void ODeviceZaurus::alarmSound ( ) 445void ODeviceZaurus::alarmSound ( )
407{ 446{
408 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 447 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
409} 448}
410 449
411void ODeviceZaurus::touchSound ( ) 450void ODeviceZaurus::touchSound ( )
412{ 451{
413 buzzer ( SHARP_BUZ_TOUCHSOUND ); 452 buzzer ( SHARP_BUZ_TOUCHSOUND );
414} 453}
415 454
416void ODeviceZaurus::keySound ( ) 455void ODeviceZaurus::keySound ( )
417{ 456{
418 buzzer ( SHARP_BUZ_KEYSOUND ); 457 buzzer ( SHARP_BUZ_KEYSOUND );
419} 458}
420 459
421 460
422uint ODeviceZaurus::hasLeds ( ) const 461uint ODeviceZaurus::hasLeds ( ) const
423{ 462{
424 return 1; 463 return 1;
425} 464}
426 465
427OLedState ODeviceZaurus::led ( uint which ) const 466OLedState ODeviceZaurus::led ( uint which ) const
428{ 467{
429 if ( which == 0 ) 468 if ( which == 0 )
430 return d-> m_leds [0]; 469 return d-> m_leds [0];
431 else 470 else
432 return OLED_Off; 471 return OLED_Off;
433} 472}
434 473
435bool ODeviceZaurus::setLed ( uint which, OLedState st ) 474bool ODeviceZaurus::setLed ( uint which, OLedState st )
436{ 475{
437 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 476 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
438 477
439 if ( which == 0 ) { 478 if ( which == 0 ) {
440 if ( fd >= 0 ) { 479 if ( fd >= 0 ) {
441 struct sharp_led_status leds; 480 struct sharp_led_status leds;
442 ::memset ( &leds, 0, sizeof( leds )); 481 ::memset ( &leds, 0, sizeof( leds ));
443 leds. which = SHARP_LED_MAIL_EXISTS; 482 leds. which = SHARP_LED_MAIL_EXISTS;
444 483
445 switch ( st ) { 484 switch ( st ) {
446 case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 485 case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
447 case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 486 case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
448 case OLED_BlinkSlow: 487 case OLED_BlinkSlow:
449 case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 488 case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
450 } 489 }
451 490
452 if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { 491 if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) {
453 d-> m_leds [0] = st; 492 d-> m_leds [0] = st;
454 return true; 493 return true;
455 } 494 }
456 } 495 }
457 } 496 }
458 return false; 497 return false;
459} 498}
460 499
461//#endif 500//#endif