author | alwin <alwin> | 2004-08-01 10:32:56 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-08-01 10:32:56 (UTC) |
commit | 142d432ef9f8215636a81c358c828d4b6986a6ad (patch) (side-by-side diff) | |
tree | faf33f40f3e19fdd0362256c61e6774ea949f70c | |
parent | 24c8aff75cbb41ccb2acf3de79675c2f4fd7ecc9 (diff) | |
download | opie-142d432ef9f8215636a81c358c828d4b6986a6ad.zip opie-142d432ef9f8215636a81c358c828d4b6986a6ad.tar.gz opie-142d432ef9f8215636a81c358c828d4b6986a6ad.tar.bz2 |
added a keyfilter singleton. All OPIE apps should use that instead of
the base from qte 'cause there are some stupids in handling pointers.
key handlers from odevice-classes will handled at top of all others
iPAQ and SIMPad are switched to that filter queue.
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 55 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 52 | ||||
-rw-r--r-- | libopie2/opiecore/okeyfilter.cpp | 119 | ||||
-rw-r--r-- | libopie2/opiecore/okeyfilter.h | 77 | ||||
-rw-r--r-- | libopie2/opiecore/opiecore.pro | 2 |
5 files changed, 255 insertions, 50 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 16c0538..791e409 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp @@ -1,90 +1,91 @@ /* - This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + This file is part of the Opie Project + Copyright (C) The Opie Team <opie-devel@handhelds.org> =. .=l. - .>+-= - _;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. - : = ...= . :.=- - -. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + .>+-= +_;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. +: = ...= . :.=- +-. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "odevice_ipaq.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> +#include <opie2/okeyfilter.h> /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #endif using namespace Opie::Core; using namespace Opie::Core::Internal; /* KERNEL */ #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) #define OD_IO(type,number) OD_IOC(0,type,number,0) #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) typedef struct { unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ unsigned char TotalTime; /* Units of 5 seconds */ unsigned char OnTime; /* units of 100m/s */ unsigned char OffTime; /* units of 100m/s */ } LED_IN; typedef struct { unsigned char mode; unsigned char pwr; unsigned char brightness; } FLITE_IN; #define LED_ON OD_IOW( 'f', 5, LED_IN ) #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) struct i_button ipaq_buttons [] = { { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), "devicebuttons/ipaq_calendar", "datebook", "nextView()", "today", "raise()" }, { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, @@ -122,98 +123,100 @@ void iPAQ::init(const QString& model) d->m_modelstr = model.mid(model.findRev('H')); if ( d->m_modelstr == "H3100" ) d->m_model = Model_iPAQ_H31xx; else if ( d->m_modelstr == "H3600" ) d->m_model = Model_iPAQ_H36xx; else if ( d->m_modelstr == "H3700" ) d->m_model = Model_iPAQ_H37xx; else if ( d->m_modelstr == "H3800" ) d->m_model = Model_iPAQ_H38xx; else if ( d->m_modelstr == "H3900" ) d->m_model = Model_iPAQ_H39xx; else if ( d->m_modelstr == "H5400" ) d->m_model = Model_iPAQ_H5xxx; else if ( d->m_modelstr == "H2200" ) d->m_model = Model_iPAQ_H22xx; else d->m_model = Model_Unknown; switch ( d->m_model ) { case Model_iPAQ_H31xx: case Model_iPAQ_H38xx: d->m_rotation = Rot90; break; case Model_iPAQ_H5xxx: case Model_iPAQ_H22xx: d->m_rotation = Rot0; break; case Model_iPAQ_H36xx: case Model_iPAQ_H37xx: case Model_iPAQ_H39xx: default: d->m_rotation = Rot270; break; } m_leds [0] = m_leds [1] = Led_Off; m_power_timer = 0; } void iPAQ::initButtons() { if ( d->m_buttons ) return; - if ( isQWS( ) ) - QWSServer::setKeyboardFilter ( this ); + if ( isQWS( ) ) { + Opie::Core::OKeyFilter::inst()->addPreHandler(this); + //QWSServer::setKeyboardFilter ( this ); + } d->m_buttons = new QValueList <ODeviceButton>; for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { i_button *ib = ipaq_buttons + i; ODeviceButton b; if (( ib->model & d->m_model ) == d->m_model ) { b. setKeycode ( ib->code ); b. setUserText ( QObject::tr ( "Button", ib->utext )); b. setPixmap ( Resource::loadPixmap ( ib->pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); d->m_buttons->append ( b ); } } reloadButtonMapping(); QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); } QValueList <OLed> iPAQ::ledList() const { QValueList <OLed> vl; vl << Led_Power; if ( d->m_model == Model_iPAQ_H38xx ) vl << Led_BlueTooth; return vl; } QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const { QValueList <OLedState> vl; if ( l == Led_Power ) vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) vl << Led_Off; // << Led_On << ??? return vl; } OLedState iPAQ::ledState ( OLed l ) const { switch ( l ) { @@ -226,106 +229,106 @@ OLedState iPAQ::ledState ( OLed l ) const } } bool iPAQ::setLedState ( OLed l, OLedState st ) { static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); if ( l == Led_Power ) { if ( fd >= 0 ) { LED_IN leds; ::memset ( &leds, 0, sizeof( leds )); leds. TotalTime = 0; leds. OnTime = 0; leds. OffTime = 1; leds. OffOnBlink = 2; switch ( st ) { case Led_Off : leds. OffOnBlink = 0; break; case Led_On : leds. OffOnBlink = 1; break; case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; } if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { m_leds [0] = st; return true; } } } return false; } bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) { int newkeycode = keycode; switch ( keycode ) { // H38xx/H39xx have no "Q" key anymore - this is now the Mail key case HardKey_Menu: { if (( d->m_model == Model_iPAQ_H38xx ) || ( d->m_model == Model_iPAQ_H39xx ) || ( d->m_model == Model_iPAQ_H5xxx)) { newkeycode = HardKey_Mail; } break; } - // Rotate cursor keys 180° or 270° + // Rotate cursor keys 180 or 270 case Key_Left : case Key_Right: case Key_Up : case Key_Down : { if (( d->m_model == Model_iPAQ_H31xx ) || ( d->m_model == Model_iPAQ_H38xx )) { newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; } - // Rotate the cursor keys by 270° + // Rotate the cursor keys by 270 // keycode - Key_Left = position of the button starting from left clockwise // add the rotation to it and modolo. No we've the original offset // add the offset to the Key_Left key if ( d-> m_model == Model_iPAQ_H5xxx ) newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; break; } // map Power Button short/long press to F34/F35 case Key_SysReq: { if ( isPress ) { if ( m_power_timer ) killTimer ( m_power_timer ); m_power_timer = startTimer ( 500 ); } else if ( m_power_timer ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); } newkeycode = Key_unknown; break; } } if ( newkeycode != keycode ) { if ( newkeycode != Key_unknown ) QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); return true; } else return false; } void iPAQ::timerEvent ( QTimerEvent * ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); } void iPAQ::playAlarmSound() { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); @@ -365,94 +368,94 @@ void iPAQ::playAlarmSound() bool iPAQ::setSoftSuspend ( bool soft ) { bool res = false; int fd; if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) res = true; else ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); ::close ( fd ); } else ::perror ( "/proc/sys/ts/suspend_button_mode" ); return res; } bool iPAQ::setDisplayBrightness ( int bright ) { bool res = false; int fd; if ( bright > 255 ) bright = 255; if ( bright < 0 ) bright = 0; if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { FLITE_IN bl; bl. mode = 1; bl. pwr = bright ? 1 : 0; bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); ::close ( fd ); } return res; } int iPAQ::displayBrightnessResolution() const { switch ( model()) { case Model_iPAQ_H31xx: case Model_iPAQ_H36xx: case Model_iPAQ_H37xx: - return 128; // really 256, but >128 could damage the LCD + return 128; // really 256, but >128 could damage the LCD case Model_iPAQ_H38xx: case Model_iPAQ_H39xx: return 64; case Model_iPAQ_H5xxx: return 255; default: return 2; } } bool iPAQ::hasLightSensor() const { return true; } int iPAQ::readLightSensor() { int fd; int val = -1; if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { char buffer [8]; if ( ::read ( fd, buffer, 5 ) == 5 ) { char *endptr; buffer [4] = 0; val = ::strtol ( buffer + 2, &endptr, 16 ); if ( *endptr != 0 ) val = -1; } ::close ( fd ); } return val; } int iPAQ::lightSensorResolution() const { return 256; } diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index e62ea18..6c3253c 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp @@ -1,90 +1,91 @@ /* - This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + This file is part of the Opie Project + Copyright (C) The Opie Team <opie-devel@handhelds.org> =. .=l. - .>+-= - _;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. - : = ...= . :.=- - -. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + .>+-= +_;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. +: = ...= . :.=- +-. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "odevice_simpad.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> +#include <opie2/okeyfilter.h> /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #endif using namespace Opie::Core; using namespace Opie::Core::Internal; struct s_button simpad_buttons [] = { { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), "devicebuttons/simpad_lower_up", "datebook", "nextView()", "today", "raise()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), "devicebuttons/simpad_lower_down", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), "devicebuttons/simpad_lower_right", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), "devicebuttons/simpad_lower_left", "opiemail", "raise()", "opiemail", "newMail()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), "devicebuttons/simpad_upper_up", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), "devicebuttons/simpad_upper_down", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, @@ -100,170 +101,173 @@ struct s_button simpad_buttons [] = { "QPE/Rotation", "flip()" }, /* { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), "devicebuttons/simpad_lower_upper", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), "devicebuttons/simpad_upper_lower", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, */ }; void SIMpad::init(const QString&) { d->m_vendorstr = "SIEMENS"; d->m_vendor = Vendor_SIEMENS; //TODO Implement model checking //FIXME For now we assume an SL4 d->m_modelstr = "SL4"; d->m_model = Model_SIMpad_SL4; switch ( d->m_model ) { default: d->m_rotation = Rot0; d->m_direction = CCW; d->m_holdtime = 1000; // 1000ms break; } //Distribution detecting code is now in base class m_leds [0] = m_leds [1] = Led_Off; m_power_timer = 0; } void SIMpad::initButtons() { if ( d->m_buttons ) return; - if ( isQWS( ) ) - QWSServer::setKeyboardFilter ( this ); + if ( isQWS( ) ) { + Opie::Core::OKeyFilter::inst()->addPreHandler(this); +// QWSServer::setKeyboardFilter ( this ); + } + d->m_buttons = new QValueList <ODeviceButton>; for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { s_button *sb = simpad_buttons + i; ODeviceButton b; if (( sb->model & d->m_model ) == d->m_model ) { b. setKeycode ( sb->code ); b. setUserText ( QObject::tr ( "Button", sb->utext )); b. setPixmap ( Resource::loadPixmap ( sb->pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); d->m_buttons->append ( b ); } } reloadButtonMapping(); QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); } // SIMpad boardcontrol register CS3 #define SIMPAD_BOARDCONTROL "/proc/cs3" #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA #define SIMPAD_EN1 0x0004 // This is only for EPROM's #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V #define SIMPAD_DISPLAY_ON 0x0010 #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 #define SIMPAD_MQ_RESET 0x0040 #define SIMPAD_PCMCIA_RESET 0x0080 #define SIMPAD_DECT_POWER_ON 0x0100 #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave #define SIMPAD_RS232_ON 0x0400 #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave #define SIMPAD_LED2_ON 0x1000 #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit #define SIMPAD_RESET_SIMCARD 0x8000 //SIMpad touchscreen backlight strength control #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" #define SIMPAD_BACKLIGHT_MASK 0x00a10044 QValueList <OLed> SIMpad::ledList() const { QValueList <OLed> vl; vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? //vl << Led_Mail; //TODO find out if LED1 is accessible anyway return vl; } QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const { QValueList <OLedState> vl; if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? vl << Led_Off << Led_On; //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway //vl << Led_Off; return vl; } OLedState SIMpad::ledState ( OLed l ) const { switch ( l ) { case Led_Power: return m_leds [0]; //case Led_Mail: - // return m_leds [1]; + // return m_leds [1]; default: return Led_Off; } } bool SIMpad::setLedState ( OLed l, OLedState st ) { #if 0 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); /*TODO Implement this like that: read from cs3 && with SIMPAD_LED2_ON write to cs3 */ m_leds [0] = st; return true; } } } #endif return false; } bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) { //TODO return false; } void SIMpad::timerEvent ( QTimerEvent * ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); } void SIMpad::playAlarmSound() { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); int fd; int vol; bool vol_reset = false; diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp new file mode 100644 index 0000000..d806dbd --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.cpp @@ -0,0 +1,119 @@ +/* + This file is part of the Opie Project + =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> + .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> + .>+-= +_;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. +: = ...= . :.=- +-. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "okeyfilter.h" +#include "device/odevice.h" +#include "odebug.h" + +namespace Opie { +namespace Core { + +QValueList<QWSServer::KeyboardFilter*> OKeyFilter::filterList; +QValueList<QWSServer::KeyboardFilter*> OKeyFilter::preFilterList; + +OKeyFilter::OKeyFilter() + :QWSServer::KeyboardFilter() +{ + filterList.clear(); + preFilterList.clear(); + if ( isQWS( ) ) { + QWSServer::setKeyboardFilter ( this ); + } +} + +OKeyFilter::~OKeyFilter() +{ +} + +OKeyFilter* OKeyFilter::inst() +{ + static OKeyFilter*ofilter = 0; + if (!ofilter) { + ofilter = new OKeyFilter; + } + return ofilter; +} + +bool OKeyFilter::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) +{ + QValueList<QWSServer::KeyboardFilter*>::Iterator iter; + for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { + if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { + return true; + } + } + for (iter=filterList.begin();iter!=filterList.end();++iter) { + if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { + return true; + } + } + return false; +} + +void OKeyFilter::addHandler(QWSServer::KeyboardFilter*aF) +{ + if (filterList.find(aF)!=filterList.end()) { + return; + } + odebug << "adding a keyboard filter handler"<<oendl; + filterList.append(aF); +} + +void OKeyFilter::remHandler(QWSServer::KeyboardFilter*aF) +{ + QValueList<QWSServer::KeyboardFilter*>::Iterator iter; + if ( (iter=filterList.find(aF))==filterList.end() ) { + return; + } + odebug << "removing a keyboard filter handler"<<oendl; + filterList.remove(iter); +} + +void OKeyFilter::addPreHandler(QWSServer::KeyboardFilter*aF) +{ + if (preFilterList.find(aF)!=preFilterList.end()) { + return; + } + odebug << "adding a preferred keyboard filter handler"<<oendl; + preFilterList.append(aF); +} + +void OKeyFilter::remPreHandler(QWSServer::KeyboardFilter*aF) +{ + QValueList<QWSServer::KeyboardFilter*>::Iterator iter; + if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { + return; + } + odebug << "removing a preferred keyboard filter handler"<<oendl; + preFilterList.remove(iter); +} + +/* namespace Core */ +} +/* namespace Opie */ +} diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h new file mode 100644 index 0000000..3f9f744 --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.h @@ -0,0 +1,77 @@ +/* + This file is part of the Opie Project + =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> + .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> + .>+-= +_;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. +: = ...= . :.=- +-. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/* QT */ +#include <qwindowsystem_qws.h> +#include <qvaluelist.h> + +namespace Opie { +namespace Core { + class ODevice; +namespace Internal { + class iPAQ; + class SIMpad; +} + +/** + * A singleton which will manage all possible keyboard filters inside opie. + * It makes sure that key handlers of odevice are checked first than the + * keyfilters of software. + * @short a keyfilter proxy + * @see QWSServer::KeyboardFilter + * @author Rajko Albrecht + * @version 1.0 + */ +class OKeyFilter:public QWSServer::KeyboardFilter +{ + friend class Opie::Core::ODevice; + friend class Opie::Core::Internal::iPAQ; + friend class Opie::Core::Internal::SIMpad; + + static QValueList<QWSServer::KeyboardFilter*> filterList; + static QValueList<QWSServer::KeyboardFilter*> preFilterList; + + OKeyFilter(); + OKeyFilter(const OKeyFilter&):QWSServer::KeyboardFilter(){}; + +protected: + void addPreHandler(QWSServer::KeyboardFilter*); + void remPreHandler(QWSServer::KeyboardFilter*); + +public: + virtual ~OKeyFilter(); + virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); + + void addHandler(QWSServer::KeyboardFilter*); + void remHandler(QWSServer::KeyboardFilter*); + + static OKeyFilter*inst(); +}; + +} +} diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index 5056d48..8189a7c 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro @@ -1,57 +1,59 @@ TEMPLATE = lib CONFIG += qt warn_on DESTDIR = $(OPIEDIR)/lib HEADERS = oapplication.h \ oconfig.h \ odebug.h \ oglobal.h \ oglobalsettings.h \ okeyconfigmanager.h \ + okeyfilter.h \ opluginloader.h \ oprocess.h \ oprocctrl.h \ osmartpointer.h \ ostorageinfo.h \ xmltree.h SOURCES = oapplication.cpp \ oconfig.cpp \ odebug.cpp \ oglobal.cpp \ oglobalsettings.cpp \ okeyconfigmanager.cpp \ + okeyfilter.cpp \ opluginloader.cpp \ oprocess.cpp \ oprocctrl.cpp \ ostorageinfo.cpp \ xmltree.cpp # The following files are currently not compileable on mac ! # Therfore I removed them from the build .. (eilers) CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) !contains( CONFTEST, y ) { HEADERS += ofilenotify.h SOURCES += ofilenotify.cpp } else { message( "ofilenotify is not available in a mac build !" ) } include ( device/device.pro ) INTERFACES = TARGET = opiecore2 VERSION = 1.9.1 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include !contains( platform, x11 ) { LIBS = -lqpe include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } |