summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorsandman <sandman>2002-06-25 22:35:38 (UTC)
committer sandman <sandman>2002-06-25 22:35:38 (UTC)
commitb970aebbdfc7e6f811c9b75ee62ad9370f74ace0 (patch) (unidiff)
tree3082f6d029574fe153520a783cba1d632cdcf522 /libopie/odevice.cpp
parent54188f54767a7057ace4e068378e1155e003c94f (diff)
downloadopie-b970aebbdfc7e6f811c9b75ee62ad9370f74ace0.zip
opie-b970aebbdfc7e6f811c9b75ee62ad9370f74ace0.tar.gz
opie-b970aebbdfc7e6f811c9b75ee62ad9370f74ace0.tar.bz2
Request from ljp: alarm/key/tap sounds should now also work on "Unknown"
modells (this includes x86 simulation)
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index d952edf..61c24f4 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -10,24 +10,26 @@
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>
23#include <qpe/resource.h>
22 24
23 25
24#include "odevice.h" 26#include "odevice.h"
25 27
26 28
27class ODeviceData { 29class ODeviceData {
28public: 30public:
29 QString m_vendorstr; 31 QString m_vendorstr;
30 OVendor m_vendor; 32 OVendor m_vendor;
31 33
32 QString m_modelstr; 34 QString m_modelstr;
33 OModel m_model; 35 OModel m_model;
@@ -35,26 +37,24 @@ public:
35 QString m_systemstr; 37 QString m_systemstr;
36 OSystem m_system; 38 OSystem m_system;
37 39
38 OLedState m_leds [4]; // just for convenience ... 40 OLedState m_leds [4]; // just for convenience ...
39}; 41};
40 42
41class ODeviceIPAQ : public ODevice { 43class ODeviceIPAQ : public ODevice {
42protected: 44protected:
43 virtual void init ( ); 45 virtual void init ( );
44 46
45public: 47public:
46 virtual void alarmSound ( ); 48 virtual void alarmSound ( );
47 virtual void keySound ( );
48 virtual void touchSound ( );
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 ( );
@@ -63,27 +63,24 @@ public:
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
75
76
77
78ODevice *ODevice::inst ( ) 75ODevice *ODevice::inst ( )
79{ 76{
80 static ODevice *dev = 0; 77 static ODevice *dev = 0;
81 78
82 if ( !dev ) { 79 if ( !dev ) {
83 if ( QFile::exists ( "/proc/hal/model" )) 80 if ( QFile::exists ( "/proc/hal/model" ))
84 dev = new ODeviceIPAQ ( ); 81 dev = new ODeviceIPAQ ( );
85 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" ))
86 dev = new ODeviceZaurus ( ); 83 dev = new ODeviceZaurus ( );
87 else 84 else
88 dev = new ODevice ( ); 85 dev = new ODevice ( );
89 86
@@ -136,32 +133,50 @@ OModel ODevice::model ( )
136QString ODevice::systemString ( ) 133QString ODevice::systemString ( )
137{ 134{
138 return d-> m_systemstr; 135 return d-> m_systemstr;
139} 136}
140 137
141OSystem ODevice::system ( ) 138OSystem ODevice::system ( )
142{ 139{
143 return d-> m_system; 140 return d-> m_system;
144} 141}
145 142
146void ODevice::alarmSound ( ) 143void ODevice::alarmSound ( )
147{ 144{
145#ifndef QT_NO_SOUND
146 static Sound snd ( "alarm" );
147
148 if ( snd. isFinished ( ))
149 snd. play ( );
150#endif
148} 151}
149 152
150void ODevice::keySound ( ) 153void ODevice::keySound ( )
151{ 154{
155#ifndef QT_NO_SOUND
156 static Sound snd ( "keysound" );
157
158 if ( snd. isFinished ( ))
159 snd. play ( );
160#endif
152} 161}
153 162
154void ODevice::touchSound ( ) 163void ODevice::touchSound ( )
155{ 164{
165#ifndef QT_NO_SOUND
166 static Sound snd ( "touchsound" );
167
168 if ( snd. isFinished ( ))
169 snd. play ( );
170#endif
156} 171}
157 172
158uint ODevice::hasLeds ( ) const 173uint ODevice::hasLeds ( ) const
159{ 174{
160 return 0; 175 return 0;
161} 176}
162 177
163OLedState ODevice::led ( uint /*which*/ ) const 178OLedState ODevice::led ( uint /*which*/ ) const
164{ 179{
165 return OLED_Off; 180 return OLED_Off;
166} 181}
167 182
@@ -206,27 +221,25 @@ void ODeviceIPAQ::init ( )
206 d-> m_systemstr = "Familiar"; 221 d-> m_systemstr = "Familiar";
207 d-> m_system = OSYSTEM_Familiar; 222 d-> m_system = OSYSTEM_Familiar;
208 } 223 }
209 224
210 d-> m_leds [0] = OLED_Off; 225 d-> m_leds [0] = OLED_Off;
211} 226}
212 227
213#include <unistd.h> 228#include <unistd.h>
214#include <fcntl.h> 229#include <fcntl.h>
215#include <sys/ioctl.h> 230#include <sys/ioctl.h>
216#include <linux/soundcard.h> 231#include <linux/soundcard.h>
217#include <qapplication.h> 232#include <qapplication.h>
218#include <qpe/resource.h>
219#include <qpe/config.h> 233#include <qpe/config.h>
220#include <qpe/sound.h>
221 234
222//#include <linux/h3600_ts.h> // including kernel headers is evil ... 235//#include <linux/h3600_ts.h> // including kernel headers is evil ...
223 236
224typedef struct h3600_ts_led { 237typedef struct h3600_ts_led {
225 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
226 unsigned char TotalTime; /* Units of 5 seconds */ 239 unsigned char TotalTime; /* Units of 5 seconds */
227 unsigned char OnTime; /* units of 100m/s */ 240 unsigned char OnTime; /* units of 100m/s */
228 unsigned char OffTime; /* units of 100m/s */ 241 unsigned char OffTime; /* units of 100m/s */
229} LED_IN; 242} LED_IN;
230 243
231 244
232// #define IOC_H3600_TS_MAGIC 'f' 245// #define IOC_H3600_TS_MAGIC 'f'
@@ -266,45 +279,24 @@ void ODeviceIPAQ::alarmSound ( )
266 snd. play ( ); 279 snd. play ( );
267 while ( !snd. isFinished ( )) 280 while ( !snd. isFinished ( ))
268 qApp-> processEvents ( ); 281 qApp-> processEvents ( );
269 282
270 if ( fd >= 0 ) { 283 if ( fd >= 0 ) {
271 if ( vol_reset ) 284 if ( vol_reset )
272 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 285 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
273 ::close ( fd ); 286 ::close ( fd );
274 } 287 }
275#endif 288#endif
276} 289}
277 290
278void ODeviceIPAQ::touchSound ( )
279{
280#ifndef QT_NO_SOUND
281 static Sound snd ( "touchsound" );
282
283 if ( snd. isFinished ( ))
284 snd. play ( );
285#endif
286}
287
288void ODeviceIPAQ::keySound ( )
289{
290#ifndef QT_NO_SOUND
291 static Sound snd ( "keysound" );
292
293 if ( snd. isFinished ( ))
294 snd. play ( );
295#endif
296}
297
298
299uint ODeviceIPAQ::hasLeds ( ) const 291uint ODeviceIPAQ::hasLeds ( ) const
300{ 292{
301 return 1; 293 return 1;
302} 294}
303 295
304OLedState ODeviceIPAQ::led ( uint which ) const 296OLedState ODeviceIPAQ::led ( uint which ) const
305{ 297{
306 if ( which == 0 ) 298 if ( which == 0 )
307 return d-> m_leds [0]; 299 return d-> m_leds [0];
308 else 300 else
309 return OLED_Off; 301 return OLED_Off;
310} 302}