summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/device.pro6
-rw-r--r--libopie2/opiecore/device/odevice.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_beagle.cpp156
-rw-r--r--libopie2/opiecore/device/odevice_beagle.h62
4 files changed, 225 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro
index 946bff1..87a3fd8 100644
--- a/libopie2/opiecore/device/device.pro
+++ b/libopie2/opiecore/device/device.pro
@@ -1,19 +1,23 @@
1HEADERS += device/odevice.h \ 1HEADERS += device/odevice.h \
2 device/odevicebutton.h \ 2 device/odevicebutton.h \
3 device/odevice_beagle.h \
3 device/odevice_ipaq.h \ 4 device/odevice_ipaq.h \
4 device/odevice_jornada.h \ 5 device/odevice_jornada.h \
5 device/odevice_ramses.h \ 6 device/odevice_ramses.h \
6 device/odevice_simpad.h \ 7 device/odevice_simpad.h \
7 device/odevice_zaurus.h \ 8 device/odevice_zaurus.h \
8 device/odevice_yopy.h \ 9 device/odevice_yopy.h \
10 device/odevice_beagle.h
9 11
10SOURCES += device/odevice.cpp \ 12SOURCES += device/odevice.cpp \
11 device/odevicebutton.cpp \ 13 device/odevicebutton.cpp \
14 device/odevice_beagle.cpp \
12 device/odevice_ipaq.cpp \ 15 device/odevice_ipaq.cpp \
13 device/odevice_jornada.cpp\ 16 device/odevice_jornada.cpp\
14 device/odevice_ramses.cpp \ 17 device/odevice_ramses.cpp \
15 device/odevice_simpad.cpp \ 18 device/odevice_simpad.cpp \
16 device/odevice_zaurus.cpp \ 19 device/odevice_zaurus.cpp \
17 device/odevice_yopy.cpp \ 20 device/odevice_yopy.cpp
21
18 22
19 23
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 2355621..2b10034 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,77 +1,78 @@
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) The Opie Team <opie-devel@handhelds.org>
4 =. 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_beagle.h"
30#include "odevice_ipaq.h" 31#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 32#include "odevice_jornada.h"
32#include "odevice_ramses.h" 33#include "odevice_ramses.h"
33#include "odevice_simpad.h" 34#include "odevice_simpad.h"
34#include "odevice_yopy.h" 35#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 36#include "odevice_zaurus.h"
36 37
37/* QT */ 38/* QT */
38#include <qapplication.h> 39#include <qapplication.h>
39#include <qfile.h> 40#include <qfile.h>
40#include <qtextstream.h> 41#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
42 43
43/* OPIE */ 44/* OPIE */
44#include <qpe/config.h> 45#include <qpe/config.h>
45#include <qpe/resource.h> 46#include <qpe/resource.h>
46#include <qpe/sound.h> 47#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 48#include <qpe/qcopenvelope_qws.h>
48#include <qpe/sound.h> 49#include <qpe/sound.h>
49#include <opie2/okeyfilter.h> 50#include <opie2/okeyfilter.h>
50 51
51/* STD */ 52/* STD */
52#include <fcntl.h> 53#include <fcntl.h>
53#include <math.h> 54#include <math.h>
54#include <stdlib.h> 55#include <stdlib.h>
55#include <signal.h> 56#include <signal.h>
56#include <sys/ioctl.h> 57#include <sys/ioctl.h>
57#include <sys/time.h> 58#include <sys/time.h>
58#include <unistd.h> 59#include <unistd.h>
59#ifndef QT_NO_SOUND 60#ifndef QT_NO_SOUND
60#include <linux/soundcard.h> 61#include <linux/soundcard.h>
61#endif 62#endif
62 63
63namespace Opie { 64namespace Opie {
64namespace Core { 65namespace Core {
65 66
66static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 67static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
67 68
68 69
69/* STATIC and common implementation */ 70/* STATIC and common implementation */
70/* EXPORT */ ODistribution distributions[] = { 71/* EXPORT */ ODistribution distributions[] = {
71 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 72 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
72 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 73 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
73 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 74 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
74 { System_Unknown, "Linux", "/etc/issue" }, 75 { System_Unknown, "Linux", "/etc/issue" },
75}; 76};
76 77
77 78
@@ -94,96 +95,97 @@ struct default_button default_buttons [] = {
94 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
95 "devicebuttons/z_calendar", 96 "devicebuttons/z_calendar",
96 "datebook", "nextView()", 97 "datebook", "nextView()",
97 "today", "raise()" }, 98 "today", "raise()" },
98 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
99 "devicebuttons/z_contact", 100 "devicebuttons/z_contact",
100 "addressbook", "raise()", 101 "addressbook", "raise()",
101 "addressbook", "beamBusinessCard()" }, 102 "addressbook", "beamBusinessCard()" },
102 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
103 "devicebuttons/z_home", 104 "devicebuttons/z_home",
104 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
106 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
107 "devicebuttons/z_menu", 108 "devicebuttons/z_menu",
108 "QPE/TaskBar", "toggleMenu()", 109 "QPE/TaskBar", "toggleMenu()",
109 "QPE/TaskBar", "toggleStartMenu()" }, 110 "QPE/TaskBar", "toggleStartMenu()" },
110 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
111 "devicebuttons/z_mail", 112 "devicebuttons/z_mail",
112 "opiemail", "raise()", 113 "opiemail", "raise()",
113 "opiemail", "newMail()" }, 114 "opiemail", "newMail()" },
114}; 115};
115 116
116ODevice *ODevice::inst() 117ODevice *ODevice::inst()
117{ 118{
118 static ODevice *dev = 0; 119 static ODevice *dev = 0;
119 120
120 // rewrite this to only use /proc/cpuinfo or so 121 // rewrite this to only use /proc/cpuinfo or so
121 QString cpu_info; 122 QString cpu_info;
122 123
123 if ( !dev ) 124 if ( !dev )
124 { 125 {
125 QFile f( PATH_PROC_CPUINFO ); 126 QFile f( PATH_PROC_CPUINFO );
126 if ( f.open( IO_ReadOnly ) ) 127 if ( f.open( IO_ReadOnly ) )
127 { 128 {
128 QTextStream s( &f ); 129 QTextStream s( &f );
129 while ( !s.atEnd() ) 130 while ( !s.atEnd() )
130 { 131 {
131 QString line; 132 QString line;
132 line = s.readLine(); 133 line = s.readLine();
133 if ( line.startsWith( "Hardware" ) ) 134 if ( line.startsWith( "Hardware" ) )
134 { 135 {
135 qDebug( "ODevice() - found '%s'", (const char*) line ); 136 qDebug( "ODevice() - found '%s'", (const char*) line );
136 cpu_info = line; 137 cpu_info = line;
137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
142 else qWarning( "ODevice() - unknown hardware - using default." ); 144 else qWarning( "ODevice() - unknown hardware - using default." );
143 break; 145 break;
144 } 146 }
145 } 147 }
146 } 148 }
147 else 149 else
148 { 150 {
149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
150 } 152 }
151 if ( !dev ) dev = new ODevice(); 153 if ( !dev ) dev = new ODevice();
152 dev->init(cpu_info); 154 dev->init(cpu_info);
153 } 155 }
154 return dev; 156 return dev;
155} 157}
156 158
157ODevice::ODevice() 159ODevice::ODevice()
158{ 160{
159 d = new ODeviceData; 161 d = new ODeviceData;
160 162
161 d->m_modelstr = "Unknown"; 163 d->m_modelstr = "Unknown";
162 d->m_model = Model_Unknown; 164 d->m_model = Model_Unknown;
163 d->m_vendorstr = "Unknown"; 165 d->m_vendorstr = "Unknown";
164 d->m_vendor = Vendor_Unknown; 166 d->m_vendor = Vendor_Unknown;
165 d->m_systemstr = "Unknown"; 167 d->m_systemstr = "Unknown";
166 d->m_system = System_Unknown; 168 d->m_system = System_Unknown;
167 d->m_sysverstr = "0.0"; 169 d->m_sysverstr = "0.0";
168 d->m_rotation = Rot0; 170 d->m_rotation = Rot0;
169 d->m_direction = CW; 171 d->m_direction = CW;
170 172
171 d->m_holdtime = 1000; // 1000ms 173 d->m_holdtime = 1000; // 1000ms
172 d->m_buttons = 0; 174 d->m_buttons = 0;
173 d->m_cpu_frequencies = new QStrList; 175 d->m_cpu_frequencies = new QStrList;
174 176
175 177
176 /* mixer */ 178 /* mixer */
177 d->m_sound = d->m_vol = d->m_mixer = -1; 179 d->m_sound = d->m_vol = d->m_mixer = -1;
178 180
179 // New distribution detection code first checks for legacy distributions, 181 // New distribution detection code first checks for legacy distributions,
180 // identified by /etc/familiar-version or /etc/oz_version. 182 // identified by /etc/familiar-version or /etc/oz_version.
181 // Then check for OpenEmbedded and lastly, read /etc/issue 183 // Then check for OpenEmbedded and lastly, read /etc/issue
182 184
183 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 185 for ( unsigned int i = 0; i < sizeof distributions; ++i )
184 { 186 {
185 if ( QFile::exists( distributions[i].sysvfile ) ) 187 if ( QFile::exists( distributions[i].sysvfile ) )
186 { 188 {
187 d->m_systemstr = distributions[i].sysstr; 189 d->m_systemstr = distributions[i].sysstr;
188 d->m_system = distributions[i].system; 190 d->m_system = distributions[i].system;
189 d->m_sysverstr = "<Unknown>"; 191 d->m_sysverstr = "<Unknown>";
@@ -221,97 +223,96 @@ void ODevice::initButtons()
221 d->m_buttons = new QValueList <ODeviceButton>; 223 d->m_buttons = new QValueList <ODeviceButton>;
222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 224 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
223 default_button *db = default_buttons + i; 225 default_button *db = default_buttons + i;
224 ODeviceButton b; 226 ODeviceButton b;
225 b. setKeycode ( db->code ); 227 b. setKeycode ( db->code );
226 b. setUserText ( QObject::tr ( "Button", db->utext )); 228 b. setUserText ( QObject::tr ( "Button", db->utext ));
227 b. setPixmap ( Resource::loadPixmap ( db->pix )); 229 b. setPixmap ( Resource::loadPixmap ( db->pix ));
228 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 230 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
229 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 231 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
230 d->m_buttons->append ( b ); 232 d->m_buttons->append ( b );
231 } 233 }
232 234
233 reloadButtonMapping(); 235 reloadButtonMapping();
234 236
235 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 237 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
236 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 238 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
237} 239}
238 240
239ODevice::~ODevice() 241ODevice::~ODevice()
240{ 242{
241// we leak m_devicebuttons and m_cpu_frequency 243// we leak m_devicebuttons and m_cpu_frequency
242// but it's a singleton and it is not so importantant 244// but it's a singleton and it is not so importantant
243// -zecke 245// -zecke
244 delete d; 246 delete d;
245} 247}
246 248
247bool ODevice::setSoftSuspend ( bool /*soft*/ ) 249bool ODevice::setSoftSuspend ( bool /*soft*/ )
248{ 250{
249 return false; 251 return false;
250} 252}
251 253
252//#include <linux/apm_bios.h> 254//#include <linux/apm_bios.h>
253 255
254#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 256#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
255 257
256/** 258/**
257* This method will try to suspend the device 259* This method will try to suspend the device
258* It only works if the user is the QWS Server and the apm application 260* It only works if the user is the QWS Server and the apm application
259* is installed. 261* is installed.
260* It tries to suspend and then waits some time cause some distributions 262* It tries to suspend and then waits some time cause some distributions
261* do have asynchronus apm implementations. 263* do have asynchronus apm implementations.
262* This method will either fail and return false or it'll suspend the 264* This method will either fail and return false or it'll suspend the
263* device and return once the device got woken up 265* device and return once the device got woken up
264* 266*
265* @return if the device got suspended 267* @return if the device got suspended
266*/ 268*/
267bool ODevice::suspend() 269bool ODevice::suspend()
268{ 270{
269 qDebug("ODevice::suspend");
270 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
271 return false; 272 return false;
272 273
273 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
274 return false; 275 return false;
275 276
276 bool res = false; 277 bool res = false;
277 ODevice::sendSuspendmsg(); 278 ODevice::sendSuspendmsg();
278 279
279 struct timeval tvs, tvn; 280 struct timeval tvs, tvn;
280 ::gettimeofday ( &tvs, 0 ); 281 ::gettimeofday ( &tvs, 0 );
281 282
282 ::sync(); // flush fs caches 283 ::sync(); // flush fs caches
283 res = ( ::system ( "apm --suspend" ) == 0 ); 284 res = ( ::system ( "apm --suspend" ) == 0 );
284 285
285 // This is needed because the iPAQ apm implementation is asynchronous and we 286 // This is needed because the iPAQ apm implementation is asynchronous and we
286 // can not be sure when exactly the device is really suspended 287 // can not be sure when exactly the device is really suspended
287 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
288 289
289 if ( res ) { 290 if ( res ) {
290 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
291 ::usleep ( 200 * 1000 ); 292 ::usleep ( 200 * 1000 );
292 ::gettimeofday ( &tvn, 0 ); 293 ::gettimeofday ( &tvn, 0 );
293 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
294 } 295 }
295 296
296 return res; 297 return res;
297} 298}
298 299
299//#include <linux/fb.h> better not rely on kernel headers in userspace ... 300//#include <linux/fb.h> better not rely on kernel headers in userspace ...
300 301
301#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
302 303
303/* VESA Blanking Levels */ 304/* VESA Blanking Levels */
304#define VESA_NO_BLANKING 0 305#define VESA_NO_BLANKING 0
305#define VESA_VSYNC_SUSPEND 1 306#define VESA_VSYNC_SUSPEND 1
306#define VESA_HSYNC_SUSPEND 2 307#define VESA_HSYNC_SUSPEND 2
307#define VESA_POWERDOWN 3 308#define VESA_POWERDOWN 3
308 309
309/** 310/**
310* This sets the display on or off 311* This sets the display on or off
311*/ 312*/
312bool ODevice::setDisplayStatus ( bool on ) 313bool ODevice::setDisplayStatus ( bool on )
313{ 314{
314 qDebug("ODevice::setDisplayStatus(%d)", on); 315 qDebug("ODevice::setDisplayStatus(%d)", on);
315 316
316 if ( d->m_model == Model_Unknown ) 317 if ( d->m_model == Model_Unknown )
317 return false; 318 return false;
diff --git a/libopie2/opiecore/device/odevice_beagle.cpp b/libopie2/opiecore/device/odevice_beagle.cpp
new file mode 100644
index 0000000..9cf640a
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_beagle.cpp
@@ -0,0 +1,156 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#include "odevicebutton.h"
31#include "odevice_beagle.h"
32
33#include <qpe/resource.h>
34
35#include <sys/types.h>
36#include <sys/ioctl.h>
37#include <fcntl.h>
38#include <unistd.h>
39
40
41
42 #define _SA1100_FL_IOCTL_ON 1
43 #define _SA1100_FL_IOCTL_OFF 2
44 #define _SA1100_FL_IOCTL_INTENSITY3
45#define _SA1100_FL_IOCTL_BACKLIGHT 4
46 #define _SA1100_FL_IOCTL_CONTRAST5
47#define _SA1100_FL_IOCTL_GET_BACKLIGHT 6
48#define _SA1100_FL_IOCTL_GET_CONTRAST 7
49// added by Sean Hsieh
50 #define _SA1100_FL_IOCTL_PWR_TOGGLE 8
51 #define _SA1100_FL_IOCTL_AUTOLIGHT 10
52
53#define FL_MAJOR 60
54#define FL_NAME "sa1100-fl"
55#define FL_FILE "/dev/sa1100-fl"
56
57namespace Opie {
58namespace Core {
59namespace Internal {
60
61struct b_button {
62 uint model;
63 Qt::Key code;
64 char *utext;
65 char *pix;
66 char *fpressedservice;
67 char *fpressedaction;
68 char *fheldservice;
69 char *fheldaction;
70};
71
72struct b_button beagle_buttons [] = {
73 { Model_Beagle_PA100,
74 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
75 "devicebuttons/beagle_calendar",
76 "datebook", "nextView()",
77 "today", "raise()" },
78 { Model_Beagle_PA100,
79 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
80 "devicebuttons/beagle_contact",
81 "addressbook", "raise()",
82 "addressbook", "beamBusinessCard()" },
83 { Model_Beagle_PA100,
84 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
85 "devicebuttons/beagle_todo",
86 "todolist", "raise()",
87 "QPE/TaskBar", "toggleMenu()" },
88 { Model_Beagle_PA100,
89 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
90 "devicebuttons/beagle_home",
91 "QPE/Launcher", "home()",
92 "buttonsettings", "raise()" },
93};
94
95
96Beagle::Beagle()
97{
98 qWarning( "Created Beagle" );
99}
100Beagle::~Beagle() {}
101
102void Beagle::init( const QString&) {
103 /*
104 * No other assabat model yet
105 */
106 d->m_vendorstr = "Tradesquare.NL";
107 d->m_vendor = Vendor_MasterIA;
108 d->m_modelstr = "Tuxpda 1";
109 d->m_rotation = Rot0;
110}
111
112void Beagle::initButtons() {
113 if ( d->m_buttons )
114 return;
115
116 d->m_buttons = new QValueList<ODeviceButton>;
117 uint length = sizeof( beagle_buttons )/ sizeof( b_button );
118 for ( uint i = 0; i < length; ++i ) {
119 b_button *bb = &beagle_buttons[i];
120 ODeviceButton b;
121 b.setKeycode( bb->code );
122 b.setUserText( QObject::tr( "Button", bb->utext ) );
123 b.setPixmap( Resource::loadPixmap( bb->pix ) );
124 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) );
125 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) );
126 d->m_buttons->append( b );
127 }
128
129 reloadButtonMapping();
130}
131
132bool Beagle::setDisplayStatus( bool on ) {
133 int fd = ::open(FL_FILE, O_WRONLY);
134
135 if ( fd < 0 )
136 return false;
137
138 return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == -1 );
139}
140
141int Beagle::displayBrightnessResolution()const {
142 return 100;
143}
144
145bool Beagle::setDisplayBrightness( int brightness ) {
146 int fd = ::open(FL_FILE, O_WRONLY);
147
148 if ( fd < 0 )
149 return false;
150
151 return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness%101 ) == 0 );
152}
153
154}
155}
156}
diff --git a/libopie2/opiecore/device/odevice_beagle.h b/libopie2/opiecore/device/odevice_beagle.h
new file mode 100644
index 0000000..1626330
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_beagle.h
@@ -0,0 +1,62 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef OPIE_CORE_DEVICE_BEAGLE_H
31#define OPIE_CORE_DEVICE_BEAGLE_H
32
33#include "odevice.h"
34
35namespace Opie {
36namespace Core {
37namespace Internal {
38class Beagle : public ODevice {
39 Q_OBJECT
40public:
41 Beagle();
42 ~Beagle();
43
44//@{
45 void init( const QString& init );
46 void initButtons();
47//@}
48
49
50//@{
51 bool setDisplayStatus( bool on );
52 int displayBrightnessResolution()const;
53 bool setDisplayBrightness( int brightness );
54//@}
55
56};
57}
58}
59}
60
61
62#endif