summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-22 11:47:08 (UTC)
committer alwin <alwin>2004-04-22 11:47:08 (UTC)
commita95b0c46820c2e9e76598cf430ce279eeba7edb8 (patch) (unidiff)
treeda8073f4a2b4041db0f7ef1cb3ae5e6eb8cb9019
parent2a950511ee173c2cbce5da4d14de9cea6fcd5034 (diff)
downloadopie-a95b0c46820c2e9e76598cf430ce279eeba7edb8.zip
opie-a95b0c46820c2e9e76598cf430ce279eeba7edb8.tar.gz
opie-a95b0c46820c2e9e76598cf430ce279eeba7edb8.tar.bz2
-added default buttons for emulation in qvfb or for unknown devices
-default email app is now opiemail instead of mail
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp33
-rw-r--r--libopie2/opiecore/device/odevice.h15
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
5 files changed, 54 insertions, 6 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index ee66d95..62a2e03 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,527 +1,560 @@
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_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie::Core; 63using namespace Opie::Core;
64 64
65struct default_button default_buttons [] = {
66 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
67 "devicebuttons/z_calendar",
68 "datebook", "nextView()",
69 "today", "raise()" },
70 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
71 "devicebuttons/z_contact",
72 "addressbook", "raise()",
73 "addressbook", "beamBusinessCard()" },
74 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
75 "devicebuttons/z_home",
76 "QPE/Launcher", "home()",
77 "buttonsettings", "raise()" },
78 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
79 "devicebuttons/z_menu",
80 "QPE/TaskBar", "toggleMenu()",
81 "QPE/TaskBar", "toggleStartMenu()" },
82 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
83 "devicebuttons/z_mail",
84 "opiemail", "raise()",
85 "opiemail", "newMail()" },
86};
87
65ODevice *ODevice::inst() 88ODevice *ODevice::inst()
66{ 89{
67 static ODevice *dev = 0; 90 static ODevice *dev = 0;
68 91
69 // rewrite this to only use /proc/cpuinfo or so 92 // rewrite this to only use /proc/cpuinfo or so
70 93
71 if ( !dev ) 94 if ( !dev )
72 { 95 {
73 QFile f( PATH_PROC_CPUINFO ); 96 QFile f( PATH_PROC_CPUINFO );
74 if ( f.open( IO_ReadOnly ) ) 97 if ( f.open( IO_ReadOnly ) )
75 { 98 {
76 QTextStream s( &f ); 99 QTextStream s( &f );
77 while ( !s.atEnd() ) 100 while ( !s.atEnd() )
78 { 101 {
79 QString line; 102 QString line;
80 line = s.readLine(); 103 line = s.readLine();
81 if ( line.startsWith( "Hardware" ) ) 104 if ( line.startsWith( "Hardware" ) )
82 { 105 {
83 qDebug( "ODevice() - found '%s'", (const char*) line ); 106 qDebug( "ODevice() - found '%s'", (const char*) line );
84 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 107 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 108 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 109 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 110 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 111 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
89 else qWarning( "ODevice() - unknown hardware - using default." ); 112 else qWarning( "ODevice() - unknown hardware - using default." );
90 break; 113 break;
91 } 114 }
92 } 115 }
93 } 116 }
94 else 117 else
95 { 118 {
96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 119 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
97 } 120 }
98 if ( !dev ) dev = new ODevice(); 121 if ( !dev ) dev = new ODevice();
99 dev->init(); 122 dev->init();
100 } 123 }
101 return dev; 124 return dev;
102} 125}
103 126
104ODevice::ODevice() 127ODevice::ODevice()
105{ 128{
106 d = new ODeviceData; 129 d = new ODeviceData;
107 130
108 d->m_modelstr = "Unknown"; 131 d->m_modelstr = "Unknown";
109 d->m_model = Model_Unknown; 132 d->m_model = Model_Unknown;
110 d->m_vendorstr = "Unknown"; 133 d->m_vendorstr = "Unknown";
111 d->m_vendor = Vendor_Unknown; 134 d->m_vendor = Vendor_Unknown;
112 d->m_systemstr = "Unknown"; 135 d->m_systemstr = "Unknown";
113 d->m_system = System_Unknown; 136 d->m_system = System_Unknown;
114 d->m_sysverstr = "0.0"; 137 d->m_sysverstr = "0.0";
115 d->m_rotation = Rot0; 138 d->m_rotation = Rot0;
116 d->m_direction = CW; 139 d->m_direction = CW;
117 140
118 d->m_holdtime = 1000; // 1000ms 141 d->m_holdtime = 1000; // 1000ms
119 d->m_buttons = 0; 142 d->m_buttons = 0;
120 d->m_cpu_frequencies = new QStrList; 143 d->m_cpu_frequencies = new QStrList;
121} 144}
122 145
123void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 146void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
124{ 147{
125 if ( msg == "deviceButtonMappingChanged()" ) { 148 if ( msg == "deviceButtonMappingChanged()" ) {
126 reloadButtonMapping(); 149 reloadButtonMapping();
127 } 150 }
128} 151}
129 152
130void ODevice::init() 153void ODevice::init()
131{ 154{
132} 155}
133 156
134/** 157/**
135* This method initialises the button mapping 158* This method initialises the button mapping
136*/ 159*/
137void ODevice::initButtons() 160void ODevice::initButtons()
138{ 161{
139 if ( d->m_buttons ) 162 if ( d->m_buttons )
140 return; 163 return;
141 164
142 qDebug ( "init Buttons" ); 165 qDebug ( "init Buttons" );
143 d->m_buttons = new QValueList <ODeviceButton>; 166 d->m_buttons = new QValueList <ODeviceButton>;
167 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
168 default_button *db = default_buttons + i;
169 ODeviceButton b;
170 b. setKeycode ( db->code );
171 b. setUserText ( QObject::tr ( "Button", db->utext ));
172 b. setPixmap ( Resource::loadPixmap ( db->pix ));
173 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
174 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
175 d->m_buttons->append ( b );
176 }
144 177
145 reloadButtonMapping(); 178 reloadButtonMapping();
146 179
147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 180 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
148 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 181 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
149} 182}
150 183
151ODevice::~ODevice() 184ODevice::~ODevice()
152{ 185{
153// we leak m_devicebuttons and m_cpu_frequency 186// we leak m_devicebuttons and m_cpu_frequency
154// but it's a singleton and it is not so importantant 187// but it's a singleton and it is not so importantant
155// -zecke 188// -zecke
156 delete d; 189 delete d;
157} 190}
158 191
159bool ODevice::setSoftSuspend ( bool /*soft*/ ) 192bool ODevice::setSoftSuspend ( bool /*soft*/ )
160{ 193{
161 return false; 194 return false;
162} 195}
163 196
164//#include <linux/apm_bios.h> 197//#include <linux/apm_bios.h>
165 198
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 199#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 200
168/** 201/**
169* This method will try to suspend the device 202* This method will try to suspend the device
170* It only works if the user is the QWS Server and the apm application 203* It only works if the user is the QWS Server and the apm application
171* is installed. 204* is installed.
172* It tries to suspend and then waits some time cause some distributions 205* It tries to suspend and then waits some time cause some distributions
173* do have asynchronus apm implementations. 206* do have asynchronus apm implementations.
174* This method will either fail and return false or it'll suspend the 207* This method will either fail and return false or it'll suspend the
175* device and return once the device got woken up 208* device and return once the device got woken up
176* 209*
177* @return if the device got suspended 210* @return if the device got suspended
178*/ 211*/
179bool ODevice::suspend() 212bool ODevice::suspend()
180{ 213{
181 qDebug("ODevice::suspend"); 214 qDebug("ODevice::suspend");
182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 215 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
183 return false; 216 return false;
184 217
185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 218 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
186 return false; 219 return false;
187 220
188 bool res = false; 221 bool res = false;
189 ODevice::sendSuspendmsg(); 222 ODevice::sendSuspendmsg();
190 223
191 struct timeval tvs, tvn; 224 struct timeval tvs, tvn;
192 ::gettimeofday ( &tvs, 0 ); 225 ::gettimeofday ( &tvs, 0 );
193 226
194 ::sync(); // flush fs caches 227 ::sync(); // flush fs caches
195 res = ( ::system ( "apm --suspend" ) == 0 ); 228 res = ( ::system ( "apm --suspend" ) == 0 );
196 229
197 // This is needed because the iPAQ apm implementation is asynchronous and we 230 // This is needed because the iPAQ apm implementation is asynchronous and we
198 // can not be sure when exactly the device is really suspended 231 // can not be sure when exactly the device is really suspended
199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 232 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
200 233
201 if ( res ) { 234 if ( res ) {
202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 235 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
203 ::usleep ( 200 * 1000 ); 236 ::usleep ( 200 * 1000 );
204 ::gettimeofday ( &tvn, 0 ); 237 ::gettimeofday ( &tvn, 0 );
205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 238 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
206 } 239 }
207 240
208 return res; 241 return res;
209} 242}
210 243
211//#include <linux/fb.h> better not rely on kernel headers in userspace ... 244//#include <linux/fb.h> better not rely on kernel headers in userspace ...
212 245
213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 246#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
214 247
215/* VESA Blanking Levels */ 248/* VESA Blanking Levels */
216#define VESA_NO_BLANKING 0 249#define VESA_NO_BLANKING 0
217#define VESA_VSYNC_SUSPEND 1 250#define VESA_VSYNC_SUSPEND 1
218#define VESA_HSYNC_SUSPEND 2 251#define VESA_HSYNC_SUSPEND 2
219#define VESA_POWERDOWN 3 252#define VESA_POWERDOWN 3
220 253
221/** 254/**
222* This sets the display on or off 255* This sets the display on or off
223*/ 256*/
224bool ODevice::setDisplayStatus ( bool on ) 257bool ODevice::setDisplayStatus ( bool on )
225{ 258{
226 qDebug("ODevice::setDisplayStatus(%d)", on); 259 qDebug("ODevice::setDisplayStatus(%d)", on);
227 260
228 if ( d->m_model == Model_Unknown ) 261 if ( d->m_model == Model_Unknown )
229 return false; 262 return false;
230 263
231 bool res = false; 264 bool res = false;
232 int fd; 265 int fd;
233 266
234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 267 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 268 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
236 ::close ( fd ); 269 ::close ( fd );
237 } 270 }
238 return res; 271 return res;
239} 272}
240 273
241/** 274/**
242* This sets the display brightness 275* This sets the display brightness
243* 276*
244* @param p The brightness to be set on a scale from 0 to 255 277* @param p The brightness to be set on a scale from 0 to 255
245* @return success or failure 278* @return success or failure
246*/ 279*/
247bool ODevice::setDisplayBrightness ( int p) 280bool ODevice::setDisplayBrightness ( int p)
248{ 281{
249 Q_UNUSED( p ) 282 Q_UNUSED( p )
250 return false; 283 return false;
251} 284}
252 285
253/** 286/**
254* @return returns the number of steppings on the brightness slider 287* @return returns the number of steppings on the brightness slider
255* in the Light-'n-Power settings. 288* in the Light-'n-Power settings.
256*/ 289*/
257int ODevice::displayBrightnessResolution() const 290int ODevice::displayBrightnessResolution() const
258{ 291{
259 return 16; 292 return 16;
260} 293}
261 294
262/** 295/**
263* This sets the display contrast 296* This sets the display contrast
264* @param p The contrast to be set on a scale from 0 to 255 297* @param p The contrast to be set on a scale from 0 to 255
265* @return success or failure 298* @return success or failure
266*/ 299*/
267bool ODevice::setDisplayContrast ( int p) 300bool ODevice::setDisplayContrast ( int p)
268{ 301{
269 Q_UNUSED( p ) 302 Q_UNUSED( p )
270 return false; 303 return false;
271} 304}
272 305
273/** 306/**
274* @return return the max value for the brightness settings slider 307* @return return the max value for the brightness settings slider
275* or 0 if the device doesn't support setting of a contrast 308* or 0 if the device doesn't support setting of a contrast
276*/ 309*/
277int ODevice::displayContrastResolution() const 310int ODevice::displayContrastResolution() const
278{ 311{
279 return 0; 312 return 0;
280} 313}
281 314
282/** 315/**
283* This returns the vendor as string 316* This returns the vendor as string
284* @return Vendor as QString 317* @return Vendor as QString
285*/ 318*/
286QString ODevice::vendorString() const 319QString ODevice::vendorString() const
287{ 320{
288 return d->m_vendorstr; 321 return d->m_vendorstr;
289} 322}
290 323
291/** 324/**
292* This returns the vendor as one of the values of OVendor 325* This returns the vendor as one of the values of OVendor
293* @return OVendor 326* @return OVendor
294*/ 327*/
295OVendor ODevice::vendor() const 328OVendor ODevice::vendor() const
296{ 329{
297 return d->m_vendor; 330 return d->m_vendor;
298} 331}
299 332
300/** 333/**
301* This returns the model as a string 334* This returns the model as a string
302* @return A string representing the model 335* @return A string representing the model
303*/ 336*/
304QString ODevice::modelString() const 337QString ODevice::modelString() const
305{ 338{
306 return d->m_modelstr; 339 return d->m_modelstr;
307} 340}
308 341
309/** 342/**
310* This does return the OModel used 343* This does return the OModel used
311*/ 344*/
312OModel ODevice::model() const 345OModel ODevice::model() const
313{ 346{
314 return d->m_model; 347 return d->m_model;
315} 348}
316 349
317/** 350/**
318* This does return the systen name 351* This does return the systen name
319*/ 352*/
320QString ODevice::systemString() const 353QString ODevice::systemString() const
321{ 354{
322 return d->m_systemstr; 355 return d->m_systemstr;
323} 356}
324 357
325/** 358/**
326* Return System as OSystem value 359* Return System as OSystem value
327*/ 360*/
328OSystem ODevice::system() const 361OSystem ODevice::system() const
329{ 362{
330 return d->m_system; 363 return d->m_system;
331} 364}
332 365
333/** 366/**
334* @return the version string of the base system 367* @return the version string of the base system
335*/ 368*/
336QString ODevice::systemVersionString() const 369QString ODevice::systemVersionString() const
337{ 370{
338 return d->m_sysverstr; 371 return d->m_sysverstr;
339} 372}
340 373
341/** 374/**
342* @return the current Transformation 375* @return the current Transformation
343*/ 376*/
344Transformation ODevice::rotation() const 377Transformation ODevice::rotation() const
345{ 378{
346 return d->m_rotation; 379 return d->m_rotation;
347} 380}
348 381
349/** 382/**
350* @return the current rotation direction 383* @return the current rotation direction
351*/ 384*/
352ODirection ODevice::direction() const 385ODirection ODevice::direction() const
353{ 386{
354 return d->m_direction; 387 return d->m_direction;
355} 388}
356 389
357/** 390/**
358* This plays an alarm sound 391* This plays an alarm sound
359*/ 392*/
360void ODevice::playAlarmSound() 393void ODevice::playAlarmSound()
361{ 394{
362#ifndef QT_NO_SOUND 395#ifndef QT_NO_SOUND
363 static Sound snd ( "alarm" ); 396 static Sound snd ( "alarm" );
364 397
365 if ( snd. isFinished()) 398 if ( snd. isFinished())
366 snd. play(); 399 snd. play();
367#endif 400#endif
368} 401}
369 402
370/** 403/**
371* This plays a key sound 404* This plays a key sound
372*/ 405*/
373void ODevice::playKeySound() 406void ODevice::playKeySound()
374{ 407{
375#ifndef QT_NO_SOUND 408#ifndef QT_NO_SOUND
376 static Sound snd ( "keysound" ); 409 static Sound snd ( "keysound" );
377 410
378 if ( snd. isFinished()) 411 if ( snd. isFinished())
379 snd. play(); 412 snd. play();
380#endif 413#endif
381} 414}
382 415
383/** 416/**
384* This plays a touch sound 417* This plays a touch sound
385*/ 418*/
386void ODevice::playTouchSound() 419void ODevice::playTouchSound()
387{ 420{
388#ifndef QT_NO_SOUND 421#ifndef QT_NO_SOUND
389 static Sound snd ( "touchsound" ); 422 static Sound snd ( "touchsound" );
390 423
391 if ( snd. isFinished()) 424 if ( snd. isFinished())
392 snd. play(); 425 snd. play();
393#endif 426#endif
394} 427}
395 428
396/** 429/**
397* This method will return a list of leds 430* This method will return a list of leds
398* available on this device 431* available on this device
399* @return a list of LEDs. 432* @return a list of LEDs.
400*/ 433*/
401QValueList <OLed> ODevice::ledList() const 434QValueList <OLed> ODevice::ledList() const
402{ 435{
403 return QValueList <OLed>(); 436 return QValueList <OLed>();
404} 437}
405 438
406/** 439/**
407* This does return the state of the LEDs 440* This does return the state of the LEDs
408*/ 441*/
409QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 442QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
410{ 443{
411 return QValueList <OLedState>(); 444 return QValueList <OLedState>();
412} 445}
413 446
414/** 447/**
415* @return the state for a given OLed 448* @return the state for a given OLed
416*/ 449*/
417OLedState ODevice::ledState ( OLed /*which*/ ) const 450OLedState ODevice::ledState ( OLed /*which*/ ) const
418{ 451{
419 return Led_Off; 452 return Led_Off;
420} 453}
421 454
422/** 455/**
423* Set the state for a LED 456* Set the state for a LED
424* @param which Which OLed to use 457* @param which Which OLed to use
425* @param st The state to set 458* @param st The state to set
426* @return success or failure 459* @return success or failure
427*/ 460*/
428bool ODevice::setLedState ( OLed which, OLedState st ) 461bool ODevice::setLedState ( OLed which, OLedState st )
429{ 462{
430 Q_UNUSED( which ) 463 Q_UNUSED( which )
431 Q_UNUSED( st ) 464 Q_UNUSED( st )
432 return false; 465 return false;
433} 466}
434 467
435/** 468/**
436* @return if the device has a light sensor 469* @return if the device has a light sensor
437*/ 470*/
438bool ODevice::hasLightSensor() const 471bool ODevice::hasLightSensor() const
439{ 472{
440 return false; 473 return false;
441} 474}
442 475
443/** 476/**
444* @return a value from the light sensor 477* @return a value from the light sensor
445*/ 478*/
446int ODevice::readLightSensor() 479int ODevice::readLightSensor()
447{ 480{
448 return -1; 481 return -1;
449} 482}
450 483
451/** 484/**
452* @return the light sensor resolution 485* @return the light sensor resolution
453*/ 486*/
454int ODevice::lightSensorResolution() const 487int ODevice::lightSensorResolution() const
455{ 488{
456 return 0; 489 return 0;
457} 490}
458 491
459/** 492/**
460* @return if the device has a hinge sensor 493* @return if the device has a hinge sensor
461*/ 494*/
462bool ODevice::hasHingeSensor() const 495bool ODevice::hasHingeSensor() const
463{ 496{
464 return false; 497 return false;
465} 498}
466 499
467/** 500/**
468* @return a value from the hinge sensor 501* @return a value from the hinge sensor
469*/ 502*/
470OHingeStatus ODevice::readHingeSensor() 503OHingeStatus ODevice::readHingeSensor()
471{ 504{
472 return CASE_UNKNOWN; 505 return CASE_UNKNOWN;
473} 506}
474 507
475/** 508/**
476* @return a list with CPU frequencies supported by the hardware 509* @return a list with CPU frequencies supported by the hardware
477*/ 510*/
478const QStrList &ODevice::allowedCpuFrequencies() const 511const QStrList &ODevice::allowedCpuFrequencies() const
479{ 512{
480 return *d->m_cpu_frequencies; 513 return *d->m_cpu_frequencies;
481} 514}
482 515
483 516
484/** 517/**
485* Set desired CPU frequency 518* Set desired CPU frequency
486* 519*
487* @param index index into d->m_cpu_frequencies of the frequency to be set 520* @param index index into d->m_cpu_frequencies of the frequency to be set
488*/ 521*/
489bool ODevice::setCurrentCpuFrequency(uint index) 522bool ODevice::setCurrentCpuFrequency(uint index)
490{ 523{
491 if (index >= d->m_cpu_frequencies->count()) 524 if (index >= d->m_cpu_frequencies->count())
492 return false; 525 return false;
493 526
494 char *freq = d->m_cpu_frequencies->at(index); 527 char *freq = d->m_cpu_frequencies->at(index);
495 qWarning("set freq to %s", freq); 528 qWarning("set freq to %s", freq);
496 529
497 int fd; 530 int fd;
498 531
499 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 532 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
500 char writeCommand[50]; 533 char writeCommand[50];
501 const int count = sprintf(writeCommand, "%s\n", freq); 534 const int count = sprintf(writeCommand, "%s\n", freq);
502 int res = (::write(fd, writeCommand, count) != -1); 535 int res = (::write(fd, writeCommand, count) != -1);
503 ::close(fd); 536 ::close(fd);
504 return res; 537 return res;
505 } 538 }
506 539
507 return false; 540 return false;
508} 541}
509 542
510 543
511/** 544/**
512* @return a list of hardware buttons 545* @return a list of hardware buttons
513*/ 546*/
514const QValueList <ODeviceButton> &ODevice::buttons() 547const QValueList <ODeviceButton> &ODevice::buttons()
515{ 548{
516 initButtons(); 549 initButtons();
517 550
518 return *d->m_buttons; 551 return *d->m_buttons;
519} 552}
520 553
521/** 554/**
522* @return The amount of time that would count as a hold 555* @return The amount of time that would count as a hold
523*/ 556*/
524uint ODevice::buttonHoldTime() const 557uint ODevice::buttonHoldTime() const
525{ 558{
526 return d->m_holdtime; 559 return d->m_holdtime;
527} 560}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 5ee9cca..0ba58f0 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,335 +1,350 @@
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#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie{ 43namespace Opie{
44namespace Core{ 44namespace Core{
45 45
46 class ODeviceData; 46 class ODeviceData;
47/** 47/**
48 * The available devices 48 * The available devices
49 */ 49 */
50enum OModel { 50enum OModel {
51 Model_Unknown, // = 0 51 Model_Unknown, // = 0
52 52
53 Model_Series_Mask = 0xff000000, 53 Model_Series_Mask = 0xff000000,
54 54
55 Model_iPAQ = ( 1 << 24 ), 55 Model_iPAQ = ( 1 << 24 ),
56 56
57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
64 64
65 Model_Jornada = ( 6 << 24 ), 65 Model_Jornada = ( 6 << 24 ),
66 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 66 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
67 67
68 Model_Zaurus = ( 2 << 24 ), 68 Model_Zaurus = ( 2 << 24 ),
69 69
70 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 70 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
71 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 71 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
72 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 72 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
73 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 73 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
74 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 74 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
75 75
76 Model_SIMpad = ( 3 << 24 ), 76 Model_SIMpad = ( 3 << 24 ),
77 77
78 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 78 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
79 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 79 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
80 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 80 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
81 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 81 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
82 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 82 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
83 83
84 Model_Ramses = ( 4 << 24 ), 84 Model_Ramses = ( 4 << 24 ),
85 85
86 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 86 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
87 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 87 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
88 88
89 Model_Yopy = ( 5 << 24 ), 89 Model_Yopy = ( 5 << 24 ),
90 90
91 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 91 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
92 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 92 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
93 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 93 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
94 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 94 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
95 95
96}; 96};
97 97
98/** 98/**
99 * The vendor of the device 99 * The vendor of the device
100 */ 100 */
101enum OVendor { 101enum OVendor {
102 Vendor_Unknown, 102 Vendor_Unknown,
103 103
104 Vendor_HP, 104 Vendor_HP,
105 Vendor_Sharp, 105 Vendor_Sharp,
106 Vendor_SIEMENS, 106 Vendor_SIEMENS,
107 Vendor_MundN, 107 Vendor_MundN,
108 Vendor_GMate, 108 Vendor_GMate,
109}; 109};
110 110
111/** 111/**
112 * The System used 112 * The System used
113 */ 113 */
114enum OSystem { 114enum OSystem {
115 System_Unknown, 115 System_Unknown,
116 116
117 System_Familiar, 117 System_Familiar,
118 System_Zaurus, 118 System_Zaurus,
119 System_OpenZaurus, 119 System_OpenZaurus,
120 System_Linupy, 120 System_Linupy,
121}; 121};
122 122
123enum OLedState { 123enum OLedState {
124 Led_Off, 124 Led_Off,
125 Led_On, 125 Led_On,
126 Led_BlinkSlow, 126 Led_BlinkSlow,
127 Led_BlinkFast 127 Led_BlinkFast
128}; 128};
129 129
130enum OLed { 130enum OLed {
131 Led_Mail, 131 Led_Mail,
132 Led_Power, 132 Led_Power,
133 Led_BlueTooth 133 Led_BlueTooth
134}; 134};
135 135
136enum OHardKey { 136enum OHardKey {
137 HardKey_Datebook = Qt::Key_F9, 137 HardKey_Datebook = Qt::Key_F9,
138 HardKey_Contacts = Qt::Key_F10, 138 HardKey_Contacts = Qt::Key_F10,
139 HardKey_Menu = Qt::Key_F11, 139 HardKey_Menu = Qt::Key_F11,
140 HardKey_Home = Qt::Key_F12, 140 HardKey_Home = Qt::Key_F12,
141 HardKey_Mail = Qt::Key_F13, 141 HardKey_Mail = Qt::Key_F13,
142 HardKey_Record = Qt::Key_F24, 142 HardKey_Record = Qt::Key_F24,
143 HardKey_Suspend = Qt::Key_F34, 143 HardKey_Suspend = Qt::Key_F34,
144 HardKey_Backlight = Qt::Key_F35, 144 HardKey_Backlight = Qt::Key_F35,
145 HardKey_Action = Qt::Key_F10, 145 HardKey_Action = Qt::Key_F10,
146 HardKey_OK = Qt::Key_F11, 146 HardKey_OK = Qt::Key_F11,
147 HardKey_End = Qt::Key_F12, 147 HardKey_End = Qt::Key_F12,
148}; 148};
149 149
150enum ODirection { 150enum ODirection {
151 CW = 0, 151 CW = 0,
152 CCW = 1, 152 CCW = 1,
153 Flip = 2, 153 Flip = 2,
154}; 154};
155 155
156enum OHingeStatus { 156enum OHingeStatus {
157 CASE_CLOSED = 3, 157 CASE_CLOSED = 3,
158 CASE_PORTRAIT = 2, 158 CASE_PORTRAIT = 2,
159 CASE_LANDSCAPE = 0, 159 CASE_LANDSCAPE = 0,
160 CASE_UNKNOWN = 1, 160 CASE_UNKNOWN = 1,
161}; 161};
162 162
163/* default button for qvfb or such
164 * see odevice.cpp for details.
165 * hint: manage a user defined button for qvfb?
166 * alwin
167 */
168struct default_button {
169 Qt::Key code;
170 char *utext;
171 char *pix;
172 char *fpressedservice;
173 char *fpressedaction;
174 char *fheldservice;
175 char *fheldaction;
176};
177
163/** 178/**
164 * A singleton which gives informations about device specefic option 179 * A singleton which gives informations about device specefic option
165 * like the Hardware used, LEDs, the Base Distribution and 180 * like the Hardware used, LEDs, the Base Distribution and
166 * hardware key mappings. 181 * hardware key mappings.
167 * 182 *
168 * @short A small class for device specefic options 183 * @short A small class for device specefic options
169 * @see QObject 184 * @see QObject
170 * @author Robert Griebl 185 * @author Robert Griebl
171 * @version 1.0 186 * @version 1.0
172 */ 187 */
173class ODevice : public QObject 188class ODevice : public QObject
174{ 189{
175 Q_OBJECT 190 Q_OBJECT
176 191
177private: 192private:
178 /* disable copy */ 193 /* disable copy */
179 ODevice ( const ODevice & ); 194 ODevice ( const ODevice & );
180 195
181protected: 196protected:
182 ODevice(); 197 ODevice();
183 virtual void init(); 198 virtual void init();
184 virtual void initButtons(); 199 virtual void initButtons();
185 static void sendSuspendmsg(); 200 static void sendSuspendmsg();
186 201
187 ODeviceData *d; 202 ODeviceData *d;
188 203
189public: 204public:
190 // sandman do we want to allow destructions? -zecke? 205 // sandman do we want to allow destructions? -zecke?
191 virtual ~ODevice(); 206 virtual ~ODevice();
192 207
193 static ODevice *inst(); 208 static ODevice *inst();
194 209
195 // information 210 // information
196 211
197 QString modelString() const; 212 QString modelString() const;
198 OModel model() const; 213 OModel model() const;
199 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 214 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
200 215
201 QString vendorString() const; 216 QString vendorString() const;
202 OVendor vendor() const; 217 OVendor vendor() const;
203 218
204 QString systemString() const; 219 QString systemString() const;
205 OSystem system() const; 220 OSystem system() const;
206 221
207 QString systemVersionString() const; 222 QString systemVersionString() const;
208 223
209 virtual Transformation rotation() const; 224 virtual Transformation rotation() const;
210 virtual ODirection direction() const; 225 virtual ODirection direction() const;
211 226
212 // system 227 // system
213 228
214 virtual bool setSoftSuspend ( bool on ); 229 virtual bool setSoftSuspend ( bool on );
215 virtual bool suspend(); 230 virtual bool suspend();
216 231
217 virtual bool setDisplayStatus ( bool on ); 232 virtual bool setDisplayStatus ( bool on );
218 virtual bool setDisplayBrightness ( int brightness ); 233 virtual bool setDisplayBrightness ( int brightness );
219 virtual int displayBrightnessResolution() const; 234 virtual int displayBrightnessResolution() const;
220 virtual bool setDisplayContrast ( int contrast ); 235 virtual bool setDisplayContrast ( int contrast );
221 virtual int displayContrastResolution() const; 236 virtual int displayContrastResolution() const;
222 237
223 // don't add new virtual methods, use this: 238 // don't add new virtual methods, use this:
224 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 239 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
225 // and in your subclass do do overwrite 240 // and in your subclass do do overwrite
226 //protected virtual int virtual_hook(int, void *) 241 //protected virtual int virtual_hook(int, void *)
227 // which is defined below 242 // which is defined below
228 243
229 // input / output 244 // input / output
230 virtual void playAlarmSound(); 245 virtual void playAlarmSound();
231 virtual void playKeySound(); 246 virtual void playKeySound();
232 virtual void playTouchSound(); 247 virtual void playTouchSound();
233 248
234 virtual QValueList <OLed> ledList() const; 249 virtual QValueList <OLed> ledList() const;
235 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 250 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
236 virtual OLedState ledState ( OLed led ) const; 251 virtual OLedState ledState ( OLed led ) const;
237 virtual bool setLedState ( OLed led, OLedState st ); 252 virtual bool setLedState ( OLed led, OLedState st );
238 253
239 virtual bool hasLightSensor() const; 254 virtual bool hasLightSensor() const;
240 virtual int readLightSensor(); 255 virtual int readLightSensor();
241 virtual int lightSensorResolution() const; 256 virtual int lightSensorResolution() const;
242 257
243 virtual bool hasHingeSensor() const; 258 virtual bool hasHingeSensor() const;
244 virtual OHingeStatus readHingeSensor(); 259 virtual OHingeStatus readHingeSensor();
245 260
246 const QStrList &allowedCpuFrequencies() const; 261 const QStrList &allowedCpuFrequencies() const;
247 bool setCurrentCpuFrequency(uint index); 262 bool setCurrentCpuFrequency(uint index);
248 263
249 /** 264 /**
250 * Returns the available buttons on this device. The number and location 265 * Returns the available buttons on this device. The number and location
251 * of buttons will vary depending on the device. Button numbers will be assigned 266 * of buttons will vary depending on the device. Button numbers will be assigned
252 * by the device manufacturer and will be from most preferred button to least preffered 267 * by the device manufacturer and will be from most preferred button to least preffered
253 * button. Note that this list only contains "user mappable" buttons. 268 * button. Note that this list only contains "user mappable" buttons.
254 * 269 *
255 * @todo Make method const and take care of calling initButtons or make that const too 270 * @todo Make method const and take care of calling initButtons or make that const too
256 * 271 *
257 */ 272 */
258 const QValueList<ODeviceButton> &buttons(); 273 const QValueList<ODeviceButton> &buttons();
259 274
260 /** 275 /**
261 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 276 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
262 * returns 0L 277 * returns 0L
263 */ 278 */
264 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 279 const ODeviceButton *buttonForKeycode ( ushort keyCode );
265 280
266 /** 281 /**
267 * Reassigns the pressed action for \a button. To return to the factory 282 * Reassigns the pressed action for \a button. To return to the factory
268 * default pass an empty string as \a qcopMessage. 283 * default pass an empty string as \a qcopMessage.
269 */ 284 */
270 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 285 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
271 286
272 /** 287 /**
273 * Reassigns the held action for \a button. To return to the factory 288 * Reassigns the held action for \a button. To return to the factory
274 * default pass an empty string as \a qcopMessage. 289 * default pass an empty string as \a qcopMessage.
275 */ 290 */
276 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 291 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
277 292
278 /** 293 /**
279 * How long (in ms) you have to press a button for a "hold" action 294 * How long (in ms) you have to press a button for a "hold" action
280 */ 295 */
281 uint buttonHoldTime() const; 296 uint buttonHoldTime() const;
282 297
283signals: 298signals:
284 void buttonMappingChanged(); 299 void buttonMappingChanged();
285 300
286private slots: 301private slots:
287 void systemMessage ( const QCString &, const QByteArray & ); 302 void systemMessage ( const QCString &, const QByteArray & );
288 303
289protected: 304protected:
290 void reloadButtonMapping(); 305 void reloadButtonMapping();
291 /* ugly virtual hook */ 306 /* ugly virtual hook */
292 virtual void virtual_hook( int id, void* data ); 307 virtual void virtual_hook( int id, void* data );
293}; 308};
294 309
295class ODeviceData { 310class ODeviceData {
296 311
297 public: 312 public:
298 QString m_vendorstr; 313 QString m_vendorstr;
299 OVendor m_vendor; 314 OVendor m_vendor;
300 315
301 QString m_modelstr; 316 QString m_modelstr;
302 OModel m_model; 317 OModel m_model;
303 318
304 QString m_systemstr; 319 QString m_systemstr;
305 OSystem m_system; 320 OSystem m_system;
306 321
307 QString m_sysverstr; 322 QString m_sysverstr;
308 323
309 Transformation m_rotation; 324 Transformation m_rotation;
310 ODirection m_direction; 325 ODirection m_direction;
311 326
312 QValueList <ODeviceButton> *m_buttons; 327 QValueList <ODeviceButton> *m_buttons;
313 uint m_holdtime; 328 uint m_holdtime;
314 QStrList *m_cpu_frequencies; 329 QStrList *m_cpu_frequencies;
315}; 330};
316 331
317} 332}
318} 333}
319 334
320static inline bool isQWS() 335static inline bool isQWS()
321{ 336{
322 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 337 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
323} 338}
324 339
325static QCString makeChannel ( const char *str ) 340static QCString makeChannel ( const char *str )
326{ 341{
327 if ( str && !::strchr ( str, '/' )) 342 if ( str && !::strchr ( str, '/' ))
328 return QCString ( "QPE/Application/" ) + str; 343 return QCString ( "QPE/Application/" ) + str;
329 else 344 else
330 return str; 345 return str;
331} 346}
332 347
333 348
334#endif 349#endif
335 350
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 2efcd3a..98e2ffa 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,485 +1,485 @@
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_ipaq.h" 30#include "odevice_ipaq.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60/* KERNEL */ 60/* KERNEL */
61#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 61#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
62 62
63#define OD_IO(type,number) OD_IOC(0,type,number,0) 63#define OD_IO(type,number) OD_IOC(0,type,number,0)
64#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 64#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
65#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 65#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
66#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 66#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
67 67
68typedef struct { 68typedef struct {
69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
70 unsigned char TotalTime; /* Units of 5 seconds */ 70 unsigned char TotalTime; /* Units of 5 seconds */
71 unsigned char OnTime; /* units of 100m/s */ 71 unsigned char OnTime; /* units of 100m/s */
72 unsigned char OffTime; /* units of 100m/s */ 72 unsigned char OffTime; /* units of 100m/s */
73} LED_IN; 73} LED_IN;
74 74
75typedef struct { 75typedef struct {
76 unsigned char mode; 76 unsigned char mode;
77 unsigned char pwr; 77 unsigned char pwr;
78 unsigned char brightness; 78 unsigned char brightness;
79} FLITE_IN; 79} FLITE_IN;
80 80
81#define LED_ON OD_IOW( 'f', 5, LED_IN ) 81#define LED_ON OD_IOW( 'f', 5, LED_IN )
82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
83 83
84struct i_button ipaq_buttons [] = { 84struct i_button ipaq_buttons [] = {
85 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 85 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
87 "devicebuttons/ipaq_calendar", 87 "devicebuttons/ipaq_calendar",
88 "datebook", "nextView()", 88 "datebook", "nextView()",
89 "today", "raise()" }, 89 "today", "raise()" },
90 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 90 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
92 "devicebuttons/ipaq_contact", 92 "devicebuttons/ipaq_contact",
93 "addressbook", "raise()", 93 "addressbook", "raise()",
94 "addressbook", "beamBusinessCard()" }, 94 "addressbook", "beamBusinessCard()" },
95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/ipaq_menu", 97 "devicebuttons/ipaq_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
102 "devicebuttons/ipaq_mail", 102 "devicebuttons/ipaq_mail",
103 "mail", "raise()", 103 "opiemail", "raise()",
104 "mail", "newMail()" }, 104 "opiemail", "newMail()" },
105 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 105 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
107 "devicebuttons/ipaq_home", 107 "devicebuttons/ipaq_home",
108 "QPE/Launcher", "home()", 108 "QPE/Launcher", "home()",
109 "buttonsettings", "raise()" }, 109 "buttonsettings", "raise()" },
110 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 110 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
111 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 111 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
112 "devicebuttons/ipaq_record", 112 "devicebuttons/ipaq_record",
113 "QPE/VMemo", "toggleRecord()", 113 "QPE/VMemo", "toggleRecord()",
114 "sound", "raise()" }, 114 "sound", "raise()" },
115}; 115};
116 116
117void iPAQ::init() 117void iPAQ::init()
118{ 118{
119 d->m_vendorstr = "HP"; 119 d->m_vendorstr = "HP";
120 d->m_vendor = Vendor_HP; 120 d->m_vendor = Vendor_HP;
121 121
122 QFile f ( "/proc/hal/model" ); 122 QFile f ( "/proc/hal/model" );
123 123
124 if ( f. open ( IO_ReadOnly )) { 124 if ( f. open ( IO_ReadOnly )) {
125 QTextStream ts ( &f ); 125 QTextStream ts ( &f );
126 126
127 d->m_modelstr = "H" + ts. readLine(); 127 d->m_modelstr = "H" + ts. readLine();
128 128
129 if ( d->m_modelstr == "H3100" ) 129 if ( d->m_modelstr == "H3100" )
130 d->m_model = Model_iPAQ_H31xx; 130 d->m_model = Model_iPAQ_H31xx;
131 else if ( d->m_modelstr == "H3600" ) 131 else if ( d->m_modelstr == "H3600" )
132 d->m_model = Model_iPAQ_H36xx; 132 d->m_model = Model_iPAQ_H36xx;
133 else if ( d->m_modelstr == "H3700" ) 133 else if ( d->m_modelstr == "H3700" )
134 d->m_model = Model_iPAQ_H37xx; 134 d->m_model = Model_iPAQ_H37xx;
135 else if ( d->m_modelstr == "H3800" ) 135 else if ( d->m_modelstr == "H3800" )
136 d->m_model = Model_iPAQ_H38xx; 136 d->m_model = Model_iPAQ_H38xx;
137 else if ( d->m_modelstr == "H3900" ) 137 else if ( d->m_modelstr == "H3900" )
138 d->m_model = Model_iPAQ_H39xx; 138 d->m_model = Model_iPAQ_H39xx;
139 else if ( d->m_modelstr == "H5400" ) 139 else if ( d->m_modelstr == "H5400" )
140 d->m_model = Model_iPAQ_H5xxx; 140 d->m_model = Model_iPAQ_H5xxx;
141 else 141 else
142 d->m_model = Model_Unknown; 142 d->m_model = Model_Unknown;
143 143
144 f. close(); 144 f. close();
145 } 145 }
146 146
147 switch ( d->m_model ) { 147 switch ( d->m_model ) {
148 case Model_iPAQ_H31xx: 148 case Model_iPAQ_H31xx:
149 case Model_iPAQ_H38xx: 149 case Model_iPAQ_H38xx:
150 d->m_rotation = Rot90; 150 d->m_rotation = Rot90;
151 break; 151 break;
152 case Model_iPAQ_H36xx: 152 case Model_iPAQ_H36xx:
153 case Model_iPAQ_H37xx: 153 case Model_iPAQ_H37xx:
154 case Model_iPAQ_H39xx: 154 case Model_iPAQ_H39xx:
155 155
156 default: 156 default:
157 d->m_rotation = Rot270; 157 d->m_rotation = Rot270;
158 break; 158 break;
159 case Model_iPAQ_H5xxx: 159 case Model_iPAQ_H5xxx:
160 d->m_rotation = Rot0; 160 d->m_rotation = Rot0;
161 } 161 }
162 162
163 f. setName ( "/etc/familiar-version" ); 163 f. setName ( "/etc/familiar-version" );
164 if ( f. open ( IO_ReadOnly )) { 164 if ( f. open ( IO_ReadOnly )) {
165 d->m_systemstr = "Familiar"; 165 d->m_systemstr = "Familiar";
166 d->m_system = System_Familiar; 166 d->m_system = System_Familiar;
167 167
168 QTextStream ts ( &f ); 168 QTextStream ts ( &f );
169 d->m_sysverstr = ts. readLine(). mid ( 10 ); 169 d->m_sysverstr = ts. readLine(). mid ( 10 );
170 170
171 f. close(); 171 f. close();
172 } else { 172 } else {
173 f. setName ( "/etc/oz_version" ); 173 f. setName ( "/etc/oz_version" );
174 174
175 if ( f. open ( IO_ReadOnly )) { 175 if ( f. open ( IO_ReadOnly )) {
176 d->m_systemstr = "OpenEmbedded/iPaq"; 176 d->m_systemstr = "OpenEmbedded/iPaq";
177 d->m_system = System_Familiar; 177 d->m_system = System_Familiar;
178 178
179 QTextStream ts ( &f ); 179 QTextStream ts ( &f );
180 ts.setDevice ( &f ); 180 ts.setDevice ( &f );
181 d->m_sysverstr = ts. readLine(); 181 d->m_sysverstr = ts. readLine();
182 f. close(); 182 f. close();
183 } 183 }
184 } 184 }
185 185
186 m_leds [0] = m_leds [1] = Led_Off; 186 m_leds [0] = m_leds [1] = Led_Off;
187 187
188 m_power_timer = 0; 188 m_power_timer = 0;
189 189
190} 190}
191 191
192void iPAQ::initButtons() 192void iPAQ::initButtons()
193{ 193{
194 if ( d->m_buttons ) 194 if ( d->m_buttons )
195 return; 195 return;
196 196
197 if ( isQWS( ) ) 197 if ( isQWS( ) )
198 QWSServer::setKeyboardFilter ( this ); 198 QWSServer::setKeyboardFilter ( this );
199 199
200 d->m_buttons = new QValueList <ODeviceButton>; 200 d->m_buttons = new QValueList <ODeviceButton>;
201 201
202 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 202 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
203 i_button *ib = ipaq_buttons + i; 203 i_button *ib = ipaq_buttons + i;
204 ODeviceButton b; 204 ODeviceButton b;
205 205
206 if (( ib->model & d->m_model ) == d->m_model ) { 206 if (( ib->model & d->m_model ) == d->m_model ) {
207 b. setKeycode ( ib->code ); 207 b. setKeycode ( ib->code );
208 b. setUserText ( QObject::tr ( "Button", ib->utext )); 208 b. setUserText ( QObject::tr ( "Button", ib->utext ));
209 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 209 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
210 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 210 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
211 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 211 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
212 212
213 d->m_buttons->append ( b ); 213 d->m_buttons->append ( b );
214 } 214 }
215 } 215 }
216 reloadButtonMapping(); 216 reloadButtonMapping();
217 217
218 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 218 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
219 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 219 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
220} 220}
221 221
222QValueList <OLed> iPAQ::ledList() const 222QValueList <OLed> iPAQ::ledList() const
223{ 223{
224 QValueList <OLed> vl; 224 QValueList <OLed> vl;
225 vl << Led_Power; 225 vl << Led_Power;
226 226
227 if ( d->m_model == Model_iPAQ_H38xx ) 227 if ( d->m_model == Model_iPAQ_H38xx )
228 vl << Led_BlueTooth; 228 vl << Led_BlueTooth;
229 return vl; 229 return vl;
230} 230}
231 231
232QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 232QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
233{ 233{
234 QValueList <OLedState> vl; 234 QValueList <OLedState> vl;
235 235
236 if ( l == Led_Power ) 236 if ( l == Led_Power )
237 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 237 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
238 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 238 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
239 vl << Led_Off; // << Led_On << ??? 239 vl << Led_Off; // << Led_On << ???
240 240
241 return vl; 241 return vl;
242} 242}
243 243
244OLedState iPAQ::ledState ( OLed l ) const 244OLedState iPAQ::ledState ( OLed l ) const
245{ 245{
246 switch ( l ) { 246 switch ( l ) {
247 case Led_Power: 247 case Led_Power:
248 return m_leds [0]; 248 return m_leds [0];
249 case Led_BlueTooth: 249 case Led_BlueTooth:
250 return m_leds [1]; 250 return m_leds [1];
251 default: 251 default:
252 return Led_Off; 252 return Led_Off;
253 } 253 }
254} 254}
255 255
256bool iPAQ::setLedState ( OLed l, OLedState st ) 256bool iPAQ::setLedState ( OLed l, OLedState st )
257{ 257{
258 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 258 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
259 259
260 if ( l == Led_Power ) { 260 if ( l == Led_Power ) {
261 if ( fd >= 0 ) { 261 if ( fd >= 0 ) {
262 LED_IN leds; 262 LED_IN leds;
263 ::memset ( &leds, 0, sizeof( leds )); 263 ::memset ( &leds, 0, sizeof( leds ));
264 leds. TotalTime = 0; 264 leds. TotalTime = 0;
265 leds. OnTime = 0; 265 leds. OnTime = 0;
266 leds. OffTime = 1; 266 leds. OffTime = 1;
267 leds. OffOnBlink = 2; 267 leds. OffOnBlink = 2;
268 268
269 switch ( st ) { 269 switch ( st ) {
270 case Led_Off : leds. OffOnBlink = 0; break; 270 case Led_Off : leds. OffOnBlink = 0; break;
271 case Led_On : leds. OffOnBlink = 1; break; 271 case Led_On : leds. OffOnBlink = 1; break;
272 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 272 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
273 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 273 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
274 } 274 }
275 275
276 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 276 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
277 m_leds [0] = st; 277 m_leds [0] = st;
278 return true; 278 return true;
279 } 279 }
280 } 280 }
281 } 281 }
282 return false; 282 return false;
283} 283}
284 284
285 285
286bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 286bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
287{ 287{
288 int newkeycode = keycode; 288 int newkeycode = keycode;
289 289
290 switch ( keycode ) { 290 switch ( keycode ) {
291 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 291 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
292 case HardKey_Menu: { 292 case HardKey_Menu: {
293 if (( d->m_model == Model_iPAQ_H38xx ) || 293 if (( d->m_model == Model_iPAQ_H38xx ) ||
294 ( d->m_model == Model_iPAQ_H39xx ) || 294 ( d->m_model == Model_iPAQ_H39xx ) ||
295 ( d->m_model == Model_iPAQ_H5xxx)) { 295 ( d->m_model == Model_iPAQ_H5xxx)) {
296 newkeycode = HardKey_Mail; 296 newkeycode = HardKey_Mail;
297 } 297 }
298 break; 298 break;
299 } 299 }
300 300
301 // Rotate cursor keys 180° or 270° 301 // Rotate cursor keys 180° or 270°
302 case Key_Left : 302 case Key_Left :
303 case Key_Right: 303 case Key_Right:
304 case Key_Up : 304 case Key_Up :
305 case Key_Down : { 305 case Key_Down : {
306 if (( d->m_model == Model_iPAQ_H31xx ) || 306 if (( d->m_model == Model_iPAQ_H31xx ) ||
307 ( d->m_model == Model_iPAQ_H38xx )) { 307 ( d->m_model == Model_iPAQ_H38xx )) {
308 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 308 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
309 } 309 }
310 // Rotate the cursor keys by 270° 310 // Rotate the cursor keys by 270°
311 // keycode - Key_Left = position of the button starting from left clockwise 311 // keycode - Key_Left = position of the button starting from left clockwise
312 // add the rotation to it and modolo. No we've the original offset 312 // add the rotation to it and modolo. No we've the original offset
313 // add the offset to the Key_Left key 313 // add the offset to the Key_Left key
314 if ( d-> m_model == Model_iPAQ_H5xxx ) 314 if ( d-> m_model == Model_iPAQ_H5xxx )
315 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 315 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
316 break; 316 break;
317 } 317 }
318 318
319 // map Power Button short/long press to F34/F35 319 // map Power Button short/long press to F34/F35
320 case Key_SysReq: { 320 case Key_SysReq: {
321 if ( isPress ) { 321 if ( isPress ) {
322 if ( m_power_timer ) 322 if ( m_power_timer )
323 killTimer ( m_power_timer ); 323 killTimer ( m_power_timer );
324 m_power_timer = startTimer ( 500 ); 324 m_power_timer = startTimer ( 500 );
325 } 325 }
326 else if ( m_power_timer ) { 326 else if ( m_power_timer ) {
327 killTimer ( m_power_timer ); 327 killTimer ( m_power_timer );
328 m_power_timer = 0; 328 m_power_timer = 0;
329 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 329 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
331 } 331 }
332 newkeycode = Key_unknown; 332 newkeycode = Key_unknown;
333 break; 333 break;
334 } 334 }
335 } 335 }
336 336
337 if ( newkeycode != keycode ) { 337 if ( newkeycode != keycode ) {
338 if ( newkeycode != Key_unknown ) 338 if ( newkeycode != Key_unknown )
339 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 339 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
340 return true; 340 return true;
341 } 341 }
342 else 342 else
343 return false; 343 return false;
344} 344}
345 345
346void iPAQ::timerEvent ( QTimerEvent * ) 346void iPAQ::timerEvent ( QTimerEvent * )
347{ 347{
348 killTimer ( m_power_timer ); 348 killTimer ( m_power_timer );
349 m_power_timer = 0; 349 m_power_timer = 0;
350 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 350 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
352} 352}
353 353
354 354
355void iPAQ::playAlarmSound() 355void iPAQ::playAlarmSound()
356{ 356{
357#ifndef QT_NO_SOUND 357#ifndef QT_NO_SOUND
358 static Sound snd ( "alarm" ); 358 static Sound snd ( "alarm" );
359 int fd; 359 int fd;
360 int vol; 360 int vol;
361 bool vol_reset = false; 361 bool vol_reset = false;
362 362
363 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 363 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
364 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 364 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
365 Config cfg ( "qpe" ); 365 Config cfg ( "qpe" );
366 cfg. setGroup ( "Volume" ); 366 cfg. setGroup ( "Volume" );
367 367
368 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 368 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
369 if ( volalarm < 0 ) 369 if ( volalarm < 0 )
370 volalarm = 0; 370 volalarm = 0;
371 else if ( volalarm > 100 ) 371 else if ( volalarm > 100 )
372 volalarm = 100; 372 volalarm = 100;
373 volalarm |= ( volalarm << 8 ); 373 volalarm |= ( volalarm << 8 );
374 374
375 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 375 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
376 vol_reset = true; 376 vol_reset = true;
377 } 377 }
378 } 378 }
379 379
380 snd. play(); 380 snd. play();
381 while ( !snd. isFinished()) 381 while ( !snd. isFinished())
382 qApp->processEvents(); 382 qApp->processEvents();
383 383
384 if ( fd >= 0 ) { 384 if ( fd >= 0 ) {
385 if ( vol_reset ) 385 if ( vol_reset )
386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
387 ::close ( fd ); 387 ::close ( fd );
388 } 388 }
389#endif 389#endif
390} 390}
391 391
392 392
393bool iPAQ::setSoftSuspend ( bool soft ) 393bool iPAQ::setSoftSuspend ( bool soft )
394{ 394{
395 bool res = false; 395 bool res = false;
396 int fd; 396 int fd;
397 397
398 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 398 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
399 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 399 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
400 res = true; 400 res = true;
401 else 401 else
402 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 402 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
403 403
404 ::close ( fd ); 404 ::close ( fd );
405 } 405 }
406 else 406 else
407 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 407 ::perror ( "/proc/sys/ts/suspend_button_mode" );
408 408
409 return res; 409 return res;
410} 410}
411 411
412 412
413bool iPAQ::setDisplayBrightness ( int bright ) 413bool iPAQ::setDisplayBrightness ( int bright )
414{ 414{
415 bool res = false; 415 bool res = false;
416 int fd; 416 int fd;
417 417
418 if ( bright > 255 ) 418 if ( bright > 255 )
419 bright = 255; 419 bright = 255;
420 if ( bright < 0 ) 420 if ( bright < 0 )
421 bright = 0; 421 bright = 0;
422 422
423 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 423 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
424 FLITE_IN bl; 424 FLITE_IN bl;
425 bl. mode = 1; 425 bl. mode = 1;
426 bl. pwr = bright ? 1 : 0; 426 bl. pwr = bright ? 1 : 0;
427 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 427 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
428 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 428 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
429 ::close ( fd ); 429 ::close ( fd );
430 } 430 }
431 return res; 431 return res;
432} 432}
433 433
434int iPAQ::displayBrightnessResolution() const 434int iPAQ::displayBrightnessResolution() const
435{ 435{
436 switch ( model()) { 436 switch ( model()) {
437 case Model_iPAQ_H31xx: 437 case Model_iPAQ_H31xx:
438 case Model_iPAQ_H36xx: 438 case Model_iPAQ_H36xx:
439 case Model_iPAQ_H37xx: 439 case Model_iPAQ_H37xx:
440 return 128; // really 256, but >128 could damage the LCD 440 return 128; // really 256, but >128 could damage the LCD
441 441
442 case Model_iPAQ_H38xx: 442 case Model_iPAQ_H38xx:
443 case Model_iPAQ_H39xx: 443 case Model_iPAQ_H39xx:
444 return 64; 444 return 64;
445 case Model_iPAQ_H5xxx: 445 case Model_iPAQ_H5xxx:
446 return 255; 446 return 255;
447 447
448 default: 448 default:
449 return 2; 449 return 2;
450 } 450 }
451} 451}
452 452
453 453
454bool iPAQ::hasLightSensor() const 454bool iPAQ::hasLightSensor() const
455{ 455{
456 return true; 456 return true;
457} 457}
458 458
459int iPAQ::readLightSensor() 459int iPAQ::readLightSensor()
460{ 460{
461 int fd; 461 int fd;
462 int val = -1; 462 int val = -1;
463 463
464 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 464 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
465 char buffer [8]; 465 char buffer [8];
466 466
467 if ( ::read ( fd, buffer, 5 ) == 5 ) { 467 if ( ::read ( fd, buffer, 5 ) == 5 ) {
468 char *endptr; 468 char *endptr;
469 469
470 buffer [4] = 0; 470 buffer [4] = 0;
471 val = ::strtol ( buffer + 2, &endptr, 16 ); 471 val = ::strtol ( buffer + 2, &endptr, 16 );
472 472
473 if ( *endptr != 0 ) 473 if ( *endptr != 0 )
474 val = -1; 474 val = -1;
475 } 475 }
476 ::close ( fd ); 476 ::close ( fd );
477 } 477 }
478 478
479 return val; 479 return val;
480} 480}
481 481
482int iPAQ::lightSensorResolution() const 482int iPAQ::lightSensorResolution() const
483{ 483{
484 return 256; 484 return 256;
485} 485}
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 7d79ef5..e9481bb 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,393 +1,393 @@
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_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct s_button simpad_buttons [] = { 59struct s_button simpad_buttons [] = {
60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
62 "devicebuttons/simpad_lower_up", 62 "devicebuttons/simpad_lower_up",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
67 "devicebuttons/simpad_lower_down", 67 "devicebuttons/simpad_lower_down",
68 "addressbook", "raise()", 68 "addressbook", "raise()",
69 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
72 "devicebuttons/simpad_lower_right", 72 "devicebuttons/simpad_lower_right",
73 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
77 "devicebuttons/simpad_lower_left", 77 "devicebuttons/simpad_lower_left",
78 "mail", "raise()", 78 "opiemail", "raise()",
79 "mail", "newMail()" }, 79 "opiemail", "newMail()" },
80 80
81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
83 "devicebuttons/simpad_upper_up", 83 "devicebuttons/simpad_upper_up",
84 "QPE/Launcher", "home()", 84 "QPE/Launcher", "home()",
85 "buttonsettings", "raise()" }, 85 "buttonsettings", "raise()" },
86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
88 "devicebuttons/simpad_upper_down", 88 "devicebuttons/simpad_upper_down",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
93 "devicebuttons/simpad_upper_right", 93 "devicebuttons/simpad_upper_right",
94 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
98 "devicebuttons/simpad_upper_left", 98 "devicebuttons/simpad_upper_left",
99 "QPE/Rotation", "flip()", 99 "QPE/Rotation", "flip()",
100 "QPE/Rotation", "flip()" }, 100 "QPE/Rotation", "flip()" },
101 /* 101 /*
102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
104 "devicebuttons/simpad_lower_upper", 104 "devicebuttons/simpad_lower_upper",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
109 "devicebuttons/simpad_upper_lower", 109 "devicebuttons/simpad_upper_lower",
110 "QPE/Launcher", "home()", 110 "QPE/Launcher", "home()",
111 "buttonsettings", "raise()" }, 111 "buttonsettings", "raise()" },
112 */ 112 */
113}; 113};
114 114
115void SIMpad::init() 115void SIMpad::init()
116{ 116{
117 d->m_vendorstr = "SIEMENS"; 117 d->m_vendorstr = "SIEMENS";
118 d->m_vendor = Vendor_SIEMENS; 118 d->m_vendor = Vendor_SIEMENS;
119 119
120 QFile f ( "/proc/hal/model" ); 120 QFile f ( "/proc/hal/model" );
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 f. setName ( "/etc/familiar-version" ); 137 f. setName ( "/etc/familiar-version" );
138 if ( f. open ( IO_ReadOnly )) { 138 if ( f. open ( IO_ReadOnly )) {
139 d->m_systemstr = "Familiar"; 139 d->m_systemstr = "Familiar";
140 d->m_system = System_Familiar; 140 d->m_system = System_Familiar;
141 141
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 d->m_sysverstr = ts. readLine(). mid ( 10 ); 143 d->m_sysverstr = ts. readLine(). mid ( 10 );
144 144
145 f. close(); 145 f. close();
146 } else { 146 } else {
147 f. setName ( "/etc/oz_version" ); 147 f. setName ( "/etc/oz_version" );
148 148
149 if ( f. open ( IO_ReadOnly )) { 149 if ( f. open ( IO_ReadOnly )) {
150 d->m_systemstr = "OpenEmbedded/SIMpad"; 150 d->m_systemstr = "OpenEmbedded/SIMpad";
151 d->m_system = System_OpenZaurus; 151 d->m_system = System_OpenZaurus;
152 152
153 QTextStream ts ( &f ); 153 QTextStream ts ( &f );
154 ts.setDevice ( &f ); 154 ts.setDevice ( &f );
155 d->m_sysverstr = ts. readLine(); 155 d->m_sysverstr = ts. readLine();
156 f. close(); 156 f. close();
157 } 157 }
158 } 158 }
159 159
160 m_leds [0] = m_leds [1] = Led_Off; 160 m_leds [0] = m_leds [1] = Led_Off;
161 161
162 m_power_timer = 0; 162 m_power_timer = 0;
163 163
164} 164}
165 165
166void SIMpad::initButtons() 166void SIMpad::initButtons()
167{ 167{
168 if ( d->m_buttons ) 168 if ( d->m_buttons )
169 return; 169 return;
170 170
171 if ( isQWS( ) ) 171 if ( isQWS( ) )
172 QWSServer::setKeyboardFilter ( this ); 172 QWSServer::setKeyboardFilter ( this );
173 173
174 d->m_buttons = new QValueList <ODeviceButton>; 174 d->m_buttons = new QValueList <ODeviceButton>;
175 175
176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
177 s_button *sb = simpad_buttons + i; 177 s_button *sb = simpad_buttons + i;
178 ODeviceButton b; 178 ODeviceButton b;
179 179
180 if (( sb->model & d->m_model ) == d->m_model ) { 180 if (( sb->model & d->m_model ) == d->m_model ) {
181 b. setKeycode ( sb->code ); 181 b. setKeycode ( sb->code );
182 b. setUserText ( QObject::tr ( "Button", sb->utext )); 182 b. setUserText ( QObject::tr ( "Button", sb->utext ));
183 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 183 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
186 186
187 d->m_buttons->append ( b ); 187 d->m_buttons->append ( b );
188 } 188 }
189 } 189 }
190 reloadButtonMapping(); 190 reloadButtonMapping();
191 191
192 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 192 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
193 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 193 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
194} 194}
195 195
196// SIMpad boardcontrol register CS3 196// SIMpad boardcontrol register CS3
197#define SIMPAD_BOARDCONTROL "/proc/cs3" 197#define SIMPAD_BOARDCONTROL "/proc/cs3"
198#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 198#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
199#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 199#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
200#define SIMPAD_EN1 0x0004 // This is only for EPROM's 200#define SIMPAD_EN1 0x0004 // This is only for EPROM's
201#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 201#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
202#define SIMPAD_DISPLAY_ON 0x0010 202#define SIMPAD_DISPLAY_ON 0x0010
203#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 203#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
204#define SIMPAD_MQ_RESET 0x0040 204#define SIMPAD_MQ_RESET 0x0040
205#define SIMPAD_PCMCIA_RESET 0x0080 205#define SIMPAD_PCMCIA_RESET 0x0080
206#define SIMPAD_DECT_POWER_ON 0x0100 206#define SIMPAD_DECT_POWER_ON 0x0100
207#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 207#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
208#define SIMPAD_RS232_ON 0x0400 208#define SIMPAD_RS232_ON 0x0400
209#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 209#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
210#define SIMPAD_LED2_ON 0x1000 210#define SIMPAD_LED2_ON 0x1000
211#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 211#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
212#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 212#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
213#define SIMPAD_RESET_SIMCARD 0x8000 213#define SIMPAD_RESET_SIMCARD 0x8000
214 214
215//SIMpad touchscreen backlight strength control 215//SIMpad touchscreen backlight strength control
216#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 216#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
217#define SIMPAD_BACKLIGHT_MASK 0x00a10044 217#define SIMPAD_BACKLIGHT_MASK 0x00a10044
218 218
219QValueList <OLed> SIMpad::ledList() const 219QValueList <OLed> SIMpad::ledList() const
220{ 220{
221 QValueList <OLed> vl; 221 QValueList <OLed> vl;
222 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 222 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
223 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 223 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
224 return vl; 224 return vl;
225} 225}
226 226
227QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 227QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
228{ 228{
229 QValueList <OLedState> vl; 229 QValueList <OLedState> vl;
230 230
231 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 231 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
232 vl << Led_Off << Led_On; 232 vl << Led_Off << Led_On;
233 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 233 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
234 //vl << Led_Off; 234 //vl << Led_Off;
235 return vl; 235 return vl;
236} 236}
237 237
238OLedState SIMpad::ledState ( OLed l ) const 238OLedState SIMpad::ledState ( OLed l ) const
239{ 239{
240 switch ( l ) { 240 switch ( l ) {
241 case Led_Power: 241 case Led_Power:
242 return m_leds [0]; 242 return m_leds [0];
243 //case Led_Mail: 243 //case Led_Mail:
244 //return m_leds [1]; 244 //return m_leds [1];
245 default: 245 default:
246 return Led_Off; 246 return Led_Off;
247 } 247 }
248} 248}
249 249
250bool SIMpad::setLedState ( OLed l, OLedState st ) 250bool SIMpad::setLedState ( OLed l, OLedState st )
251{ 251{
252#if 0 252#if 0
253 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 253 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
254 254
255 /*TODO Implement this like that: 255 /*TODO Implement this like that:
256 read from cs3 256 read from cs3
257 && with SIMPAD_LED2_ON 257 && with SIMPAD_LED2_ON
258 write to cs3 */ 258 write to cs3 */
259 m_leds [0] = st; 259 m_leds [0] = st;
260 return true; 260 return true;
261 } 261 }
262 } 262 }
263 } 263 }
264 264
265#endif 265#endif
266 return false; 266 return false;
267} 267}
268 268
269 269
270bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 270bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
271{ 271{
272 //TODO 272 //TODO
273 return false; 273 return false;
274} 274}
275 275
276void SIMpad::timerEvent ( QTimerEvent * ) 276void SIMpad::timerEvent ( QTimerEvent * )
277{ 277{
278 killTimer ( m_power_timer ); 278 killTimer ( m_power_timer );
279 m_power_timer = 0; 279 m_power_timer = 0;
280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
281 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 281 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
282} 282}
283 283
284 284
285void SIMpad::playAlarmSound() 285void SIMpad::playAlarmSound()
286{ 286{
287#ifndef QT_NO_SOUND 287#ifndef QT_NO_SOUND
288 static Sound snd ( "alarm" ); 288 static Sound snd ( "alarm" );
289 int fd; 289 int fd;
290 int vol; 290 int vol;
291 bool vol_reset = false; 291 bool vol_reset = false;
292 292
293 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 293 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
294 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 294 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
295 Config cfg ( "qpe" ); 295 Config cfg ( "qpe" );
296 cfg. setGroup ( "Volume" ); 296 cfg. setGroup ( "Volume" );
297 297
298 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 298 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
299 if ( volalarm < 0 ) 299 if ( volalarm < 0 )
300 volalarm = 0; 300 volalarm = 0;
301 else if ( volalarm > 100 ) 301 else if ( volalarm > 100 )
302 volalarm = 100; 302 volalarm = 100;
303 volalarm |= ( volalarm << 8 ); 303 volalarm |= ( volalarm << 8 );
304 304
305 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 305 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
306 vol_reset = true; 306 vol_reset = true;
307 } 307 }
308 } 308 }
309 309
310 snd. play(); 310 snd. play();
311 while ( !snd. isFinished()) 311 while ( !snd. isFinished())
312 qApp->processEvents(); 312 qApp->processEvents();
313 313
314 if ( fd >= 0 ) { 314 if ( fd >= 0 ) {
315 if ( vol_reset ) 315 if ( vol_reset )
316 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 316 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
317 ::close ( fd ); 317 ::close ( fd );
318 } 318 }
319#endif 319#endif
320} 320}
321 321
322 322
323bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 323bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
324{ 324{
325 qDebug( "ODevice for SIMpad: suspend()" ); 325 qDebug( "ODevice for SIMpad: suspend()" );
326 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 326 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
327 return false; 327 return false;
328 328
329 bool res = false; 329 bool res = false;
330 ODevice::sendSuspendmsg(); 330 ODevice::sendSuspendmsg();
331 331
332 struct timeval tvs, tvn; 332 struct timeval tvs, tvn;
333 ::gettimeofday ( &tvs, 0 ); 333 ::gettimeofday ( &tvs, 0 );
334 334
335 ::sync(); // flush fs caches 335 ::sync(); // flush fs caches
336 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 336 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
337 337
338 return res; 338 return res;
339} 339}
340 340
341 341
342bool SIMpad::setSoftSuspend ( bool soft ) 342bool SIMpad::setSoftSuspend ( bool soft )
343{ 343{
344 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 344 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
345 return false; 345 return false;
346} 346}
347 347
348 348
349bool SIMpad::setDisplayStatus ( bool on ) 349bool SIMpad::setDisplayStatus ( bool on )
350{ 350{
351 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 351 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
352 352
353 bool res = false; 353 bool res = false;
354 int fd; 354 int fd;
355 355
356 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 356 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
357 357
358 res = ( ::system( (const char*) cmdline ) == 0 ); 358 res = ( ::system( (const char*) cmdline ) == 0 );
359 359
360 return res; 360 return res;
361} 361}
362 362
363 363
364bool SIMpad::setDisplayBrightness ( int bright ) 364bool SIMpad::setDisplayBrightness ( int bright )
365{ 365{
366 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 366 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
367 bool res = false; 367 bool res = false;
368 int fd; 368 int fd;
369 369
370 if ( bright > 255 ) 370 if ( bright > 255 )
371 bright = 255; 371 bright = 255;
372 if ( bright < 1 ) 372 if ( bright < 1 )
373 bright = 0; 373 bright = 0;
374 374
375 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 375 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
376 int value = 255 - bright; 376 int value = 255 - bright;
377 const int mask = SIMPAD_BACKLIGHT_MASK; 377 const int mask = SIMPAD_BACKLIGHT_MASK;
378 value = value << 8; 378 value = value << 8;
379 value += mask; 379 value += mask;
380 char writeCommand[100]; 380 char writeCommand[100];
381 const int count = sprintf( writeCommand, "0x%x\n", value ); 381 const int count = sprintf( writeCommand, "0x%x\n", value );
382 res = ( ::write ( fd, writeCommand, count ) != -1 ); 382 res = ( ::write ( fd, writeCommand, count ) != -1 );
383 ::close ( fd ); 383 ::close ( fd );
384 } 384 }
385 return res; 385 return res;
386} 386}
387 387
388 388
389int SIMpad::displayBrightnessResolution() const 389int SIMpad::displayBrightnessResolution() const
390{ 390{
391 return 255; // All SIMpad models share the same display 391 return 255; // All SIMpad models share the same display
392} 392}
393 393
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 000d29c..1434e69 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,463 +1,463 @@
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_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "mail", "raise()", 78 "opiemail", "raise()",
79 "mail", "newMail()" }, 79 "opiemail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
106// class up into individual classes. We need three classes 106// class up into individual classes. We need three classes
107// 107//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
111// 111//
112// Only question right now is: Do we really need to do it? Because as soon 112// Only question right now is: Do we really need to do it? Because as soon
113// as the OpenZaurus kernel is ready, there will be a unified interface for all 113// as the OpenZaurus kernel is ready, there will be a unified interface for all
114// Zaurus models (concerning apm, backlight, buttons, etc.) 114// Zaurus models (concerning apm, backlight, buttons, etc.)
115// 115//
116// Comments? - mickeyl. 116// Comments? - mickeyl.
117 117
118void Zaurus::init() 118void Zaurus::init()
119{ 119{
120 d->m_vendorstr = "Sharp"; 120 d->m_vendorstr = "Sharp";
121 d->m_vendor = Vendor_Sharp; 121 d->m_vendor = Vendor_Sharp;
122 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 122 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
123 123
124 // QFile f ( "/proc/filesystems" ); 124 // QFile f ( "/proc/filesystems" );
125 QString model; 125 QString model;
126 126
127 // It isn't a good idea to check the system configuration to 127 // It isn't a good idea to check the system configuration to
128 // detect the distribution ! 128 // detect the distribution !
129 // Otherwise it may happen that any other distribution is detected as openzaurus, just 129 // Otherwise it may happen that any other distribution is detected as openzaurus, just
130 // because it uses a jffs2 filesystem.. 130 // because it uses a jffs2 filesystem..
131 // (eilers) 131 // (eilers)
132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { 132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
133 QFile f ("/etc/oz_version"); 133 QFile f ("/etc/oz_version");
134 if ( f.exists() ){ 134 if ( f.exists() ){
135 d->m_vendorstr = "OpenZaurus Team"; 135 d->m_vendorstr = "OpenZaurus Team";
136 d->m_systemstr = "OpenZaurus"; 136 d->m_systemstr = "OpenZaurus";
137 d->m_system = System_OpenZaurus; 137 d->m_system = System_OpenZaurus;
138 138
139 if ( f. open ( IO_ReadOnly )) { 139 if ( f. open ( IO_ReadOnly )) {
140 QTextStream ts ( &f ); 140 QTextStream ts ( &f );
141 d->m_sysverstr = ts. readLine();//. mid ( 10 ); 141 d->m_sysverstr = ts. readLine();//. mid ( 10 );
142 f. close(); 142 f. close();
143 } 143 }
144 144
145 // Openzaurus sometimes uses the embedix kernel! 145 // Openzaurus sometimes uses the embedix kernel!
146 // => Check whether this is an embedix kernel 146 // => Check whether this is an embedix kernel
147 FILE *uname = popen("uname -r", "r"); 147 FILE *uname = popen("uname -r", "r");
148 QString line; 148 QString line;
149 if ( f.open(IO_ReadOnly, uname) ) { 149 if ( f.open(IO_ReadOnly, uname) ) {
150 QTextStream ts ( &f ); 150 QTextStream ts ( &f );
151 line = ts. readLine(); 151 line = ts. readLine();
152 int loc = line. find ( "embedix" ); 152 int loc = line. find ( "embedix" );
153 if ( loc != -1 ) 153 if ( loc != -1 )
154 m_embedix = true; 154 m_embedix = true;
155 else 155 else
156 m_embedix = false; 156 m_embedix = false;
157 f. close(); 157 f. close();
158 } 158 }
159 pclose(uname); 159 pclose(uname);
160 } 160 }
161 else { 161 else {
162 d->m_systemstr = "Zaurus"; 162 d->m_systemstr = "Zaurus";
163 d->m_system = System_Zaurus; 163 d->m_system = System_Zaurus;
164 } 164 }
165 165
166 f. setName ( "/proc/cpuinfo" ); 166 f. setName ( "/proc/cpuinfo" );
167 if ( f. open ( IO_ReadOnly ) ) { 167 if ( f. open ( IO_ReadOnly ) ) {
168 QTextStream ts ( &f ); 168 QTextStream ts ( &f );
169 QString line; 169 QString line;
170 while( line = ts. readLine() ) { 170 while( line = ts. readLine() ) {
171 if ( line. left ( 8 ) == "Hardware" ) 171 if ( line. left ( 8 ) == "Hardware" )
172 break; 172 break;
173 } 173 }
174 int loc = line. find ( ":" ); 174 int loc = line. find ( ":" );
175 if ( loc != -1 ) 175 if ( loc != -1 )
176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
177 } 177 }
178 178
179 if ( model == "SHARP Corgi" ) { 179 if ( model == "SHARP Corgi" ) {
180 d->m_model = Model_Zaurus_SLC7x0; 180 d->m_model = Model_Zaurus_SLC7x0;
181 d->m_modelstr = "Zaurus SL-C700"; 181 d->m_modelstr = "Zaurus SL-C700";
182 } else if ( model == "SHARP Shepherd" ) { 182 } else if ( model == "SHARP Shepherd" ) {
183 d->m_model = Model_Zaurus_SLC7x0; 183 d->m_model = Model_Zaurus_SLC7x0;
184 d->m_modelstr = "Zaurus SL-C750"; 184 d->m_modelstr = "Zaurus SL-C750";
185 } else if ( model == "SHARP Husky" ) { 185 } else if ( model == "SHARP Husky" ) {
186 d->m_model = Model_Zaurus_SLC7x0; 186 d->m_model = Model_Zaurus_SLC7x0;
187 d->m_modelstr = "Zaurus SL-C760"; 187 d->m_modelstr = "Zaurus SL-C760";
188 } else if ( model == "SHARP Poodle" ) { 188 } else if ( model == "SHARP Poodle" ) {
189 d->m_model = Model_Zaurus_SLB600; 189 d->m_model = Model_Zaurus_SLB600;
190 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 190 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
191 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 191 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
192 d->m_model = Model_Zaurus_SL5500; 192 d->m_model = Model_Zaurus_SL5500;
193 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 193 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
194 } else { 194 } else {
195 d->m_model = Model_Zaurus_SL5500; 195 d->m_model = Model_Zaurus_SL5500;
196 d->m_modelstr = "Zaurus (Model unknown)"; 196 d->m_modelstr = "Zaurus (Model unknown)";
197 } 197 }
198 198
199 bool flipstate = false; 199 bool flipstate = false;
200 switch ( d->m_model ) { 200 switch ( d->m_model ) {
201 case Model_Zaurus_SLA300: 201 case Model_Zaurus_SLA300:
202 d->m_rotation = Rot0; 202 d->m_rotation = Rot0;
203 break; 203 break;
204 case Model_Zaurus_SLC7x0: 204 case Model_Zaurus_SLC7x0:
205 d->m_rotation = rotation(); 205 d->m_rotation = rotation();
206 d->m_direction = direction(); 206 d->m_direction = direction();
207 break; 207 break;
208 case Model_Zaurus_SLB600: 208 case Model_Zaurus_SLB600:
209 case Model_Zaurus_SL5500: 209 case Model_Zaurus_SL5500:
210 case Model_Zaurus_SL5000: 210 case Model_Zaurus_SL5000:
211 default: 211 default:
212 d->m_rotation = Rot270; 212 d->m_rotation = Rot270;
213 break; 213 break;
214 } 214 }
215 m_leds [0] = Led_Off; 215 m_leds [0] = Led_Off;
216} 216}
217 217
218void Zaurus::initButtons() 218void Zaurus::initButtons()
219{ 219{
220 if ( d->m_buttons ) 220 if ( d->m_buttons )
221 return; 221 return;
222 222
223 d->m_buttons = new QValueList <ODeviceButton>; 223 d->m_buttons = new QValueList <ODeviceButton>;
224 224
225 struct z_button * pz_buttons; 225 struct z_button * pz_buttons;
226 int buttoncount; 226 int buttoncount;
227 switch ( d->m_model ) { 227 switch ( d->m_model ) {
228 case Model_Zaurus_SLC7x0: 228 case Model_Zaurus_SLC7x0:
229 pz_buttons = z_buttons_c700; 229 pz_buttons = z_buttons_c700;
230 buttoncount = ARRAY_SIZE(z_buttons_c700); 230 buttoncount = ARRAY_SIZE(z_buttons_c700);
231 break; 231 break;
232 default: 232 default:
233 pz_buttons = z_buttons; 233 pz_buttons = z_buttons;
234 buttoncount = ARRAY_SIZE(z_buttons); 234 buttoncount = ARRAY_SIZE(z_buttons);
235 break; 235 break;
236 } 236 }
237 237
238 for ( int i = 0; i < buttoncount; i++ ) { 238 for ( int i = 0; i < buttoncount; i++ ) {
239 struct z_button *zb = pz_buttons + i; 239 struct z_button *zb = pz_buttons + i;
240 ODeviceButton b; 240 ODeviceButton b;
241 241
242 b. setKeycode ( zb->code ); 242 b. setKeycode ( zb->code );
243 b. setUserText ( QObject::tr ( "Button", zb->utext )); 243 b. setUserText ( QObject::tr ( "Button", zb->utext ));
244 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 244 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
245 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 245 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
246 zb->fpressedaction )); 246 zb->fpressedaction ));
247 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 247 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
248 zb->fheldaction )); 248 zb->fheldaction ));
249 249
250 d->m_buttons->append ( b ); 250 d->m_buttons->append ( b );
251 } 251 }
252 252
253 reloadButtonMapping(); 253 reloadButtonMapping();
254 254
255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
256 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), 256 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
257 this, SLOT( systemMessage(const QCString&,const QByteArray&))); 257 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
258} 258}
259 259
260#include <unistd.h> 260#include <unistd.h>
261#include <fcntl.h> 261#include <fcntl.h>
262#include <sys/ioctl.h> 262#include <sys/ioctl.h>
263 263
264//#include <asm/sharp_char.h> // including kernel headers is evil ... 264//#include <asm/sharp_char.h> // including kernel headers is evil ...
265 265
266#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 266#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
267 267
268 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 268 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
269#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 269#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
270 270
271#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 271#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
272#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 272#define SHARP_BUZ_KEYSOUND 2 /* key sound */
273#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 273#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
274 274
275/* --- for SHARP_BUZZER device --- */ 275/* --- for SHARP_BUZZER device --- */
276 276
277 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 277 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
278//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 278//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
279 279
280#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 280#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
281#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 281#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
282#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 282#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
283#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 283#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
284#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 284#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
285 285
286//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 286//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
287//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 287//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
288 288
289//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 289//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
290//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 290//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
291//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 291//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
292//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 292//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
293//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 293//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
294//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 294//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
295//#define SHARP_PDA_APPSTART 9 /* application start */ 295//#define SHARP_PDA_APPSTART 9 /* application start */
296//#define SHARP_PDA_APPQUIT 10 /* application ends */ 296//#define SHARP_PDA_APPQUIT 10 /* application ends */
297 297
298//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 298//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
299//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 299//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
300//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 300//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
301//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 301//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
302// 302//
303 303
304 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 304 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
305#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 305#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
306 306
307#define SHARP_IOCTL_GET_ROTATION 0x413c 307#define SHARP_IOCTL_GET_ROTATION 0x413c
308 308
309typedef struct sharp_led_status { 309typedef struct sharp_led_status {
310int which; /* select which LED status is wanted. */ 310int which; /* select which LED status is wanted. */
311int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 311int status; /* set new led status if you call SHARP_LED_SETSTATUS */
312} sharp_led_status; 312} sharp_led_status;
313 313
314#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 314#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
315 315
316#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 316#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
317#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 317#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
318#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 318#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
319 319
320// #include <asm/sharp_apm.h> // including kernel headers is evil ... 320// #include <asm/sharp_apm.h> // including kernel headers is evil ...
321 321
322#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 322#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
323#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 323#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
324#define APM_EVT_POWER_BUTTON (1 << 0) 324#define APM_EVT_POWER_BUTTON (1 << 0)
325 325
326#define FL_IOCTL_STEP_CONTRAST 100 326#define FL_IOCTL_STEP_CONTRAST 100
327 327
328 328
329void Zaurus::buzzer ( int sound ) 329void Zaurus::buzzer ( int sound )
330{ 330{
331#ifndef QT_NO_SOUND 331#ifndef QT_NO_SOUND
332 QString soundname; 332 QString soundname;
333 333
334 // Not all devices have real sound 334 // Not all devices have real sound
335 if ( d->m_model == Model_Zaurus_SLC7x0 335 if ( d->m_model == Model_Zaurus_SLC7x0
336 || d->m_model == Model_Zaurus_SLB600 ){ 336 || d->m_model == Model_Zaurus_SLB600 ){
337 337
338 switch ( sound ){ 338 switch ( sound ){
339 case SHARP_BUZ_SCHEDULE_ALARM: 339 case SHARP_BUZ_SCHEDULE_ALARM:
340 soundname = "alarm"; 340 soundname = "alarm";
341 break; 341 break;
342 case SHARP_BUZ_TOUCHSOUND: 342 case SHARP_BUZ_TOUCHSOUND:
343 soundname = "touchsound"; 343 soundname = "touchsound";
344 break; 344 break;
345 case SHARP_BUZ_KEYSOUND: 345 case SHARP_BUZ_KEYSOUND:
346 soundname = "keysound"; 346 soundname = "keysound";
347 break; 347 break;
348 default: 348 default:
349 soundname = "alarm"; 349 soundname = "alarm";
350 350
351 } 351 }
352 } 352 }
353 353
354 // If a soundname is defined, we expect that this device has 354 // If a soundname is defined, we expect that this device has
355 // sound capabilities.. Otherwise we expect to have the buzzer 355 // sound capabilities.. Otherwise we expect to have the buzzer
356 // device.. 356 // device..
357 if ( !soundname.isEmpty() ){ 357 if ( !soundname.isEmpty() ){
358 int fd; 358 int fd;
359 int vol; 359 int vol;
360 bool vol_reset = false; 360 bool vol_reset = false;
361 361
362 Sound snd ( soundname ); 362 Sound snd ( soundname );
363 363
364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
366 Config cfg ( "qpe" ); 366 Config cfg ( "qpe" );
367 cfg. setGroup ( "Volume" ); 367 cfg. setGroup ( "Volume" );
368 368
369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
370 if ( volalarm < 0 ) 370 if ( volalarm < 0 )
371 volalarm = 0; 371 volalarm = 0;
372 else if ( volalarm > 100 ) 372 else if ( volalarm > 100 )
373 volalarm = 100; 373 volalarm = 100;
374 volalarm |= ( volalarm << 8 ); 374 volalarm |= ( volalarm << 8 );
375 375
376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
377 vol_reset = true; 377 vol_reset = true;
378 } 378 }
379 } 379 }
380 380
381 snd. play(); 381 snd. play();
382 while ( !snd. isFinished()) 382 while ( !snd. isFinished())
383 qApp->processEvents(); 383 qApp->processEvents();
384 384
385 if ( fd >= 0 ) { 385 if ( fd >= 0 ) {
386 if ( vol_reset ) 386 if ( vol_reset )
387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
388 ::close ( fd ); 388 ::close ( fd );
389 } 389 }
390 } else { 390 } else {
391 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 391 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
392 392
393 if ( fd >= 0 ) { 393 if ( fd >= 0 ) {
394 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 394 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
395 ::close ( fd ); 395 ::close ( fd );
396 } 396 }
397 397
398 } 398 }
399#endif 399#endif
400} 400}
401 401
402 402
403void Zaurus::playAlarmSound() 403void Zaurus::playAlarmSound()
404{ 404{
405 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 405 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
406} 406}
407 407
408void Zaurus::playTouchSound() 408void Zaurus::playTouchSound()
409{ 409{
410 buzzer ( SHARP_BUZ_TOUCHSOUND ); 410 buzzer ( SHARP_BUZ_TOUCHSOUND );
411} 411}
412 412
413void Zaurus::playKeySound() 413void Zaurus::playKeySound()
414{ 414{
415 buzzer ( SHARP_BUZ_KEYSOUND ); 415 buzzer ( SHARP_BUZ_KEYSOUND );
416} 416}
417 417
418 418
419QValueList <OLed> Zaurus::ledList() const 419QValueList <OLed> Zaurus::ledList() const
420{ 420{
421 QValueList <OLed> vl; 421 QValueList <OLed> vl;
422 vl << Led_Mail; 422 vl << Led_Mail;
423 return vl; 423 return vl;
424} 424}
425 425
426QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 426QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
427{ 427{
428 QValueList <OLedState> vl; 428 QValueList <OLedState> vl;
429 429
430 if ( l == Led_Mail ) 430 if ( l == Led_Mail )
431 vl << Led_Off << Led_On << Led_BlinkSlow; 431 vl << Led_Off << Led_On << Led_BlinkSlow;
432 return vl; 432 return vl;
433} 433}
434 434
435OLedState Zaurus::ledState ( OLed which ) const 435OLedState Zaurus::ledState ( OLed which ) const
436{ 436{
437 if ( which == Led_Mail ) 437 if ( which == Led_Mail )
438 return m_leds [0]; 438 return m_leds [0];
439 else 439 else
440 return Led_Off; 440 return Led_Off;
441} 441}
442 442
443bool Zaurus::setLedState ( OLed which, OLedState st ) 443bool Zaurus::setLedState ( OLed which, OLedState st )
444{ 444{
445 if (!m_embedix) // Currently not supported on non_embedix kernels 445 if (!m_embedix) // Currently not supported on non_embedix kernels
446 return false; 446 return false;
447 447
448 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 448 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
449 449
450 if ( which == Led_Mail ) { 450 if ( which == Led_Mail ) {
451 if ( fd >= 0 ) { 451 if ( fd >= 0 ) {
452 struct sharp_led_status leds; 452 struct sharp_led_status leds;
453 ::memset ( &leds, 0, sizeof( leds )); 453 ::memset ( &leds, 0, sizeof( leds ));
454 leds. which = SHARP_LED_MAIL_EXISTS; 454 leds. which = SHARP_LED_MAIL_EXISTS;
455 bool ok = true; 455 bool ok = true;
456 456
457 switch ( st ) { 457 switch ( st ) {
458 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 458 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
459 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 459 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
460 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 460 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
461 default : ok = false; 461 default : ok = false;
462 } 462 }
463 463