author | mickeyl <mickeyl> | 2005-08-31 10:21:12 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-08-31 10:21:12 (UTC) |
commit | cde931654d1966be6989e6c8f3cfacb23e6822a2 (patch) (unidiff) | |
tree | 9a8244f4da0180a685554ebca0d7b628630fb42e /libopie2/opiecore/device/odevice_zaurus.cpp | |
parent | 142e7e82efa6dd45884805c34fadec2160225e4b (diff) | |
download | opie-cde931654d1966be6989e6c8f3cfacb23e6822a2.zip opie-cde931654d1966be6989e6c8f3cfacb23e6822a2.tar.gz opie-cde931654d1966be6989e6c8f3cfacb23e6822a2.tar.bz2 |
- add support for the new Switches type in the Linux Input System (coming with 2.6.14)
- use the new Switches support to rewrite the hinge sensor handling on Zaurus models w/ 2.6
- add Switches support to SysInfo, OInputSystem, oinputsystemdemo
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 73 |
1 files changed, 65 insertions, 8 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 33d5cd6..a75f566 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -41,12 +41,14 @@ | |||
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qwindowsystem_qws.h> | 43 | #include <qwindowsystem_qws.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <string.h> | ||
48 | #include <errno.h> | ||
47 | #include <fcntl.h> | 49 | #include <fcntl.h> |
48 | #include <math.h> | 50 | #include <math.h> |
49 | #include <stdlib.h> | 51 | #include <stdlib.h> |
50 | #include <signal.h> | 52 | #include <signal.h> |
51 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
52 | #include <sys/time.h> | 54 | #include <sys/time.h> |
@@ -301,14 +303,16 @@ void Zaurus::initButtons() | |||
301 | buttoncount = ARRAY_SIZE(z_buttons_6000); | 303 | buttoncount = ARRAY_SIZE(z_buttons_6000); |
302 | break; | 304 | break; |
303 | case Model_Zaurus_SLC3100: // fallthrough | 305 | case Model_Zaurus_SLC3100: // fallthrough |
304 | case Model_Zaurus_SLC3000: // fallthrough | 306 | case Model_Zaurus_SLC3000: // fallthrough |
305 | case Model_Zaurus_SLC1000: // fallthrough | 307 | case Model_Zaurus_SLC1000: // fallthrough |
306 | case Model_Zaurus_SLC7x0: | 308 | case Model_Zaurus_SLC7x0: |
307 | if ( isQWS( ) ) { | 309 | if ( isQWS( ) ) |
308 | addPreHandler(this); // hinge-sensor-handler | 310 | { // setup hinge sensor stuff |
311 | addPreHandler(this); | ||
312 | initHingeSensor(); | ||
309 | } | 313 | } |
310 | pz_buttons = z_buttons_c700; | 314 | pz_buttons = z_buttons_c700; |
311 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 315 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
312 | break; | 316 | break; |
313 | default: | 317 | default: |
314 | pz_buttons = z_buttons; | 318 | pz_buttons = z_buttons; |
@@ -659,19 +663,72 @@ OHingeStatus Zaurus::readHingeSensor() const | |||
659 | return CASE_UNKNOWN; | 663 | return CASE_UNKNOWN; |
660 | } | 664 | } |
661 | } | 665 | } |
662 | } | 666 | } |
663 | else | 667 | else |
664 | { | 668 | { |
665 | // corgi keyboard is event source 0 in OZ kernel 2.6 | 669 | /* |
670 | * The corgi keyboard is event source 0 in OZ kernel 2.6. | ||
671 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | ||
672 | * | ||
673 | * ------------------------- | ||
674 | * | SW0 | SW1 | CASE | | ||
675 | * |-----|-----|-----------| | ||
676 | * | 0 0 Landscape | | ||
677 | * | 0 1 Portrait | | ||
678 | * | 1 0 Unknown | | ||
679 | * | 1 1 Closed | | ||
680 | * ------------------------- | ||
681 | */ | ||
666 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 682 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
667 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; | 683 | bool switch0 = true; |
668 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; | 684 | bool switch1 = false; |
669 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; | 685 | if ( keyboard ) |
670 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 686 | { |
671 | return CASE_UNKNOWN; | 687 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
688 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | ||
689 | } | ||
690 | if ( switch0 ) | ||
691 | { | ||
692 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | ||
693 | } | ||
694 | else | ||
695 | { | ||
696 | return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE; | ||
697 | } | ||
698 | } | ||
699 | } | ||
700 | |||
701 | void Zaurus::initHingeSensor() | ||
702 | { | ||
703 | if ( m_embedix ) return; | ||
704 | |||
705 | m_hinge.setName( "/dev/input/event0" ); | ||
706 | if ( !m_hinge.open( IO_ReadOnly ) ) | ||
707 | { | ||
708 | qDebug( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) ); | ||
709 | return; | ||
710 | } | ||
711 | |||
712 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); | ||
713 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); | ||
714 | } | ||
715 | |||
716 | void Zaurus::hingeSensorTriggered() | ||
717 | { | ||
718 | qDebug( "Zaurus::hingeSensorTriggered() - got event" ); | ||
719 | struct input_event e; | ||
720 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) | ||
721 | { | ||
722 | qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); | ||
723 | if ( e.type != EV_SW ) return; | ||
724 | if ( readHingeSensor() != CASE_UNKNOWN ) | ||
725 | { | ||
726 | qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); | ||
727 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); | ||
728 | } | ||
672 | } | 729 | } |
673 | } | 730 | } |
674 | 731 | ||
675 | /* | 732 | /* |
676 | * Take code from iPAQ device. | 733 | * Take code from iPAQ device. |
677 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | 734 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. |