-rw-r--r-- | libopie/odevice.cpp | 16 | ||||
-rw-r--r-- | libopie/odevice.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9931684..bc8014a 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,500 +1,514 @@ | |||
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 | ||
29 | class ODeviceData { | 29 | class ODeviceData { |
30 | public: | 30 | public: |
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 | QString m_sysverstr; | ||
41 | |||
40 | OLedState m_leds [4]; // just for convenience ... | 42 | OLedState m_leds [4]; // just for convenience ... |
41 | }; | 43 | }; |
42 | 44 | ||
43 | class ODeviceIPAQ : public ODevice { | 45 | class ODeviceIPAQ : public ODevice { |
44 | protected: | 46 | protected: |
45 | virtual void init ( ); | 47 | virtual void init ( ); |
46 | 48 | ||
47 | public: | 49 | public: |
48 | virtual void alarmSound ( ); | 50 | virtual void alarmSound ( ); |
49 | 51 | ||
50 | virtual uint hasLeds ( ) const; | 52 | virtual uint hasLeds ( ) const; |
51 | virtual OLedState led ( uint which ) const; | 53 | virtual OLedState led ( uint which ) const; |
52 | virtual bool setLed ( uint which, OLedState st ); | 54 | virtual bool setLed ( uint which, OLedState st ); |
53 | }; | 55 | }; |
54 | 56 | ||
55 | class ODeviceZaurus : public ODevice { | 57 | class ODeviceZaurus : public ODevice { |
56 | protected: | 58 | protected: |
57 | virtual void init ( ); | 59 | virtual void init ( ); |
58 | 60 | ||
59 | public: | 61 | public: |
60 | virtual void alarmSound ( ); | 62 | virtual void alarmSound ( ); |
61 | virtual void keySound ( ); | 63 | virtual void keySound ( ); |
62 | virtual void touchSound ( ); | 64 | virtual void touchSound ( ); |
63 | 65 | ||
64 | virtual uint hasLeds ( ) const; | 66 | virtual uint hasLeds ( ) const; |
65 | virtual OLedState led ( uint which ) const; | 67 | virtual OLedState led ( uint which ) const; |
66 | virtual bool setLed ( uint which, OLedState st ); | 68 | virtual bool setLed ( uint which, OLedState st ); |
67 | 69 | ||
68 | protected: | 70 | protected: |
69 | virtual void buzzer ( int snd ); | 71 | virtual void buzzer ( int snd ); |
70 | }; | 72 | }; |
71 | 73 | ||
72 | 74 | ||
73 | 75 | ||
74 | 76 | ||
75 | ODevice *ODevice::inst ( ) | 77 | ODevice *ODevice::inst ( ) |
76 | { | 78 | { |
77 | static ODevice *dev = 0; | 79 | static ODevice *dev = 0; |
78 | 80 | ||
79 | if ( !dev ) { | 81 | if ( !dev ) { |
80 | if ( QFile::exists ( "/proc/hal/model" )) | 82 | if ( QFile::exists ( "/proc/hal/model" )) |
81 | dev = new ODeviceIPAQ ( ); | 83 | dev = new ODeviceIPAQ ( ); |
82 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 84 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
83 | dev = new ODeviceZaurus ( ); | 85 | dev = new ODeviceZaurus ( ); |
84 | else | 86 | else |
85 | dev = new ODevice ( ); | 87 | dev = new ODevice ( ); |
86 | 88 | ||
87 | dev-> init ( ); | 89 | dev-> init ( ); |
88 | } | 90 | } |
89 | return dev; | 91 | return dev; |
90 | } | 92 | } |
91 | 93 | ||
92 | ODevice::ODevice ( ) | 94 | ODevice::ODevice ( ) |
93 | { | 95 | { |
94 | d = new ODeviceData; | 96 | d = new ODeviceData; |
95 | 97 | ||
96 | d-> m_modelstr = "Unknown"; | 98 | d-> m_modelstr = "Unknown"; |
97 | d-> m_model = OMODEL_Unknown; | 99 | d-> m_model = OMODEL_Unknown; |
98 | d-> m_vendorstr = "Unkown"; | 100 | d-> m_vendorstr = "Unkown"; |
99 | d-> m_vendor = OVENDOR_Unknown; | 101 | d-> m_vendor = OVENDOR_Unknown; |
100 | d-> m_systemstr = "Unkown"; | 102 | d-> m_systemstr = "Unkown"; |
101 | d-> m_system = OSYSTEM_Unknown; | 103 | d-> m_system = OSYSTEM_Unknown; |
104 | d-> m_sysverstr = "0.0"; | ||
102 | } | 105 | } |
103 | 106 | ||
104 | void ODevice::init ( ) | 107 | void ODevice::init ( ) |
105 | { | 108 | { |
106 | } | 109 | } |
107 | 110 | ||
108 | ODevice::~ODevice ( ) | 111 | ODevice::~ODevice ( ) |
109 | { | 112 | { |
110 | delete d; | 113 | delete d; |
111 | } | 114 | } |
112 | 115 | ||
113 | QString ODevice::vendorString ( ) | 116 | QString ODevice::vendorString ( ) |
114 | { | 117 | { |
115 | return d-> m_vendorstr; | 118 | return d-> m_vendorstr; |
116 | } | 119 | } |
117 | 120 | ||
118 | OVendor ODevice::vendor ( ) | 121 | OVendor ODevice::vendor ( ) |
119 | { | 122 | { |
120 | return d-> m_vendor; | 123 | return d-> m_vendor; |
121 | } | 124 | } |
122 | 125 | ||
123 | QString ODevice::modelString ( ) | 126 | QString ODevice::modelString ( ) |
124 | { | 127 | { |
125 | return d-> m_modelstr; | 128 | return d-> m_modelstr; |
126 | } | 129 | } |
127 | 130 | ||
128 | OModel ODevice::model ( ) | 131 | OModel ODevice::model ( ) |
129 | { | 132 | { |
130 | return d-> m_model; | 133 | return d-> m_model; |
131 | } | 134 | } |
132 | 135 | ||
133 | QString ODevice::systemString ( ) | 136 | QString ODevice::systemString ( ) |
134 | { | 137 | { |
135 | return d-> m_systemstr; | 138 | return d-> m_systemstr; |
136 | } | 139 | } |
137 | 140 | ||
138 | OSystem ODevice::system ( ) | 141 | OSystem ODevice::system ( ) |
139 | { | 142 | { |
140 | return d-> m_system; | 143 | return d-> m_system; |
141 | } | 144 | } |
142 | 145 | ||
146 | QString ODevice::systemVersionString ( ) | ||
147 | { | ||
148 | return d-> m_sysverstr; | ||
149 | } | ||
150 | |||
143 | void ODevice::alarmSound ( ) | 151 | void ODevice::alarmSound ( ) |
144 | { | 152 | { |
145 | #ifndef QT_QWS_EBX | 153 | #ifndef QT_QWS_EBX |
146 | #ifndef QT_NO_SOUND | 154 | #ifndef QT_NO_SOUND |
147 | static Sound snd ( "alarm" ); | 155 | static Sound snd ( "alarm" ); |
148 | 156 | ||
149 | if ( snd. isFinished ( )) | 157 | if ( snd. isFinished ( )) |
150 | snd. play ( ); | 158 | snd. play ( ); |
151 | #endif | 159 | #endif |
152 | #endif | 160 | #endif |
153 | } | 161 | } |
154 | 162 | ||
155 | void ODevice::keySound ( ) | 163 | void ODevice::keySound ( ) |
156 | { | 164 | { |
157 | #ifndef QT_QWS_EBX | 165 | #ifndef QT_QWS_EBX |
158 | #ifndef QT_NO_SOUND | 166 | #ifndef QT_NO_SOUND |
159 | static Sound snd ( "keysound" ); | 167 | static Sound snd ( "keysound" ); |
160 | 168 | ||
161 | if ( snd. isFinished ( )) | 169 | if ( snd. isFinished ( )) |
162 | snd. play ( ); | 170 | snd. play ( ); |
163 | #endif | 171 | #endif |
164 | #endif | 172 | #endif |
165 | } | 173 | } |
166 | 174 | ||
167 | void ODevice::touchSound ( ) | 175 | void ODevice::touchSound ( ) |
168 | { | 176 | { |
169 | 177 | ||
170 | #ifndef QT_QWS_EBX | 178 | #ifndef QT_QWS_EBX |
171 | #ifndef QT_NO_SOUND | 179 | #ifndef QT_NO_SOUND |
172 | static Sound snd ( "touchsound" ); | 180 | static Sound snd ( "touchsound" ); |
173 | //qDebug("touchSound"); | 181 | //qDebug("touchSound"); |
174 | if ( snd. isFinished ( )) { | 182 | if ( snd. isFinished ( )) { |
175 | snd. play ( ); | 183 | snd. play ( ); |
176 | // qDebug("sound should play"); | 184 | // qDebug("sound should play"); |
177 | } | 185 | } |
178 | #endif | 186 | #endif |
179 | #endif | 187 | #endif |
180 | } | 188 | } |
181 | 189 | ||
182 | uint ODevice::hasLeds ( ) const | 190 | uint ODevice::hasLeds ( ) const |
183 | { | 191 | { |
184 | return 0; | 192 | return 0; |
185 | } | 193 | } |
186 | 194 | ||
187 | OLedState ODevice::led ( uint /*which*/ ) const | 195 | OLedState ODevice::led ( uint /*which*/ ) const |
188 | { | 196 | { |
189 | return OLED_Off; | 197 | return OLED_Off; |
190 | } | 198 | } |
191 | 199 | ||
192 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) | 200 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) |
193 | { | 201 | { |
194 | return false; | 202 | return false; |
195 | } | 203 | } |
196 | 204 | ||
197 | 205 | ||
198 | 206 | ||
199 | 207 | ||
200 | //#if defined( QT_QWS_IPAQ ) // IPAQ | 208 | //#if defined( QT_QWS_IPAQ ) // IPAQ |
201 | 209 | ||
202 | 210 | ||
203 | void ODeviceIPAQ::init ( ) | 211 | void ODeviceIPAQ::init ( ) |
204 | { | 212 | { |
205 | d-> m_vendorstr = "HP"; | 213 | d-> m_vendorstr = "HP"; |
206 | d-> m_vendor = OVENDOR_HP; | 214 | d-> m_vendor = OVENDOR_HP; |
207 | 215 | ||
208 | QFile f ( "/proc/hal/model" ); | 216 | QFile f ( "/proc/hal/model" ); |
209 | 217 | ||
210 | if ( f. open ( IO_ReadOnly )) { | 218 | if ( f. open ( IO_ReadOnly )) { |
211 | QTextStream ts ( &f ); | 219 | QTextStream ts ( &f ); |
212 | 220 | ||
213 | d-> m_modelstr = "H" + ts. readLine ( ); | 221 | d-> m_modelstr = "H" + ts. readLine ( ); |
214 | 222 | ||
215 | if ( d-> m_modelstr == "H3100" ) | 223 | if ( d-> m_modelstr == "H3100" ) |
216 | d-> m_model = OMODEL_iPAQ_H31xx; | 224 | d-> m_model = OMODEL_iPAQ_H31xx; |
217 | else if ( d-> m_modelstr == "H3600" ) | 225 | else if ( d-> m_modelstr == "H3600" ) |
218 | d-> m_model = OMODEL_iPAQ_H36xx; | 226 | d-> m_model = OMODEL_iPAQ_H36xx; |
219 | else if ( d-> m_modelstr == "H3700" ) | 227 | else if ( d-> m_modelstr == "H3700" ) |
220 | d-> m_model = OMODEL_iPAQ_H37xx; | 228 | d-> m_model = OMODEL_iPAQ_H37xx; |
221 | else if ( d-> m_modelstr == "H3800" ) | 229 | else if ( d-> m_modelstr == "H3800" ) |
222 | d-> m_model = OMODEL_iPAQ_H38xx; | 230 | d-> m_model = OMODEL_iPAQ_H38xx; |
223 | else | 231 | else |
224 | d-> m_model = OMODEL_Unknown; | 232 | d-> m_model = OMODEL_Unknown; |
225 | 233 | ||
226 | f. close ( ); | 234 | f. close ( ); |
227 | } | 235 | } |
228 | 236 | ||
229 | if ( QFile::exists ( "/etc/familiar-version" )) { | 237 | f. setName ( "/etc/familiar-version" ); |
238 | if ( f. open ( IO_ReadOnly )) { | ||
230 | d-> m_systemstr = "Familiar"; | 239 | d-> m_systemstr = "Familiar"; |
231 | d-> m_system = OSYSTEM_Familiar; | 240 | d-> m_system = OSYSTEM_Familiar; |
241 | |||
242 | QTextStream ts ( &f ); | ||
243 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | ||
244 | |||
245 | f. close ( ); | ||
232 | } | 246 | } |
233 | 247 | ||
234 | d-> m_leds [0] = OLED_Off; | 248 | d-> m_leds [0] = OLED_Off; |
235 | } | 249 | } |
236 | 250 | ||
237 | #include <unistd.h> | 251 | #include <unistd.h> |
238 | #include <fcntl.h> | 252 | #include <fcntl.h> |
239 | #include <sys/ioctl.h> | 253 | #include <sys/ioctl.h> |
240 | #include <linux/soundcard.h> | 254 | #include <linux/soundcard.h> |
241 | #include <qapplication.h> | 255 | #include <qapplication.h> |
242 | #include <qpe/config.h> | 256 | #include <qpe/config.h> |
243 | 257 | ||
244 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 258 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
245 | 259 | ||
246 | typedef struct h3600_ts_led { | 260 | typedef struct h3600_ts_led { |
247 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 261 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
248 | unsigned char TotalTime; /* Units of 5 seconds */ | 262 | unsigned char TotalTime; /* Units of 5 seconds */ |
249 | unsigned char OnTime; /* units of 100m/s */ | 263 | unsigned char OnTime; /* units of 100m/s */ |
250 | unsigned char OffTime; /* units of 100m/s */ | 264 | unsigned char OffTime; /* units of 100m/s */ |
251 | } LED_IN; | 265 | } LED_IN; |
252 | 266 | ||
253 | 267 | ||
254 | // #define IOC_H3600_TS_MAGIC 'f' | 268 | // #define IOC_H3600_TS_MAGIC 'f' |
255 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) | 269 | // #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 :( | 270 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( |
257 | 271 | ||
258 | 272 | ||
259 | void ODeviceIPAQ::alarmSound ( ) | 273 | void ODeviceIPAQ::alarmSound ( ) |
260 | { | 274 | { |
261 | #if defined( QT_QWS_IPAQ ) // IPAQ | 275 | #if defined( QT_QWS_IPAQ ) // IPAQ |
262 | #ifndef QT_NO_SOUND | 276 | #ifndef QT_NO_SOUND |
263 | static Sound snd ( "alarm" ); | 277 | static Sound snd ( "alarm" ); |
264 | int fd; | 278 | int fd; |
265 | int vol; | 279 | int vol; |
266 | bool vol_reset = false; | 280 | bool vol_reset = false; |
267 | 281 | ||
268 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 282 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
269 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 283 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
270 | 284 | ||
271 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 285 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
272 | Config cfg ( "qpe" ); | 286 | Config cfg ( "qpe" ); |
273 | cfg. setGroup ( "Volume" ); | 287 | cfg. setGroup ( "Volume" ); |
274 | 288 | ||
275 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 289 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
276 | if ( volalarm < 0 ) | 290 | if ( volalarm < 0 ) |
277 | volalarm = 0; | 291 | volalarm = 0; |
278 | else if ( volalarm > 100 ) | 292 | else if ( volalarm > 100 ) |
279 | volalarm = 100; | 293 | volalarm = 100; |
280 | volalarm |= ( volalarm << 8 ); | 294 | volalarm |= ( volalarm << 8 ); |
281 | 295 | ||
282 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 296 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
283 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 297 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
284 | vol_reset = true; | 298 | vol_reset = true; |
285 | } | 299 | } |
286 | } | 300 | } |
287 | } | 301 | } |
288 | 302 | ||
289 | snd. play ( ); | 303 | snd. play ( ); |
290 | while ( !snd. isFinished ( )) | 304 | while ( !snd. isFinished ( )) |
291 | qApp-> processEvents ( ); | 305 | qApp-> processEvents ( ); |
292 | 306 | ||
293 | if ( fd >= 0 ) { | 307 | if ( fd >= 0 ) { |
294 | if ( vol_reset ) | 308 | if ( vol_reset ) |
295 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 309 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
296 | ::close ( fd ); | 310 | ::close ( fd ); |
297 | } | 311 | } |
298 | #endif | 312 | #endif |
299 | #endif | 313 | #endif |
300 | } | 314 | } |
301 | 315 | ||
302 | uint ODeviceIPAQ::hasLeds ( ) const | 316 | uint ODeviceIPAQ::hasLeds ( ) const |
303 | { | 317 | { |
304 | return 1; | 318 | return 1; |
305 | } | 319 | } |
306 | 320 | ||
307 | OLedState ODeviceIPAQ::led ( uint which ) const | 321 | OLedState ODeviceIPAQ::led ( uint which ) const |
308 | { | 322 | { |
309 | if ( which == 0 ) | 323 | if ( which == 0 ) |
310 | return d-> m_leds [0]; | 324 | return d-> m_leds [0]; |
311 | else | 325 | else |
312 | return OLED_Off; | 326 | return OLED_Off; |
313 | } | 327 | } |
314 | 328 | ||
315 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) | 329 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) |
316 | { | 330 | { |
317 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); | 331 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); |
318 | 332 | ||
319 | if ( which == 0 ) { | 333 | if ( which == 0 ) { |
320 | if ( fd >= 0 ) { | 334 | if ( fd >= 0 ) { |
321 | struct h3600_ts_led leds; | 335 | struct h3600_ts_led leds; |
322 | ::memset ( &leds, 0, sizeof( leds )); | 336 | ::memset ( &leds, 0, sizeof( leds )); |
323 | leds. TotalTime = 0; | 337 | leds. TotalTime = 0; |
324 | leds. OnTime = 0; | 338 | leds. OnTime = 0; |
325 | leds. OffTime = 1; | 339 | leds. OffTime = 1; |
326 | leds. OffOnBlink = 2; | 340 | leds. OffOnBlink = 2; |
327 | 341 | ||
328 | switch ( st ) { | 342 | switch ( st ) { |
329 | case OLED_Off : leds. OffOnBlink = 0; break; | 343 | case OLED_Off : leds. OffOnBlink = 0; break; |
330 | case OLED_On : leds. OffOnBlink = 1; break; | 344 | case OLED_On : leds. OffOnBlink = 1; break; |
331 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 345 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
332 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 346 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
333 | } | 347 | } |
334 | 348 | ||
335 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 349 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
336 | d-> m_leds [0] = st; | 350 | d-> m_leds [0] = st; |
337 | return true; | 351 | return true; |
338 | } | 352 | } |
339 | } | 353 | } |
340 | } | 354 | } |
341 | return false; | 355 | return false; |
342 | } | 356 | } |
343 | 357 | ||
344 | 358 | ||
345 | //#endif | 359 | //#endif |
346 | 360 | ||
347 | 361 | ||
348 | 362 | ||
349 | 363 | ||
350 | 364 | ||
351 | //#if defined( QT_QWS_EBX ) // Zaurus | 365 | //#if defined( QT_QWS_EBX ) // Zaurus |
352 | 366 | ||
353 | void ODeviceZaurus::init ( ) | 367 | void ODeviceZaurus::init ( ) |
354 | { | 368 | { |
355 | d-> m_modelstr = "Zaurus SL5000"; | 369 | d-> m_modelstr = "Zaurus SL5000"; |
356 | d-> m_model = OMODEL_Zaurus_SL5000; | 370 | d-> m_model = OMODEL_Zaurus_SL5000; |
357 | d-> m_vendorstr = "Sharp"; | 371 | d-> m_vendorstr = "Sharp"; |
358 | d-> m_vendor = OVENDOR_Sharp; | 372 | d-> m_vendor = OVENDOR_Sharp; |
359 | 373 | ||
360 | QFile f ( "/proc/filesystems" ); | 374 | QFile f ( "/proc/filesystems" ); |
361 | 375 | ||
362 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 376 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
363 | d-> m_systemstr = "OpenZaurus"; | 377 | d-> m_systemstr = "OpenZaurus"; |
364 | d-> m_system = OSYSTEM_OpenZaurus; | 378 | d-> m_system = OSYSTEM_OpenZaurus; |
365 | 379 | ||
366 | f. close ( ); | 380 | f. close ( ); |
367 | } | 381 | } |
368 | else { | 382 | else { |
369 | d-> m_systemstr = "Zaurus"; | 383 | d-> m_systemstr = "Zaurus"; |
370 | d-> m_system = OSYSTEM_Zaurus; | 384 | d-> m_system = OSYSTEM_Zaurus; |
371 | } | 385 | } |
372 | 386 | ||
373 | d-> m_leds [0] = OLED_Off; | 387 | d-> m_leds [0] = OLED_Off; |
374 | } | 388 | } |
375 | 389 | ||
376 | #include <unistd.h> | 390 | #include <unistd.h> |
377 | #include <fcntl.h> | 391 | #include <fcntl.h> |
378 | #include <sys/ioctl.h> | 392 | #include <sys/ioctl.h> |
379 | 393 | ||
380 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 394 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
381 | 395 | ||
382 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 396 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
383 | 397 | ||
384 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 398 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
385 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 399 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
386 | 400 | ||
387 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 401 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
388 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 402 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
389 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 403 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
390 | 404 | ||
391 | /* --- for SHARP_BUZZER device --- */ | 405 | /* --- for SHARP_BUZZER device --- */ |
392 | 406 | ||
393 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 407 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
394 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 408 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
395 | 409 | ||
396 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 410 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
397 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 411 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
398 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 412 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
399 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 413 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
400 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 414 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
401 | 415 | ||
402 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 416 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
403 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 417 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
404 | 418 | ||
405 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 419 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
406 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 420 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
407 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 421 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
408 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 422 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
409 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 423 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
410 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 424 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
411 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 425 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
412 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 426 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
413 | 427 | ||
414 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 428 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
415 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 429 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
416 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 430 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
417 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 431 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
418 | // | 432 | // |
419 | 433 | ||
420 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 434 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
421 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 435 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
422 | 436 | ||
423 | typedef struct sharp_led_status { | 437 | typedef struct sharp_led_status { |
424 | int which; /* select which LED status is wanted. */ | 438 | int which; /* select which LED status is wanted. */ |
425 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 439 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
426 | } sharp_led_status; | 440 | } sharp_led_status; |
427 | 441 | ||
428 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 442 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
429 | 443 | ||
430 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 444 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
431 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 445 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
432 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 446 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
433 | 447 | ||
434 | 448 | ||
435 | 449 | ||
436 | void ODeviceZaurus::buzzer ( int sound ) | 450 | void ODeviceZaurus::buzzer ( int sound ) |
437 | { | 451 | { |
438 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 452 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
439 | 453 | ||
440 | if ( fd >= 0 ) | 454 | if ( fd >= 0 ) |
441 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 455 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
442 | } | 456 | } |
443 | 457 | ||
444 | 458 | ||
445 | void ODeviceZaurus::alarmSound ( ) | 459 | void ODeviceZaurus::alarmSound ( ) |
446 | { | 460 | { |
447 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 461 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
448 | } | 462 | } |
449 | 463 | ||
450 | void ODeviceZaurus::touchSound ( ) | 464 | void ODeviceZaurus::touchSound ( ) |
451 | { | 465 | { |
452 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 466 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
453 | } | 467 | } |
454 | 468 | ||
455 | void ODeviceZaurus::keySound ( ) | 469 | void ODeviceZaurus::keySound ( ) |
456 | { | 470 | { |
457 | buzzer ( SHARP_BUZ_KEYSOUND ); | 471 | buzzer ( SHARP_BUZ_KEYSOUND ); |
458 | } | 472 | } |
459 | 473 | ||
460 | 474 | ||
461 | uint ODeviceZaurus::hasLeds ( ) const | 475 | uint ODeviceZaurus::hasLeds ( ) const |
462 | { | 476 | { |
463 | return 1; | 477 | return 1; |
464 | } | 478 | } |
465 | 479 | ||
466 | OLedState ODeviceZaurus::led ( uint which ) const | 480 | OLedState ODeviceZaurus::led ( uint which ) const |
467 | { | 481 | { |
468 | if ( which == 0 ) | 482 | if ( which == 0 ) |
469 | return d-> m_leds [0]; | 483 | return d-> m_leds [0]; |
470 | else | 484 | else |
471 | return OLED_Off; | 485 | return OLED_Off; |
472 | } | 486 | } |
473 | 487 | ||
474 | bool ODeviceZaurus::setLed ( uint which, OLedState st ) | 488 | bool ODeviceZaurus::setLed ( uint which, OLedState st ) |
475 | { | 489 | { |
476 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 490 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
477 | 491 | ||
478 | if ( which == 0 ) { | 492 | if ( which == 0 ) { |
479 | if ( fd >= 0 ) { | 493 | if ( fd >= 0 ) { |
480 | struct sharp_led_status leds; | 494 | struct sharp_led_status leds; |
481 | ::memset ( &leds, 0, sizeof( leds )); | 495 | ::memset ( &leds, 0, sizeof( leds )); |
482 | leds. which = SHARP_LED_MAIL_EXISTS; | 496 | leds. which = SHARP_LED_MAIL_EXISTS; |
483 | 497 | ||
484 | switch ( st ) { | 498 | switch ( st ) { |
485 | case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 499 | case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
486 | case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 500 | case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
487 | case OLED_BlinkSlow: | 501 | case OLED_BlinkSlow: |
488 | case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 502 | case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
489 | } | 503 | } |
490 | 504 | ||
491 | if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { | 505 | if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { |
492 | d-> m_leds [0] = st; | 506 | d-> m_leds [0] = st; |
493 | return true; | 507 | return true; |
494 | } | 508 | } |
495 | } | 509 | } |
496 | } | 510 | } |
497 | return false; | 511 | return false; |
498 | } | 512 | } |
499 | 513 | ||
500 | //#endif | 514 | //#endif |
diff --git a/libopie/odevice.h b/libopie/odevice.h index b40abe7..b54e576 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,107 +1,108 @@ | |||
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 | QString systemVersionString ( ); | ||
81 | 82 | ||
82 | // input / output | 83 | // input / output |
83 | 84 | ||
84 | virtual void alarmSound ( ); | 85 | virtual void alarmSound ( ); |
85 | virtual void keySound ( ); | 86 | virtual void keySound ( ); |
86 | virtual void touchSound ( ); | 87 | virtual void touchSound ( ); |
87 | 88 | ||
88 | virtual uint hasLeds ( ) const; | 89 | virtual uint hasLeds ( ) const; |
89 | virtual OLedState led ( uint which ) const; | 90 | virtual OLedState led ( uint which ) const; |
90 | virtual bool setLed ( uint which, OLedState st ); | 91 | virtual bool setLed ( uint which, OLedState st ); |
91 | 92 | ||
92 | virtual ~ODevice ( ); | 93 | virtual ~ODevice ( ); |
93 | 94 | ||
94 | protected: | 95 | protected: |
95 | ODevice ( ); | 96 | ODevice ( ); |
96 | virtual void init ( ); | 97 | virtual void init ( ); |
97 | 98 | ||
98 | ODeviceData *d; | 99 | ODeviceData *d; |
99 | 100 | ||
100 | private: | 101 | private: |
101 | ODevice ( const ODevice & ); | 102 | ODevice ( const ODevice & ); |
102 | 103 | ||
103 | }; | 104 | }; |
104 | 105 | ||
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | 108 | ||