-rw-r--r-- | libopie/odevice.cpp | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 25c9826..2d2f7db 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -211,225 +211,219 @@ bool ODevice::suspend ( ) | |||
211 | 211 | ||
212 | ::sync ( ); // flush fs caches | 212 | ::sync ( ); // flush fs caches |
213 | 213 | ||
214 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending | 214 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending |
215 | ::close ( fd ); | 215 | ::close ( fd ); |
216 | 216 | ||
217 | if ( res ) { | 217 | if ( res ) { |
218 | // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group | 218 | // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group |
219 | 219 | ||
220 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 220 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
221 | ::usleep ( 200 * 1000 ); | 221 | ::usleep ( 200 * 1000 ); |
222 | ::gettimeofday ( &tvn, 0 ); | 222 | ::gettimeofday ( &tvn, 0 ); |
223 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 223 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
224 | 224 | ||
225 | // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group | 225 | // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group |
226 | } | 226 | } |
227 | 227 | ||
228 | // ::signal ( SIGTSTP, SIG_DFL ); | 228 | // ::signal ( SIGTSTP, SIG_DFL ); |
229 | } | 229 | } |
230 | 230 | ||
231 | return res; | 231 | return res; |
232 | } | 232 | } |
233 | 233 | ||
234 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 234 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
235 | 235 | ||
236 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 236 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
237 | 237 | ||
238 | /* VESA Blanking Levels */ | 238 | /* VESA Blanking Levels */ |
239 | #define VESA_NO_BLANKING 0 | 239 | #define VESA_NO_BLANKING 0 |
240 | #define VESA_VSYNC_SUSPEND 1 | 240 | #define VESA_VSYNC_SUSPEND 1 |
241 | #define VESA_HSYNC_SUSPEND 2 | 241 | #define VESA_HSYNC_SUSPEND 2 |
242 | #define VESA_POWERDOWN 3 | 242 | #define VESA_POWERDOWN 3 |
243 | 243 | ||
244 | 244 | ||
245 | bool ODevice::setDisplayStatus ( bool on ) | 245 | bool ODevice::setDisplayStatus ( bool on ) |
246 | { | 246 | { |
247 | if ( d-> m_model == Model_Unknown ) | 247 | if ( d-> m_model == Model_Unknown ) |
248 | return false; | 248 | return false; |
249 | 249 | ||
250 | bool res = false; | 250 | bool res = false; |
251 | int fd; | 251 | int fd; |
252 | 252 | ||
253 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 253 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
254 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 254 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
255 | ::close ( fd ); | 255 | ::close ( fd ); |
256 | } | 256 | } |
257 | return res; | 257 | return res; |
258 | } | 258 | } |
259 | 259 | ||
260 | bool ODevice::setDisplayBrightness ( int ) | 260 | bool ODevice::setDisplayBrightness ( int ) |
261 | { | 261 | { |
262 | return false; | 262 | return false; |
263 | } | 263 | } |
264 | 264 | ||
265 | int ODevice::displayBrightnessResolution ( ) const | 265 | int ODevice::displayBrightnessResolution ( ) const |
266 | { | 266 | { |
267 | return 16; | 267 | return 16; |
268 | } | 268 | } |
269 | 269 | ||
270 | QString ODevice::vendorString ( ) const | 270 | QString ODevice::vendorString ( ) const |
271 | { | 271 | { |
272 | return d-> m_vendorstr; | 272 | return d-> m_vendorstr; |
273 | } | 273 | } |
274 | 274 | ||
275 | OVendor ODevice::vendor ( ) const | 275 | OVendor ODevice::vendor ( ) const |
276 | { | 276 | { |
277 | return d-> m_vendor; | 277 | return d-> m_vendor; |
278 | } | 278 | } |
279 | 279 | ||
280 | QString ODevice::modelString ( ) const | 280 | QString ODevice::modelString ( ) const |
281 | { | 281 | { |
282 | return d-> m_modelstr; | 282 | return d-> m_modelstr; |
283 | } | 283 | } |
284 | 284 | ||
285 | OModel ODevice::model ( ) const | 285 | OModel ODevice::model ( ) const |
286 | { | 286 | { |
287 | return d-> m_model; | 287 | return d-> m_model; |
288 | } | 288 | } |
289 | 289 | ||
290 | QString ODevice::systemString ( ) const | 290 | QString ODevice::systemString ( ) const |
291 | { | 291 | { |
292 | return d-> m_systemstr; | 292 | return d-> m_systemstr; |
293 | } | 293 | } |
294 | 294 | ||
295 | OSystem ODevice::system ( ) const | 295 | OSystem ODevice::system ( ) const |
296 | { | 296 | { |
297 | return d-> m_system; | 297 | return d-> m_system; |
298 | } | 298 | } |
299 | 299 | ||
300 | QString ODevice::systemVersionString ( ) const | 300 | QString ODevice::systemVersionString ( ) const |
301 | { | 301 | { |
302 | return d-> m_sysverstr; | 302 | return d-> m_sysverstr; |
303 | } | 303 | } |
304 | 304 | ||
305 | void ODevice::alarmSound ( ) | 305 | void ODevice::alarmSound ( ) |
306 | { | 306 | { |
307 | #ifndef QT_QWS_EBX | ||
308 | #ifndef QT_NO_SOUND | 307 | #ifndef QT_NO_SOUND |
309 | static Sound snd ( "alarm" ); | 308 | static Sound snd ( "alarm" ); |
310 | 309 | ||
311 | if ( snd. isFinished ( )) | 310 | if ( snd. isFinished ( )) |
312 | snd. play ( ); | 311 | snd. play ( ); |
313 | #endif | 312 | #endif |
314 | #endif | ||
315 | } | 313 | } |
316 | 314 | ||
317 | void ODevice::keySound ( ) | 315 | void ODevice::keySound ( ) |
318 | { | 316 | { |
319 | #ifndef QT_QWS_EBX | ||
320 | #ifndef QT_NO_SOUND | 317 | #ifndef QT_NO_SOUND |
321 | static Sound snd ( "keysound" ); | 318 | static Sound snd ( "keysound" ); |
322 | 319 | ||
323 | if ( snd. isFinished ( )) | 320 | if ( snd. isFinished ( )) |
324 | snd. play ( ); | 321 | snd. play ( ); |
325 | #endif | 322 | #endif |
326 | #endif | ||
327 | } | 323 | } |
328 | 324 | ||
329 | void ODevice::touchSound ( ) | 325 | void ODevice::touchSound ( ) |
330 | { | 326 | { |
331 | 327 | ||
332 | #ifndef QT_QWS_EBX | ||
333 | #ifndef QT_NO_SOUND | 328 | #ifndef QT_NO_SOUND |
334 | static Sound snd ( "touchsound" ); | 329 | static Sound snd ( "touchsound" ); |
335 | 330 | ||
336 | if ( snd. isFinished ( )) | 331 | if ( snd. isFinished ( )) |
337 | snd. play ( ); | 332 | snd. play ( ); |
338 | #endif | 333 | #endif |
339 | #endif | ||
340 | } | 334 | } |
341 | 335 | ||
342 | 336 | ||
343 | QValueList <OLed> ODevice::ledList ( ) const | 337 | QValueList <OLed> ODevice::ledList ( ) const |
344 | { | 338 | { |
345 | return QValueList <OLed> ( ); | 339 | return QValueList <OLed> ( ); |
346 | } | 340 | } |
347 | 341 | ||
348 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 342 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
349 | { | 343 | { |
350 | return QValueList <OLedState> ( ); | 344 | return QValueList <OLedState> ( ); |
351 | } | 345 | } |
352 | 346 | ||
353 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 347 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
354 | { | 348 | { |
355 | return Led_Off; | 349 | return Led_Off; |
356 | } | 350 | } |
357 | 351 | ||
358 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 352 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
359 | { | 353 | { |
360 | return false; | 354 | return false; |
361 | } | 355 | } |
362 | 356 | ||
363 | bool ODevice::hasLightSensor ( ) const | 357 | bool ODevice::hasLightSensor ( ) const |
364 | { | 358 | { |
365 | return false; | 359 | return false; |
366 | } | 360 | } |
367 | 361 | ||
368 | int ODevice::readLightSensor ( ) | 362 | int ODevice::readLightSensor ( ) |
369 | { | 363 | { |
370 | return -1; | 364 | return -1; |
371 | } | 365 | } |
372 | 366 | ||
373 | int ODevice::lightSensorResolution ( ) const | 367 | int ODevice::lightSensorResolution ( ) const |
374 | { | 368 | { |
375 | return 0; | 369 | return 0; |
376 | } | 370 | } |
377 | 371 | ||
378 | //QValueList <int> ODevice::keyList ( ) const | 372 | //QValueList <int> ODevice::keyList ( ) const |
379 | //{ | 373 | //{ |
380 | //return QValueList <int> ( ); | 374 | //return QValueList <int> ( ); |
381 | //} | 375 | //} |
382 | 376 | ||
383 | 377 | ||
384 | 378 | ||
385 | /************************************************** | 379 | /************************************************** |
386 | * | 380 | * |
387 | * iPAQ | 381 | * iPAQ |
388 | * | 382 | * |
389 | **************************************************/ | 383 | **************************************************/ |
390 | 384 | ||
391 | void iPAQ::init ( ) | 385 | void iPAQ::init ( ) |
392 | { | 386 | { |
393 | d-> m_vendorstr = "HP"; | 387 | d-> m_vendorstr = "HP"; |
394 | d-> m_vendor = Vendor_HP; | 388 | d-> m_vendor = Vendor_HP; |
395 | 389 | ||
396 | QFile f ( "/proc/hal/model" ); | 390 | QFile f ( "/proc/hal/model" ); |
397 | 391 | ||
398 | if ( f. open ( IO_ReadOnly )) { | 392 | if ( f. open ( IO_ReadOnly )) { |
399 | QTextStream ts ( &f ); | 393 | QTextStream ts ( &f ); |
400 | 394 | ||
401 | d-> m_modelstr = "H" + ts. readLine ( ); | 395 | d-> m_modelstr = "H" + ts. readLine ( ); |
402 | 396 | ||
403 | if ( d-> m_modelstr == "H3100" ) | 397 | if ( d-> m_modelstr == "H3100" ) |
404 | d-> m_model = Model_iPAQ_H31xx; | 398 | d-> m_model = Model_iPAQ_H31xx; |
405 | else if ( d-> m_modelstr == "H3600" ) | 399 | else if ( d-> m_modelstr == "H3600" ) |
406 | d-> m_model = Model_iPAQ_H36xx; | 400 | d-> m_model = Model_iPAQ_H36xx; |
407 | else if ( d-> m_modelstr == "H3700" ) | 401 | else if ( d-> m_modelstr == "H3700" ) |
408 | d-> m_model = Model_iPAQ_H37xx; | 402 | d-> m_model = Model_iPAQ_H37xx; |
409 | else if ( d-> m_modelstr == "H3800" ) | 403 | else if ( d-> m_modelstr == "H3800" ) |
410 | d-> m_model = Model_iPAQ_H38xx; | 404 | d-> m_model = Model_iPAQ_H38xx; |
411 | else if ( d-> m_modelstr == "H3900" ) | 405 | else if ( d-> m_modelstr == "H3900" ) |
412 | d-> m_model = Model_iPAQ_H39xx; | 406 | d-> m_model = Model_iPAQ_H39xx; |
413 | else | 407 | else |
414 | d-> m_model = Model_Unknown; | 408 | d-> m_model = Model_Unknown; |
415 | 409 | ||
416 | f. close ( ); | 410 | f. close ( ); |
417 | } | 411 | } |
418 | 412 | ||
419 | f. setName ( "/etc/familiar-version" ); | 413 | f. setName ( "/etc/familiar-version" ); |
420 | if ( f. open ( IO_ReadOnly )) { | 414 | if ( f. open ( IO_ReadOnly )) { |
421 | d-> m_systemstr = "Familiar"; | 415 | d-> m_systemstr = "Familiar"; |
422 | d-> m_system = System_Familiar; | 416 | d-> m_system = System_Familiar; |
423 | 417 | ||
424 | QTextStream ts ( &f ); | 418 | QTextStream ts ( &f ); |
425 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 419 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
426 | 420 | ||
427 | f. close ( ); | 421 | f. close ( ); |
428 | } | 422 | } |
429 | 423 | ||
430 | m_leds [0] = m_leds [1] = Led_Off; | 424 | m_leds [0] = m_leds [1] = Led_Off; |
431 | 425 | ||
432 | m_power_timer = 0; | 426 | m_power_timer = 0; |
433 | 427 | ||
434 | if ( d-> m_qwsserver ) | 428 | if ( d-> m_qwsserver ) |
435 | QWSServer::setKeyboardFilter ( this ); | 429 | QWSServer::setKeyboardFilter ( this ); |
@@ -499,229 +493,227 @@ bool iPAQ::setLedState ( OLed l, OLedState st ) | |||
499 | ::memset ( &leds, 0, sizeof( leds )); | 493 | ::memset ( &leds, 0, sizeof( leds )); |
500 | leds. TotalTime = 0; | 494 | leds. TotalTime = 0; |
501 | leds. OnTime = 0; | 495 | leds. OnTime = 0; |
502 | leds. OffTime = 1; | 496 | leds. OffTime = 1; |
503 | leds. OffOnBlink = 2; | 497 | leds. OffOnBlink = 2; |
504 | 498 | ||
505 | switch ( st ) { | 499 | switch ( st ) { |
506 | case Led_Off : leds. OffOnBlink = 0; break; | 500 | case Led_Off : leds. OffOnBlink = 0; break; |
507 | case Led_On : leds. OffOnBlink = 1; break; | 501 | case Led_On : leds. OffOnBlink = 1; break; |
508 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 502 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
509 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 503 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
510 | } | 504 | } |
511 | 505 | ||
512 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 506 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
513 | m_leds [0] = st; | 507 | m_leds [0] = st; |
514 | return true; | 508 | return true; |
515 | } | 509 | } |
516 | } | 510 | } |
517 | } | 511 | } |
518 | return false; | 512 | return false; |
519 | } | 513 | } |
520 | 514 | ||
521 | 515 | ||
522 | //QValueList <int> iPAQ::keyList ( ) const | 516 | //QValueList <int> iPAQ::keyList ( ) const |
523 | //{ | 517 | //{ |
524 | //QValueList <int> vl; | 518 | //QValueList <int> vl; |
525 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; | 519 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; |
526 | //return vl; | 520 | //return vl; |
527 | //} | 521 | //} |
528 | 522 | ||
529 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 523 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
530 | { | 524 | { |
531 | int newkeycode = keycode; | 525 | int newkeycode = keycode; |
532 | 526 | ||
533 | 527 | ||
534 | // simple susbstitutions | 528 | // simple susbstitutions |
535 | switch ( d-> m_model ) { | 529 | switch ( d-> m_model ) { |
536 | case Model_iPAQ_H38xx: | 530 | case Model_iPAQ_H38xx: |
537 | // H38xx has no "Q" key anymore - this is now the Mail key | 531 | // H38xx has no "Q" key anymore - this is now the Mail key |
538 | if ( keycode == HardKey_Menu ) | 532 | if ( keycode == HardKey_Menu ) |
539 | newkeycode = HardKey_Mail; | 533 | newkeycode = HardKey_Mail; |
540 | //nobreak | 534 | //nobreak |
541 | 535 | ||
542 | case Model_iPAQ_H31xx: | 536 | case Model_iPAQ_H31xx: |
543 | // Rotate cursor keys 180° | 537 | // Rotate cursor keys 180° |
544 | switch ( keycode ) { | 538 | switch ( keycode ) { |
545 | case Key_Left : newkeycode = Key_Right; break; | 539 | case Key_Left : newkeycode = Key_Right; break; |
546 | case Key_Right: newkeycode = Key_Left; break; | 540 | case Key_Right: newkeycode = Key_Left; break; |
547 | case Key_Up : newkeycode = Key_Down; break; | 541 | case Key_Up : newkeycode = Key_Down; break; |
548 | case Key_Down : newkeycode = Key_Up; break; | 542 | case Key_Down : newkeycode = Key_Up; break; |
549 | } | 543 | } |
550 | //nobreak; | 544 | //nobreak; |
551 | 545 | ||
552 | case Model_iPAQ_H36xx: | 546 | case Model_iPAQ_H36xx: |
553 | case Model_iPAQ_H37xx: | 547 | case Model_iPAQ_H37xx: |
554 | // map Power Button short/long press to F34/F35 | 548 | // map Power Button short/long press to F34/F35 |
555 | if ( keycode == Key_SysReq ) { | 549 | if ( keycode == Key_SysReq ) { |
556 | if ( isPress ) { | 550 | if ( isPress ) { |
557 | if ( m_power_timer ) | 551 | if ( m_power_timer ) |
558 | killTimer ( m_power_timer ); | 552 | killTimer ( m_power_timer ); |
559 | m_power_timer = startTimer ( 500 ); | 553 | m_power_timer = startTimer ( 500 ); |
560 | } | 554 | } |
561 | else if ( m_power_timer ) { | 555 | else if ( m_power_timer ) { |
562 | killTimer ( m_power_timer ); | 556 | killTimer ( m_power_timer ); |
563 | m_power_timer = 0; | 557 | m_power_timer = 0; |
564 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 558 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
565 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 559 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
566 | } | 560 | } |
567 | newkeycode = Key_unknown; | 561 | newkeycode = Key_unknown; |
568 | } | 562 | } |
569 | //nobreak; | 563 | //nobreak; |
570 | 564 | ||
571 | default: | 565 | default: |
572 | break; | 566 | break; |
573 | } | 567 | } |
574 | 568 | ||
575 | if ( newkeycode != keycode ) { | 569 | if ( newkeycode != keycode ) { |
576 | if ( newkeycode != Key_unknown ) | 570 | if ( newkeycode != Key_unknown ) |
577 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 571 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
578 | return true; | 572 | return true; |
579 | } | 573 | } |
580 | else | 574 | else |
581 | return false; | 575 | return false; |
582 | } | 576 | } |
583 | 577 | ||
584 | void iPAQ::timerEvent ( QTimerEvent * ) | 578 | void iPAQ::timerEvent ( QTimerEvent * ) |
585 | { | 579 | { |
586 | killTimer ( m_power_timer ); | 580 | killTimer ( m_power_timer ); |
587 | m_power_timer = 0; | 581 | m_power_timer = 0; |
588 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 582 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
589 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 583 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
590 | } | 584 | } |
591 | 585 | ||
592 | 586 | ||
593 | void iPAQ::alarmSound ( ) | 587 | void iPAQ::alarmSound ( ) |
594 | { | 588 | { |
595 | #if defined( QT_QWS_IPAQ ) // IPAQ | ||
596 | #ifndef QT_NO_SOUND | 589 | #ifndef QT_NO_SOUND |
597 | static Sound snd ( "alarm" ); | 590 | static Sound snd ( "alarm" ); |
598 | int fd; | 591 | int fd; |
599 | int vol; | 592 | int vol; |
600 | bool vol_reset = false; | 593 | bool vol_reset = false; |
601 | 594 | ||
602 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 595 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
603 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 596 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
604 | Config cfg ( "qpe" ); | 597 | Config cfg ( "qpe" ); |
605 | cfg. setGroup ( "Volume" ); | 598 | cfg. setGroup ( "Volume" ); |
606 | 599 | ||
607 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 600 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
608 | if ( volalarm < 0 ) | 601 | if ( volalarm < 0 ) |
609 | volalarm = 0; | 602 | volalarm = 0; |
610 | else if ( volalarm > 100 ) | 603 | else if ( volalarm > 100 ) |
611 | volalarm = 100; | 604 | volalarm = 100; |
612 | volalarm |= ( volalarm << 8 ); | 605 | volalarm |= ( volalarm << 8 ); |
613 | 606 | ||
614 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 607 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
615 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 608 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
616 | vol_reset = true; | 609 | vol_reset = true; |
617 | } | 610 | } |
618 | } | 611 | } |
619 | } | 612 | } |
620 | 613 | ||
621 | snd. play ( ); | 614 | snd. play ( ); |
622 | while ( !snd. isFinished ( )) | 615 | while ( !snd. isFinished ( )) |
623 | qApp-> processEvents ( ); | 616 | qApp-> processEvents ( ); |
624 | 617 | ||
625 | if ( fd >= 0 ) { | 618 | if ( fd >= 0 ) { |
626 | if ( vol_reset ) | 619 | if ( vol_reset ) |
627 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 620 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
628 | ::close ( fd ); | 621 | ::close ( fd ); |
629 | } | 622 | } |
630 | #endif | 623 | #endif |
631 | #endif | ||
632 | } | 624 | } |
633 | 625 | ||
634 | 626 | ||
635 | bool iPAQ::setSoftSuspend ( bool soft ) | 627 | bool iPAQ::setSoftSuspend ( bool soft ) |
636 | { | 628 | { |
637 | bool res = false; | 629 | bool res = false; |
638 | int fd; | 630 | int fd; |
639 | 631 | ||
640 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 632 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
641 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 633 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
642 | res = true; | 634 | res = true; |
643 | else | 635 | else |
644 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 636 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
645 | 637 | ||
646 | ::close ( fd ); | 638 | ::close ( fd ); |
647 | } | 639 | } |
648 | else | 640 | else |
649 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 641 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
650 | 642 | ||
651 | return res; | 643 | return res; |
652 | } | 644 | } |
653 | 645 | ||
654 | 646 | ||
655 | bool iPAQ::setDisplayBrightness ( int bright ) | 647 | bool iPAQ::setDisplayBrightness ( int bright ) |
656 | { | 648 | { |
657 | bool res = false; | 649 | bool res = false; |
658 | int fd; | 650 | int fd; |
659 | 651 | ||
660 | if ( bright > 255 ) | 652 | if ( bright > 255 ) |
661 | bright = 255; | 653 | bright = 255; |
662 | if ( bright < 0 ) | 654 | if ( bright < 0 ) |
663 | bright = 0; | 655 | bright = 0; |
664 | 656 | ||
665 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 657 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
666 | FLITE_IN bl; | 658 | FLITE_IN bl; |
667 | bl. mode = 1; | 659 | bl. mode = 1; |
668 | bl. pwr = bright ? 1 : 0; | 660 | bl. pwr = bright ? 1 : 0; |
669 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 661 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
670 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 662 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
671 | ::close ( fd ); | 663 | ::close ( fd ); |
672 | } | 664 | } |
673 | return res; | 665 | return res; |
674 | } | 666 | } |
675 | 667 | ||
676 | int iPAQ::displayBrightnessResolution ( ) const | 668 | int iPAQ::displayBrightnessResolution ( ) const |
677 | { | 669 | { |
678 | switch ( model ( )) { | 670 | switch ( model ( )) { |
679 | case Model_iPAQ_H31xx: | 671 | case Model_iPAQ_H31xx: |
680 | case Model_iPAQ_H36xx: | 672 | case Model_iPAQ_H36xx: |
681 | case Model_iPAQ_H37xx: | 673 | case Model_iPAQ_H37xx: |
682 | return 128; // really 256, but >128 could damage the LCD | 674 | return 128; // really 256, but >128 could damage the LCD |
683 | 675 | ||
684 | case Model_iPAQ_H38xx: | 676 | case Model_iPAQ_H38xx: |
685 | case Model_iPAQ_H39xx: | 677 | case Model_iPAQ_H39xx: |
686 | return 64; | 678 | return 64; |
687 | 679 | ||
688 | default: | 680 | default: |
689 | return 2; | 681 | return 2; |
690 | } | 682 | } |
691 | } | 683 | } |
692 | 684 | ||
693 | 685 | ||
694 | bool iPAQ::hasLightSensor ( ) const | 686 | bool iPAQ::hasLightSensor ( ) const |
695 | { | 687 | { |
696 | return true; | 688 | return true; |
697 | } | 689 | } |
698 | 690 | ||
699 | int iPAQ::readLightSensor ( ) | 691 | int iPAQ::readLightSensor ( ) |
700 | { | 692 | { |
701 | int fd; | 693 | int fd; |
702 | int val = -1; | 694 | int val = -1; |
703 | 695 | ||
704 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 696 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
705 | char buffer [8]; | 697 | char buffer [8]; |
706 | 698 | ||
707 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 699 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
708 | char *endptr; | 700 | char *endptr; |
709 | 701 | ||
710 | buffer [4] = 0; | 702 | buffer [4] = 0; |
711 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 703 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
712 | 704 | ||
713 | if ( *endptr != 0 ) | 705 | if ( *endptr != 0 ) |
714 | val = -1; | 706 | val = -1; |
715 | } | 707 | } |
716 | ::close ( fd ); | 708 | ::close ( fd ); |
717 | } | 709 | } |
718 | 710 | ||
719 | return val; | 711 | return val; |
720 | } | 712 | } |
721 | 713 | ||
722 | int iPAQ::lightSensorResolution ( ) const | 714 | int iPAQ::lightSensorResolution ( ) const |
723 | { | 715 | { |
724 | return 256; | 716 | return 256; |
725 | } | 717 | } |
726 | 718 | ||
727 | /************************************************** | 719 | /************************************************** |