author | kergoth <kergoth> | 2003-04-19 20:47:28 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-19 20:47:28 (UTC) |
commit | c502394063598e63591e06072802f1c5a9e0c266 (patch) (side-by-side diff) | |
tree | 66b5e6c888f2370437a399aa8bea7659a04cdb95 | |
parent | eb276a6663540849ef98819eeaa8f935a7e1b945 (diff) | |
download | opie-c502394063598e63591e06072802f1c5a9e0c266.zip opie-c502394063598e63591e06072802f1c5a9e0c266.tar.gz opie-c502394063598e63591e06072802f1c5a9e0c266.tar.bz2 |
Add SL-C700 button handling, so we can handle the keycode for the physical screen rotation.
-rw-r--r-- | libopie/odevice.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 713cc90..cb7dd74 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -10,64 +10,67 @@ 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 <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <signal.h> #include <sys/time.h> #include <linux/soundcard.h> #include <math.h> #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qpe/sound.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include "odevice.h" #include <qwindowsystem_qws.h> +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif // _IO and friends are only defined in kernel headers ... #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)) using namespace Opie; class ODeviceData { public: bool m_qwsserver : 1; QString m_vendorstr; OVendor m_vendor; QString m_modelstr; OModel m_model; QString m_systemstr; OSystem m_system; QString m_sysverstr; Transformation m_rotation; ODirection m_direction; QValueList <ODeviceButton> *m_buttons; uint m_holdtime; @@ -176,64 +179,87 @@ struct i_button { struct z_button { Qt::Key code; char *utext; char *pix; char *fpressedservice; char *fpressedaction; char *fheldservice; char *fheldaction; } z_buttons [] = { { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), "devicebuttons/z_calendar", "datebook", "nextView()", "today", "raise()" }, { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), "devicebuttons/z_contact", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/z_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/z_mail", "mail", "raise()", "mail", "newMail()" }, }; +struct z_button z_buttons_c700 [] = { + { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), + "devicebuttons/z_calendar", + "datebook", "nextView()", + "today", "raise()" }, + { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), + "devicebuttons/z_contact", + "addressbook", "raise()", + "addressbook", "beamBusinessCard()" }, + { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), + "devicebuttons/z_home", + "QPE/Launcher", "home()", + "buttonsettings", "raise()" }, + { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), + "devicebuttons/z_menu", + "QPE/TaskBar", "toggleMenu()", + "QPE/TaskBar", "toggleStartMenu()" }, + { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), + "", + "QPE/Rotation", "flip()", + "QPE/Rotation", "flip()" }, +}; + static QCString makeChannel ( const char *str ) { if ( str && !::strchr ( str, '/' )) return QCString ( "QPE/Application/" ) + str; else return str; } ODevice *ODevice::inst ( ) { static ODevice *dev = 0; if ( !dev ) { if ( QFile::exists ( "/proc/hal/model" )) dev = new iPAQ ( ); else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) dev = new Zaurus ( ); else dev = new ODevice ( ); dev-> init ( ); } return dev; } /************************************************** * * common @@ -1112,105 +1138,118 @@ void Zaurus::init ( ) d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); f. close ( ); } } else { d-> m_systemstr = "Zaurus"; d-> m_system = System_Zaurus; } f. setName ( "/proc/deviceinfo/product" ); if ( f. open ( IO_ReadOnly ) ) { QTextStream ts ( &f ); QString model = ts. readLine ( ); f. close ( ); d-> m_modelstr = QString("Zaurus ") + model; if ( model == "SL-5500" ) d-> m_model = Model_Zaurus_SL5500; else if ( model == "SL-C700" ) d-> m_model = Model_Zaurus_SLC700; else if ( model == "SL-A300" ) d-> m_model = Model_Zaurus_SLA300; else if ( model == "SL-B600" || model == "SL-5600" ) d-> m_model = Model_Zaurus_SLB600; else d-> m_model = Model_Zaurus_SL5000; } else { d-> m_model = Model_Zaurus_SL5000; d-> m_modelstr = "Zaurus (model unknown)"; } + bool flipstate = false; switch ( d-> m_model ) { case Model_Zaurus_SLA300: d-> m_rotation = Rot0; break; case Model_Zaurus_SLC700: - bool flipstate = false; // Note: need to 1) set flipstate based on physical screen orientation // and 2) check to see if the user overrode the rotation direction // using appearance, and if so, remove that item from the Config to // ensure the rotate applet flips us back to the previous state. if ( flipstate ) { // 480x640 d-> m_rotation = Rot0; d-> m_direction = CW; } else { // 640x480 d-> m_rotation = Rot270; d-> m_direction = CCW; } break; case Model_Zaurus_SLB600: case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: default: d-> m_rotation = Rot270; break; } m_leds [0] = Led_Off; } void Zaurus::initButtons ( ) { if ( d-> m_buttons ) return; d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; d-> m_buttons = new QValueList <ODeviceButton>; - for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { - z_button *zb = z_buttons + i; + struct z_button * pz_buttons; + int buttoncount; + switch ( d-> m_model ) { + case Model_Zaurus_SLC700: + pz_buttons = z_buttons_c700; + buttoncount = ARRAY_SIZE(z_buttons_c700); + break; + default: + pz_buttons = z_buttons; + buttoncount = ARRAY_SIZE(z_buttons); + break; + } + + for ( int i = 0; i < buttoncount; i++ ) { + struct z_button *zb = pz_buttons + i; ODeviceButton b; b. setKeycode ( zb-> code ); b. setUserText ( QObject::tr ( "Button", zb-> utext )); b. setPixmap ( Resource::loadPixmap ( zb-> pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> 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 & ))); } #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> //#include <asm/sharp_char.h> // including kernel headers is evil ... #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ #define SHARP_BUZ_KEYSOUND 2 /* key sound */ #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |