author | alwin <alwin> | 2005-03-13 14:47:33 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-13 14:47:33 (UTC) |
commit | 826bc5ef2aa34877fd8816ddfc4156f865dc9149 (patch) (unidiff) | |
tree | 1862353f2954b81a2f1d8b5b522e147a43f46d55 /libopie2/opiecore/device | |
parent | eaec48ce99bc4e2f4e53dbd539a031b3ed993fb3 (diff) | |
download | opie-826bc5ef2aa34877fd8816ddfc4156f865dc9149.zip opie-826bc5ef2aa34877fd8816ddfc4156f865dc9149.tar.gz opie-826bc5ef2aa34877fd8816ddfc4156f865dc9149.tar.bz2 |
inserted a keyevent-filter just used by CL3000 and C7x0/C8x0.
That way I map the cursor keys depending on hinge-status, eg, on portrait
mode scrolling wheel down the cursor key will realy key down and not key left.
If this is the wrong place, please correct and tell me - I had tooked this
idea and code from iPAQ (but it works fine this moment).
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 87 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 50 |
2 files changed, 92 insertions, 45 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,32 +1,32 @@ | |||
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 */ |
@@ -233,16 +233,20 @@ void Zaurus::init(const QString& cpu_info) | |||
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; |
@@ -586,8 +590,47 @@ OHingeStatus Zaurus::readHingeSensor() const | |||
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 | } | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index 6e6ca46..1fb0cd9 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -1,42 +1,45 @@ | |||
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 | #ifndef ODEVICE_ZAURUS | 30 | #ifndef ODEVICE_ZAURUS |
31 | #define ODEVICE_ZAURUS | 31 | #define ODEVICE_ZAURUS |
32 | 32 | ||
33 | #include "odevice_abstractmobiledevice.h" | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | /* QT */ | ||
36 | #include <qwindowsystem_qws.h> | ||
37 | |||
35 | #ifndef ARRAY_SIZE | 38 | #ifndef ARRAY_SIZE |
36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 39 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
37 | #endif | 40 | #endif |
38 | 41 | ||
39 | // _IO and friends are only defined in kernel headers ... | 42 | // _IO and friends are only defined in kernel headers ... |
40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 43 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 44 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 45 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
@@ -86,17 +89,17 @@ | |||
86 | // Vesa Standard | 89 | // Vesa Standard |
87 | #define FB_BLANK_UNBLANK 0 | 90 | #define FB_BLANK_UNBLANK 0 |
88 | #define FB_BLANK_POWERDOWN 4 | 91 | #define FB_BLANK_POWERDOWN 4 |
89 | 92 | ||
90 | namespace Opie { | 93 | namespace Opie { |
91 | namespace Core { | 94 | namespace Core { |
92 | namespace Internal { | 95 | namespace Internal { |
93 | 96 | ||
94 | class Zaurus : public OAbstractMobileDevice | 97 | class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter |
95 | { | 98 | { |
96 | protected: | 99 | protected: |
97 | virtual void init(const QString&); | 100 | virtual void init(const QString&); |
98 | virtual void initButtons(); | 101 | virtual void initButtons(); |
99 | 102 | ||
100 | public: | 103 | public: |
101 | virtual bool setDisplayBrightness( int b ); | 104 | virtual bool setDisplayBrightness( int b ); |
102 | virtual bool setDisplayStatus( bool on ); | 105 | virtual bool setDisplayStatus( bool on ); |
@@ -114,16 +117,17 @@ class Zaurus : public OAbstractMobileDevice | |||
114 | virtual bool hasHingeSensor() const; | 117 | virtual bool hasHingeSensor() const; |
115 | virtual OHingeStatus readHingeSensor() const; | 118 | virtual OHingeStatus readHingeSensor() const; |
116 | 119 | ||
117 | virtual Transformation rotation() const; | 120 | virtual Transformation rotation() const; |
118 | virtual ODirection direction() const; | 121 | virtual ODirection direction() const; |
119 | 122 | ||
120 | protected: | 123 | protected: |
121 | virtual void buzzer( int snd ); | 124 | virtual void buzzer( int snd ); |
125 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
122 | 126 | ||
123 | OLedState m_leds[1]; | 127 | OLedState m_leds[1]; |
124 | bool m_embedix; | 128 | bool m_embedix; |
125 | }; | 129 | }; |
126 | 130 | ||
127 | struct z_button { | 131 | struct z_button { |
128 | Qt::Key code; | 132 | Qt::Key code; |
129 | char *utext; | 133 | char *utext; |