Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 87 |
1 files changed, 65 insertions, 22 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 67dfa41..89b9258 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,48 +1,48 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Â Â Â Â Â Â Â Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 21 | Â : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/oinputsystem.h> | 39 | #include <opie2/oinputsystem.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | #include <math.h> | 47 | #include <math.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
@@ -217,48 +217,52 @@ void Zaurus::init(const QString& cpu_info) | |||
217 | case Model_Zaurus_SLC7x0: | 217 | case Model_Zaurus_SLC7x0: |
218 | d->m_rotation = rotation(); | 218 | d->m_rotation = rotation(); |
219 | d->m_direction = direction(); | 219 | d->m_direction = direction(); |
220 | break; | 220 | break; |
221 | case Model_Zaurus_SLB600: // fallthrough | 221 | case Model_Zaurus_SLB600: // fallthrough |
222 | case Model_Zaurus_SL5000: // fallthrough | 222 | case Model_Zaurus_SL5000: // fallthrough |
223 | case Model_Zaurus_SL5500: // fallthrough | 223 | case Model_Zaurus_SL5500: // fallthrough |
224 | default: | 224 | default: |
225 | d->m_rotation = Rot270; | 225 | d->m_rotation = Rot270; |
226 | break; | 226 | break; |
227 | } | 227 | } |
228 | m_leds[0] = Led_Off; | 228 | m_leds[0] = Led_Off; |
229 | 229 | ||
230 | if ( m_embedix ) | 230 | if ( m_embedix ) |
231 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); | 231 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); |
232 | else | 232 | else |
233 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 233 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
234 | } | 234 | } |
235 | 235 | ||
236 | void Zaurus::initButtons() | 236 | void Zaurus::initButtons() |
237 | { | 237 | { |
238 | if ( d->m_buttons ) | 238 | if ( d->m_buttons ) |
239 | return; | 239 | return; |
240 | 240 | ||
241 | if ( isQWS( ) ) { | ||
242 | addPreHandler(this); | ||
243 | } | ||
244 | |||
241 | d->m_buttons = new QValueList <ODeviceButton>; | 245 | d->m_buttons = new QValueList <ODeviceButton>; |
242 | 246 | ||
243 | struct z_button * pz_buttons; | 247 | struct z_button * pz_buttons; |
244 | int buttoncount; | 248 | int buttoncount; |
245 | switch ( d->m_model ) { | 249 | switch ( d->m_model ) { |
246 | case Model_Zaurus_SLC3000: // fallthrough | 250 | case Model_Zaurus_SLC3000: // fallthrough |
247 | case Model_Zaurus_SLC7x0: | 251 | case Model_Zaurus_SLC7x0: |
248 | pz_buttons = z_buttons_c700; | 252 | pz_buttons = z_buttons_c700; |
249 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 253 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
250 | break; | 254 | break; |
251 | default: | 255 | default: |
252 | pz_buttons = z_buttons; | 256 | pz_buttons = z_buttons; |
253 | buttoncount = ARRAY_SIZE(z_buttons); | 257 | buttoncount = ARRAY_SIZE(z_buttons); |
254 | break; | 258 | break; |
255 | } | 259 | } |
256 | 260 | ||
257 | for ( int i = 0; i < buttoncount; i++ ) { | 261 | for ( int i = 0; i < buttoncount; i++ ) { |
258 | struct z_button *zb = pz_buttons + i; | 262 | struct z_button *zb = pz_buttons + i; |
259 | ODeviceButton b; | 263 | ODeviceButton b; |
260 | 264 | ||
261 | b.setKeycode( zb->code ); | 265 | b.setKeycode( zb->code ); |
262 | b.setUserText( QObject::tr( "Button", zb->utext )); | 266 | b.setUserText( QObject::tr( "Button", zb->utext )); |
263 | b.setPixmap( Resource::loadPixmap( zb->pix )); | 267 | b.setPixmap( Resource::loadPixmap( zb->pix )); |
264 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 268 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
@@ -570,24 +574,63 @@ OHingeStatus Zaurus::readHingeSensor() const | |||
570 | ::close (handle); | 574 | ::close (handle); |
571 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 575 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
572 | { | 576 | { |
573 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 577 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
574 | return static_cast<OHingeStatus>( retval ); | 578 | return static_cast<OHingeStatus>( retval ); |
575 | } | 579 | } |
576 | else | 580 | else |
577 | { | 581 | { |
578 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 582 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
579 | return CASE_UNKNOWN; | 583 | return CASE_UNKNOWN; |
580 | } | 584 | } |
581 | } | 585 | } |
582 | } | 586 | } |
583 | else | 587 | else |
584 | { | 588 | { |
585 | // corgi keyboard is event source 0 in OZ kernel 2.6 | 589 | // corgi keyboard is event source 0 in OZ kernel 2.6 |
586 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 590 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
587 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; | 591 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; |
588 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; | 592 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; |
589 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; | 593 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; |
590 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 594 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
591 | return CASE_UNKNOWN; | 595 | return CASE_UNKNOWN; |
592 | } | 596 | } |
593 | } | 597 | } |
598 | |||
599 | /* | ||
600 | * Take code from iPAQ device. | ||
601 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | ||
602 | * I hope that is ok - Alwin | ||
603 | */ | ||
604 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
605 | { | ||
606 | Transformation rot; | ||
607 | int newkeycode = keycode; | ||
608 | |||
609 | |||
610 | if (d->m_model!=Model_Zaurus_SLC3000 && d->m_model!=Model_Zaurus_SLC7x0) return false; | ||
611 | rot = rotation(); | ||
612 | if (rot==Rot0) return false; | ||
613 | |||
614 | /* map cursor keys depending on the hinge status */ | ||
615 | switch ( keycode ) { | ||
616 | // Rotate cursor keys | ||
617 | case Key_Left : | ||
618 | case Key_Right: | ||
619 | case Key_Up : | ||
620 | case Key_Down : | ||
621 | { | ||
622 | if (rot==Rot90) { | ||
623 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | ||
624 | } | ||
625 | } | ||
626 | break; | ||
627 | |||
628 | } | ||
629 | if (newkeycode!=keycode) { | ||
630 | if ( newkeycode != Key_unknown ) { | ||
631 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | ||
632 | } | ||
633 | return true; | ||
634 | } | ||
635 | return false; | ||
636 | } | ||