Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

odevice_beagle.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C)2004 The Opie Team <opie-devel@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #include "odevicebutton.h"
00032 #include "odevice_beagle.h"
00033 
00034 #include <opie2/oresource.h>
00035 
00036 #include <sys/types.h>
00037 #include <sys/ioctl.h>
00038 #include <fcntl.h>
00039 #include <unistd.h>
00040 
00041 
00042 /*
00043  * Intel Assabat FrontLight Control
00044  */
00045 #define _SA1100_FL_IOCTL_ON             1
00046 #define _SA1100_FL_IOCTL_OFF            2
00047 #define _SA1100_FL_IOCTL_INTENSITY      3
00048 #define _SA1100_FL_IOCTL_BACKLIGHT  4
00049 #define _SA1100_FL_IOCTL_CONTRAST       5
00050 #define _SA1100_FL_IOCTL_GET_BACKLIGHT  6
00051 #define _SA1100_FL_IOCTL_GET_CONTRAST  7
00052 // added by Sean Hsieh
00053 #define _SA1100_FL_IOCTL_PWR_TOGGLE             8
00054 #define _SA1100_FL_IOCTL_AUTOLIGHT              10
00055 
00056 /*
00057  * The device
00058  */
00059 #define FL_MAJOR   60
00060 #define FL_NAME   "sa1100-fl"
00061 #define FL_FILE   "/dev/sa1100-fl"
00062 
00063 namespace Opie {
00064 namespace Core {
00065 namespace Internal {
00066 
00067 struct b_button {
00068     uint model;
00069     Qt::Key code;
00070     char *utext;
00071     char *pix;
00072     char *fpressedservice;
00073     char *fpressedaction;
00074     char *fheldservice;
00075     char *fheldaction;
00076 };
00077 
00078 
00079 /*
00080  * The MVista Beagle kernel maps the action
00081  * buttons to the Qt keymap
00082  */
00083 struct b_button beagle_buttons [] = {
00084     { Model_Beagle_PA100,
00085       Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Record Button"),
00086       "devicebuttons/beagle_record",
00087       "QPE/VMemo", "toggleRecord()",
00088       "sound", "raise()" },
00089     { Model_Beagle_PA100,
00090       Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
00091       "devicebuttons/beagle_calendar",
00092       "datebook", "nextView()",
00093       "today", "raise()" },
00094     { Model_Beagle_PA100,
00095       Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
00096       "devicebuttons/beagle_contact",
00097       "addressbook", "raise()",
00098       "addressbook", "beamBusinessCard()" },
00099     { Model_Beagle_PA100,
00100       Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
00101       "devicebuttons/beagle_todo",
00102       "todolist", "raise()",
00103       "QPE/TaskBar", "toggleMenu()" },
00104     { Model_Beagle_PA100,
00105       Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
00106       "devicebuttons/beagle_home",
00107       "QPE/Launcher", "home()",
00108       "buttonsettings", "raise()" },
00109 };
00110 
00111 
00112 Beagle::Beagle()  {}
00113 
00114 Beagle::~Beagle() {}
00115 
00116 /*
00117  * Simply set the Tradesquare.NL data
00118  */
00119 void Beagle::init( const QString&) {
00120     /*
00121      * No other assabat model yet
00122      */
00123     d->m_vendorstr = "Tradesquare.NL";
00124     d->m_vendor = Vendor_MasterIA;
00125     d->m_modelstr = "Tuxpda 1";
00126     d->m_rotation = Rot0;
00127     d->m_model = Model_Beagle_PA100;
00128 }
00129 
00130 
00131 /*
00132  * Initialize the Buttons. We only do it
00133  * if not yet initialized.
00134  * We go through our hardware button array
00135  * and set the 'Factory' Pressed and Held Action
00136  * reloadButtonMapping will then apply the user
00137  * configuration to the buttons
00138  */
00139 void Beagle::initButtons() {
00140     if ( d->m_buttons )
00141         return;
00142 
00143     d->m_buttons = new QValueList<ODeviceButton>;
00144     uint length = sizeof( beagle_buttons )/ sizeof( b_button );
00145     for ( uint i = 0; i < length; ++i ) {
00146         b_button *bb = &beagle_buttons[i];
00147         ODeviceButton b;
00148         b.setKeycode( bb->code );
00149         b.setUserText( QObject::tr( "Button", bb->utext ) );
00150         b.setPixmap( OResource::loadPixmap( bb->pix ) );
00151         b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) );
00152         b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) );
00153         d->m_buttons->append( b );
00154     }
00155 
00156     reloadButtonMapping();
00157 }
00158 
00159 /*
00160  * Turn the display on. We do it by ioctl on FL_FILE
00161  */
00162 bool Beagle::setDisplayStatus( bool on ) {
00163     int fd = ::open(FL_FILE, O_WRONLY);
00164 
00165     if ( fd < 0 )
00166         return false;
00167 
00168     return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == 0 );
00169 }
00170 
00171 /*
00172  * 0-100 are legal steps of the frontlight.
00173  */
00174 int Beagle::displayBrightnessResolution()const {
00175     return 100;
00176 }
00177 
00178 /*
00179  * Opie uses the values 0-255 for the frontlight
00180  * intensity and we need to map it to the range
00181  * of 0-100.
00182  * But first we do some sanity of the range of brightness
00183  *
00184  */
00185 bool Beagle::setDisplayBrightness( int brightness ) {
00186     if ( brightness > 255 )
00187         brightness = 255;
00188     else if ( brightness < 0 )
00189         brightness = 0;
00190     brightness = (100*brightness)/255;
00191 
00192     int fd = ::open(FL_FILE, O_WRONLY);
00193 
00194     if ( fd < 0 )
00195         return false;
00196 
00197     return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness ) == 0 );
00198 }
00199 
00200 }
00201 }
00202 }

Generated on Sat Nov 5 16:16:05 2005 for OPIE by  doxygen 1.4.2