author | zecke <zecke> | 2004-09-21 00:40:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-21 00:40:38 (UTC) |
commit | 97e20b7cc746d5e2822385fc815739853a9c6e2f (patch) (unidiff) | |
tree | 8c72e5148518cd7b11be4ccce3d9e9f9c4c541d5 | |
parent | ee21a12cded5c53f196a5183f39e8069a22ef835 (diff) | |
download | opie-97e20b7cc746d5e2822385fc815739853a9c6e2f.zip opie-97e20b7cc746d5e2822385fc815739853a9c6e2f.tar.gz opie-97e20b7cc746d5e2822385fc815739853a9c6e2f.tar.bz2 |
If sound is not yet finished return and do not try to play
it again.
if(!snd.isFinished())
return;
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 4 |
4 files changed, 8 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 7f5aa7b..6193ddc 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -270,128 +270,130 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
270 | ( d->m_model == Model_iPAQ_H5xxx)) { | 270 | ( d->m_model == Model_iPAQ_H5xxx)) { |
271 | newkeycode = HardKey_Mail; | 271 | newkeycode = HardKey_Mail; |
272 | } | 272 | } |
273 | break; | 273 | break; |
274 | } | 274 | } |
275 | 275 | ||
276 | // Rotate cursor keys 180 or 270 | 276 | // Rotate cursor keys 180 or 270 |
277 | case Key_Left : | 277 | case Key_Left : |
278 | case Key_Right: | 278 | case Key_Right: |
279 | case Key_Up : | 279 | case Key_Up : |
280 | case Key_Down : { | 280 | case Key_Down : { |
281 | if (( d->m_model == Model_iPAQ_H31xx ) || | 281 | if (( d->m_model == Model_iPAQ_H31xx ) || |
282 | ( d->m_model == Model_iPAQ_H38xx )) { | 282 | ( d->m_model == Model_iPAQ_H38xx )) { |
283 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 283 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
284 | } | 284 | } |
285 | // Rotate the cursor keys by 270 | 285 | // Rotate the cursor keys by 270 |
286 | // keycode - Key_Left = position of the button starting from left clockwise | 286 | // keycode - Key_Left = position of the button starting from left clockwise |
287 | // add the rotation to it and modolo. No we've the original offset | 287 | // add the rotation to it and modolo. No we've the original offset |
288 | // add the offset to the Key_Left key | 288 | // add the offset to the Key_Left key |
289 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 289 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
290 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 290 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
291 | break; | 291 | break; |
292 | } | 292 | } |
293 | 293 | ||
294 | // map Power Button short/long press to F34/F35 | 294 | // map Power Button short/long press to F34/F35 |
295 | case Key_SysReq: { | 295 | case Key_SysReq: { |
296 | if ( isPress ) { | 296 | if ( isPress ) { |
297 | if ( m_power_timer ) | 297 | if ( m_power_timer ) |
298 | killTimer ( m_power_timer ); | 298 | killTimer ( m_power_timer ); |
299 | m_power_timer = startTimer ( 500 ); | 299 | m_power_timer = startTimer ( 500 ); |
300 | } | 300 | } |
301 | else if ( m_power_timer ) { | 301 | else if ( m_power_timer ) { |
302 | killTimer ( m_power_timer ); | 302 | killTimer ( m_power_timer ); |
303 | m_power_timer = 0; | 303 | m_power_timer = 0; |
304 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 304 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
305 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 305 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
306 | } | 306 | } |
307 | newkeycode = Key_unknown; | 307 | newkeycode = Key_unknown; |
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | if ( newkeycode != keycode ) { | 312 | if ( newkeycode != keycode ) { |
313 | if ( newkeycode != Key_unknown ) | 313 | if ( newkeycode != Key_unknown ) |
314 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 314 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
315 | return true; | 315 | return true; |
316 | } | 316 | } |
317 | else | 317 | else |
318 | return false; | 318 | return false; |
319 | } | 319 | } |
320 | 320 | ||
321 | void iPAQ::timerEvent ( QTimerEvent * ) | 321 | void iPAQ::timerEvent ( QTimerEvent * ) |
322 | { | 322 | { |
323 | killTimer ( m_power_timer ); | 323 | killTimer ( m_power_timer ); |
324 | m_power_timer = 0; | 324 | m_power_timer = 0; |
325 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 325 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
326 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 326 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void iPAQ::playAlarmSound() | 330 | void iPAQ::playAlarmSound() |
331 | { | 331 | { |
332 | #ifndef QT_NO_SOUND | 332 | #ifndef QT_NO_SOUND |
333 | static Sound snd ( "alarm" ); | 333 | static Sound snd ( "alarm" ); |
334 | if(!snd.isFinished()) | ||
335 | return; | ||
334 | 336 | ||
335 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 337 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
336 | snd. play(); | 338 | snd. play(); |
337 | #endif | 339 | #endif |
338 | } | 340 | } |
339 | 341 | ||
340 | 342 | ||
341 | bool iPAQ::setSoftSuspend ( bool soft ) | 343 | bool iPAQ::setSoftSuspend ( bool soft ) |
342 | { | 344 | { |
343 | bool res = false; | 345 | bool res = false; |
344 | int fd; | 346 | int fd; |
345 | 347 | ||
346 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 348 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
347 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 349 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
348 | res = true; | 350 | res = true; |
349 | else | 351 | else |
350 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 352 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
351 | 353 | ||
352 | ::close ( fd ); | 354 | ::close ( fd ); |
353 | } | 355 | } |
354 | else | 356 | else |
355 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 357 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
356 | 358 | ||
357 | return res; | 359 | return res; |
358 | } | 360 | } |
359 | 361 | ||
360 | 362 | ||
361 | bool iPAQ::setDisplayBrightness ( int bright ) | 363 | bool iPAQ::setDisplayBrightness ( int bright ) |
362 | { | 364 | { |
363 | bool res = false; | 365 | bool res = false; |
364 | int fd; | 366 | int fd; |
365 | 367 | ||
366 | if ( bright > 255 ) | 368 | if ( bright > 255 ) |
367 | bright = 255; | 369 | bright = 255; |
368 | if ( bright < 0 ) | 370 | if ( bright < 0 ) |
369 | bright = 0; | 371 | bright = 0; |
370 | 372 | ||
371 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 373 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
372 | FLITE_IN bl; | 374 | FLITE_IN bl; |
373 | bl. mode = 1; | 375 | bl. mode = 1; |
374 | bl. pwr = bright ? 1 : 0; | 376 | bl. pwr = bright ? 1 : 0; |
375 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 377 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
376 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 378 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
377 | ::close ( fd ); | 379 | ::close ( fd ); |
378 | } | 380 | } |
379 | return res; | 381 | return res; |
380 | } | 382 | } |
381 | 383 | ||
382 | int iPAQ::displayBrightnessResolution() const | 384 | int iPAQ::displayBrightnessResolution() const |
383 | { | 385 | { |
384 | switch ( model()) { | 386 | switch ( model()) { |
385 | case Model_iPAQ_H31xx: | 387 | case Model_iPAQ_H31xx: |
386 | case Model_iPAQ_H36xx: | 388 | case Model_iPAQ_H36xx: |
387 | case Model_iPAQ_H37xx: | 389 | case Model_iPAQ_H37xx: |
388 | return 128; // really 256, but >128 could damage the LCD | 390 | return 128; // really 256, but >128 could damage the LCD |
389 | 391 | ||
390 | case Model_iPAQ_H38xx: | 392 | case Model_iPAQ_H38xx: |
391 | case Model_iPAQ_H39xx: | 393 | case Model_iPAQ_H39xx: |
392 | return 64; | 394 | return 64; |
393 | case Model_iPAQ_H5xxx: | 395 | case Model_iPAQ_H5xxx: |
394 | return 255; | 396 | return 255; |
395 | 397 | ||
396 | default: | 398 | default: |
397 | return 2; | 399 | return 2; |
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp index 0cddf85..c75ea3a 100644 --- a/libopie2/opiecore/device/odevice_ramses.cpp +++ b/libopie2/opiecore/device/odevice_ramses.cpp | |||
@@ -38,128 +38,130 @@ | |||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | using namespace Opie::Core; | 56 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 57 | using namespace Opie::Core::Internal; |
58 | 58 | ||
59 | 59 | ||
60 | void Ramses::init(const QString&) | 60 | void Ramses::init(const QString&) |
61 | { | 61 | { |
62 | d->m_vendorstr = "M und N"; | 62 | d->m_vendorstr = "M und N"; |
63 | d->m_vendor = Vendor_MundN; | 63 | d->m_vendor = Vendor_MundN; |
64 | 64 | ||
65 | // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 | 65 | // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 |
66 | //d->m_modelstr = "Ramses"; | 66 | //d->m_modelstr = "Ramses"; |
67 | //d->m_model = Model_Ramses_MNCI; | 67 | //d->m_model = Model_Ramses_MNCI; |
68 | //d->m_rotation = Rot0; | 68 | //d->m_rotation = Rot0; |
69 | 69 | ||
70 | // all current Hardware, with /proc/sys/board/lcd_type = 2 | 70 | // all current Hardware, with /proc/sys/board/lcd_type = 2 |
71 | d->m_modelstr = "MNCIRX"; | 71 | d->m_modelstr = "MNCIRX"; |
72 | d->m_model = Model_Ramses_MNCIRX; | 72 | d->m_model = Model_Ramses_MNCIRX; |
73 | d->m_rotation = Rot90; | 73 | d->m_rotation = Rot90; |
74 | 74 | ||
75 | d->m_holdtime = 500; | 75 | d->m_holdtime = 500; |
76 | 76 | ||
77 | 77 | ||
78 | // This table is true for a Intel XScale PXA 255 | 78 | // This table is true for a Intel XScale PXA 255 |
79 | 79 | ||
80 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 80 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
81 | #define OC(x...) x | 81 | #define OC(x...) x |
82 | #else | 82 | #else |
83 | #define OC(x...) | 83 | #define OC(x...) |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 86 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
87 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 87 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
88 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 88 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
89 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 89 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
90 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 90 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
91 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 91 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
92 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 92 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
93 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 93 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
94 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 94 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | void Ramses::playAlarmSound() | 98 | void Ramses::playAlarmSound() |
99 | { | 99 | { |
100 | #ifndef QT_NO_SOUND | 100 | #ifndef QT_NO_SOUND |
101 | static Sound snd ( "alarm" ); | 101 | static Sound snd ( "alarm" ); |
102 | if(!snd.isFinished()) | ||
103 | return; | ||
102 | 104 | ||
103 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 105 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
104 | snd.play(); | 106 | snd.play(); |
105 | #else | 107 | #else |
106 | #error QT_NO_SOUND defined | 108 | #error QT_NO_SOUND defined |
107 | #endif | 109 | #endif |
108 | } | 110 | } |
109 | 111 | ||
110 | 112 | ||
111 | bool Ramses::suspend() | 113 | bool Ramses::suspend() |
112 | { | 114 | { |
113 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 115 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
114 | return false; | 116 | return false; |
115 | 117 | ||
116 | sendSuspendmsg(); | 118 | sendSuspendmsg(); |
117 | ::sync(); | 119 | ::sync(); |
118 | 120 | ||
119 | int fd; | 121 | int fd; |
120 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | 122 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { |
121 | char writeCommand[] = "1\n"; | 123 | char writeCommand[] = "1\n"; |
122 | ::write(fd, writeCommand, sizeof(writeCommand) ); | 124 | ::write(fd, writeCommand, sizeof(writeCommand) ); |
123 | ::close(fd); | 125 | ::close(fd); |
124 | } | 126 | } |
125 | 127 | ||
126 | ::usleep ( 200 * 1000 ); | 128 | ::usleep ( 200 * 1000 ); |
127 | return true; | 129 | return true; |
128 | } | 130 | } |
129 | 131 | ||
130 | 132 | ||
131 | bool Ramses::setDisplayBrightness(int bright) | 133 | bool Ramses::setDisplayBrightness(int bright) |
132 | { | 134 | { |
133 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); | 135 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); |
134 | bool res = false; | 136 | bool res = false; |
135 | int fd; | 137 | int fd; |
136 | 138 | ||
137 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 139 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
138 | 140 | ||
139 | if (bright > 255 ) | 141 | if (bright > 255 ) |
140 | bright = 255; | 142 | bright = 255; |
141 | if (bright < 0) | 143 | if (bright < 0) |
142 | bright = 0; | 144 | bright = 0; |
143 | 145 | ||
144 | // Turn backlight completely off if brightness=0 | 146 | // Turn backlight completely off if brightness=0 |
145 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 147 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
146 | char writeCommand[10]; | 148 | char writeCommand[10]; |
147 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 149 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
148 | res = (::write(fd, writeCommand, count) != -1); | 150 | res = (::write(fd, writeCommand, count) != -1); |
149 | ::close(fd); | 151 | ::close(fd); |
150 | } | 152 | } |
151 | 153 | ||
152 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { | 154 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { |
153 | char writeCommand[10]; | 155 | char writeCommand[10]; |
154 | const int count = sprintf(writeCommand, "%d\n", bright); | 156 | const int count = sprintf(writeCommand, "%d\n", bright); |
155 | res = (::write(fd, writeCommand, count) != -1); | 157 | res = (::write(fd, writeCommand, count) != -1); |
156 | ::close(fd); | 158 | ::close(fd); |
157 | } | 159 | } |
158 | return res; | 160 | return res; |
159 | } | 161 | } |
160 | 162 | ||
161 | 163 | ||
162 | int Ramses::displayBrightnessResolution() const | 164 | int Ramses::displayBrightnessResolution() const |
163 | { | 165 | { |
164 | return 32; | 166 | return 32; |
165 | } | 167 | } |
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index fd46b95..34876da 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -258,128 +258,130 @@ static bool setCS3Bit( bool bitset, int bit ) { | |||
258 | 258 | ||
259 | 259 | ||
260 | QValueList <OLed> SIMpad::ledList() const | 260 | QValueList <OLed> SIMpad::ledList() const |
261 | { | 261 | { |
262 | QValueList <OLed> vl; | 262 | QValueList <OLed> vl; |
263 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 263 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
264 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 264 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
265 | return vl; | 265 | return vl; |
266 | } | 266 | } |
267 | 267 | ||
268 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 268 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
269 | { | 269 | { |
270 | QValueList <OLedState> vl; | 270 | QValueList <OLedState> vl; |
271 | 271 | ||
272 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 272 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
273 | vl << Led_Off << Led_On; | 273 | vl << Led_Off << Led_On; |
274 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 274 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
275 | //vl << Led_Off; | 275 | //vl << Led_Off; |
276 | return vl; | 276 | return vl; |
277 | } | 277 | } |
278 | 278 | ||
279 | OLedState SIMpad::ledState ( OLed l ) const | 279 | OLedState SIMpad::ledState ( OLed l ) const |
280 | { | 280 | { |
281 | switch ( l ) { | 281 | switch ( l ) { |
282 | case Led_Power: | 282 | case Led_Power: |
283 | return m_leds [0]; | 283 | return m_leds [0]; |
284 | //case Led_Mail: | 284 | //case Led_Mail: |
285 | // return m_leds [1]; | 285 | // return m_leds [1]; |
286 | default: | 286 | default: |
287 | return Led_Off; | 287 | return Led_Off; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 291 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
292 | { | 292 | { |
293 | if ( l == Led_Power ) { | 293 | if ( l == Led_Power ) { |
294 | m_leds [0] = st; | 294 | m_leds [0] = st; |
295 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); | 295 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); |
296 | return true; | 296 | return true; |
297 | } | 297 | } |
298 | 298 | ||
299 | return false; | 299 | return false; |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) | 303 | bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) |
304 | { | 304 | { |
305 | //TODO | 305 | //TODO |
306 | return false; | 306 | return false; |
307 | } | 307 | } |
308 | 308 | ||
309 | void SIMpad::timerEvent ( QTimerEvent * ) | 309 | void SIMpad::timerEvent ( QTimerEvent * ) |
310 | { | 310 | { |
311 | killTimer ( m_power_timer ); | 311 | killTimer ( m_power_timer ); |
312 | m_power_timer = 0; | 312 | m_power_timer = 0; |
313 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 313 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
314 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 314 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void SIMpad::playAlarmSound() | 318 | void SIMpad::playAlarmSound() |
319 | { | 319 | { |
320 | #ifndef QT_NO_SOUND | 320 | #ifndef QT_NO_SOUND |
321 | static Sound snd ( "alarm" ); | 321 | static Sound snd ( "alarm" ); |
322 | if(!snd.isFinished()) | ||
323 | return; | ||
322 | 324 | ||
323 | /* save as the Sound is static! */ | 325 | /* save as the Sound is static! */ |
324 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 326 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
325 | snd. play(); | 327 | snd. play(); |
326 | #endif | 328 | #endif |
327 | } | 329 | } |
328 | 330 | ||
329 | 331 | ||
330 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 332 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
331 | { | 333 | { |
332 | qDebug( "ODevice for SIMpad: suspend()" ); | 334 | qDebug( "ODevice for SIMpad: suspend()" ); |
333 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 335 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
334 | return false; | 336 | return false; |
335 | 337 | ||
336 | /* | 338 | /* |
337 | * we need to save the screen content | 339 | * we need to save the screen content |
338 | * then go to suspend using ODevice::suspend | 340 | * then go to suspend using ODevice::suspend |
339 | * and finally restore the screen content | 341 | * and finally restore the screen content |
340 | */ | 342 | */ |
341 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); | 343 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); |
342 | bool res = ODevice::suspend(); | 344 | bool res = ODevice::suspend(); |
343 | 345 | ||
344 | /* | 346 | /* |
345 | * restore | 347 | * restore |
346 | */ | 348 | */ |
347 | if ( res ) | 349 | if ( res ) |
348 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); | 350 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); |
349 | 351 | ||
350 | return res; | 352 | return res; |
351 | } | 353 | } |
352 | 354 | ||
353 | 355 | ||
354 | bool SIMpad::setSoftSuspend ( bool soft ) | 356 | bool SIMpad::setSoftSuspend ( bool soft ) |
355 | { | 357 | { |
356 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 358 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
357 | return false; | 359 | return false; |
358 | } | 360 | } |
359 | 361 | ||
360 | 362 | ||
361 | bool SIMpad::setDisplayStatus ( bool on ) | 363 | bool SIMpad::setDisplayStatus ( bool on ) |
362 | { | 364 | { |
363 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 365 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
364 | 366 | ||
365 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); | 367 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); |
366 | } | 368 | } |
367 | 369 | ||
368 | 370 | ||
369 | bool SIMpad::setDisplayBrightness ( int bright ) | 371 | bool SIMpad::setDisplayBrightness ( int bright ) |
370 | { | 372 | { |
371 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 373 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
372 | bool res = false; | 374 | bool res = false; |
373 | int fd; | 375 | int fd; |
374 | 376 | ||
375 | if ( bright > 255 ) | 377 | if ( bright > 255 ) |
376 | bright = 255; | 378 | bright = 255; |
377 | if ( bright < 1 ) | 379 | if ( bright < 1 ) |
378 | bright = 0; | 380 | bright = 0; |
379 | 381 | ||
380 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 382 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
381 | int value = 255 - bright; | 383 | int value = 255 - bright; |
382 | const int mask = SIMPAD_BACKLIGHT_MASK; | 384 | const int mask = SIMPAD_BACKLIGHT_MASK; |
383 | value = value << 8; | 385 | value = value << 8; |
384 | value += mask; | 386 | value += mask; |
385 | char writeCommand[100]; | 387 | char writeCommand[100]; |
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 64fa199..733479e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -284,132 +284,132 @@ void Zaurus::initButtons() | |||
284 | 284 | ||
285 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 285 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
286 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 286 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
287 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 287 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
288 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 288 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
289 | // | 289 | // |
290 | 290 | ||
291 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 291 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
292 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 292 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
293 | 293 | ||
294 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 294 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
295 | 295 | ||
296 | typedef struct sharp_led_status { | 296 | typedef struct sharp_led_status { |
297 | int which; /* select which LED status is wanted. */ | 297 | int which; /* select which LED status is wanted. */ |
298 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 298 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
299 | } sharp_led_status; | 299 | } sharp_led_status; |
300 | 300 | ||
301 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 301 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
302 | 302 | ||
303 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 303 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
304 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 304 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
305 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 305 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
306 | 306 | ||
307 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 307 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
308 | 308 | ||
309 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 309 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
310 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 310 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
311 | #define APM_EVT_POWER_BUTTON (1 << 0) | 311 | #define APM_EVT_POWER_BUTTON (1 << 0) |
312 | 312 | ||
313 | #define FL_IOCTL_STEP_CONTRAST 100 | 313 | #define FL_IOCTL_STEP_CONTRAST 100 |
314 | 314 | ||
315 | 315 | ||
316 | void Zaurus::buzzer ( int sound ) | 316 | void Zaurus::buzzer ( int sound ) |
317 | { | 317 | { |
318 | #ifndef QT_NO_SOUND | 318 | #ifndef QT_NO_SOUND |
319 | Sound *snd = 0; | 319 | Sound *snd = 0; |
320 | 320 | ||
321 | // Not all devices have real sound | 321 | // Not all devices have real sound |
322 | if ( d->m_model == Model_Zaurus_SLC7x0 | 322 | if ( d->m_model == Model_Zaurus_SLC7x0 |
323 | || d->m_model == Model_Zaurus_SLB600 ){ | 323 | || d->m_model == Model_Zaurus_SLB600 ){ |
324 | 324 | ||
325 | switch ( sound ){ | 325 | switch ( sound ){ |
326 | case SHARP_BUZ_TOUCHSOUND: { | 326 | case SHARP_BUZ_TOUCHSOUND: { |
327 | static Sound touch_sound("touchsound"); | 327 | static Sound touch_sound("touchsound"); |
328 | snd = &touch_sound; | 328 | snd = &touch_sound; |
329 | } | 329 | } |
330 | break; | 330 | break; |
331 | case SHARP_BUZ_KEYSOUND: { | 331 | case SHARP_BUZ_KEYSOUND: { |
332 | static Sound key_sound( "keysound" ); | 332 | static Sound key_sound( "keysound" ); |
333 | snd = &key_sound; | 333 | snd = &key_sound; |
334 | } | 334 | } |
335 | break; | 335 | break; |
336 | case SHARP_BUZ_SCHEDULE_ALARM: | 336 | case SHARP_BUZ_SCHEDULE_ALARM: |
337 | default: { | 337 | default: { |
338 | static Sound alarm_sound("alarm"); | 338 | static Sound alarm_sound("alarm"); |
339 | snd = &alarm_sound; | 339 | snd = &alarm_sound; |
340 | } | 340 | } |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | // If a soundname is defined, we expect that this device has | 345 | // If a soundname is defined, we expect that this device has |
346 | // sound capabilities.. Otherwise we expect to have the buzzer | 346 | // sound capabilities.. Otherwise we expect to have the buzzer |
347 | // device.. | 347 | // device.. |
348 | if ( snd ){ | 348 | if ( snd && snd->isFinished() ){ |
349 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 349 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
350 | snd-> play(); | 350 | snd-> play(); |
351 | } else { | 351 | } else if( !snd ) { |
352 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 352 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
353 | 353 | ||
354 | if ( fd >= 0 ) { | 354 | if ( fd >= 0 ) { |
355 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 355 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
356 | ::close ( fd ); | 356 | ::close ( fd ); |
357 | } | 357 | } |
358 | 358 | ||
359 | } | 359 | } |
360 | #endif | 360 | #endif |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void Zaurus::playAlarmSound() | 364 | void Zaurus::playAlarmSound() |
365 | { | 365 | { |
366 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 366 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
367 | } | 367 | } |
368 | 368 | ||
369 | void Zaurus::playTouchSound() | 369 | void Zaurus::playTouchSound() |
370 | { | 370 | { |
371 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 371 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
372 | } | 372 | } |
373 | 373 | ||
374 | void Zaurus::playKeySound() | 374 | void Zaurus::playKeySound() |
375 | { | 375 | { |
376 | buzzer ( SHARP_BUZ_KEYSOUND ); | 376 | buzzer ( SHARP_BUZ_KEYSOUND ); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | QValueList <OLed> Zaurus::ledList() const | 380 | QValueList <OLed> Zaurus::ledList() const |
381 | { | 381 | { |
382 | QValueList <OLed> vl; | 382 | QValueList <OLed> vl; |
383 | vl << Led_Mail; | 383 | vl << Led_Mail; |
384 | return vl; | 384 | return vl; |
385 | } | 385 | } |
386 | 386 | ||
387 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 387 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
388 | { | 388 | { |
389 | QValueList <OLedState> vl; | 389 | QValueList <OLedState> vl; |
390 | 390 | ||
391 | if ( l == Led_Mail ) | 391 | if ( l == Led_Mail ) |
392 | vl << Led_Off << Led_On << Led_BlinkSlow; | 392 | vl << Led_Off << Led_On << Led_BlinkSlow; |
393 | return vl; | 393 | return vl; |
394 | } | 394 | } |
395 | 395 | ||
396 | OLedState Zaurus::ledState ( OLed which ) const | 396 | OLedState Zaurus::ledState ( OLed which ) const |
397 | { | 397 | { |
398 | if ( which == Led_Mail ) | 398 | if ( which == Led_Mail ) |
399 | return m_leds [0]; | 399 | return m_leds [0]; |
400 | else | 400 | else |
401 | return Led_Off; | 401 | return Led_Off; |
402 | } | 402 | } |
403 | 403 | ||
404 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 404 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
405 | { | 405 | { |
406 | if (!m_embedix) // Currently not supported on non_embedix kernels | 406 | if (!m_embedix) // Currently not supported on non_embedix kernels |
407 | return false; | 407 | return false; |
408 | 408 | ||
409 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 409 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
410 | 410 | ||
411 | if ( which == Led_Mail ) { | 411 | if ( which == Led_Mail ) { |
412 | if ( fd >= 0 ) { | 412 | if ( fd >= 0 ) { |
413 | struct sharp_led_status leds; | 413 | struct sharp_led_status leds; |
414 | ::memset ( &leds, 0, sizeof( leds )); | 414 | ::memset ( &leds, 0, sizeof( leds )); |
415 | leds. which = SHARP_LED_MAIL_EXISTS; | 415 | leds. which = SHARP_LED_MAIL_EXISTS; |