summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp72
1 files changed, 35 insertions, 37 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index d8415ad..bc43c52 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -453,170 +453,168 @@ QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
453{ 453{
454 QValueList <OLedState> vl; 454 QValueList <OLedState> vl;
455 455
456 if ( l == Led_Power ) 456 if ( l == Led_Power )
457 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 457 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
458 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 458 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
459 vl << Led_Off; // << Led_On << ??? 459 vl << Led_Off; // << Led_On << ???
460 460
461 return vl; 461 return vl;
462} 462}
463 463
464OLedState iPAQ::ledState ( OLed l ) const 464OLedState iPAQ::ledState ( OLed l ) const
465 { 465 {
466 switch ( l ) { 466 switch ( l ) {
467 case Led_Power: 467 case Led_Power:
468 return m_leds [0]; 468 return m_leds [0];
469 case Led_BlueTooth: 469 case Led_BlueTooth:
470 return m_leds [1]; 470 return m_leds [1];
471 default: 471 default:
472 return Led_Off; 472 return Led_Off;
473 } 473 }
474} 474}
475 475
476bool iPAQ::setLedState ( OLed l, OLedState st ) 476bool iPAQ::setLedState ( OLed l, OLedState st )
477{ 477{
478 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 478 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
479 479
480 if ( l == Led_Power ) { 480 if ( l == Led_Power ) {
481 if ( fd >= 0 ) { 481 if ( fd >= 0 ) {
482 LED_IN leds; 482 LED_IN leds;
483 ::memset ( &leds, 0, sizeof( leds )); 483 ::memset ( &leds, 0, sizeof( leds ));
484 leds. TotalTime = 0; 484 leds. TotalTime = 0;
485 leds. OnTime = 0; 485 leds. OnTime = 0;
486 leds. OffTime = 1; 486 leds. OffTime = 1;
487 leds. OffOnBlink = 2; 487 leds. OffOnBlink = 2;
488 488
489 switch ( st ) { 489 switch ( st ) {
490 case Led_Off : leds. OffOnBlink = 0; break; 490 case Led_Off : leds. OffOnBlink = 0; break;
491 case Led_On : leds. OffOnBlink = 1; break; 491 case Led_On : leds. OffOnBlink = 1; break;
492 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 492 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
493 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 493 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
494 } 494 }
495 495
496 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 496 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
497 m_leds [0] = st; 497 m_leds [0] = st;
498 return true; 498 return true;
499 } 499 }
500 } 500 }
501 } 501 }
502 return false; 502 return false;
503} 503}
504 504
505 505
506//QValueList <int> iPAQ::keyList ( ) const 506//QValueList <int> iPAQ::keyList ( ) const
507//{ 507//{
508 //QValueList <int> vl; 508 //QValueList <int> vl;
509 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; 509 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight;
510 //return vl; 510 //return vl;
511//} 511//}
512 512
513bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 513bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
514{ 514{
515 int newkeycode = keycode; 515 int newkeycode = keycode;
516 516
517 517 switch ( keycode ) {
518 // simple susbstitutions 518 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
519 switch ( d-> m_model ) { 519 case HardKey_Menu: {
520 case Model_iPAQ_H38xx: 520 if (( d-> m_model == Model_iPAQ_H38xx ) ||
521 // H38xx has no "Q" key anymore - this is now the Mail key 521 ( d-> m_model == Model_iPAQ_H39xx )) {
522 if ( keycode == HardKey_Menu )
523 newkeycode = HardKey_Mail; 522 newkeycode = HardKey_Mail;
524 //nobreak
525
526 case Model_iPAQ_H31xx:
527 // Rotate cursor keys 180°
528 switch ( keycode ) {
529 case Key_Left : newkeycode = Key_Right; break;
530 case Key_Right: newkeycode = Key_Left; break;
531 case Key_Up : newkeycode = Key_Down; break;
532 case Key_Down : newkeycode = Key_Up; break;
533 } 523 }
534 //nobreak; 524 break;
535 525 }
536 case Model_iPAQ_H36xx: 526
537 case Model_iPAQ_H37xx: 527 // Rotate cursor keys 180°
538 // map Power Button short/long press to F34/F35 528 case Key_Left :
539 if ( keycode == Key_SysReq ) { 529 case Key_Right:
540 if ( isPress ) { 530 case Key_Up :
541 if ( m_power_timer ) 531 case Key_Down : {
542 killTimer ( m_power_timer ); 532 if (( d-> m_model == Model_iPAQ_H31xx ) ||
543 m_power_timer = startTimer ( 500 ); 533 ( d-> m_model == Model_iPAQ_H38xx )) {
544 } 534 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
545 else if ( m_power_timer ) {
546 killTimer ( m_power_timer );
547 m_power_timer = 0;
548 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
549 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
550 }
551 newkeycode = Key_unknown;
552 } 535 }
553 //nobreak;
554
555 default:
556 break; 536 break;
557 } 537 }
558 538
539 // map Power Button short/long press to F34/F35
540 case Key_SysReq: {
541 if ( isPress ) {
542 if ( m_power_timer )
543 killTimer ( m_power_timer );
544 m_power_timer = startTimer ( 500 );
545 }
546 else if ( m_power_timer ) {
547 killTimer ( m_power_timer );
548 m_power_timer = 0;
549 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
550 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
551 }
552 newkeycode = Key_unknown;
553 break;
554 }
555 }
556
559 if ( newkeycode != keycode ) { 557 if ( newkeycode != keycode ) {
560 if ( newkeycode != Key_unknown ) 558 if ( newkeycode != Key_unknown )
561 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 559 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
562 return true; 560 return true;
563 } 561 }
564 else 562 else
565 return false; 563 return false;
566} 564}
567 565
568void iPAQ::timerEvent ( QTimerEvent * ) 566void iPAQ::timerEvent ( QTimerEvent * )
569{ 567{
570 killTimer ( m_power_timer ); 568 killTimer ( m_power_timer );
571 m_power_timer = 0; 569 m_power_timer = 0;
572 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 570 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
573 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 571 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
574} 572}
575 573
576 574
577void iPAQ::alarmSound ( ) 575void iPAQ::alarmSound ( )
578{ 576{
579#ifndef QT_NO_SOUND 577#ifndef QT_NO_SOUND
580 static Sound snd ( "alarm" ); 578 static Sound snd ( "alarm" );
581 int fd; 579 int fd;
582 int vol; 580 int vol;
583 bool vol_reset = false; 581 bool vol_reset = false;
584 582
585 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 583 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
586 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 584 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
587 Config cfg ( "qpe" ); 585 Config cfg ( "qpe" );
588 cfg. setGroup ( "Volume" ); 586 cfg. setGroup ( "Volume" );
589 587
590 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 588 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
591 if ( volalarm < 0 ) 589 if ( volalarm < 0 )
592 volalarm = 0; 590 volalarm = 0;
593 else if ( volalarm > 100 ) 591 else if ( volalarm > 100 )
594 volalarm = 100; 592 volalarm = 100;
595 volalarm |= ( volalarm << 8 ); 593 volalarm |= ( volalarm << 8 );
596 594
597 if (( volalarm & 0xff ) > ( vol & 0xff )) { 595 if (( volalarm & 0xff ) > ( vol & 0xff )) {
598 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 596 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
599 vol_reset = true; 597 vol_reset = true;
600 } 598 }
601 } 599 }
602 } 600 }
603 601
604 snd. play ( ); 602 snd. play ( );
605 while ( !snd. isFinished ( )) 603 while ( !snd. isFinished ( ))
606 qApp-> processEvents ( ); 604 qApp-> processEvents ( );
607 605
608 if ( fd >= 0 ) { 606 if ( fd >= 0 ) {
609 if ( vol_reset ) 607 if ( vol_reset )
610 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 608 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
611 ::close ( fd ); 609 ::close ( fd );
612 } 610 }
613#endif 611#endif
614} 612}
615 613
616 614
617bool iPAQ::setSoftSuspend ( bool soft ) 615bool iPAQ::setSoftSuspend ( bool soft )
618{ 616{
619 bool res = false; 617 bool res = false;
620 int fd; 618 int fd;
621 619
622 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 620 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {