00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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
00053 #define _SA1100_FL_IOCTL_PWR_TOGGLE 8
00054 #define _SA1100_FL_IOCTL_AUTOLIGHT 10
00055
00056
00057
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
00081
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
00118
00119 void Beagle::init( const QString&) {
00120
00121
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
00133
00134
00135
00136
00137
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
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
00173
00174 int Beagle::displayBrightnessResolution()const {
00175 return 100;
00176 }
00177
00178
00179
00180
00181
00182
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 }