summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-13 14:47:33 (UTC)
committer alwin <alwin>2005-03-13 14:47:33 (UTC)
commit826bc5ef2aa34877fd8816ddfc4156f865dc9149 (patch) (unidiff)
tree1862353f2954b81a2f1d8b5b522e147a43f46d55
parenteaec48ce99bc4e2f4e53dbd539a031b3ed993fb3 (diff)
downloadopie-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).
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp87
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h50
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,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
236void Zaurus::initButtons() 236void 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 */
604bool 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,58 +1,61 @@
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))
43#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 46#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
44#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 47#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
45 48
46// Audio 49// Audio
47#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 50#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
48 51
49#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 52#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
50#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 53#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
51 54
52#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 55#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
53#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 56#define SHARP_BUZ_KEYSOUND 2 /* key sound */
54#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 57#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
55 58
56#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 59#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
57#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 60#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
58#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 61#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
@@ -70,70 +73,71 @@
70 73
71// Rotation and Power Management 74// Rotation and Power Management
72#define SHARP_IOCTL_GET_ROTATION 0x413c 75#define SHARP_IOCTL_GET_ROTATION 0x413c
73 76
74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 77#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 78#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
76#define APM_EVT_POWER_BUTTON (1 << 0) 79#define APM_EVT_POWER_BUTTON (1 << 0)
77 80
78// Brightness Embedix 81// Brightness Embedix
79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 82#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
80#define SHARP_FL_IOCTL_ON 1 83#define SHARP_FL_IOCTL_ON 1
81#define SHARP_FL_IOCTL_OFF 2 84#define SHARP_FL_IOCTL_OFF 2
82#define SHARP_FL_IOCTL_STEP_CONTRAST 100 85#define SHARP_FL_IOCTL_STEP_CONTRAST 100
83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 86#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
84#define SHARP_FL_IOCTL_GET_STEP 102 87#define SHARP_FL_IOCTL_GET_STEP 102
85 88
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
90namespace Opie { 93namespace Opie {
91namespace Core { 94namespace Core {
92namespace Internal { 95namespace Internal {
93 96
94class Zaurus : public OAbstractMobileDevice 97class 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 );
103 virtual int displayBrightnessResolution() const; 106 virtual int displayBrightnessResolution() const;
104 107
105 virtual void playAlarmSound(); 108 virtual void playAlarmSound();
106 virtual void playKeySound(); 109 virtual void playKeySound();
107 virtual void playTouchSound(); 110 virtual void playTouchSound();
108 111
109 virtual QValueList <OLed> ledList() const; 112 virtual QValueList <OLed> ledList() const;
110 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 113 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
111 virtual OLedState ledState( OLed led ) const; 114 virtual OLedState ledState( OLed led ) const;
112 virtual bool setLedState( OLed led, OLedState st ); 115 virtual bool setLedState( OLed led, OLedState st );
113 116
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
127struct z_button { 131struct z_button {
128 Qt::Key code; 132 Qt::Key code;
129 char *utext; 133 char *utext;
130 char *pix; 134 char *pix;
131 char *fpressedservice; 135 char *fpressedservice;
132 char *fpressedaction; 136 char *fpressedaction;
133 char *fheldservice; 137 char *fheldservice;
134 char *fheldaction; 138 char *fheldaction;
135}; 139};
136} 140}
137} 141}
138} 142}
139#endif 143#endif