author | sandman <sandman> | 2002-06-25 22:35:38 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-25 22:35:38 (UTC) |
commit | b970aebbdfc7e6f811c9b75ee62ad9370f74ace0 (patch) (unidiff) | |
tree | 3082f6d029574fe153520a783cba1d632cdcf522 | |
parent | 54188f54767a7057ace4e068378e1155e003c94f (diff) | |
download | opie-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)
-rw-r--r-- | libopie/odevice.cpp | 48 | ||||
-rw-r--r-- | libopie/odevice.h | 2 |
2 files changed, 21 insertions, 29 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index d952edf..61c24f4 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,426 +1,418 @@ | |||
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> | ||
23 | #include <qpe/resource.h> | ||
22 | 24 | ||
23 | 25 | ||
24 | #include "odevice.h" | 26 | #include "odevice.h" |
25 | 27 | ||
26 | 28 | ||
27 | class ODeviceData { | 29 | class ODeviceData { |
28 | public: | 30 | public: |
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; |
34 | 36 | ||
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 | ||
41 | class ODeviceIPAQ : public ODevice { | 43 | class ODeviceIPAQ : public ODevice { |
42 | protected: | 44 | protected: |
43 | virtual void init ( ); | 45 | virtual void init ( ); |
44 | 46 | ||
45 | public: | 47 | public: |
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 | ||
55 | class ODeviceZaurus : public ODevice { | 55 | class ODeviceZaurus : public ODevice { |
56 | protected: | 56 | protected: |
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 | ||
68 | protected: | 68 | protected: |
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 | |||
78 | ODevice *ODevice::inst ( ) | 75 | ODevice *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 | ||
90 | dev-> init ( ); | 87 | dev-> init ( ); |
91 | } | 88 | } |
92 | return dev; | 89 | return dev; |
93 | } | 90 | } |
94 | 91 | ||
95 | ODevice::ODevice ( ) | 92 | ODevice::ODevice ( ) |
96 | { | 93 | { |
97 | d = new ODeviceData; | 94 | d = new ODeviceData; |
98 | 95 | ||
99 | d-> m_modelstr = "Unknown"; | 96 | d-> m_modelstr = "Unknown"; |
100 | d-> m_model = OMODEL_Unknown; | 97 | d-> m_model = OMODEL_Unknown; |
101 | d-> m_vendorstr = "Unkown"; | 98 | d-> m_vendorstr = "Unkown"; |
102 | d-> m_vendor = OVENDOR_Unknown; | 99 | d-> m_vendor = OVENDOR_Unknown; |
103 | d-> m_systemstr = "Unkown"; | 100 | d-> m_systemstr = "Unkown"; |
104 | d-> m_system = OSYSTEM_Unknown; | 101 | d-> m_system = OSYSTEM_Unknown; |
105 | } | 102 | } |
106 | 103 | ||
107 | void ODevice::init ( ) | 104 | void ODevice::init ( ) |
108 | { | 105 | { |
109 | } | 106 | } |
110 | 107 | ||
111 | ODevice::~ODevice ( ) | 108 | ODevice::~ODevice ( ) |
112 | { | 109 | { |
113 | delete d; | 110 | delete d; |
114 | } | 111 | } |
115 | 112 | ||
116 | QString ODevice::vendorString ( ) | 113 | QString ODevice::vendorString ( ) |
117 | { | 114 | { |
118 | return d-> m_vendorstr; | 115 | return d-> m_vendorstr; |
119 | } | 116 | } |
120 | 117 | ||
121 | OVendor ODevice::vendor ( ) | 118 | OVendor ODevice::vendor ( ) |
122 | { | 119 | { |
123 | return d-> m_vendor; | 120 | return d-> m_vendor; |
124 | } | 121 | } |
125 | 122 | ||
126 | QString ODevice::modelString ( ) | 123 | QString ODevice::modelString ( ) |
127 | { | 124 | { |
128 | return d-> m_modelstr; | 125 | return d-> m_modelstr; |
129 | } | 126 | } |
130 | 127 | ||
131 | OModel ODevice::model ( ) | 128 | OModel ODevice::model ( ) |
132 | { | 129 | { |
133 | return d-> m_model; | 130 | return d-> m_model; |
134 | } | 131 | } |
135 | 132 | ||
136 | QString ODevice::systemString ( ) | 133 | QString ODevice::systemString ( ) |
137 | { | 134 | { |
138 | return d-> m_systemstr; | 135 | return d-> m_systemstr; |
139 | } | 136 | } |
140 | 137 | ||
141 | OSystem ODevice::system ( ) | 138 | OSystem ODevice::system ( ) |
142 | { | 139 | { |
143 | return d-> m_system; | 140 | return d-> m_system; |
144 | } | 141 | } |
145 | 142 | ||
146 | void ODevice::alarmSound ( ) | 143 | void 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 | ||
150 | void ODevice::keySound ( ) | 153 | void 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 | ||
154 | void ODevice::touchSound ( ) | 163 | void 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 | ||
158 | uint ODevice::hasLeds ( ) const | 173 | uint ODevice::hasLeds ( ) const |
159 | { | 174 | { |
160 | return 0; | 175 | return 0; |
161 | } | 176 | } |
162 | 177 | ||
163 | OLedState ODevice::led ( uint /*which*/ ) const | 178 | OLedState ODevice::led ( uint /*which*/ ) const |
164 | { | 179 | { |
165 | return OLED_Off; | 180 | return OLED_Off; |
166 | } | 181 | } |
167 | 182 | ||
168 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) | 183 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) |
169 | { | 184 | { |
170 | return false; | 185 | return false; |
171 | } | 186 | } |
172 | 187 | ||
173 | 188 | ||
174 | 189 | ||
175 | 190 | ||
176 | //#if defined( QT_QWS_IPAQ ) // IPAQ | 191 | //#if defined( QT_QWS_IPAQ ) // IPAQ |
177 | 192 | ||
178 | 193 | ||
179 | void ODeviceIPAQ::init ( ) | 194 | void ODeviceIPAQ::init ( ) |
180 | { | 195 | { |
181 | d-> m_vendorstr = "HP"; | 196 | d-> m_vendorstr = "HP"; |
182 | d-> m_vendor = OVENDOR_HP; | 197 | d-> m_vendor = OVENDOR_HP; |
183 | 198 | ||
184 | QFile f ( "/proc/hal/model" ); | 199 | QFile f ( "/proc/hal/model" ); |
185 | 200 | ||
186 | if ( f. open ( IO_ReadOnly )) { | 201 | if ( f. open ( IO_ReadOnly )) { |
187 | QTextStream ts ( &f ); | 202 | QTextStream ts ( &f ); |
188 | 203 | ||
189 | d-> m_modelstr = "H" + ts. readLine ( ); | 204 | d-> m_modelstr = "H" + ts. readLine ( ); |
190 | 205 | ||
191 | if ( d-> m_modelstr == "H3100" ) | 206 | if ( d-> m_modelstr == "H3100" ) |
192 | d-> m_model = OMODEL_iPAQ_H31xx; | 207 | d-> m_model = OMODEL_iPAQ_H31xx; |
193 | else if ( d-> m_modelstr == "H3600" ) | 208 | else if ( d-> m_modelstr == "H3600" ) |
194 | d-> m_model = OMODEL_iPAQ_H36xx; | 209 | d-> m_model = OMODEL_iPAQ_H36xx; |
195 | else if ( d-> m_modelstr == "H3700" ) | 210 | else if ( d-> m_modelstr == "H3700" ) |
196 | d-> m_model = OMODEL_iPAQ_H37xx; | 211 | d-> m_model = OMODEL_iPAQ_H37xx; |
197 | else if ( d-> m_modelstr == "H3800" ) | 212 | else if ( d-> m_modelstr == "H3800" ) |
198 | d-> m_model = OMODEL_iPAQ_H38xx; | 213 | d-> m_model = OMODEL_iPAQ_H38xx; |
199 | else | 214 | else |
200 | d-> m_model = OMODEL_Unknown; | 215 | d-> m_model = OMODEL_Unknown; |
201 | 216 | ||
202 | f. close ( ); | 217 | f. close ( ); |
203 | } | 218 | } |
204 | 219 | ||
205 | if ( QFile::exists ( "/etc/familiar-version" )) { | 220 | if ( QFile::exists ( "/etc/familiar-version" )) { |
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 | ||
224 | typedef struct h3600_ts_led { | 237 | typedef 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' |
233 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) | 246 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) |
234 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( | 247 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( |
235 | 248 | ||
236 | 249 | ||
237 | void ODeviceIPAQ::alarmSound ( ) | 250 | void ODeviceIPAQ::alarmSound ( ) |
238 | { | 251 | { |
239 | #ifndef QT_NO_SOUND | 252 | #ifndef QT_NO_SOUND |
240 | static Sound snd ( "alarm" ); | 253 | static Sound snd ( "alarm" ); |
241 | int fd; | 254 | int fd; |
242 | int vol; | 255 | int vol; |
243 | bool vol_reset = false; | 256 | bool vol_reset = false; |
244 | 257 | ||
245 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 258 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
246 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 259 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
247 | 260 | ||
248 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 261 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
249 | Config cfg ( "qpe" ); | 262 | Config cfg ( "qpe" ); |
250 | cfg. setGroup ( "Volume" ); | 263 | cfg. setGroup ( "Volume" ); |
251 | 264 | ||
252 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 265 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
253 | if ( volalarm < 0 ) | 266 | if ( volalarm < 0 ) |
254 | volalarm = 0; | 267 | volalarm = 0; |
255 | else if ( volalarm > 100 ) | 268 | else if ( volalarm > 100 ) |
256 | volalarm = 100; | 269 | volalarm = 100; |
257 | volalarm |= ( volalarm << 8 ); | 270 | volalarm |= ( volalarm << 8 ); |
258 | 271 | ||
259 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 272 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
260 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 273 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
261 | vol_reset = true; | 274 | vol_reset = true; |
262 | } | 275 | } |
263 | } | 276 | } |
264 | } | 277 | } |
265 | 278 | ||
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 | ||
278 | void 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 | |||
288 | void 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 | |||
299 | uint ODeviceIPAQ::hasLeds ( ) const | 291 | uint ODeviceIPAQ::hasLeds ( ) const |
300 | { | 292 | { |
301 | return 1; | 293 | return 1; |
302 | } | 294 | } |
303 | 295 | ||
304 | OLedState ODeviceIPAQ::led ( uint which ) const | 296 | OLedState 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 | } |
311 | 303 | ||
312 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) | 304 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) |
313 | { | 305 | { |
314 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); | 306 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); |
315 | 307 | ||
316 | if ( which == 0 ) { | 308 | if ( which == 0 ) { |
317 | if ( fd >= 0 ) { | 309 | if ( fd >= 0 ) { |
318 | struct h3600_ts_led leds; | 310 | struct h3600_ts_led leds; |
319 | ::memset ( &leds, 0, sizeof( leds )); | 311 | ::memset ( &leds, 0, sizeof( leds )); |
320 | leds. TotalTime = 0; | 312 | leds. TotalTime = 0; |
321 | leds. OnTime = 0; | 313 | leds. OnTime = 0; |
322 | leds. OffTime = 1; | 314 | leds. OffTime = 1; |
323 | leds. OffOnBlink = 2; | 315 | leds. OffOnBlink = 2; |
324 | 316 | ||
325 | switch ( st ) { | 317 | switch ( st ) { |
326 | case OLED_Off : leds. OffOnBlink = 0; break; | 318 | case OLED_Off : leds. OffOnBlink = 0; break; |
327 | case OLED_On : leds. OffOnBlink = 1; break; | 319 | case OLED_On : leds. OffOnBlink = 1; break; |
328 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 320 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
329 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 321 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
330 | } | 322 | } |
331 | 323 | ||
332 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 324 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
333 | d-> m_leds [0] = st; | 325 | d-> m_leds [0] = st; |
334 | return true; | 326 | return true; |
335 | } | 327 | } |
336 | } | 328 | } |
337 | } | 329 | } |
338 | return false; | 330 | return false; |
339 | } | 331 | } |
340 | 332 | ||
341 | 333 | ||
342 | //#endif | 334 | //#endif |
343 | 335 | ||
344 | 336 | ||
345 | 337 | ||
346 | 338 | ||
347 | 339 | ||
348 | //#if defined( QT_QWS_CUSTOM ) // Zaurus | 340 | //#if defined( QT_QWS_CUSTOM ) // Zaurus |
349 | 341 | ||
350 | void ODeviceZaurus::init ( ) | 342 | void ODeviceZaurus::init ( ) |
351 | { | 343 | { |
352 | d-> m_modelstr = "Zaurus SL5000"; | 344 | d-> m_modelstr = "Zaurus SL5000"; |
353 | d-> m_model = OMODEL_Zaurus_SL5000; | 345 | d-> m_model = OMODEL_Zaurus_SL5000; |
354 | d-> m_vendorstr = "Sharp"; | 346 | d-> m_vendorstr = "Sharp"; |
355 | d-> m_vendor = OVENDOR_Sharp; | 347 | d-> m_vendor = OVENDOR_Sharp; |
356 | 348 | ||
357 | QFile f ( "/proc/filesystems" ); | 349 | QFile f ( "/proc/filesystems" ); |
358 | 350 | ||
359 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 351 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
360 | d-> m_systemstr = "OpenZaurus"; | 352 | d-> m_systemstr = "OpenZaurus"; |
361 | d-> m_system = OSYSTEM_OpenZaurus; | 353 | d-> m_system = OSYSTEM_OpenZaurus; |
362 | 354 | ||
363 | f. close ( ); | 355 | f. close ( ); |
364 | } | 356 | } |
365 | else { | 357 | else { |
366 | d-> m_systemstr = "Zaurus"; | 358 | d-> m_systemstr = "Zaurus"; |
367 | d-> m_system = OSYSTEM_Zaurus; | 359 | d-> m_system = OSYSTEM_Zaurus; |
368 | } | 360 | } |
369 | 361 | ||
370 | d-> m_leds [0] = OLED_Off; | 362 | d-> m_leds [0] = OLED_Off; |
371 | } | 363 | } |
372 | 364 | ||
373 | #include <unistd.h> | 365 | #include <unistd.h> |
374 | #include <fcntl.h> | 366 | #include <fcntl.h> |
375 | #include <sys/ioctl.h> | 367 | #include <sys/ioctl.h> |
376 | 368 | ||
377 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 369 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
378 | 370 | ||
379 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 371 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
380 | 372 | ||
381 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 373 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
382 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 374 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
383 | 375 | ||
384 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 376 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
385 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 377 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
386 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 378 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
387 | 379 | ||
388 | 380 | ||
389 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 381 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
390 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 382 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
391 | 383 | ||
392 | typedef struct sharp_led_status { | 384 | typedef struct sharp_led_status { |
393 | int which; /* select which LED status is wanted. */ | 385 | int which; /* select which LED status is wanted. */ |
394 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 386 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
395 | } sharp_led_status; | 387 | } sharp_led_status; |
396 | 388 | ||
397 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 389 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
398 | 390 | ||
399 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 391 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
400 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 392 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
401 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 393 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
402 | 394 | ||
403 | 395 | ||
404 | 396 | ||
405 | void ODeviceZaurus::buzzer ( int sound ) | 397 | void ODeviceZaurus::buzzer ( int sound ) |
406 | { | 398 | { |
407 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 399 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
408 | 400 | ||
409 | if ( fd >= 0 ) | 401 | if ( fd >= 0 ) |
410 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 402 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
411 | } | 403 | } |
412 | 404 | ||
413 | 405 | ||
414 | void ODeviceZaurus::alarmSound ( ) | 406 | void ODeviceZaurus::alarmSound ( ) |
415 | { | 407 | { |
416 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 408 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
417 | } | 409 | } |
418 | 410 | ||
419 | void ODeviceZaurus::touchSound ( ) | 411 | void ODeviceZaurus::touchSound ( ) |
420 | { | 412 | { |
421 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 413 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
422 | } | 414 | } |
423 | 415 | ||
424 | void ODeviceZaurus::keySound ( ) | 416 | void ODeviceZaurus::keySound ( ) |
425 | { | 417 | { |
426 | buzzer ( SHARP_BUZ_KEYSOUND ); | 418 | buzzer ( SHARP_BUZ_KEYSOUND ); |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 793becc..b40abe7 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,107 +1,107 @@ | |||
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 | #ifndef _LIBOPIE_ODEVICE_H_ | 20 | #ifndef _LIBOPIE_ODEVICE_H_ |
21 | #define _LIBOPIE_ODEVICE_H_ | 21 | #define _LIBOPIE_ODEVICE_H_ |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | 24 | ||
25 | 25 | ||
26 | class ODeviceData; | 26 | class ODeviceData; |
27 | 27 | ||
28 | enum OModel { | 28 | enum OModel { |
29 | OMODEL_Unknown, | 29 | OMODEL_Unknown, |
30 | 30 | ||
31 | OMODEL_iPAQ_H31xx, | 31 | OMODEL_iPAQ_H31xx, |
32 | OMODEL_iPAQ_H36xx, | 32 | OMODEL_iPAQ_H36xx, |
33 | OMODEL_iPAQ_H37xx, | 33 | OMODEL_iPAQ_H37xx, |
34 | OMODEL_iPAQ_H38xx, | 34 | OMODEL_iPAQ_H38xx, |
35 | 35 | ||
36 | OMODEL_Zaurus_SL5000 | 36 | OMODEL_Zaurus_SL5000 |
37 | }; | 37 | }; |
38 | 38 | ||
39 | enum OVendor { | 39 | enum OVendor { |
40 | OVENDOR_Unknown, | 40 | OVENDOR_Unknown, |
41 | 41 | ||
42 | OVENDOR_HP, | 42 | OVENDOR_HP, |
43 | OVENDOR_Sharp, | 43 | OVENDOR_Sharp |
44 | }; | 44 | }; |
45 | 45 | ||
46 | enum OSystem { | 46 | enum OSystem { |
47 | OSYSTEM_Unknown, | 47 | OSYSTEM_Unknown, |
48 | 48 | ||
49 | OSYSTEM_Familiar, | 49 | OSYSTEM_Familiar, |
50 | OSYSTEM_Zaurus, | 50 | OSYSTEM_Zaurus, |
51 | OSYSTEM_OpenZaurus | 51 | OSYSTEM_OpenZaurus |
52 | }; | 52 | }; |
53 | 53 | ||
54 | enum OLedState { | 54 | enum OLedState { |
55 | OLED_Off, | 55 | OLED_Off, |
56 | OLED_On, | 56 | OLED_On, |
57 | OLED_BlinkSlow, | 57 | OLED_BlinkSlow, |
58 | OLED_BlinkFast | 58 | OLED_BlinkFast |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | class ODevice | 62 | class ODevice |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | 65 | ||
66 | public: | 66 | public: |
67 | static ODevice *inst ( ); | 67 | static ODevice *inst ( ); |
68 | 68 | ||
69 | 69 | ||
70 | // information | 70 | // information |
71 | 71 | ||
72 | QString modelString ( ); | 72 | QString modelString ( ); |
73 | OModel model ( ); | 73 | OModel model ( ); |
74 | 74 | ||
75 | QString vendorString ( ); | 75 | QString vendorString ( ); |
76 | OVendor vendor ( ); | 76 | OVendor vendor ( ); |
77 | 77 | ||
78 | QString systemString ( ); | 78 | QString systemString ( ); |
79 | OSystem system ( ); | 79 | OSystem system ( ); |
80 | 80 | ||
81 | 81 | ||
82 | // input / output | 82 | // input / output |
83 | 83 | ||
84 | virtual void alarmSound ( ); | 84 | virtual void alarmSound ( ); |
85 | virtual void keySound ( ); | 85 | virtual void keySound ( ); |
86 | virtual void touchSound ( ); | 86 | virtual void touchSound ( ); |
87 | 87 | ||
88 | virtual uint hasLeds ( ) const; | 88 | virtual uint hasLeds ( ) const; |
89 | virtual OLedState led ( uint which ) const; | 89 | virtual OLedState led ( uint which ) const; |
90 | virtual bool setLed ( uint which, OLedState st ); | 90 | virtual bool setLed ( uint which, OLedState st ); |
91 | 91 | ||
92 | virtual ~ODevice ( ); | 92 | virtual ~ODevice ( ); |
93 | 93 | ||
94 | protected: | 94 | protected: |
95 | ODevice ( ); | 95 | ODevice ( ); |
96 | virtual void init ( ); | 96 | virtual void init ( ); |
97 | 97 | ||
98 | ODeviceData *d; | 98 | ODeviceData *d; |
99 | 99 | ||
100 | private: | 100 | private: |
101 | ODevice ( const ODevice & ); | 101 | ODevice ( const ODevice & ); |
102 | 102 | ||
103 | }; | 103 | }; |
104 | 104 | ||
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | 107 | ||