summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp73
-rw-r--r--libopie2/opiecore/device/odevice.h4
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp55
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h84
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp82
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h50
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp50
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h72
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp56
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h81
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp239
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h62
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp103
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h96
-rw-r--r--libopie2/opiecore/opiecore.pro6
15 files changed, 602 insertions, 511 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 0f88c3c..6c8432f 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,623 +1,622 @@
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.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h"
32#include "odevice_ramses.h"
33#include "odevice_simpad.h"
34#include "odevice_yopy.h"
35#include "odevice_zaurus.h"
31 36
32/* QT */ 37/* QT */
33#include <qapplication.h> 38#include <qapplication.h>
34#include <qfile.h> 39#include <qfile.h>
35#include <qtextstream.h> 40#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
37 42
38/* OPIE */ 43/* OPIE */
39#include <qpe/config.h> 44#include <qpe/config.h>
40#include <qpe/resource.h> 45#include <qpe/resource.h>
41#include <qpe/sound.h> 46#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
43 48
44/* STD */ 49/* STD */
45#include <fcntl.h> 50#include <fcntl.h>
46#include <math.h> 51#include <math.h>
47#include <stdlib.h> 52#include <stdlib.h>
48#include <signal.h> 53#include <signal.h>
49#include <sys/ioctl.h> 54#include <sys/ioctl.h>
50#include <sys/time.h> 55#include <sys/time.h>
51#include <unistd.h> 56#include <unistd.h>
52#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 58#include <linux/soundcard.h>
54#endif 59#endif
55 60
56#ifndef ARRAY_SIZE 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63
64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 62
69using namespace Opie; 63using namespace Opie;
70 64
71class iPAQ;
72class Zaurus;
73class SIMpad;
74class Ramses;
75class Jornada;
76
77ODevice *ODevice::inst() 65ODevice *ODevice::inst()
78{ 66{
79 static ODevice *dev = 0; 67 static ODevice *dev = 0;
80 68
81 // rewrite this to only use /proc/devinfo or so 69 // rewrite this to only use /proc/cpuinfo or so
82 70
83 /* 71 if ( !dev )
84 if ( !dev ) { 72 {
85 if ( QFile::exists ( "/proc/hal/model" )) 73 QFile f( PATH_PROC_CPUINFO );
86 dev = new iPAQ(); 74 if ( f.open( IO_ReadOnly ) )
87 else if ( Zaurus::isZaurus() ) 75 {
88 dev = new Zaurus(); 76 QTextStream s( &f );
89 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 77 while ( !s.atEnd() )
90 dev = new SIMpad(); 78 {
91 else if ( QFile::exists ( "/proc/sys/board/name" )) 79 QString line;
92 dev = new Ramses(); 80 line = s.readLine();
93 else if ( Yopy::isYopy() ) 81 if ( line.startsWith( "Hardware" ) )
94 dev = new Yopy(); 82 {
95 else if ( Jornada::isJornada() ) 83 qDebug( "ODevice() - found '%s'", (const char*) line );
96 dev = new Jornada(); 84 if ( line.contains( "sharp", false ) ) dev = new Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Ramses();
89 else qWarning( "ODevice() - unknown hardware - using default." );
90 break;
91 }
92 }
93 }
97 else 94 else
98 dev = new ODevice(); 95 {
96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." );
97 }
98 if ( !dev ) dev = new ODevice();
99 dev->init(); 99 dev->init();
100 } 100 }
101 */
102 return dev; 101 return dev;
103} 102}
104 103
105ODevice::ODevice() 104ODevice::ODevice()
106{ 105{
107 d = new ODeviceData; 106 d = new ODeviceData;
108 107
109 d->m_modelstr = "Unknown"; 108 d->m_modelstr = "Unknown";
110 d->m_model = Model_Unknown; 109 d->m_model = Model_Unknown;
111 d->m_vendorstr = "Unknown"; 110 d->m_vendorstr = "Unknown";
112 d->m_vendor = Vendor_Unknown; 111 d->m_vendor = Vendor_Unknown;
113 d->m_systemstr = "Unknown"; 112 d->m_systemstr = "Unknown";
114 d->m_system = System_Unknown; 113 d->m_system = System_Unknown;
115 d->m_sysverstr = "0.0"; 114 d->m_sysverstr = "0.0";
116 d->m_rotation = Rot0; 115 d->m_rotation = Rot0;
117 d->m_direction = CW; 116 d->m_direction = CW;
118 117
119 d->m_holdtime = 1000; // 1000ms 118 d->m_holdtime = 1000; // 1000ms
120 d->m_buttons = 0; 119 d->m_buttons = 0;
121 d->m_cpu_frequencies = new QStrList; 120 d->m_cpu_frequencies = new QStrList;
122} 121}
123 122
124void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 123void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
125{ 124{
126 if ( msg == "deviceButtonMappingChanged()" ) { 125 if ( msg == "deviceButtonMappingChanged()" ) {
127 reloadButtonMapping(); 126 reloadButtonMapping();
128 } 127 }
129} 128}
130 129
131void ODevice::init() 130void ODevice::init()
132{ 131{
133} 132}
134 133
135/** 134/**
136* This method initialises the button mapping 135* This method initialises the button mapping
137*/ 136*/
138void ODevice::initButtons() 137void ODevice::initButtons()
139{ 138{
140 if ( d->m_buttons ) 139 if ( d->m_buttons )
141 return; 140 return;
142 141
143 qDebug ( "init Buttons" ); 142 qDebug ( "init Buttons" );
144 d->m_buttons = new QValueList <ODeviceButton>; 143 d->m_buttons = new QValueList <ODeviceButton>;
145 144
146 reloadButtonMapping(); 145 reloadButtonMapping();
147 146
148 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
149 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 148 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
150} 149}
151 150
152ODevice::~ODevice() 151ODevice::~ODevice()
153{ 152{
154// we leak m_devicebuttons and m_cpu_frequency 153// we leak m_devicebuttons and m_cpu_frequency
155// but it's a singleton and it is not so importantant 154// but it's a singleton and it is not so importantant
156// -zecke 155// -zecke
157 delete d; 156 delete d;
158} 157}
159 158
160bool ODevice::setSoftSuspend ( bool /*soft*/ ) 159bool ODevice::setSoftSuspend ( bool /*soft*/ )
161{ 160{
162 return false; 161 return false;
163} 162}
164 163
165//#include <linux/apm_bios.h> 164//#include <linux/apm_bios.h>
166 165
167#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 166#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
168 167
169/** 168/**
170* This method will try to suspend the device 169* This method will try to suspend the device
171* It only works if the user is the QWS Server and the apm application 170* It only works if the user is the QWS Server and the apm application
172* is installed. 171* is installed.
173* It tries to suspend and then waits some time cause some distributions 172* It tries to suspend and then waits some time cause some distributions
174* do have asynchronus apm implementations. 173* do have asynchronus apm implementations.
175* This method will either fail and return false or it'll suspend the 174* This method will either fail and return false or it'll suspend the
176* device and return once the device got woken up 175* device and return once the device got woken up
177* 176*
178* @return if the device got suspended 177* @return if the device got suspended
179*/ 178*/
180bool ODevice::suspend() 179bool ODevice::suspend()
181{ 180{
182 qDebug("ODevice::suspend"); 181 qDebug("ODevice::suspend");
183 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
184 return false; 183 return false;
185 184
186 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
187 return false; 186 return false;
188 187
189 bool res = false; 188 bool res = false;
190 189
191 struct timeval tvs, tvn; 190 struct timeval tvs, tvn;
192 ::gettimeofday ( &tvs, 0 ); 191 ::gettimeofday ( &tvs, 0 );
193 192
194 ::sync(); // flush fs caches 193 ::sync(); // flush fs caches
195 res = ( ::system ( "apm --suspend" ) == 0 ); 194 res = ( ::system ( "apm --suspend" ) == 0 );
196 195
197 // This is needed because the iPAQ apm implementation is asynchronous and we 196 // This is needed because the iPAQ apm implementation is asynchronous and we
198 // can not be sure when exactly the device is really suspended 197 // 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. 198 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
200 199
201 if ( res ) { 200 if ( res ) {
202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 201 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
203 ::usleep ( 200 * 1000 ); 202 ::usleep ( 200 * 1000 );
204 ::gettimeofday ( &tvn, 0 ); 203 ::gettimeofday ( &tvn, 0 );
205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 204 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
206 } 205 }
207 206
208 return res; 207 return res;
209} 208}
210 209
211//#include <linux/fb.h> better not rely on kernel headers in userspace ... 210//#include <linux/fb.h> better not rely on kernel headers in userspace ...
212 211
213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 212#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
214 213
215/* VESA Blanking Levels */ 214/* VESA Blanking Levels */
216#define VESA_NO_BLANKING 0 215#define VESA_NO_BLANKING 0
217#define VESA_VSYNC_SUSPEND 1 216#define VESA_VSYNC_SUSPEND 1
218#define VESA_HSYNC_SUSPEND 2 217#define VESA_HSYNC_SUSPEND 2
219#define VESA_POWERDOWN 3 218#define VESA_POWERDOWN 3
220 219
221/** 220/**
222* This sets the display on or off 221* This sets the display on or off
223*/ 222*/
224bool ODevice::setDisplayStatus ( bool on ) 223bool ODevice::setDisplayStatus ( bool on )
225{ 224{
226 qDebug("ODevice::setDisplayStatus(%d)", on); 225 qDebug("ODevice::setDisplayStatus(%d)", on);
227 226
228 if ( d->m_model == Model_Unknown ) 227 if ( d->m_model == Model_Unknown )
229 return false; 228 return false;
230 229
231 bool res = false; 230 bool res = false;
232 int fd; 231 int fd;
233 232
234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 233 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 234 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
236 ::close ( fd ); 235 ::close ( fd );
237 } 236 }
238 return res; 237 return res;
239} 238}
240 239
241/** 240/**
242* This sets the display brightness 241* This sets the display brightness
243* 242*
244* @param p The brightness to be set on a scale from 0 to 255 243* @param p The brightness to be set on a scale from 0 to 255
245* @return success or failure 244* @return success or failure
246*/ 245*/
247bool ODevice::setDisplayBrightness ( int p) 246bool ODevice::setDisplayBrightness ( int p)
248{ 247{
249 Q_UNUSED( p ) 248 Q_UNUSED( p )
250 return false; 249 return false;
251} 250}
252 251
253/** 252/**
254* @return returns the number of steppings on the brightness slider 253* @return returns the number of steppings on the brightness slider
255* in the Light-'n-Power settings. 254* in the Light-'n-Power settings.
256*/ 255*/
257int ODevice::displayBrightnessResolution() const 256int ODevice::displayBrightnessResolution() const
258{ 257{
259 return 16; 258 return 16;
260} 259}
261 260
262/** 261/**
263* This sets the display contrast 262* This sets the display contrast
264* @param p The contrast to be set on a scale from 0 to 255 263* @param p The contrast to be set on a scale from 0 to 255
265* @return success or failure 264* @return success or failure
266*/ 265*/
267bool ODevice::setDisplayContrast ( int p) 266bool ODevice::setDisplayContrast ( int p)
268{ 267{
269 Q_UNUSED( p ) 268 Q_UNUSED( p )
270 return false; 269 return false;
271} 270}
272 271
273/** 272/**
274* @return return the max value for the brightness settings slider 273* @return return the max value for the brightness settings slider
275* or 0 if the device doesn't support setting of a contrast 274* or 0 if the device doesn't support setting of a contrast
276*/ 275*/
277int ODevice::displayContrastResolution() const 276int ODevice::displayContrastResolution() const
278{ 277{
279 return 0; 278 return 0;
280} 279}
281 280
282/** 281/**
283* This returns the vendor as string 282* This returns the vendor as string
284* @return Vendor as QString 283* @return Vendor as QString
285*/ 284*/
286QString ODevice::vendorString() const 285QString ODevice::vendorString() const
287{ 286{
288 return d->m_vendorstr; 287 return d->m_vendorstr;
289} 288}
290 289
291/** 290/**
292* This returns the vendor as one of the values of OVendor 291* This returns the vendor as one of the values of OVendor
293* @return OVendor 292* @return OVendor
294*/ 293*/
295OVendor ODevice::vendor() const 294OVendor ODevice::vendor() const
296{ 295{
297 return d->m_vendor; 296 return d->m_vendor;
298} 297}
299 298
300/** 299/**
301* This returns the model as a string 300* This returns the model as a string
302* @return A string representing the model 301* @return A string representing the model
303*/ 302*/
304QString ODevice::modelString() const 303QString ODevice::modelString() const
305{ 304{
306 return d->m_modelstr; 305 return d->m_modelstr;
307} 306}
308 307
309/** 308/**
310* This does return the OModel used 309* This does return the OModel used
311*/ 310*/
312OModel ODevice::model() const 311OModel ODevice::model() const
313{ 312{
314 return d->m_model; 313 return d->m_model;
315} 314}
316 315
317/** 316/**
318* This does return the systen name 317* This does return the systen name
319*/ 318*/
320QString ODevice::systemString() const 319QString ODevice::systemString() const
321{ 320{
322 return d->m_systemstr; 321 return d->m_systemstr;
323} 322}
324 323
325/** 324/**
326* Return System as OSystem value 325* Return System as OSystem value
327*/ 326*/
328OSystem ODevice::system() const 327OSystem ODevice::system() const
329{ 328{
330 return d->m_system; 329 return d->m_system;
331} 330}
332 331
333/** 332/**
334* @return the version string of the base system 333* @return the version string of the base system
335*/ 334*/
336QString ODevice::systemVersionString() const 335QString ODevice::systemVersionString() const
337{ 336{
338 return d->m_sysverstr; 337 return d->m_sysverstr;
339} 338}
340 339
341/** 340/**
342* @return the current Transformation 341* @return the current Transformation
343*/ 342*/
344Transformation ODevice::rotation() const 343Transformation ODevice::rotation() const
345{ 344{
346 return d->m_rotation; 345 return d->m_rotation;
347} 346}
348 347
349/** 348/**
350* @return the current rotation direction 349* @return the current rotation direction
351*/ 350*/
352ODirection ODevice::direction() const 351ODirection ODevice::direction() const
353{ 352{
354 return d->m_direction; 353 return d->m_direction;
355} 354}
356 355
357/** 356/**
358* This plays an alarmSound 357* This plays an alarmSound
359*/ 358*/
360void ODevice::alarmSound() 359void ODevice::alarmSound()
361{ 360{
362#ifndef QT_NO_SOUND 361#ifndef QT_NO_SOUND
363 static Sound snd ( "alarm" ); 362 static Sound snd ( "alarm" );
364 363
365 if ( snd. isFinished()) 364 if ( snd. isFinished())
366 snd. play(); 365 snd. play();
367#endif 366#endif
368} 367}
369 368
370/** 369/**
371* This plays a key sound 370* This plays a key sound
372*/ 371*/
373void ODevice::keySound() 372void ODevice::keySound()
374{ 373{
375#ifndef QT_NO_SOUND 374#ifndef QT_NO_SOUND
376 static Sound snd ( "keysound" ); 375 static Sound snd ( "keysound" );
377 376
378 if ( snd. isFinished()) 377 if ( snd. isFinished())
379 snd. play(); 378 snd. play();
380#endif 379#endif
381} 380}
382 381
383/** 382/**
384* This plays a touch sound 383* This plays a touch sound
385*/ 384*/
386void ODevice::touchSound() 385void ODevice::touchSound()
387{ 386{
388#ifndef QT_NO_SOUND 387#ifndef QT_NO_SOUND
389 static Sound snd ( "touchsound" ); 388 static Sound snd ( "touchsound" );
390 389
391 if ( snd. isFinished()) 390 if ( snd. isFinished())
392 snd. play(); 391 snd. play();
393#endif 392#endif
394} 393}
395 394
396/** 395/**
397* This method will return a list of leds 396* This method will return a list of leds
398* available on this device 397* available on this device
399* @return a list of LEDs. 398* @return a list of LEDs.
400*/ 399*/
401QValueList <OLed> ODevice::ledList() const 400QValueList <OLed> ODevice::ledList() const
402{ 401{
403 return QValueList <OLed>(); 402 return QValueList <OLed>();
404} 403}
405 404
406/** 405/**
407* This does return the state of the LEDs 406* This does return the state of the LEDs
408*/ 407*/
409QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 408QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
410{ 409{
411 return QValueList <OLedState>(); 410 return QValueList <OLedState>();
412} 411}
413 412
414/** 413/**
415* @return the state for a given OLed 414* @return the state for a given OLed
416*/ 415*/
417OLedState ODevice::ledState ( OLed /*which*/ ) const 416OLedState ODevice::ledState ( OLed /*which*/ ) const
418{ 417{
419 return Led_Off; 418 return Led_Off;
420} 419}
421 420
422/** 421/**
423* Set the state for a LED 422* Set the state for a LED
424* @param which Which OLed to use 423* @param which Which OLed to use
425* @param st The state to set 424* @param st The state to set
426* @return success or failure 425* @return success or failure
427*/ 426*/
428bool ODevice::setLedState ( OLed which, OLedState st ) 427bool ODevice::setLedState ( OLed which, OLedState st )
429{ 428{
430 Q_UNUSED( which ) 429 Q_UNUSED( which )
431 Q_UNUSED( st ) 430 Q_UNUSED( st )
432 return false; 431 return false;
433} 432}
434 433
435/** 434/**
436* @return if the device has a light sensor 435* @return if the device has a light sensor
437*/ 436*/
438bool ODevice::hasLightSensor() const 437bool ODevice::hasLightSensor() const
439{ 438{
440 return false; 439 return false;
441} 440}
442 441
443/** 442/**
444* @return a value from the light sensor 443* @return a value from the light sensor
445*/ 444*/
446int ODevice::readLightSensor() 445int ODevice::readLightSensor()
447{ 446{
448 return -1; 447 return -1;
449} 448}
450 449
451/** 450/**
452* @return the light sensor resolution 451* @return the light sensor resolution
453*/ 452*/
454int ODevice::lightSensorResolution() const 453int ODevice::lightSensorResolution() const
455{ 454{
456 return 0; 455 return 0;
457} 456}
458 457
459/** 458/**
460* @return if the device has a hinge sensor 459* @return if the device has a hinge sensor
461*/ 460*/
462bool ODevice::hasHingeSensor() const 461bool ODevice::hasHingeSensor() const
463{ 462{
464 return false; 463 return false;
465} 464}
466 465
467/** 466/**
468* @return a value from the hinge sensor 467* @return a value from the hinge sensor
469*/ 468*/
470OHingeStatus ODevice::readHingeSensor() 469OHingeStatus ODevice::readHingeSensor()
471{ 470{
472 return CASE_UNKNOWN; 471 return CASE_UNKNOWN;
473} 472}
474 473
475/** 474/**
476* @return a list with CPU frequencies supported by the hardware 475* @return a list with CPU frequencies supported by the hardware
477*/ 476*/
478const QStrList &ODevice::allowedCpuFrequencies() const 477const QStrList &ODevice::allowedCpuFrequencies() const
479{ 478{
480 return *d->m_cpu_frequencies; 479 return *d->m_cpu_frequencies;
481} 480}
482 481
483 482
484/** 483/**
485* Set desired CPU frequency 484* Set desired CPU frequency
486* 485*
487* @param index index into d->m_cpu_frequencies of the frequency to be set 486* @param index index into d->m_cpu_frequencies of the frequency to be set
488*/ 487*/
489bool ODevice::setCurrentCpuFrequency(uint index) 488bool ODevice::setCurrentCpuFrequency(uint index)
490{ 489{
491 if (index >= d->m_cpu_frequencies->count()) 490 if (index >= d->m_cpu_frequencies->count())
492 return false; 491 return false;
493 492
494 char *freq = d->m_cpu_frequencies->at(index); 493 char *freq = d->m_cpu_frequencies->at(index);
495 qWarning("set freq to %s", freq); 494 qWarning("set freq to %s", freq);
496 495
497 int fd; 496 int fd;
498 497
499 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 498 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
500 char writeCommand[50]; 499 char writeCommand[50];
501 const int count = sprintf(writeCommand, "%s\n", freq); 500 const int count = sprintf(writeCommand, "%s\n", freq);
502 int res = (::write(fd, writeCommand, count) != -1); 501 int res = (::write(fd, writeCommand, count) != -1);
503 ::close(fd); 502 ::close(fd);
504 return res; 503 return res;
505 } 504 }
506 505
507 return false; 506 return false;
508} 507}
509 508
510 509
511/** 510/**
512* @return a list of hardware buttons 511* @return a list of hardware buttons
513*/ 512*/
514const QValueList <ODeviceButton> &ODevice::buttons() 513const QValueList <ODeviceButton> &ODevice::buttons()
515{ 514{
516 initButtons(); 515 initButtons();
517 516
518 return *d->m_buttons; 517 return *d->m_buttons;
519} 518}
520 519
521/** 520/**
522* @return The amount of time that would count as a hold 521* @return The amount of time that would count as a hold
523*/ 522*/
524uint ODevice::buttonHoldTime() const 523uint ODevice::buttonHoldTime() const
525{ 524{
526 return d->m_holdtime; 525 return d->m_holdtime;
527} 526}
528 527
529/** 528/**
530* This method return a ODeviceButton for a key code 529* This method return a ODeviceButton for a key code
531* or 0 if no special hardware button is available for the device 530* or 0 if no special hardware button is available for the device
532* 531*
533* @return The devicebutton or 0l 532* @return The devicebutton or 0l
534* @see ODeviceButton 533* @see ODeviceButton
535*/ 534*/
536const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 535const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
537{ 536{
538 initButtons(); 537 initButtons();
539 538
540 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 539 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
541 if ( (*it). keycode() == code ) 540 if ( (*it). keycode() == code )
542 return &(*it); 541 return &(*it);
543 } 542 }
544 return 0; 543 return 0;
545} 544}
546 545
547void ODevice::reloadButtonMapping() 546void ODevice::reloadButtonMapping()
548{ 547{
549 initButtons(); 548 initButtons();
550 549
551 Config cfg ( "ButtonSettings" ); 550 Config cfg ( "ButtonSettings" );
552 551
553 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 552 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
554 ODeviceButton &b = ( *d->m_buttons ) [i]; 553 ODeviceButton &b = ( *d->m_buttons ) [i];
555 QString group = "Button" + QString::number ( i ); 554 QString group = "Button" + QString::number ( i );
556 555
557 QCString pch, hch; 556 QCString pch, hch;
558 QCString pm, hm; 557 QCString pm, hm;
559 QByteArray pdata, hdata; 558 QByteArray pdata, hdata;
560 559
561 if ( cfg. hasGroup ( group )) { 560 if ( cfg. hasGroup ( group )) {
562 cfg. setGroup ( group ); 561 cfg. setGroup ( group );
563 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 562 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
564 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 563 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
565 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 564 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
566 565
567 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 566 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
568 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 567 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
569 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 568 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
570 } 569 }
571 570
572 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 571 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
573 572
574 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 573 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
575 } 574 }
576} 575}
577 576
578void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 577void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
579{ 578{
580 initButtons(); 579 initButtons();
581 580
582 QString mb_chan; 581 QString mb_chan;
583 582
584 if ( button >= (int) d->m_buttons->count()) 583 if ( button >= (int) d->m_buttons->count())
585 return; 584 return;
586 585
587 ODeviceButton &b = ( *d->m_buttons ) [button]; 586 ODeviceButton &b = ( *d->m_buttons ) [button];
588 b. setPressedAction ( action ); 587 b. setPressedAction ( action );
589 588
590 mb_chan=b. pressedAction(). channel(); 589 mb_chan=b. pressedAction(). channel();
591 590
592 Config buttonFile ( "ButtonSettings" ); 591 Config buttonFile ( "ButtonSettings" );
593 buttonFile. setGroup ( "Button" + QString::number ( button )); 592 buttonFile. setGroup ( "Button" + QString::number ( button ));
594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 593 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 594 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
596 595
597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 596 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
598 597
599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 598 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
600} 599}
601 600
602void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 601void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
603{ 602{
604 initButtons(); 603 initButtons();
605 604
606 if ( button >= (int) d->m_buttons->count()) 605 if ( button >= (int) d->m_buttons->count())
607 return; 606 return;
608 607
609 ODeviceButton &b = ( *d->m_buttons ) [button]; 608 ODeviceButton &b = ( *d->m_buttons ) [button];
610 b. setHeldAction ( action ); 609 b. setHeldAction ( action );
611 610
612 Config buttonFile ( "ButtonSettings" ); 611 Config buttonFile ( "ButtonSettings" );
613 buttonFile. setGroup ( "Button" + QString::number ( button )); 612 buttonFile. setGroup ( "Button" + QString::number ( button ));
614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 613 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 614 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
616 615
617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 616 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
618 617
619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 618 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
620} 619}
621void ODevice::virtual_hook(int, void* ){ 620void ODevice::virtual_hook(int, void* ){
622 621
623} 622}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index bde6411..8ae7ffa 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,329 +1,329 @@
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#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
34 36
35/* QT */ 37/* QT */
36#include <qnamespace.h> 38#include <qnamespace.h>
37#include <qobject.h> 39#include <qobject.h>
38#include <qstring.h> 40#include <qstring.h>
39#include <qstrlist.h> 41#include <qstrlist.h>
40 42
41#include <qpe/qpeapplication.h> /* for Transformation enum.. */
42
43namespace Opie 43namespace Opie
44{ 44{
45 class ODeviceData; 45 class ODeviceData;
46/** 46/**
47 * The available devices 47 * The available devices
48 */ 48 */
49enum OModel { 49enum OModel {
50 Model_Unknown, // = 0 50 Model_Unknown, // = 0
51 51
52 Model_Series_Mask = 0xff000000, 52 Model_Series_Mask = 0xff000000,
53 53
54 Model_iPAQ = ( 1 << 24 ), 54 Model_iPAQ = ( 1 << 24 ),
55 55
56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
63 63
64 Model_Jornada = ( 6 << 24 ), 64 Model_Jornada = ( 6 << 24 ),
65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
66 66
67 Model_Zaurus = ( 2 << 24 ), 67 Model_Zaurus = ( 2 << 24 ),
68 68
69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
73 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 73 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
74 74
75 Model_SIMpad = ( 3 << 24 ), 75 Model_SIMpad = ( 3 << 24 ),
76 76
77 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 77 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
78 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 78 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
79 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 79 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
80 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 80 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
81 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 81 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
82 82
83 Model_Ramses = ( 4 << 24 ), 83 Model_Ramses = ( 4 << 24 ),
84 84
85 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 85 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
86 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 86 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
87 87
88 Model_Yopy = ( 5 << 24 ), 88 Model_Yopy = ( 5 << 24 ),
89 89
90 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 90 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
91 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 91 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
92 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 92 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
93 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 93 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
94 94
95}; 95};
96 96
97/** 97/**
98 * The vendor of the device 98 * The vendor of the device
99 */ 99 */
100enum OVendor { 100enum OVendor {
101 Vendor_Unknown, 101 Vendor_Unknown,
102 102
103 Vendor_HP, 103 Vendor_HP,
104 Vendor_Sharp, 104 Vendor_Sharp,
105 Vendor_SIEMENS, 105 Vendor_SIEMENS,
106 Vendor_MundN, 106 Vendor_MundN,
107 Vendor_GMate, 107 Vendor_GMate,
108}; 108};
109 109
110/** 110/**
111 * The System used 111 * The System used
112 */ 112 */
113enum OSystem { 113enum OSystem {
114 System_Unknown, 114 System_Unknown,
115 115
116 System_Familiar, 116 System_Familiar,
117 System_Zaurus, 117 System_Zaurus,
118 System_OpenZaurus, 118 System_OpenZaurus,
119 System_Linupy, 119 System_Linupy,
120}; 120};
121 121
122enum OLedState { 122enum OLedState {
123 Led_Off, 123 Led_Off,
124 Led_On, 124 Led_On,
125 Led_BlinkSlow, 125 Led_BlinkSlow,
126 Led_BlinkFast 126 Led_BlinkFast
127}; 127};
128 128
129enum OLed { 129enum OLed {
130 Led_Mail, 130 Led_Mail,
131 Led_Power, 131 Led_Power,
132 Led_BlueTooth 132 Led_BlueTooth
133}; 133};
134 134
135enum OHardKey { 135enum OHardKey {
136 HardKey_Datebook = Qt::Key_F9, 136 HardKey_Datebook = Qt::Key_F9,
137 HardKey_Contacts = Qt::Key_F10, 137 HardKey_Contacts = Qt::Key_F10,
138 HardKey_Menu = Qt::Key_F11, 138 HardKey_Menu = Qt::Key_F11,
139 HardKey_Home = Qt::Key_F12, 139 HardKey_Home = Qt::Key_F12,
140 HardKey_Mail = Qt::Key_F13, 140 HardKey_Mail = Qt::Key_F13,
141 HardKey_Record = Qt::Key_F24, 141 HardKey_Record = Qt::Key_F24,
142 HardKey_Suspend = Qt::Key_F34, 142 HardKey_Suspend = Qt::Key_F34,
143 HardKey_Backlight = Qt::Key_F35, 143 HardKey_Backlight = Qt::Key_F35,
144 HardKey_Action = Qt::Key_F10, 144 HardKey_Action = Qt::Key_F10,
145 HardKey_OK = Qt::Key_F11, 145 HardKey_OK = Qt::Key_F11,
146 HardKey_End = Qt::Key_F12, 146 HardKey_End = Qt::Key_F12,
147}; 147};
148 148
149enum ODirection { 149enum ODirection {
150 CW = 0, 150 CW = 0,
151 CCW = 1, 151 CCW = 1,
152 Flip = 2, 152 Flip = 2,
153}; 153};
154 154
155enum OHingeStatus { 155enum OHingeStatus {
156 CASE_CLOSED = 3, 156 CASE_CLOSED = 3,
157 CASE_PORTRAIT = 2, 157 CASE_PORTRAIT = 2,
158 CASE_LANDSCAPE = 0, 158 CASE_LANDSCAPE = 0,
159 CASE_UNKNOWN = 1, 159 CASE_UNKNOWN = 1,
160}; 160};
161 161
162/** 162/**
163 * A singleton which gives informations about device specefic option 163 * A singleton which gives informations about device specefic option
164 * like the Hardware used, LEDs, the Base Distribution and 164 * like the Hardware used, LEDs, the Base Distribution and
165 * hardware key mappings. 165 * hardware key mappings.
166 * 166 *
167 * @short A small class for device specefic options 167 * @short A small class for device specefic options
168 * @see QObject 168 * @see QObject
169 * @author Robert Griebl 169 * @author Robert Griebl
170 * @version 1.0 170 * @version 1.0
171 */ 171 */
172class ODevice : public QObject 172class ODevice : public QObject
173{ 173{
174 Q_OBJECT 174 Q_OBJECT
175 175
176private: 176private:
177 /* disable copy */ 177 /* disable copy */
178 ODevice ( const ODevice & ); 178 ODevice ( const ODevice & );
179 179
180protected: 180protected:
181 ODevice(); 181 ODevice();
182 virtual void init(); 182 virtual void init();
183 virtual void initButtons(); 183 virtual void initButtons();
184 184
185 ODeviceData *d; 185 ODeviceData *d;
186 186
187public: 187public:
188 // sandman do we want to allow destructions? -zecke? 188 // sandman do we want to allow destructions? -zecke?
189 virtual ~ODevice(); 189 virtual ~ODevice();
190 190
191 static ODevice *inst(); 191 static ODevice *inst();
192 192
193 // information 193 // information
194 194
195 QString modelString() const; 195 QString modelString() const;
196 OModel model() const; 196 OModel model() const;
197 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 197 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
198 198
199 QString vendorString() const; 199 QString vendorString() const;
200 OVendor vendor() const; 200 OVendor vendor() const;
201 201
202 QString systemString() const; 202 QString systemString() const;
203 OSystem system() const; 203 OSystem system() const;
204 204
205 QString systemVersionString() const; 205 QString systemVersionString() const;
206 206
207 virtual Transformation rotation() const; 207 virtual Transformation rotation() const;
208 virtual ODirection direction() const; 208 virtual ODirection direction() const;
209 209
210 // system 210 // system
211 211
212 virtual bool setSoftSuspend ( bool on ); 212 virtual bool setSoftSuspend ( bool on );
213 virtual bool suspend(); 213 virtual bool suspend();
214 214
215 virtual bool setDisplayStatus ( bool on ); 215 virtual bool setDisplayStatus ( bool on );
216 virtual bool setDisplayBrightness ( int brightness ); 216 virtual bool setDisplayBrightness ( int brightness );
217 virtual int displayBrightnessResolution() const; 217 virtual int displayBrightnessResolution() const;
218 virtual bool setDisplayContrast ( int contrast ); 218 virtual bool setDisplayContrast ( int contrast );
219 virtual int displayContrastResolution() const; 219 virtual int displayContrastResolution() const;
220 220
221 // don't add new virtual methods, use this: 221 // don't add new virtual methods, use this:
222 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 222 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
223 // and in your subclass do do overwrite 223 // and in your subclass do do overwrite
224 //protected virtual int virtual_hook(int, void *) 224 //protected virtual int virtual_hook(int, void *)
225 // which is defined below 225 // which is defined below
226 226
227 // input / output 227 // input / output
228 //FIXME playAlarmSound and al might be better -zecke 228 //FIXME playAlarmSound and al might be better -zecke
229 virtual void alarmSound(); 229 virtual void alarmSound();
230 virtual void keySound(); 230 virtual void keySound();
231 virtual void touchSound(); 231 virtual void touchSound();
232 232
233 virtual QValueList <OLed> ledList() const; 233 virtual QValueList <OLed> ledList() const;
234 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 234 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
235 virtual OLedState ledState ( OLed led ) const; 235 virtual OLedState ledState ( OLed led ) const;
236 virtual bool setLedState ( OLed led, OLedState st ); 236 virtual bool setLedState ( OLed led, OLedState st );
237 237
238 virtual bool hasLightSensor() const; 238 virtual bool hasLightSensor() const;
239 virtual int readLightSensor(); 239 virtual int readLightSensor();
240 virtual int lightSensorResolution() const; 240 virtual int lightSensorResolution() const;
241 241
242 virtual bool hasHingeSensor() const; 242 virtual bool hasHingeSensor() const;
243 virtual OHingeStatus readHingeSensor(); 243 virtual OHingeStatus readHingeSensor();
244 244
245 const QStrList &allowedCpuFrequencies() const; 245 const QStrList &allowedCpuFrequencies() const;
246 bool setCurrentCpuFrequency(uint index); 246 bool setCurrentCpuFrequency(uint index);
247 247
248 /** 248 /**
249 * Returns the available buttons on this device. The number and location 249 * Returns the available buttons on this device. The number and location
250 * of buttons will vary depending on the device. Button numbers will be assigned 250 * of buttons will vary depending on the device. Button numbers will be assigned
251 * by the device manufacturer and will be from most preferred button to least preffered 251 * by the device manufacturer and will be from most preferred button to least preffered
252 * button. Note that this list only contains "user mappable" buttons. 252 * button. Note that this list only contains "user mappable" buttons.
253 */ 253 */
254 const QValueList<ODeviceButton> &buttons() /* ### make const */; 254 const QValueList<ODeviceButton> &buttons() /* ### make const */;
255 255
256 /** 256 /**
257 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 257 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
258 * returns 0L 258 * returns 0L
259 */ 259 */
260 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 260 const ODeviceButton *buttonForKeycode ( ushort keyCode );
261 261
262 /** 262 /**
263 * Reassigns the pressed action for \a button. To return to the factory 263 * Reassigns the pressed action for \a button. To return to the factory
264 * default pass an empty string as \a qcopMessage. 264 * default pass an empty string as \a qcopMessage.
265 */ 265 */
266 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 266 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
267 267
268 /** 268 /**
269 * Reassigns the held action for \a button. To return to the factory 269 * Reassigns the held action for \a button. To return to the factory
270 * default pass an empty string as \a qcopMessage. 270 * default pass an empty string as \a qcopMessage.
271 */ 271 */
272 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 272 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
273 273
274 /** 274 /**
275 * How long (in ms) you have to press a button for a "hold" action 275 * How long (in ms) you have to press a button for a "hold" action
276 */ 276 */
277 uint buttonHoldTime() const; 277 uint buttonHoldTime() const;
278 278
279signals: 279signals:
280 void buttonMappingChanged(); 280 void buttonMappingChanged();
281 281
282private slots: 282private slots:
283 void systemMessage ( const QCString &, const QByteArray & ); 283 void systemMessage ( const QCString &, const QByteArray & );
284 284
285protected: 285protected:
286 void reloadButtonMapping(); 286 void reloadButtonMapping();
287 /* ugly virtual hook */ 287 /* ugly virtual hook */
288 virtual void virtual_hook( int id, void* data ); 288 virtual void virtual_hook( int id, void* data );
289}; 289};
290 290
291class ODeviceData { 291class ODeviceData {
292 292
293 public: 293 public:
294 QString m_vendorstr; 294 QString m_vendorstr;
295 OVendor m_vendor; 295 OVendor m_vendor;
296 296
297 QString m_modelstr; 297 QString m_modelstr;
298 OModel m_model; 298 OModel m_model;
299 299
300 QString m_systemstr; 300 QString m_systemstr;
301 OSystem m_system; 301 OSystem m_system;
302 302
303 QString m_sysverstr; 303 QString m_sysverstr;
304 304
305 Transformation m_rotation; 305 Transformation m_rotation;
306 ODirection m_direction; 306 ODirection m_direction;
307 307
308 QValueList <ODeviceButton> *m_buttons; 308 QValueList <ODeviceButton> *m_buttons;
309 uint m_holdtime; 309 uint m_holdtime;
310 QStrList *m_cpu_frequencies; 310 QStrList *m_cpu_frequencies;
311}; 311};
312 312
313} 313}
314 314
315static inline bool isQWS() 315static inline bool isQWS()
316{ 316{
317 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 317 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
318} 318}
319 319
320static QCString makeChannel ( const char *str ) 320static QCString makeChannel ( const char *str )
321{ 321{
322 if ( str && !::strchr ( str, '/' )) 322 if ( str && !::strchr ( str, '/' ))
323 return QCString ( "QPE/Application/" ) + str; 323 return QCString ( "QPE/Application/" ) + str;
324 else 324 else
325 return str; 325 return str;
326} 326}
327 327
328#endif 328#endif
329 329
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index d928806..d68bce1 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,524 +1,475 @@
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.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#ifndef ARRAY_SIZE 56/* KERNEL */
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63 58
64#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 63
69typedef struct { 64typedef struct {
70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
71 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
72 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
73 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
74} LED_IN; 69} LED_IN;
75 70
76typedef struct { 71typedef struct {
77 unsigned char mode; 72 unsigned char mode;
78 unsigned char pwr; 73 unsigned char pwr;
79 unsigned char brightness; 74 unsigned char brightness;
80} FLITE_IN; 75} FLITE_IN;
81 76
82#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
84 79
85using namespace Opie; 80struct i_button ipaq_buttons [] = {
86
87class iPAQ : public ODevice, public QWSServer::KeyboardFilter
88{
89
90 protected:
91 virtual void init();
92 virtual void initButtons();
93
94 public:
95 virtual bool setSoftSuspend( bool soft );
96
97 virtual bool setDisplayBrightness( int b );
98 virtual int displayBrightnessResolution() const;
99
100 virtual void alarmSound();
101
102 virtual QValueList <OLed> ledList() const;
103 virtual QValueList <OLedState> ledStateList( OLed led ) const;
104 virtual OLedState ledState( OLed led ) const;
105 virtual bool setLedState( OLed led, OLedState st );
106
107 virtual bool hasLightSensor() const;
108 virtual int readLightSensor();
109 virtual int lightSensorResolution() const;
110
111 protected:
112 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
113 virtual void timerEvent( QTimerEvent *te );
114
115 int m_power_timer;
116
117 OLedState m_leds [2];
118};
119
120struct i_button {
121 uint model;
122 Qt::Key code;
123 char *utext;
124 char *pix;
125 char *fpressedservice;
126 char *fpressedaction;
127 char *fheldservice;
128 char *fheldaction;
129} ipaq_buttons [] = {
130 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 81 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
131 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 82 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
132 "devicebuttons/ipaq_calendar", 83 "devicebuttons/ipaq_calendar",
133 "datebook", "nextView()", 84 "datebook", "nextView()",
134 "today", "raise()" }, 85 "today", "raise()" },
135 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
136 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
137 "devicebuttons/ipaq_contact", 88 "devicebuttons/ipaq_contact",
138 "addressbook", "raise()", 89 "addressbook", "raise()",
139 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
140 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
141 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 92 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
142 "devicebuttons/ipaq_menu", 93 "devicebuttons/ipaq_menu",
143 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
144 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
145 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 96 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
146 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
147 "devicebuttons/ipaq_mail", 98 "devicebuttons/ipaq_mail",
148 "mail", "raise()", 99 "mail", "raise()",
149 "mail", "newMail()" }, 100 "mail", "newMail()" },
150 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 101 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
151 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
152 "devicebuttons/ipaq_home", 103 "devicebuttons/ipaq_home",
153 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
154 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
155 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
156 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 107 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
157 "devicebuttons/ipaq_record", 108 "devicebuttons/ipaq_record",
158 "QPE/VMemo", "toggleRecord()", 109 "QPE/VMemo", "toggleRecord()",
159 "sound", "raise()" }, 110 "sound", "raise()" },
160}; 111};
161 112
162void iPAQ::init() 113void iPAQ::init()
163{ 114{
164 d->m_vendorstr = "HP"; 115 d->m_vendorstr = "HP";
165 d->m_vendor = Vendor_HP; 116 d->m_vendor = Vendor_HP;
166 117
167 QFile f ( "/proc/hal/model" ); 118 QFile f ( "/proc/hal/model" );
168 119
169 if ( f. open ( IO_ReadOnly )) { 120 if ( f. open ( IO_ReadOnly )) {
170 QTextStream ts ( &f ); 121 QTextStream ts ( &f );
171 122
172 d->m_modelstr = "H" + ts. readLine(); 123 d->m_modelstr = "H" + ts. readLine();
173 124
174 if ( d->m_modelstr == "H3100" ) 125 if ( d->m_modelstr == "H3100" )
175 d->m_model = Model_iPAQ_H31xx; 126 d->m_model = Model_iPAQ_H31xx;
176 else if ( d->m_modelstr == "H3600" ) 127 else if ( d->m_modelstr == "H3600" )
177 d->m_model = Model_iPAQ_H36xx; 128 d->m_model = Model_iPAQ_H36xx;
178 else if ( d->m_modelstr == "H3700" ) 129 else if ( d->m_modelstr == "H3700" )
179 d->m_model = Model_iPAQ_H37xx; 130 d->m_model = Model_iPAQ_H37xx;
180 else if ( d->m_modelstr == "H3800" ) 131 else if ( d->m_modelstr == "H3800" )
181 d->m_model = Model_iPAQ_H38xx; 132 d->m_model = Model_iPAQ_H38xx;
182 else if ( d->m_modelstr == "H3900" ) 133 else if ( d->m_modelstr == "H3900" )
183 d->m_model = Model_iPAQ_H39xx; 134 d->m_model = Model_iPAQ_H39xx;
184 else if ( d->m_modelstr == "H5400" ) 135 else if ( d->m_modelstr == "H5400" )
185 d->m_model = Model_iPAQ_H5xxx; 136 d->m_model = Model_iPAQ_H5xxx;
186 else 137 else
187 d->m_model = Model_Unknown; 138 d->m_model = Model_Unknown;
188 139
189 f. close(); 140 f. close();
190 } 141 }
191 142
192 switch ( d->m_model ) { 143 switch ( d->m_model ) {
193 case Model_iPAQ_H31xx: 144 case Model_iPAQ_H31xx:
194 case Model_iPAQ_H38xx: 145 case Model_iPAQ_H38xx:
195 d->m_rotation = Rot90; 146 d->m_rotation = Rot90;
196 break; 147 break;
197 case Model_iPAQ_H36xx: 148 case Model_iPAQ_H36xx:
198 case Model_iPAQ_H37xx: 149 case Model_iPAQ_H37xx:
199 case Model_iPAQ_H39xx: 150 case Model_iPAQ_H39xx:
200 151
201 default: 152 default:
202 d->m_rotation = Rot270; 153 d->m_rotation = Rot270;
203 break; 154 break;
204 case Model_iPAQ_H5xxx: 155 case Model_iPAQ_H5xxx:
205 d->m_rotation = Rot0; 156 d->m_rotation = Rot0;
206 } 157 }
207 158
208 f. setName ( "/etc/familiar-version" ); 159 f. setName ( "/etc/familiar-version" );
209 if ( f. open ( IO_ReadOnly )) { 160 if ( f. open ( IO_ReadOnly )) {
210 d->m_systemstr = "Familiar"; 161 d->m_systemstr = "Familiar";
211 d->m_system = System_Familiar; 162 d->m_system = System_Familiar;
212 163
213 QTextStream ts ( &f ); 164 QTextStream ts ( &f );
214 d->m_sysverstr = ts. readLine(). mid ( 10 ); 165 d->m_sysverstr = ts. readLine(). mid ( 10 );
215 166
216 f. close(); 167 f. close();
217 } else { 168 } else {
218 f. setName ( "/etc/oz_version" ); 169 f. setName ( "/etc/oz_version" );
219 170
220 if ( f. open ( IO_ReadOnly )) { 171 if ( f. open ( IO_ReadOnly )) {
221 d->m_systemstr = "OpenEmbedded/iPaq"; 172 d->m_systemstr = "OpenEmbedded/iPaq";
222 d->m_system = System_Familiar; 173 d->m_system = System_Familiar;
223 174
224 QTextStream ts ( &f ); 175 QTextStream ts ( &f );
225 ts.setDevice ( &f ); 176 ts.setDevice ( &f );
226 d->m_sysverstr = ts. readLine(); 177 d->m_sysverstr = ts. readLine();
227 f. close(); 178 f. close();
228 } 179 }
229 } 180 }
230 181
231 m_leds [0] = m_leds [1] = Led_Off; 182 m_leds [0] = m_leds [1] = Led_Off;
232 183
233 m_power_timer = 0; 184 m_power_timer = 0;
234 185
235} 186}
236 187
237void iPAQ::initButtons() 188void iPAQ::initButtons()
238{ 189{
239 if ( d->m_buttons ) 190 if ( d->m_buttons )
240 return; 191 return;
241 192
242 if ( isQWS( ) ) 193 if ( isQWS( ) )
243 QWSServer::setKeyboardFilter ( this ); 194 QWSServer::setKeyboardFilter ( this );
244 195
245 d->m_buttons = new QValueList <ODeviceButton>; 196 d->m_buttons = new QValueList <ODeviceButton>;
246 197
247 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 198 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
248 i_button *ib = ipaq_buttons + i; 199 i_button *ib = ipaq_buttons + i;
249 ODeviceButton b; 200 ODeviceButton b;
250 201
251 if (( ib->model & d->m_model ) == d->m_model ) { 202 if (( ib->model & d->m_model ) == d->m_model ) {
252 b. setKeycode ( ib->code ); 203 b. setKeycode ( ib->code );
253 b. setUserText ( QObject::tr ( "Button", ib->utext )); 204 b. setUserText ( QObject::tr ( "Button", ib->utext ));
254 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 205 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
255 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 206 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
256 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 207 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
257 208
258 d->m_buttons->append ( b ); 209 d->m_buttons->append ( b );
259 } 210 }
260 } 211 }
261 reloadButtonMapping(); 212 reloadButtonMapping();
262 213
263 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 214 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
264 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 215 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
265} 216}
266 217
267QValueList <OLed> iPAQ::ledList() const 218QValueList <OLed> iPAQ::ledList() const
268{ 219{
269 QValueList <OLed> vl; 220 QValueList <OLed> vl;
270 vl << Led_Power; 221 vl << Led_Power;
271 222
272 if ( d->m_model == Model_iPAQ_H38xx ) 223 if ( d->m_model == Model_iPAQ_H38xx )
273 vl << Led_BlueTooth; 224 vl << Led_BlueTooth;
274 return vl; 225 return vl;
275} 226}
276 227
277QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 228QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
278{ 229{
279 QValueList <OLedState> vl; 230 QValueList <OLedState> vl;
280 231
281 if ( l == Led_Power ) 232 if ( l == Led_Power )
282 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 233 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
283 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 234 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
284 vl << Led_Off; // << Led_On << ??? 235 vl << Led_Off; // << Led_On << ???
285 236
286 return vl; 237 return vl;
287} 238}
288 239
289OLedState iPAQ::ledState ( OLed l ) const 240OLedState iPAQ::ledState ( OLed l ) const
290{ 241{
291 switch ( l ) { 242 switch ( l ) {
292 case Led_Power: 243 case Led_Power:
293 return m_leds [0]; 244 return m_leds [0];
294 case Led_BlueTooth: 245 case Led_BlueTooth:
295 return m_leds [1]; 246 return m_leds [1];
296 default: 247 default:
297 return Led_Off; 248 return Led_Off;
298 } 249 }
299} 250}
300 251
301bool iPAQ::setLedState ( OLed l, OLedState st ) 252bool iPAQ::setLedState ( OLed l, OLedState st )
302{ 253{
303 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 254 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
304 255
305 if ( l == Led_Power ) { 256 if ( l == Led_Power ) {
306 if ( fd >= 0 ) { 257 if ( fd >= 0 ) {
307 LED_IN leds; 258 LED_IN leds;
308 ::memset ( &leds, 0, sizeof( leds )); 259 ::memset ( &leds, 0, sizeof( leds ));
309 leds. TotalTime = 0; 260 leds. TotalTime = 0;
310 leds. OnTime = 0; 261 leds. OnTime = 0;
311 leds. OffTime = 1; 262 leds. OffTime = 1;
312 leds. OffOnBlink = 2; 263 leds. OffOnBlink = 2;
313 264
314 switch ( st ) { 265 switch ( st ) {
315 case Led_Off : leds. OffOnBlink = 0; break; 266 case Led_Off : leds. OffOnBlink = 0; break;
316 case Led_On : leds. OffOnBlink = 1; break; 267 case Led_On : leds. OffOnBlink = 1; break;
317 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 268 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
318 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 269 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
319 } 270 }
320 271
321 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 272 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
322 m_leds [0] = st; 273 m_leds [0] = st;
323 return true; 274 return true;
324 } 275 }
325 } 276 }
326 } 277 }
327 return false; 278 return false;
328} 279}
329 280
330 281
331bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 282bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
332{ 283{
333 int newkeycode = keycode; 284 int newkeycode = keycode;
334 285
335 switch ( keycode ) { 286 switch ( keycode ) {
336 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 287 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
337 case HardKey_Menu: { 288 case HardKey_Menu: {
338 if (( d->m_model == Model_iPAQ_H38xx ) || 289 if (( d->m_model == Model_iPAQ_H38xx ) ||
339 ( d->m_model == Model_iPAQ_H39xx ) || 290 ( d->m_model == Model_iPAQ_H39xx ) ||
340 ( d->m_model == Model_iPAQ_H5xxx)) { 291 ( d->m_model == Model_iPAQ_H5xxx)) {
341 newkeycode = HardKey_Mail; 292 newkeycode = HardKey_Mail;
342 } 293 }
343 break; 294 break;
344 } 295 }
345 296
346 // Rotate cursor keys 180° 297 // Rotate cursor keys 180°
347 case Key_Left : 298 case Key_Left :
348 case Key_Right: 299 case Key_Right:
349 case Key_Up : 300 case Key_Up :
350 case Key_Down : { 301 case Key_Down : {
351 if (( d->m_model == Model_iPAQ_H31xx ) || 302 if (( d->m_model == Model_iPAQ_H31xx ) ||
352 ( d->m_model == Model_iPAQ_H38xx )) { 303 ( d->m_model == Model_iPAQ_H38xx )) {
353 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 304 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
354 } 305 }
355 break; 306 break;
356 } 307 }
357 308
358 // map Power Button short/long press to F34/F35 309 // map Power Button short/long press to F34/F35
359 case Key_SysReq: { 310 case Key_SysReq: {
360 if ( isPress ) { 311 if ( isPress ) {
361 if ( m_power_timer ) 312 if ( m_power_timer )
362 killTimer ( m_power_timer ); 313 killTimer ( m_power_timer );
363 m_power_timer = startTimer ( 500 ); 314 m_power_timer = startTimer ( 500 );
364 } 315 }
365 else if ( m_power_timer ) { 316 else if ( m_power_timer ) {
366 killTimer ( m_power_timer ); 317 killTimer ( m_power_timer );
367 m_power_timer = 0; 318 m_power_timer = 0;
368 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 319 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
369 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 320 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
370 } 321 }
371 newkeycode = Key_unknown; 322 newkeycode = Key_unknown;
372 break; 323 break;
373 } 324 }
374 } 325 }
375 326
376 if ( newkeycode != keycode ) { 327 if ( newkeycode != keycode ) {
377 if ( newkeycode != Key_unknown ) 328 if ( newkeycode != Key_unknown )
378 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 329 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
379 return true; 330 return true;
380 } 331 }
381 else 332 else
382 return false; 333 return false;
383} 334}
384 335
385void iPAQ::timerEvent ( QTimerEvent * ) 336void iPAQ::timerEvent ( QTimerEvent * )
386{ 337{
387 killTimer ( m_power_timer ); 338 killTimer ( m_power_timer );
388 m_power_timer = 0; 339 m_power_timer = 0;
389 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 340 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
390 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 341 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
391} 342}
392 343
393 344
394void iPAQ::alarmSound() 345void iPAQ::alarmSound()
395{ 346{
396#ifndef QT_NO_SOUND 347#ifndef QT_NO_SOUND
397 static Sound snd ( "alarm" ); 348 static Sound snd ( "alarm" );
398 int fd; 349 int fd;
399 int vol; 350 int vol;
400 bool vol_reset = false; 351 bool vol_reset = false;
401 352
402 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 353 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
403 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 354 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
404 Config cfg ( "qpe" ); 355 Config cfg ( "qpe" );
405 cfg. setGroup ( "Volume" ); 356 cfg. setGroup ( "Volume" );
406 357
407 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 358 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
408 if ( volalarm < 0 ) 359 if ( volalarm < 0 )
409 volalarm = 0; 360 volalarm = 0;
410 else if ( volalarm > 100 ) 361 else if ( volalarm > 100 )
411 volalarm = 100; 362 volalarm = 100;
412 volalarm |= ( volalarm << 8 ); 363 volalarm |= ( volalarm << 8 );
413 364
414 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 365 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
415 vol_reset = true; 366 vol_reset = true;
416 } 367 }
417 } 368 }
418 369
419 snd. play(); 370 snd. play();
420 while ( !snd. isFinished()) 371 while ( !snd. isFinished())
421 qApp->processEvents(); 372 qApp->processEvents();
422 373
423 if ( fd >= 0 ) { 374 if ( fd >= 0 ) {
424 if ( vol_reset ) 375 if ( vol_reset )
425 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 376 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
426 ::close ( fd ); 377 ::close ( fd );
427 } 378 }
428#endif 379#endif
429} 380}
430 381
431 382
432bool iPAQ::setSoftSuspend ( bool soft ) 383bool iPAQ::setSoftSuspend ( bool soft )
433{ 384{
434 bool res = false; 385 bool res = false;
435 int fd; 386 int fd;
436 387
437 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 388 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
438 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 389 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
439 res = true; 390 res = true;
440 else 391 else
441 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 392 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
442 393
443 ::close ( fd ); 394 ::close ( fd );
444 } 395 }
445 else 396 else
446 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 397 ::perror ( "/proc/sys/ts/suspend_button_mode" );
447 398
448 return res; 399 return res;
449} 400}
450 401
451 402
452bool iPAQ::setDisplayBrightness ( int bright ) 403bool iPAQ::setDisplayBrightness ( int bright )
453{ 404{
454 bool res = false; 405 bool res = false;
455 int fd; 406 int fd;
456 407
457 if ( bright > 255 ) 408 if ( bright > 255 )
458 bright = 255; 409 bright = 255;
459 if ( bright < 0 ) 410 if ( bright < 0 )
460 bright = 0; 411 bright = 0;
461 412
462 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 413 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
463 FLITE_IN bl; 414 FLITE_IN bl;
464 bl. mode = 1; 415 bl. mode = 1;
465 bl. pwr = bright ? 1 : 0; 416 bl. pwr = bright ? 1 : 0;
466 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 417 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
467 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 418 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
468 ::close ( fd ); 419 ::close ( fd );
469 } 420 }
470 return res; 421 return res;
471} 422}
472 423
473int iPAQ::displayBrightnessResolution() const 424int iPAQ::displayBrightnessResolution() const
474{ 425{
475 switch ( model()) { 426 switch ( model()) {
476 case Model_iPAQ_H31xx: 427 case Model_iPAQ_H31xx:
477 case Model_iPAQ_H36xx: 428 case Model_iPAQ_H36xx:
478 case Model_iPAQ_H37xx: 429 case Model_iPAQ_H37xx:
479 return 128; // really 256, but >128 could damage the LCD 430 return 128; // really 256, but >128 could damage the LCD
480 431
481 case Model_iPAQ_H38xx: 432 case Model_iPAQ_H38xx:
482 case Model_iPAQ_H39xx: 433 case Model_iPAQ_H39xx:
483 return 64; 434 return 64;
484 case Model_iPAQ_H5xxx: 435 case Model_iPAQ_H5xxx:
485 return 255; 436 return 255;
486 437
487 default: 438 default:
488 return 2; 439 return 2;
489 } 440 }
490} 441}
491 442
492 443
493bool iPAQ::hasLightSensor() const 444bool iPAQ::hasLightSensor() const
494{ 445{
495 return true; 446 return true;
496} 447}
497 448
498int iPAQ::readLightSensor() 449int iPAQ::readLightSensor()
499{ 450{
500 int fd; 451 int fd;
501 int val = -1; 452 int val = -1;
502 453
503 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 454 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
504 char buffer [8]; 455 char buffer [8];
505 456
506 if ( ::read ( fd, buffer, 5 ) == 5 ) { 457 if ( ::read ( fd, buffer, 5 ) == 5 ) {
507 char *endptr; 458 char *endptr;
508 459
509 buffer [4] = 0; 460 buffer [4] = 0;
510 val = ::strtol ( buffer + 2, &endptr, 16 ); 461 val = ::strtol ( buffer + 2, &endptr, 16 );
511 462
512 if ( *endptr != 0 ) 463 if ( *endptr != 0 )
513 val = -1; 464 val = -1;
514 } 465 }
515 ::close ( fd ); 466 ::close ( fd );
516 } 467 }
517 468
518 return val; 469 return val;
519} 470}
520 471
521int iPAQ::lightSensorResolution() const 472int iPAQ::lightSensorResolution() const
522{ 473{
523 return 256; 474 return 256;
524} 475}
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
new file mode 100644
index 0000000..baf7215
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -0,0 +1,84 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ
32
33#include "odevice.h"
34
35/* QT */
36#include <qwindowsystem_qws.h>
37
38using namespace Opie;
39
40class iPAQ : public ODevice, public QWSServer::KeyboardFilter
41{
42
43 protected:
44 virtual void init();
45 virtual void initButtons();
46
47 public:
48 virtual bool setSoftSuspend( bool soft );
49
50 virtual bool setDisplayBrightness( int b );
51 virtual int displayBrightnessResolution() const;
52
53 virtual void alarmSound();
54
55 virtual QValueList <OLed> ledList() const;
56 virtual QValueList <OLedState> ledStateList( OLed led ) const;
57 virtual OLedState ledState( OLed led ) const;
58 virtual bool setLedState( OLed led, OLedState st );
59
60 virtual bool hasLightSensor() const;
61 virtual int readLightSensor();
62 virtual int lightSensorResolution() const;
63
64 protected:
65 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
66 virtual void timerEvent( QTimerEvent *te );
67
68 int m_power_timer;
69
70 OLedState m_leds [2];
71};
72
73struct i_button {
74 uint model;
75 Qt::Key code;
76 char *utext;
77 char *pix;
78 char *fpressedservice;
79 char *fpressedaction;
80 char *fheldservice;
81 char *fheldaction;
82};
83
84#endif
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index bcd03ed..37bd6e9 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -1,214 +1,150 @@
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.h" 30#include "odevice_jornada.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#ifndef ARRAY_SIZE 56/* KERNEL */
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63 58
64#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 63
69typedef struct { 64typedef struct {
70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
71 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
72 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
73 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
74} LED_IN; 69} LED_IN;
75 70
76typedef struct { 71typedef struct {
77 unsigned char mode; 72 unsigned char mode;
78 unsigned char pwr; 73 unsigned char pwr;
79 unsigned char brightness; 74 unsigned char brightness;
80} FLITE_IN; 75} FLITE_IN;
81 76
82#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
84 79
85using namespace Opie; 80using namespace Opie;
86 81
87class Jornada : public ODevice
88{
89
90 protected:
91 virtual void init();
92
93 public:
94 virtual bool setSoftSuspend ( bool soft );
95 virtual bool setDisplayBrightness ( int b );
96 virtual int displayBrightnessResolution() const;
97 static bool isJornada();
98};
99
100
101bool Jornada::isJornada()
102{
103 QFile f( "/proc/cpuinfo" );
104 if ( f. open ( IO_ReadOnly ) ) {
105 QTextStream ts ( &f );
106 QString line;
107 while( line = ts. readLine() ) {
108 if ( line. left ( 8 ) == "Hardware" ) {
109 int loc = line. find ( ":" );
110 if ( loc != -1 ) {
111 QString model = line.mid( loc + 2 ).simplifyWhiteSpace( );
112 return ( model == "HP Jornada 56x" );
113 }
114 }
115 }
116 }
117 return false;
118}
119
120void Jornada::init() 82void Jornada::init()
121{ 83{
122 d->m_vendorstr = "HP"; 84 d->m_vendorstr = "HP";
123 d->m_vendor = Vendor_HP; 85 d->m_vendor = Vendor_HP;
124 d->m_modelstr = "Jornada 56x"; 86 d->m_modelstr = "Jornada 56x";
125 d->m_model = Model_Jornada_56x; 87 d->m_model = Model_Jornada_56x;
126 d->m_systemstr = "Familiar"; 88 d->m_systemstr = "Familiar";
127 d->m_system = System_Familiar; 89 d->m_system = System_Familiar;
128 d->m_rotation = Rot0; 90 d->m_rotation = Rot0;
129 91
130 QFile f ( "/etc/familiar-version" ); 92 QFile f ( "/etc/familiar-version" );
131 f. setName ( "/etc/familiar-version" ); 93 f.setName ( "/etc/familiar-version" );
132 if ( f. open ( IO_ReadOnly )) { 94 if ( f.open ( IO_ReadOnly )) {
133 95
134 QTextStream ts ( &f ); 96 QTextStream ts ( &f );
135 d->m_sysverstr = ts. readLine(). mid ( 10 ); 97 d->m_sysverstr = ts.readLine().mid( 10 );
136 98
137 f. close(); 99 f. close();
138 } 100 }
139} 101}
140 102
141#if 0
142void Jornada::initButtons()
143{
144 if ( d->m_buttons )
145 return;
146
147 // Simulation uses iPAQ 3660 device buttons
148
149 qDebug ( "init Buttons" );
150 d->m_buttons = new QValueList <ODeviceButton>;
151
152 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
153 i_button *ib = ipaq_buttons + i;
154 ODeviceButton b;
155
156 if (( ib->model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
157 b. setKeycode ( ib->code );
158 b. setUserText ( QObject::tr ( "Button", ib->utext ));
159 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
160 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
161 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
162 d->m_buttons->append ( b );
163 }
164 }
165 reloadButtonMapping();
166
167 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
168 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
169}
170#endif
171 103
172int Jornada::displayBrightnessResolution() const 104int Jornada::displayBrightnessResolution() const
173{ 105{
106 return 0;
174} 107}
175 108
109
176bool Jornada::setDisplayBrightness( int bright ) 110bool Jornada::setDisplayBrightness( int bright )
177{ 111{
178 bool res = false; 112 bool res = false;
179 int fd; 113 int fd;
180 114
181 if ( bright > 255 ) 115 if ( bright > 255 )
182 bright = 255; 116 bright = 255;
183 if ( bright < 0 ) 117 if ( bright < 0 )
184 bright = 0; 118 bright = 0;
185 119
186 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
187 FLITE_IN bl; 121 FLITE_IN bl;
188 bl. mode = 1; 122 bl. mode = 1;
189 bl. pwr = bright ? 1 : 0; 123 bl. pwr = bright ? 1 : 0;
190 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
191 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
192 ::close ( fd ); 126 ::close ( fd );
193 } 127 }
194 return res; 128 return res;
195} 129}
196 130
131
197bool Jornada::setSoftSuspend( bool soft ) 132bool Jornada::setSoftSuspend( bool soft )
198{ 133{
199 bool res = false; 134 bool res = false;
200 int fd; 135 int fd;
201 136
202 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 137 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
203 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 138 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
204 res = true; 139 res = true;
205 else 140 else
206 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 141 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
207 142
208 ::close ( fd ); 143 ::close ( fd );
209 } 144 }
210 else 145 else
211 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 146 ::perror ( "/proc/sys/ts/suspend_button_mode" );
212 147
213 return res; 148 return res;
214} 149}
150
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
new file mode 100644
index 0000000..59be8da
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -0,0 +1,50 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA
32
33#include <opie2/odevice.h>
34
35using namespace Opie;
36
37class Jornada : public ODevice
38{
39
40 protected:
41 virtual void init();
42
43 public:
44 virtual bool setSoftSuspend ( bool soft );
45 virtual bool setDisplayBrightness ( int b );
46 virtual int displayBrightnessResolution() const;
47};
48
49#endif
50
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index a90c3a0..5bcf6a9 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -1,317 +1,271 @@
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.h" 30#include "odevice_ramses.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#ifndef ARRAY_SIZE 56struct r_button ramses_buttons [] = {
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63
64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68
69using namespace Opie;
70
71class Ramses : public ODevice, public QWSServer::KeyboardFilter
72{
73 protected:
74 virtual void init();
75
76 public:
77 virtual bool setSoftSuspend( bool soft );
78 virtual bool suspend();
79
80 virtual bool setDisplayStatus( bool on );
81 virtual bool setDisplayBrightness( int b );
82 virtual int displayBrightnessResolution() const;
83 virtual bool setDisplayContrast( int b );
84 virtual int displayContrastResolution() const;
85
86 protected:
87 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
88 virtual void timerEvent ( QTimerEvent *te );
89
90 int m_power_timer;
91};
92
93struct r_button {
94 uint model;
95 Qt::Key code;
96 char *utext;
97 char *pix;
98 char *fpressedservice;
99 char *fpressedaction;
100 char *fheldservice;
101 char *fheldaction;
102} ramses_buttons [] = {
103 { Model_Ramses_MNCI, 57 { Model_Ramses_MNCI,
104 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 58 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
105 "devicebuttons/z_menu", 59 "devicebuttons/z_menu",
106 "QPE/TaskBar", "toggleMenu()", 60 "QPE/TaskBar", "toggleMenu()",
107 "QPE/TaskBar", "toggleStartMenu()" }, 61 "QPE/TaskBar", "toggleStartMenu()" },
108 { Model_Ramses_MNCI, 62 { Model_Ramses_MNCI,
109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 63 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
110 "devicebuttons/ipaq_home", 64 "devicebuttons/ipaq_home",
111 "QPE/Launcher", "home()", 65 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 66 "buttonsettings", "raise()" },
113}; 67};
114 68
115void Ramses::init() 69void Ramses::init()
116{ 70{
117 d->m_vendorstr = "M und N"; 71 d->m_vendorstr = "M und N";
118 d->m_vendor = Vendor_MundN; 72 d->m_vendor = Vendor_MundN;
119 73
120 QFile f("/proc/sys/board/ramses"); 74 QFile f("/proc/sys/board/ramses");
121 75
122 d->m_modelstr = "Ramses"; 76 d->m_modelstr = "Ramses";
123 d->m_model = Model_Ramses_MNCI; 77 d->m_model = Model_Ramses_MNCI;
124 78
125 d->m_rotation = Rot0; 79 d->m_rotation = Rot0;
126 d->m_holdtime = 1000; 80 d->m_holdtime = 1000;
127 81
128 f.setName("/etc/oz_version"); 82 f.setName("/etc/oz_version");
129 83
130 if (f.open(IO_ReadOnly)) { 84 if (f.open(IO_ReadOnly)) {
131 d->m_systemstr = "OpenEmbedded/Ramses"; 85 d->m_systemstr = "OpenEmbedded/Ramses";
132 d->m_system = System_OpenZaurus; 86 d->m_system = System_OpenZaurus;
133 87
134 QTextStream ts(&f); 88 QTextStream ts(&f);
135 ts.setDevice(&f); 89 ts.setDevice(&f);
136 d->m_sysverstr = ts.readLine(); 90 d->m_sysverstr = ts.readLine();
137 f.close(); 91 f.close();
138 } 92 }
139 93
140 m_power_timer = 0; 94 m_power_timer = 0;
141 95
142#ifdef QT_QWS_ALLOW_OVERCLOCK 96#ifdef QT_QWS_ALLOW_OVERCLOCK
143#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 97#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
144#define OC(x...) x 98#define OC(x...) x
145#else 99#else
146#define OC(x...) 100#define OC(x...)
147#endif 101#endif
148 102
149 // This table is true for a Intel XScale PXA 255 103 // This table is true for a Intel XScale PXA 255
150 104
151 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 105 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
152OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 106OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
153 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 107 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
154OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 108OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
155 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 109 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
156OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 110OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
157 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 111 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
158 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 112 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
159OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 113OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
160 114
161} 115}
162 116
163bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 117bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
164{ 118{
165 Q_UNUSED( keycode ); 119 Q_UNUSED( keycode );
166 Q_UNUSED( modifiers ); 120 Q_UNUSED( modifiers );
167 Q_UNUSED( isPress ); 121 Q_UNUSED( isPress );
168 Q_UNUSED( autoRepeat ); 122 Q_UNUSED( autoRepeat );
169 return false; 123 return false;
170} 124}
171 125
172void Ramses::timerEvent(QTimerEvent *) 126void Ramses::timerEvent(QTimerEvent *)
173{ 127{
174 killTimer(m_power_timer); 128 killTimer(m_power_timer);
175 m_power_timer = 0; 129 m_power_timer = 0;
176 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 130 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
177 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 131 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
178} 132}
179 133
180 134
181bool Ramses::setSoftSuspend(bool soft) 135bool Ramses::setSoftSuspend(bool soft)
182{ 136{
183 qDebug("Ramses::setSoftSuspend(%d)", soft); 137 qDebug("Ramses::setSoftSuspend(%d)", soft);
184#if 0 138#if 0
185 bool res = false; 139 bool res = false;
186 int fd; 140 int fd;
187 141
188 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 142 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
189 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 143 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
190 144
191 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 145 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
192 146
193 if (sources >= 0) { 147 if (sources >= 0) {
194 if (soft) 148 if (soft)
195 sources &= ~APM_EVT_POWER_BUTTON; 149 sources &= ~APM_EVT_POWER_BUTTON;
196 else 150 else
197 sources |= APM_EVT_POWER_BUTTON; 151 sources |= APM_EVT_POWER_BUTTON;
198 152
199 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 153 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
200 res = true; 154 res = true;
201 else 155 else
202 perror("APM_IOCGEVTSRC"); 156 perror("APM_IOCGEVTSRC");
203 } 157 }
204 else 158 else
205 perror("APM_IOCGEVTSRC"); 159 perror("APM_IOCGEVTSRC");
206 160
207 ::close(fd); 161 ::close(fd);
208 } 162 }
209 else 163 else
210 perror("/dev/apm_bios or /dev/misc/apm_bios"); 164 perror("/dev/apm_bios or /dev/misc/apm_bios");
211 165
212 return res; 166 return res;
213#else 167#else
214 return true; 168 return true;
215#endif 169#endif
216} 170}
217 171
218bool Ramses::suspend() 172bool Ramses::suspend()
219{ 173{
220 qDebug("Ramses::suspend"); 174 qDebug("Ramses::suspend");
221 return false; 175 return false;
222} 176}
223 177
224/** 178/**
225* This sets the display on or off 179* This sets the display on or off
226*/ 180*/
227bool Ramses::setDisplayStatus(bool on) 181bool Ramses::setDisplayStatus(bool on)
228{ 182{
229 qDebug("Ramses::setDisplayStatus(%d)", on); 183 qDebug("Ramses::setDisplayStatus(%d)", on);
230#if 0 184#if 0
231 bool res = false; 185 bool res = false;
232 int fd; 186 int fd;
233 187
234 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 188 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
235 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 189 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
236 ::close(fd); 190 ::close(fd);
237 } 191 }
238 return res; 192 return res;
239#else 193#else
240 return true; 194 return true;
241#endif 195#endif
242} 196}
243 197
244 198
245/* 199/*
246* We get something between 0..255 into us 200* We get something between 0..255 into us
247*/ 201*/
248bool Ramses::setDisplayBrightness(int bright) 202bool Ramses::setDisplayBrightness(int bright)
249{ 203{
250 qDebug("Ramses::setDisplayBrightness(%d)", bright); 204 qDebug("Ramses::setDisplayBrightness(%d)", bright);
251 bool res = false; 205 bool res = false;
252 int fd; 206 int fd;
253 207
254 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 208 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
255 209
256 if (bright > 255 ) 210 if (bright > 255 )
257 bright = 255; 211 bright = 255;
258 if (bright < 0) 212 if (bright < 0)
259 bright = 0; 213 bright = 0;
260 214
261 // Turn backlight completely off 215 // Turn backlight completely off
262 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 216 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
263 char writeCommand[10]; 217 char writeCommand[10];
264 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 218 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
265 res = (::write(fd, writeCommand, count) != -1); 219 res = (::write(fd, writeCommand, count) != -1);
266 ::close(fd); 220 ::close(fd);
267 } 221 }
268 222
269 // scale backlight brightness to hardware 223 // scale backlight brightness to hardware
270 bright = 500-(bright * 500 / 255); 224 bright = 500-(bright * 500 / 255);
271 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 225 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
272 qDebug(" %d ->pwm1", bright); 226 qDebug(" %d ->pwm1", bright);
273 char writeCommand[100]; 227 char writeCommand[100];
274 const int count = sprintf(writeCommand, "%d\n", bright); 228 const int count = sprintf(writeCommand, "%d\n", bright);
275 res = (::write(fd, writeCommand, count) != -1); 229 res = (::write(fd, writeCommand, count) != -1);
276 ::close(fd); 230 ::close(fd);
277 } 231 }
278 return res; 232 return res;
279} 233}
280 234
281 235
282int Ramses::displayBrightnessResolution() const 236int Ramses::displayBrightnessResolution() const
283{ 237{
284 return 32; 238 return 32;
285} 239}
286 240
287bool Ramses::setDisplayContrast(int contr) 241bool Ramses::setDisplayContrast(int contr)
288{ 242{
289 qDebug("Ramses::setDisplayContrast(%d)", contr); 243 qDebug("Ramses::setDisplayContrast(%d)", contr);
290 bool res = false; 244 bool res = false;
291 int fd; 245 int fd;
292 246
293 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 247 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
294 248
295 if (contr > 255 ) 249 if (contr > 255 )
296 contr = 255; 250 contr = 255;
297 if (contr < 0) 251 if (contr < 0)
298 contr = 0; 252 contr = 0;
299 contr = 90 - (contr * 20 / 255); 253 contr = 90 - (contr * 20 / 255);
300 254
301 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 255 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
302 qDebug(" %d ->pwm0", contr); 256 qDebug(" %d ->pwm0", contr);
303 char writeCommand[100]; 257 char writeCommand[100];
304 const int count = sprintf(writeCommand, "%d\n", contr); 258 const int count = sprintf(writeCommand, "%d\n", contr);
305 res = (::write(fd, writeCommand, count) != -1); 259 res = (::write(fd, writeCommand, count) != -1);
306 res = true; 260 res = true;
307 ::close(fd); 261 ::close(fd);
308 } 262 }
309 return res; 263 return res;
310} 264}
311 265
312 266
313int Ramses::displayContrastResolution() const 267int Ramses::displayContrastResolution() const
314{ 268{
315 return 20; 269 return 20;
316} 270}
317 271
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
new file mode 100644
index 0000000..1b660ab
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -0,0 +1,72 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_RAMSES
31#define ODEVICE_RAMSES
32
33#include <opie2/odevice.h>
34/* QT */
35#include <qwindowsystem_qws.h>
36
37using namespace Opie;
38
39class Ramses : public ODevice, public QWSServer::KeyboardFilter
40{
41 protected:
42 virtual void init();
43
44 public:
45 virtual bool setSoftSuspend( bool soft );
46 virtual bool suspend();
47
48 virtual bool setDisplayStatus( bool on );
49 virtual bool setDisplayBrightness( int b );
50 virtual int displayBrightnessResolution() const;
51 virtual bool setDisplayContrast( int b );
52 virtual int displayContrastResolution() const;
53
54 protected:
55 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
56 virtual void timerEvent ( QTimerEvent *te );
57
58 int m_power_timer;
59};
60
61struct r_button {
62 uint model;
63 Qt::Key code;
64 char *utext;
65 char *pix;
66 char *fpressedservice;
67 char *fpressedaction;
68 char *fheldservice;
69 char *fheldaction;
70};
71
72#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 82dce10..a2cd419 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,443 +1,391 @@
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.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
56#ifndef ARRAY_SIZE
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63
64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68
69using namespace Opie; 56using namespace Opie;
70 57
71class SIMpad : public ODevice, public QWSServer::KeyboardFilter 58struct s_button simpad_buttons [] = {
72{
73 protected:
74 virtual void init();
75 virtual void initButtons();
76
77 public:
78 virtual bool setSoftSuspend( bool soft );
79 virtual bool suspend();
80
81 virtual bool setDisplayStatus( bool on );
82 virtual bool setDisplayBrightness( int b );
83 virtual int displayBrightnessResolution() const;
84
85 virtual void alarmSound();
86
87 virtual QValueList <OLed> ledList() const;
88 virtual QValueList <OLedState> ledStateList( OLed led ) const;
89 virtual OLedState ledState( OLed led ) const;
90 virtual bool setLedState( OLed led, OLedState st );
91
92 protected:
93 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
94 virtual void timerEvent( QTimerEvent *te );
95
96 int m_power_timer;
97
98 OLedState m_leds [1];
99};
100
101struct s_button {
102 uint model;
103 Qt::Key code;
104 char *utext;
105 char *pix;
106 char *fpressedservice;
107 char *fpressedaction;
108 char *fheldservice;
109 char *fheldaction;
110} simpad_buttons [] = {
111 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
112 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
113 "devicebuttons/simpad_lower_up", 61 "devicebuttons/simpad_lower_up",
114 "datebook", "nextView()", 62 "datebook", "nextView()",
115 "today", "raise()" }, 63 "today", "raise()" },
116 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
117 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
118 "devicebuttons/simpad_lower_down", 66 "devicebuttons/simpad_lower_down",
119 "addressbook", "raise()", 67 "addressbook", "raise()",
120 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
121 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
122 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
123 "devicebuttons/simpad_lower_right", 71 "devicebuttons/simpad_lower_right",
124 "QPE/TaskBar", "toggleMenu()", 72 "QPE/TaskBar", "toggleMenu()",
125 "QPE/TaskBar", "toggleStartMenu()" }, 73 "QPE/TaskBar", "toggleStartMenu()" },
126 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
127 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
128 "devicebuttons/simpad_lower_left", 76 "devicebuttons/simpad_lower_left",
129 "mail", "raise()", 77 "mail", "raise()",
130 "mail", "newMail()" }, 78 "mail", "newMail()" },
131 79
132 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
133 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
134 "devicebuttons/simpad_upper_up", 82 "devicebuttons/simpad_upper_up",
135 "QPE/Launcher", "home()", 83 "QPE/Launcher", "home()",
136 "buttonsettings", "raise()" }, 84 "buttonsettings", "raise()" },
137 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
138 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
139 "devicebuttons/simpad_upper_down", 87 "devicebuttons/simpad_upper_down",
140 "addressbook", "raise()", 88 "addressbook", "raise()",
141 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
142 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
143 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
144 "devicebuttons/simpad_upper_right", 92 "devicebuttons/simpad_upper_right",
145 "QPE/TaskBar", "toggleMenu()", 93 "QPE/TaskBar", "toggleMenu()",
146 "QPE/TaskBar", "toggleStartMenu()" }, 94 "QPE/TaskBar", "toggleStartMenu()" },
147 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
148 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
149 "devicebuttons/simpad_upper_left", 97 "devicebuttons/simpad_upper_left",
150 "QPE/Rotation", "flip()", 98 "QPE/Rotation", "flip()",
151 "QPE/Rotation", "flip()" }, 99 "QPE/Rotation", "flip()" },
152 /* 100 /*
153 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
154 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
155 "devicebuttons/simpad_lower_upper", 103 "devicebuttons/simpad_lower_upper",
156 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
157 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
158 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 106 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
159 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
160 "devicebuttons/simpad_upper_lower", 108 "devicebuttons/simpad_upper_lower",
161 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
162 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
163 */ 111 */
164}; 112};
165 113
166void SIMpad::init() 114void SIMpad::init()
167{ 115{
168 d->m_vendorstr = "SIEMENS"; 116 d->m_vendorstr = "SIEMENS";
169 d->m_vendor = Vendor_SIEMENS; 117 d->m_vendor = Vendor_SIEMENS;
170 118
171 QFile f ( "/proc/hal/model" ); 119 QFile f ( "/proc/hal/model" );
172 120
173 //TODO Implement model checking 121 //TODO Implement model checking
174 //FIXME For now we assume an SL4 122 //FIXME For now we assume an SL4
175 123
176 d->m_modelstr = "SL4"; 124 d->m_modelstr = "SL4";
177 d->m_model = Model_SIMpad_SL4; 125 d->m_model = Model_SIMpad_SL4;
178 126
179 switch ( d->m_model ) { 127 switch ( d->m_model ) {
180 default: 128 default:
181 d->m_rotation = Rot0; 129 d->m_rotation = Rot0;
182 d->m_direction = CCW; 130 d->m_direction = CCW;
183 d->m_holdtime = 1000; // 1000ms 131 d->m_holdtime = 1000; // 1000ms
184 132
185 break; 133 break;
186 } 134 }
187 135
188 f. setName ( "/etc/familiar-version" ); 136 f. setName ( "/etc/familiar-version" );
189 if ( f. open ( IO_ReadOnly )) { 137 if ( f. open ( IO_ReadOnly )) {
190 d->m_systemstr = "Familiar"; 138 d->m_systemstr = "Familiar";
191 d->m_system = System_Familiar; 139 d->m_system = System_Familiar;
192 140
193 QTextStream ts ( &f ); 141 QTextStream ts ( &f );
194 d->m_sysverstr = ts. readLine(). mid ( 10 ); 142 d->m_sysverstr = ts. readLine(). mid ( 10 );
195 143
196 f. close(); 144 f. close();
197 } else { 145 } else {
198 f. setName ( "/etc/oz_version" ); 146 f. setName ( "/etc/oz_version" );
199 147
200 if ( f. open ( IO_ReadOnly )) { 148 if ( f. open ( IO_ReadOnly )) {
201 d->m_systemstr = "OpenEmbedded/SIMpad"; 149 d->m_systemstr = "OpenEmbedded/SIMpad";
202 d->m_system = System_OpenZaurus; 150 d->m_system = System_OpenZaurus;
203 151
204 QTextStream ts ( &f ); 152 QTextStream ts ( &f );
205 ts.setDevice ( &f ); 153 ts.setDevice ( &f );
206 d->m_sysverstr = ts. readLine(); 154 d->m_sysverstr = ts. readLine();
207 f. close(); 155 f. close();
208 } 156 }
209 } 157 }
210 158
211 m_leds [0] = m_leds [1] = Led_Off; 159 m_leds [0] = m_leds [1] = Led_Off;
212 160
213 m_power_timer = 0; 161 m_power_timer = 0;
214 162
215} 163}
216 164
217void SIMpad::initButtons() 165void SIMpad::initButtons()
218{ 166{
219 if ( d->m_buttons ) 167 if ( d->m_buttons )
220 return; 168 return;
221 169
222 if ( isQWS( ) ) 170 if ( isQWS( ) )
223 QWSServer::setKeyboardFilter ( this ); 171 QWSServer::setKeyboardFilter ( this );
224 172
225 d->m_buttons = new QValueList <ODeviceButton>; 173 d->m_buttons = new QValueList <ODeviceButton>;
226 174
227 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
228 s_button *sb = simpad_buttons + i; 176 s_button *sb = simpad_buttons + i;
229 ODeviceButton b; 177 ODeviceButton b;
230 178
231 if (( sb->model & d->m_model ) == d->m_model ) { 179 if (( sb->model & d->m_model ) == d->m_model ) {
232 b. setKeycode ( sb->code ); 180 b. setKeycode ( sb->code );
233 b. setUserText ( QObject::tr ( "Button", sb->utext )); 181 b. setUserText ( QObject::tr ( "Button", sb->utext ));
234 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 182 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
235 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
236 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
237 185
238 d->m_buttons->append ( b ); 186 d->m_buttons->append ( b );
239 } 187 }
240 } 188 }
241 reloadButtonMapping(); 189 reloadButtonMapping();
242 190
243 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
244 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 192 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
245} 193}
246 194
247// SIMpad boardcontrol register CS3 195// SIMpad boardcontrol register CS3
248#define SIMPAD_BOARDCONTROL "/proc/cs3" 196#define SIMPAD_BOARDCONTROL "/proc/cs3"
249#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
250#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
251#define SIMPAD_EN1 0x0004 // This is only for EPROM's 199#define SIMPAD_EN1 0x0004 // This is only for EPROM's
252#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
253#define SIMPAD_DISPLAY_ON 0x0010 201#define SIMPAD_DISPLAY_ON 0x0010
254#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
255#define SIMPAD_MQ_RESET 0x0040 203#define SIMPAD_MQ_RESET 0x0040
256#define SIMPAD_PCMCIA_RESET 0x0080 204#define SIMPAD_PCMCIA_RESET 0x0080
257#define SIMPAD_DECT_POWER_ON 0x0100 205#define SIMPAD_DECT_POWER_ON 0x0100
258#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
259#define SIMPAD_RS232_ON 0x0400 207#define SIMPAD_RS232_ON 0x0400
260#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
261#define SIMPAD_LED2_ON 0x1000 209#define SIMPAD_LED2_ON 0x1000
262#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
263#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
264#define SIMPAD_RESET_SIMCARD 0x8000 212#define SIMPAD_RESET_SIMCARD 0x8000
265 213
266//SIMpad touchscreen backlight strength control 214//SIMpad touchscreen backlight strength control
267#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
268#define SIMPAD_BACKLIGHT_MASK 0x00a10044 216#define SIMPAD_BACKLIGHT_MASK 0x00a10044
269 217
270QValueList <OLed> SIMpad::ledList() const 218QValueList <OLed> SIMpad::ledList() const
271{ 219{
272 QValueList <OLed> vl; 220 QValueList <OLed> vl;
273 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
274 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
275 return vl; 223 return vl;
276} 224}
277 225
278QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
279{ 227{
280 QValueList <OLedState> vl; 228 QValueList <OLedState> vl;
281 229
282 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
283 vl << Led_Off << Led_On; 231 vl << Led_Off << Led_On;
284 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
285 //vl << Led_Off; 233 //vl << Led_Off;
286 return vl; 234 return vl;
287} 235}
288 236
289OLedState SIMpad::ledState ( OLed l ) const 237OLedState SIMpad::ledState ( OLed l ) const
290{ 238{
291 switch ( l ) { 239 switch ( l ) {
292 case Led_Power: 240 case Led_Power:
293 return m_leds [0]; 241 return m_leds [0];
294 //case Led_Mail: 242 //case Led_Mail:
295 //return m_leds [1]; 243 //return m_leds [1];
296 default: 244 default:
297 return Led_Off; 245 return Led_Off;
298 } 246 }
299} 247}
300 248
301bool SIMpad::setLedState ( OLed l, OLedState st ) 249bool SIMpad::setLedState ( OLed l, OLedState st )
302{ 250{
303#if 0 251#if 0
304 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
305 253
306 /*TODO Implement this like that: 254 /*TODO Implement this like that:
307 read from cs3 255 read from cs3
308 && with SIMPAD_LED2_ON 256 && with SIMPAD_LED2_ON
309 write to cs3 */ 257 write to cs3 */
310 m_leds [0] = st; 258 m_leds [0] = st;
311 return true; 259 return true;
312 } 260 }
313 } 261 }
314 } 262 }
315 263
316#endif 264#endif
317 return false; 265 return false;
318} 266}
319 267
320 268
321bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
322{ 270{
323 //TODO 271 //TODO
324 return false; 272 return false;
325} 273}
326 274
327void SIMpad::timerEvent ( QTimerEvent * ) 275void SIMpad::timerEvent ( QTimerEvent * )
328{ 276{
329 killTimer ( m_power_timer ); 277 killTimer ( m_power_timer );
330 m_power_timer = 0; 278 m_power_timer = 0;
331 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
332 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
333} 281}
334 282
335 283
336void SIMpad::alarmSound() 284void SIMpad::alarmSound()
337{ 285{
338#ifndef QT_NO_SOUND 286#ifndef QT_NO_SOUND
339 static Sound snd ( "alarm" ); 287 static Sound snd ( "alarm" );
340 int fd; 288 int fd;
341 int vol; 289 int vol;
342 bool vol_reset = false; 290 bool vol_reset = false;
343 291
344 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
345 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
346 Config cfg ( "qpe" ); 294 Config cfg ( "qpe" );
347 cfg. setGroup ( "Volume" ); 295 cfg. setGroup ( "Volume" );
348 296
349 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
350 if ( volalarm < 0 ) 298 if ( volalarm < 0 )
351 volalarm = 0; 299 volalarm = 0;
352 else if ( volalarm > 100 ) 300 else if ( volalarm > 100 )
353 volalarm = 100; 301 volalarm = 100;
354 volalarm |= ( volalarm << 8 ); 302 volalarm |= ( volalarm << 8 );
355 303
356 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
357 vol_reset = true; 305 vol_reset = true;
358 } 306 }
359 } 307 }
360 308
361 snd. play(); 309 snd. play();
362 while ( !snd. isFinished()) 310 while ( !snd. isFinished())
363 qApp->processEvents(); 311 qApp->processEvents();
364 312
365 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
366 if ( vol_reset ) 314 if ( vol_reset )
367 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
368 ::close ( fd ); 316 ::close ( fd );
369 } 317 }
370#endif 318#endif
371} 319}
372 320
373 321
374bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
375{ 323{
376 qDebug( "ODevice for SIMpad: suspend()" ); 324 qDebug( "ODevice for SIMpad: suspend()" );
377 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
378 return false; 326 return false;
379 327
380 bool res = false; 328 bool res = false;
381 329
382 struct timeval tvs, tvn; 330 struct timeval tvs, tvn;
383 ::gettimeofday ( &tvs, 0 ); 331 ::gettimeofday ( &tvs, 0 );
384 332
385 ::sync(); // flush fs caches 333 ::sync(); // flush fs caches
386 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 334 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
387 335
388 return res; 336 return res;
389} 337}
390 338
391 339
392bool SIMpad::setSoftSuspend ( bool soft ) 340bool SIMpad::setSoftSuspend ( bool soft )
393{ 341{
394 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 342 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
395 return false; 343 return false;
396} 344}
397 345
398 346
399bool SIMpad::setDisplayStatus ( bool on ) 347bool SIMpad::setDisplayStatus ( bool on )
400{ 348{
401 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 349 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
402 350
403 bool res = false; 351 bool res = false;
404 int fd; 352 int fd;
405 353
406 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 354 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
407 355
408 res = ( ::system( (const char*) cmdline ) == 0 ); 356 res = ( ::system( (const char*) cmdline ) == 0 );
409 357
410 return res; 358 return res;
411} 359}
412 360
413 361
414bool SIMpad::setDisplayBrightness ( int bright ) 362bool SIMpad::setDisplayBrightness ( int bright )
415{ 363{
416 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 364 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
417 bool res = false; 365 bool res = false;
418 int fd; 366 int fd;
419 367
420 if ( bright > 255 ) 368 if ( bright > 255 )
421 bright = 255; 369 bright = 255;
422 if ( bright < 1 ) 370 if ( bright < 1 )
423 bright = 0; 371 bright = 0;
424 372
425 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 373 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
426 int value = 255 - bright; 374 int value = 255 - bright;
427 const int mask = SIMPAD_BACKLIGHT_MASK; 375 const int mask = SIMPAD_BACKLIGHT_MASK;
428 value = value << 8; 376 value = value << 8;
429 value += mask; 377 value += mask;
430 char writeCommand[100]; 378 char writeCommand[100];
431 const int count = sprintf( writeCommand, "0x%x\n", value ); 379 const int count = sprintf( writeCommand, "0x%x\n", value );
432 res = ( ::write ( fd, writeCommand, count ) != -1 ); 380 res = ( ::write ( fd, writeCommand, count ) != -1 );
433 ::close ( fd ); 381 ::close ( fd );
434 } 382 }
435 return res; 383 return res;
436} 384}
437 385
438 386
439int SIMpad::displayBrightnessResolution() const 387int SIMpad::displayBrightnessResolution() const
440{ 388{
441 return 255; // All SIMpad models share the same display 389 return 255; // All SIMpad models share the same display
442} 390}
443 391
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
new file mode 100644
index 0000000..615effc
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -0,0 +1,81 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD
32
33#include <opie2/odevice.h>
34
35/* QT */
36#include <qwindowsystem_qws.h>
37
38using namespace Opie;
39
40class SIMpad : public ODevice, public QWSServer::KeyboardFilter
41{
42 protected:
43 virtual void init();
44 virtual void initButtons();
45
46 public:
47 virtual bool setSoftSuspend( bool soft );
48 virtual bool suspend();
49
50 virtual bool setDisplayStatus( bool on );
51 virtual bool setDisplayBrightness( int b );
52 virtual int displayBrightnessResolution() const;
53
54 virtual void alarmSound();
55
56 virtual QValueList <OLed> ledList() const;
57 virtual QValueList <OLedState> ledStateList( OLed led ) const;
58 virtual OLedState ledState( OLed led ) const;
59 virtual bool setLedState( OLed led, OLedState st );
60
61 protected:
62 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
63 virtual void timerEvent( QTimerEvent *te );
64
65 int m_power_timer;
66
67 OLedState m_leds [1];
68};
69
70struct s_button {
71 uint model;
72 Qt::Key code;
73 char *utext;
74 char *pix;
75 char *fpressedservice;
76 char *fpressedaction;
77 char *fheldservice;
78 char *fheldaction;
79};
80
81#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index 9d0cdeb..a76f90b 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -1,212 +1,163 @@
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.h" 30#include "odevice_yopy.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#ifndef ARRAY_SIZE
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63
64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68
69using namespace Opie; 56using namespace Opie;
70 57
71class Yopy : public ODevice 58struct yopy_button yopy_buttons [] = {
72{ 59 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
73 protected: 60 "devicebuttons/yopy_action",
74 61 "datebook", "nextView()",
75 virtual void init(); 62 "today", "raise()" },
76 virtual void initButtons(); 63 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
77 64 "devicebuttons/yopy_ok",
78 public: 65 "addressbook", "raise()",
79 virtual bool suspend(); 66 "addressbook", "beamBusinessCard()" },
80 67 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
81 virtual bool setDisplayBrightness ( int b ); 68 "devicebuttons/yopy_end",
82 virtual int displayBrightnessResolution() const; 69 "QPE/Launcher", "home()",
83 70 "buttonsettings", "raise()" },
84 static bool isYopy();
85}; 71};
86 72
87struct yopy_button { 73void Yopy::init()
88 Qt::Key code;
89 char *utext;
90 char *pix;
91 char *fpressedservice;
92 char *fpressedaction;
93 char *fheldservice;
94 char *fheldaction;
95} yopy_buttons [] = {
96{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
97 "devicebuttons/yopy_action",
98 "datebook", "nextView()",
99 "today", "raise()" },
100{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
101 "devicebuttons/yopy_ok",
102 "addressbook", "raise()",
103 "addressbook", "beamBusinessCard()" },
104{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
105 "devicebuttons/yopy_end",
106 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" },
108};
109
110bool Yopy::isYopy()
111{ 74{
112QFile f( "/proc/cpuinfo" ); 75 d->m_vendorstr = "G.Mate";
113if ( f. open ( IO_ReadOnly ) ) { 76 d->m_vendor = Vendor_GMate;
114 QTextStream ts ( &f ); 77 d->m_modelstr = "Yopy3700";
115 QString line; 78 d->m_model = Model_Yopy_3700;
116 while( line = ts. readLine() ) { 79 d->m_rotation = Rot0;
117 if ( line. left ( 8 ) == "Hardware" ) { 80
118 int loc = line. find ( ":" ); 81 d->m_systemstr = "Linupy";
119 if ( loc != -1 ) { 82 d->m_system = System_Linupy;
120 QString model = 83
121 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 84 QFile f ( "/etc/issue" );
122 return ( model == "Yopy" ); 85 if ( f. open ( IO_ReadOnly ) )
123 } 86 {
124 } 87 QTextStream ts ( &f );
88 ts.readLine();
89 d->m_sysverstr = ts. readLine();
90 f. close();
125 } 91 }
126} 92}
127return false;
128}
129 93
130void Yopy::init()
131{
132d->m_vendorstr = "G.Mate";
133d->m_vendor = Vendor_GMate;
134d->m_modelstr = "Yopy3700";
135d->m_model = Model_Yopy_3700;
136d->m_rotation = Rot0;
137
138d->m_systemstr = "Linupy";
139d->m_system = System_Linupy;
140
141QFile f ( "/etc/issue" );
142if ( f. open ( IO_ReadOnly )) {
143 QTextStream ts ( &f );
144 ts.readLine();
145 d->m_sysverstr = ts. readLine();
146 f. close();
147}
148}
149 94
150void Yopy::initButtons() 95void Yopy::initButtons()
151{ 96{
152if ( d->m_buttons ) 97 if ( d->m_buttons )
153 return; 98 return ;
154 99
155d->m_buttons = new QValueList <ODeviceButton>; 100 d->m_buttons = new QValueList <ODeviceButton>;
156 101
157for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 102 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
103 {
158 104
159 yopy_button *ib = yopy_buttons + i; 105 yopy_button *ib = yopy_buttons + i;
160 106
161 ODeviceButton b; 107 ODeviceButton b;
162 108
163 b. setKeycode ( ib->code ); 109 b. setKeycode ( ib->code );
164 b. setUserText ( QObject::tr ( "Button", ib->utext )); 110 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
165 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 111 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
166 b. setFactoryPresetPressedAction 112 b. setFactoryPresetPressedAction
167 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 113 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
168 b. setFactoryPresetHeldAction 114 b. setFactoryPresetHeldAction
169 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 115 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
170 116
171 d->m_buttons->append ( b ); 117 d->m_buttons->append ( b );
172} 118 }
173reloadButtonMapping(); 119 reloadButtonMapping();
174 120
175QCopChannel *sysch = new QCopChannel("QPE/System", this); 121 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
176connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 122 connect( sysch, SIGNAL( received( const QCString &, const QByteArray & ) ),
177 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 123 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
178} 124}
179 125
126
180bool Yopy::suspend() 127bool Yopy::suspend()
181{ 128{
182/* Opie for Yopy does not implement its own power management at the 129 /* Opie for Yopy does not implement its own power management at the
183 moment. The public version runs parallel to X, and relies on the 130 moment. The public version runs parallel to X, and relies on the
184 existing power management features. */ 131 existing power management features. */
185return false; 132 return false;
186} 133}
187 134
188bool Yopy::setDisplayBrightness(int bright) 135
136bool Yopy::setDisplayBrightness( int bright )
189{ 137{
190/* The code here works, but is disabled as the current version runs 138 /* The code here works, but is disabled as the current version runs
191 parallel to X, and relies on the existing backlight demon. */ 139 parallel to X, and relies on the existing backlight demon. */
192#if 0 140#if 0
193if ( QFile::exists("/proc/sys/pm/light") ) { 141 if ( QFile::exists( "/proc/sys/pm/light" ) )
194 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 142 {
195 if (fd >= 0 ) { 143 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
196 if (bright) 144 if ( fd >= 0 )
197 ::write(fd, "1\n", 2); 145 {
198 else 146 if ( bright )
199 ::write(fd, "0\n", 2); 147 ::write( fd, "1\n", 2 );
200 ::close(fd); 148 else
201 return true; 149 ::write( fd, "0\n", 2 );
150 ::close( fd );
151 return true;
152 }
202 } 153 }
203}
204#endif 154#endif
205return false; 155 return false;
206} 156}
207 157
158
208int Yopy::displayBrightnessResolution() const 159int Yopy::displayBrightnessResolution() const
209{ 160{
210 return 2; 161 return 2;
211} 162}
212 163
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
new file mode 100644
index 0000000..be8f62c
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -0,0 +1,62 @@
1/*
2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6          .>+-=
7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_YOPY
31#define ODEVICE_YOPY
32
33#include <opie2/odevice.h>
34
35using namespace Opie;
36
37class Yopy : public ODevice
38{
39 protected:
40
41 virtual void init();
42 virtual void initButtons();
43
44 public:
45 virtual bool suspend();
46
47 virtual bool setDisplayBrightness ( int b );
48 virtual int displayBrightnessResolution() const;
49};
50
51struct yopy_button
52{
53 Qt::Key code;
54 char *utext;
55 char *pix;
56 char *fpressedservice;
57 char *fpressedaction;
58 char *fheldservice;
59 char *fheldaction;
60};
61
62#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index a6e8b82..78bc62e 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,790 +1,691 @@
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.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
56#ifndef ARRAY_SIZE
57#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58#endif
59
60// _IO and friends are only defined in kernel headers ...
61
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63
64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68
69using namespace Opie; 56using namespace Opie;
70 57
71class Zaurus : public ODevice 58struct z_button z_buttons [] = {
72{
73
74 protected:
75 virtual void init();
76 virtual void initButtons();
77
78 public:
79 virtual bool setSoftSuspend ( bool soft );
80
81 virtual bool setDisplayBrightness ( int b );
82 virtual int displayBrightnessResolution() const;
83
84 virtual void alarmSound();
85 virtual void keySound();
86 virtual void touchSound();
87
88 virtual QValueList <OLed> ledList() const;
89 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
90 virtual OLedState ledState( OLed led ) const;
91 virtual bool setLedState( OLed led, OLedState st );
92
93 virtual bool hasHingeSensor() const;
94 virtual OHingeStatus readHingeSensor();
95
96 static bool isZaurus();
97
98 virtual bool suspend();
99 virtual Transformation rotation() const;
100 virtual ODirection direction() const;
101
102 protected:
103 virtual void buzzer ( int snd );
104
105 OLedState m_leds [1];
106 bool m_embedix;
107};
108
109struct z_button {
110 Qt::Key code;
111 char *utext;
112 char *pix;
113 char *fpressedservice;
114 char *fpressedaction;
115 char *fheldservice;
116 char *fheldaction;
117} z_buttons [] = {
118 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
119 "devicebuttons/z_calendar", 60 "devicebuttons/z_calendar",
120 "datebook", "nextView()", 61 "datebook", "nextView()",
121 "today", "raise()" }, 62 "today", "raise()" },
122 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
123 "devicebuttons/z_contact", 64 "devicebuttons/z_contact",
124 "addressbook", "raise()", 65 "addressbook", "raise()",
125 "addressbook", "beamBusinessCard()" }, 66 "addressbook", "beamBusinessCard()" },
126 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
127 "devicebuttons/z_home", 68 "devicebuttons/z_home",
128 "QPE/Launcher", "home()", 69 "QPE/Launcher", "home()",
129 "buttonsettings", "raise()" }, 70 "buttonsettings", "raise()" },
130 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
131 "devicebuttons/z_menu", 72 "devicebuttons/z_menu",
132 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
133 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
134 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
135 "devicebuttons/z_mail", 76 "devicebuttons/z_mail",
136 "mail", "raise()", 77 "mail", "raise()",
137 "mail", "newMail()" }, 78 "mail", "newMail()" },
138}; 79};
139 80
140struct z_button z_buttons_c700 [] = { 81struct z_button z_buttons_c700 [] = {
141 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
142 "devicebuttons/z_calendar", 83 "devicebuttons/z_calendar",
143 "datebook", "nextView()", 84 "datebook", "nextView()",
144 "today", "raise()" }, 85 "today", "raise()" },
145 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
146 "devicebuttons/z_contact", 87 "devicebuttons/z_contact",
147 "addressbook", "raise()", 88 "addressbook", "raise()",
148 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
149 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
150 "devicebuttons/z_home", 91 "devicebuttons/z_home",
151 "QPE/Launcher", "home()", 92 "QPE/Launcher", "home()",
152 "buttonsettings", "raise()" }, 93 "buttonsettings", "raise()" },
153 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
154 "devicebuttons/z_menu", 95 "devicebuttons/z_menu",
155 "QPE/TaskBar", "toggleMenu()", 96 "QPE/TaskBar", "toggleMenu()",
156 "QPE/TaskBar", "toggleStartMenu()" }, 97 "QPE/TaskBar", "toggleStartMenu()" },
157 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
158 "devicebuttons/z_hinge", 99 "devicebuttons/z_hinge",
159 "QPE/Rotation", "rotateDefault()", 100 "QPE/Rotation", "rotateDefault()",
160 "QPE/Dummy", "doNothing()" }, 101 "QPE/Dummy", "doNothing()" },
161}; 102};
162 103
163// Check whether this device is the sharp zaurus..
164// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
165// class up into individual classes. We need three classes 105// class up into individual classes. We need three classes
166// 106//
167// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 107// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
168// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 108// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
169// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 109// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
170// 110//
171// Only question right now is: Do we really need to do it? Because as soon 111// Only question right now is: Do we really need to do it? Because as soon
172// as the OpenZaurus kernel is ready, there will be a unified interface for all 112// as the OpenZaurus kernel is ready, there will be a unified interface for all
173// Zaurus models (concerning apm, backlight, buttons, etc.) 113// Zaurus models (concerning apm, backlight, buttons, etc.)
174// 114//
175// Comments? - mickeyl. 115// Comments? - mickeyl.
176 116
177bool Zaurus::isZaurus()
178{
179
180 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
181 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
182 return true;
183 }
184
185 // On non-embedix kernels, we have to look closer.
186 bool is_zaurus = false;
187 QFile f ( "/proc/cpuinfo" );
188 if ( f. open ( IO_ReadOnly ) ) {
189 QString model;
190 QFile f ( "/proc/cpuinfo" );
191
192 QTextStream ts ( &f );
193 QString line;
194 while( line = ts. readLine() ) {
195 if ( line. left ( 8 ) == "Hardware" )
196 break;
197 }
198 int loc = line. find ( ":" );
199 if ( loc != -1 )
200 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
201
202 if ( model == "Sharp-Collie"
203 || model == "Collie"
204 || model == "SHARP Corgi"
205 || model == "SHARP Shepherd"
206 || model == "SHARP Poodle"
207 || model == "SHARP Husky"
208 )
209 is_zaurus = true;
210
211 }
212 return is_zaurus;
213}
214
215
216void Zaurus::init() 117void Zaurus::init()
217{ 118{
218 d->m_vendorstr = "Sharp"; 119 d->m_vendorstr = "Sharp";
219 d->m_vendor = Vendor_Sharp; 120 d->m_vendor = Vendor_Sharp;
220 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 121 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
221 122
222 // QFile f ( "/proc/filesystems" ); 123 // QFile f ( "/proc/filesystems" );
223 QString model; 124 QString model;
224 125
225 // It isn't a good idea to check the system configuration to 126 // It isn't a good idea to check the system configuration to
226 // detect the distribution ! 127 // detect the distribution !
227 // Otherwise it may happen that any other distribution is detected as openzaurus, just 128 // Otherwise it may happen that any other distribution is detected as openzaurus, just
228 // because it uses a jffs2 filesystem.. 129 // because it uses a jffs2 filesystem..
229 // (eilers) 130 // (eilers)
230 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { 131 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
231 QFile f ("/etc/oz_version"); 132 QFile f ("/etc/oz_version");
232 if ( f.exists() ){ 133 if ( f.exists() ){
233 d->m_vendorstr = "OpenZaurus Team"; 134 d->m_vendorstr = "OpenZaurus Team";
234 d->m_systemstr = "OpenZaurus"; 135 d->m_systemstr = "OpenZaurus";
235 d->m_system = System_OpenZaurus; 136 d->m_system = System_OpenZaurus;
236 137
237 if ( f. open ( IO_ReadOnly )) { 138 if ( f. open ( IO_ReadOnly )) {
238 QTextStream ts ( &f ); 139 QTextStream ts ( &f );
239 d->m_sysverstr = ts. readLine();//. mid ( 10 ); 140 d->m_sysverstr = ts. readLine();//. mid ( 10 );
240 f. close(); 141 f. close();
241 } 142 }
242 143
243 // Openzaurus sometimes uses the embedix kernel! 144 // Openzaurus sometimes uses the embedix kernel!
244 // => Check whether this is an embedix kernel 145 // => Check whether this is an embedix kernel
245 FILE *uname = popen("uname -r", "r"); 146 FILE *uname = popen("uname -r", "r");
246 QString line; 147 QString line;
247 if ( f.open(IO_ReadOnly, uname) ) { 148 if ( f.open(IO_ReadOnly, uname) ) {
248 QTextStream ts ( &f ); 149 QTextStream ts ( &f );
249 line = ts. readLine(); 150 line = ts. readLine();
250 int loc = line. find ( "embedix" ); 151 int loc = line. find ( "embedix" );
251 if ( loc != -1 ) 152 if ( loc != -1 )
252 m_embedix = true; 153 m_embedix = true;
253 else 154 else
254 m_embedix = false; 155 m_embedix = false;
255 f. close(); 156 f. close();
256 } 157 }
257 pclose(uname); 158 pclose(uname);
258 } 159 }
259 else { 160 else {
260 d->m_systemstr = "Zaurus"; 161 d->m_systemstr = "Zaurus";
261 d->m_system = System_Zaurus; 162 d->m_system = System_Zaurus;
262 } 163 }
263 164
264 f. setName ( "/proc/cpuinfo" ); 165 f. setName ( "/proc/cpuinfo" );
265 if ( f. open ( IO_ReadOnly ) ) { 166 if ( f. open ( IO_ReadOnly ) ) {
266 QTextStream ts ( &f ); 167 QTextStream ts ( &f );
267 QString line; 168 QString line;
268 while( line = ts. readLine() ) { 169 while( line = ts. readLine() ) {
269 if ( line. left ( 8 ) == "Hardware" ) 170 if ( line. left ( 8 ) == "Hardware" )
270 break; 171 break;
271 } 172 }
272 int loc = line. find ( ":" ); 173 int loc = line. find ( ":" );
273 if ( loc != -1 ) 174 if ( loc != -1 )
274 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 175 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
275 } 176 }
276 177
277 if ( model == "SHARP Corgi" ) { 178 if ( model == "SHARP Corgi" ) {
278 d->m_model = Model_Zaurus_SLC7x0; 179 d->m_model = Model_Zaurus_SLC7x0;
279 d->m_modelstr = "Zaurus SL-C700"; 180 d->m_modelstr = "Zaurus SL-C700";
280 } else if ( model == "SHARP Shepherd" ) { 181 } else if ( model == "SHARP Shepherd" ) {
281 d->m_model = Model_Zaurus_SLC7x0; 182 d->m_model = Model_Zaurus_SLC7x0;
282 d->m_modelstr = "Zaurus SL-C750"; 183 d->m_modelstr = "Zaurus SL-C750";
283 } else if ( model == "SHARP Husky" ) { 184 } else if ( model == "SHARP Husky" ) {
284 d->m_model = Model_Zaurus_SLC7x0; 185 d->m_model = Model_Zaurus_SLC7x0;
285 d->m_modelstr = "Zaurus SL-C760"; 186 d->m_modelstr = "Zaurus SL-C760";
286 } else if ( model == "SHARP Poodle" ) { 187 } else if ( model == "SHARP Poodle" ) {
287 d->m_model = Model_Zaurus_SLB600; 188 d->m_model = Model_Zaurus_SLB600;
288 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 189 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
289 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 190 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
290 d->m_model = Model_Zaurus_SL5500; 191 d->m_model = Model_Zaurus_SL5500;
291 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 192 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
292 } else { 193 } else {
293 d->m_model = Model_Zaurus_SL5500; 194 d->m_model = Model_Zaurus_SL5500;
294 d->m_modelstr = "Zaurus (Model unknown)"; 195 d->m_modelstr = "Zaurus (Model unknown)";
295 } 196 }
296 197
297 bool flipstate = false; 198 bool flipstate = false;
298 switch ( d->m_model ) { 199 switch ( d->m_model ) {
299 case Model_Zaurus_SLA300: 200 case Model_Zaurus_SLA300:
300 d->m_rotation = Rot0; 201 d->m_rotation = Rot0;
301 break; 202 break;
302 case Model_Zaurus_SLC7x0: 203 case Model_Zaurus_SLC7x0:
303 d->m_rotation = rotation(); 204 d->m_rotation = rotation();
304 d->m_direction = direction(); 205 d->m_direction = direction();
305 break; 206 break;
306 case Model_Zaurus_SLB600: 207 case Model_Zaurus_SLB600:
307 case Model_Zaurus_SL5500: 208 case Model_Zaurus_SL5500:
308 case Model_Zaurus_SL5000: 209 case Model_Zaurus_SL5000:
309 default: 210 default:
310 d->m_rotation = Rot270; 211 d->m_rotation = Rot270;
311 break; 212 break;
312 } 213 }
313 m_leds [0] = Led_Off; 214 m_leds [0] = Led_Off;
314} 215}
315 216
316void Zaurus::initButtons() 217void Zaurus::initButtons()
317{ 218{
318 if ( d->m_buttons ) 219 if ( d->m_buttons )
319 return; 220 return;
320 221
321 d->m_buttons = new QValueList <ODeviceButton>; 222 d->m_buttons = new QValueList <ODeviceButton>;
322 223
323 struct z_button * pz_buttons; 224 struct z_button * pz_buttons;
324 int buttoncount; 225 int buttoncount;
325 switch ( d->m_model ) { 226 switch ( d->m_model ) {
326 case Model_Zaurus_SLC7x0: 227 case Model_Zaurus_SLC7x0:
327 pz_buttons = z_buttons_c700; 228 pz_buttons = z_buttons_c700;
328 buttoncount = ARRAY_SIZE(z_buttons_c700); 229 buttoncount = ARRAY_SIZE(z_buttons_c700);
329 break; 230 break;
330 default: 231 default:
331 pz_buttons = z_buttons; 232 pz_buttons = z_buttons;
332 buttoncount = ARRAY_SIZE(z_buttons); 233 buttoncount = ARRAY_SIZE(z_buttons);
333 break; 234 break;
334 } 235 }
335 236
336 for ( int i = 0; i < buttoncount; i++ ) { 237 for ( int i = 0; i < buttoncount; i++ ) {
337 struct z_button *zb = pz_buttons + i; 238 struct z_button *zb = pz_buttons + i;
338 ODeviceButton b; 239 ODeviceButton b;
339 240
340 b. setKeycode ( zb->code ); 241 b. setKeycode ( zb->code );
341 b. setUserText ( QObject::tr ( "Button", zb->utext )); 242 b. setUserText ( QObject::tr ( "Button", zb->utext ));
342 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 243 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
343 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 244 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
344 zb->fpressedaction )); 245 zb->fpressedaction ));
345 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 246 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
346 zb->fheldaction )); 247 zb->fheldaction ));
347 248
348 d->m_buttons->append ( b ); 249 d->m_buttons->append ( b );
349 } 250 }
350 251
351 reloadButtonMapping(); 252 reloadButtonMapping();
352 253
353 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 254 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
354 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 255 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
355 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 256 this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
356} 257}
357 258
358#include <unistd.h> 259#include <unistd.h>
359#include <fcntl.h> 260#include <fcntl.h>
360#include <sys/ioctl.h> 261#include <sys/ioctl.h>
361 262
362//#include <asm/sharp_char.h> // including kernel headers is evil ... 263//#include <asm/sharp_char.h> // including kernel headers is evil ...
363 264
364#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 265#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
365 266
366 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 267 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
367#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 268#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
368 269
369#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 270#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
370#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 271#define SHARP_BUZ_KEYSOUND 2 /* key sound */
371#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 272#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
372 273
373/* --- for SHARP_BUZZER device --- */ 274/* --- for SHARP_BUZZER device --- */
374 275
375 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 276 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
376//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 277//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
377 278
378#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 279#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
379#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 280#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
380#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 281#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
381#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 282#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
382#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 283#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
383 284
384//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 285//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
385//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 286//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
386 287
387//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 288//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
388//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 289//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
389//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 290//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
390//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 291//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
391//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 292//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
392//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 293//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
393//#define SHARP_PDA_APPSTART 9 /* application start */ 294//#define SHARP_PDA_APPSTART 9 /* application start */
394//#define SHARP_PDA_APPQUIT 10 /* application ends */ 295//#define SHARP_PDA_APPQUIT 10 /* application ends */
395 296
396//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 297//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
397//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 298//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
398//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 299//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
399//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 300//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
400// 301//
401 302
402 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 303 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
403#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 304#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
404 305
405#define SHARP_IOCTL_GET_ROTATION 0x413c 306#define SHARP_IOCTL_GET_ROTATION 0x413c
406 307
407typedef struct sharp_led_status { 308typedef struct sharp_led_status {
408int which; /* select which LED status is wanted. */ 309int which; /* select which LED status is wanted. */
409int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 310int status; /* set new led status if you call SHARP_LED_SETSTATUS */
410} sharp_led_status; 311} sharp_led_status;
411 312
412#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 313#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
413 314
414#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 315#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
415#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 316#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
416#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 317#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
417 318
418// #include <asm/sharp_apm.h> // including kernel headers is evil ... 319// #include <asm/sharp_apm.h> // including kernel headers is evil ...
419 320
420#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 321#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
421#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 322#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
422#define APM_EVT_POWER_BUTTON (1 << 0) 323#define APM_EVT_POWER_BUTTON (1 << 0)
423 324
424#define FL_IOCTL_STEP_CONTRAST 100 325#define FL_IOCTL_STEP_CONTRAST 100
425 326
426 327
427void Zaurus::buzzer ( int sound ) 328void Zaurus::buzzer ( int sound )
428{ 329{
429#ifndef QT_NO_SOUND 330#ifndef QT_NO_SOUND
430 QString soundname; 331 QString soundname;
431 332
432 // Not all devices have real sound 333 // Not all devices have real sound
433 if ( d->m_model == Model_Zaurus_SLC7x0 334 if ( d->m_model == Model_Zaurus_SLC7x0
434 || d->m_model == Model_Zaurus_SLB600 ){ 335 || d->m_model == Model_Zaurus_SLB600 ){
435 336
436 switch ( sound ){ 337 switch ( sound ){
437 case SHARP_BUZ_SCHEDULE_ALARM: 338 case SHARP_BUZ_SCHEDULE_ALARM:
438 soundname = "alarm"; 339 soundname = "alarm";
439 break; 340 break;
440 case SHARP_BUZ_TOUCHSOUND: 341 case SHARP_BUZ_TOUCHSOUND:
441 soundname = "touchsound"; 342 soundname = "touchsound";
442 break; 343 break;
443 case SHARP_BUZ_KEYSOUND: 344 case SHARP_BUZ_KEYSOUND:
444 soundname = "keysound"; 345 soundname = "keysound";
445 break; 346 break;
446 default: 347 default:
447 soundname = "alarm"; 348 soundname = "alarm";
448 349
449 } 350 }
450 } 351 }
451 352
452 // If a soundname is defined, we expect that this device has 353 // If a soundname is defined, we expect that this device has
453 // sound capabilities.. Otherwise we expect to have the buzzer 354 // sound capabilities.. Otherwise we expect to have the buzzer
454 // device.. 355 // device..
455 if ( !soundname.isEmpty() ){ 356 if ( !soundname.isEmpty() ){
456 int fd; 357 int fd;
457 int vol; 358 int vol;
458 bool vol_reset = false; 359 bool vol_reset = false;
459 360
460 Sound snd ( soundname ); 361 Sound snd ( soundname );
461 362
462 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 363 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
463 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 364 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
464 Config cfg ( "qpe" ); 365 Config cfg ( "qpe" );
465 cfg. setGroup ( "Volume" ); 366 cfg. setGroup ( "Volume" );
466 367
467 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 368 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
468 if ( volalarm < 0 ) 369 if ( volalarm < 0 )
469 volalarm = 0; 370 volalarm = 0;
470 else if ( volalarm > 100 ) 371 else if ( volalarm > 100 )
471 volalarm = 100; 372 volalarm = 100;
472 volalarm |= ( volalarm << 8 ); 373 volalarm |= ( volalarm << 8 );
473 374
474 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 375 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
475 vol_reset = true; 376 vol_reset = true;
476 } 377 }
477 } 378 }
478 379
479 snd. play(); 380 snd. play();
480 while ( !snd. isFinished()) 381 while ( !snd. isFinished())
481 qApp->processEvents(); 382 qApp->processEvents();
482 383
483 if ( fd >= 0 ) { 384 if ( fd >= 0 ) {
484 if ( vol_reset ) 385 if ( vol_reset )
485 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
486 ::close ( fd ); 387 ::close ( fd );
487 } 388 }
488 } else { 389 } else {
489 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 390 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
490 391
491 if ( fd >= 0 ) { 392 if ( fd >= 0 ) {
492 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 393 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
493 ::close ( fd ); 394 ::close ( fd );
494 } 395 }
495 396
496 } 397 }
497#endif 398#endif
498} 399}
499 400
500 401
501void Zaurus::alarmSound() 402void Zaurus::alarmSound()
502{ 403{
503 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 404 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
504} 405}
505 406
506void Zaurus::touchSound() 407void Zaurus::touchSound()
507{ 408{
508 buzzer ( SHARP_BUZ_TOUCHSOUND ); 409 buzzer ( SHARP_BUZ_TOUCHSOUND );
509} 410}
510 411
511void Zaurus::keySound() 412void Zaurus::keySound()
512{ 413{
513 buzzer ( SHARP_BUZ_KEYSOUND ); 414 buzzer ( SHARP_BUZ_KEYSOUND );
514} 415}
515 416
516 417
517QValueList <OLed> Zaurus::ledList() const 418QValueList <OLed> Zaurus::ledList() const
518{ 419{
519 QValueList <OLed> vl; 420 QValueList <OLed> vl;
520 vl << Led_Mail; 421 vl << Led_Mail;
521 return vl; 422 return vl;
522} 423}
523 424
524QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 425QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
525{ 426{
526 QValueList <OLedState> vl; 427 QValueList <OLedState> vl;
527 428
528 if ( l == Led_Mail ) 429 if ( l == Led_Mail )
529 vl << Led_Off << Led_On << Led_BlinkSlow; 430 vl << Led_Off << Led_On << Led_BlinkSlow;
530 return vl; 431 return vl;
531} 432}
532 433
533OLedState Zaurus::ledState ( OLed which ) const 434OLedState Zaurus::ledState ( OLed which ) const
534{ 435{
535 if ( which == Led_Mail ) 436 if ( which == Led_Mail )
536 return m_leds [0]; 437 return m_leds [0];
537 else 438 else
538 return Led_Off; 439 return Led_Off;
539} 440}
540 441
541bool Zaurus::setLedState ( OLed which, OLedState st ) 442bool Zaurus::setLedState ( OLed which, OLedState st )
542{ 443{
543 if (!m_embedix) // Currently not supported on non_embedix kernels 444 if (!m_embedix) // Currently not supported on non_embedix kernels
544 return false; 445 return false;
545 446
546 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 447 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
547 448
548 if ( which == Led_Mail ) { 449 if ( which == Led_Mail ) {
549 if ( fd >= 0 ) { 450 if ( fd >= 0 ) {
550 struct sharp_led_status leds; 451 struct sharp_led_status leds;
551 ::memset ( &leds, 0, sizeof( leds )); 452 ::memset ( &leds, 0, sizeof( leds ));
552 leds. which = SHARP_LED_MAIL_EXISTS; 453 leds. which = SHARP_LED_MAIL_EXISTS;
553 bool ok = true; 454 bool ok = true;
554 455
555 switch ( st ) { 456 switch ( st ) {
556 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 457 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
557 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 458 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
558 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 459 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
559 default : ok = false; 460 default : ok = false;
560 } 461 }
561 462
562 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 463 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
563 m_leds [0] = st; 464 m_leds [0] = st;
564 return true; 465 return true;
565 } 466 }
566 } 467 }
567 } 468 }
568 return false; 469 return false;
569} 470}
570 471
571bool Zaurus::setSoftSuspend ( bool soft ) 472bool Zaurus::setSoftSuspend ( bool soft )
572{ 473{
573 if (!m_embedix) { 474 if (!m_embedix) {
574 /* non-Embedix kernels dont have kernel autosuspend */ 475 /* non-Embedix kernels dont have kernel autosuspend */
575 return ODevice::setSoftSuspend( soft ); 476 return ODevice::setSoftSuspend( soft );
576 } 477 }
577 478
578 bool res = false; 479 bool res = false;
579 int fd; 480 int fd;
580 481
581 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 482 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
582 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 483 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
583 484
584 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 485 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
585 486
586 if ( sources >= 0 ) { 487 if ( sources >= 0 ) {
587 if ( soft ) 488 if ( soft )
588 sources &= ~APM_EVT_POWER_BUTTON; 489 sources &= ~APM_EVT_POWER_BUTTON;
589 else 490 else
590 sources |= APM_EVT_POWER_BUTTON; 491 sources |= APM_EVT_POWER_BUTTON;
591 492
592 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 493 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
593 res = true; 494 res = true;
594 else 495 else
595 perror ( "APM_IOCGEVTSRC" ); 496 perror ( "APM_IOCGEVTSRC" );
596 } 497 }
597 else 498 else
598 perror ( "APM_IOCGEVTSRC" ); 499 perror ( "APM_IOCGEVTSRC" );
599 500
600 ::close ( fd ); 501 ::close ( fd );
601 } 502 }
602 else 503 else
603 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 504 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
604 505
605 return res; 506 return res;
606} 507}
607 508
608 509
609bool Zaurus::setDisplayBrightness ( int bright ) 510bool Zaurus::setDisplayBrightness ( int bright )
610{ 511{
611 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 512 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
612 bool res = false; 513 bool res = false;
613 int fd; 514 int fd;
614 515
615 if ( bright > 255 ) bright = 255; 516 if ( bright > 255 ) bright = 255;
616 if ( bright < 0 ) bright = 0; 517 if ( bright < 0 ) bright = 0;
617 518
618 if ( m_embedix ) 519 if ( m_embedix )
619 { 520 {
620 if ( d->m_model == Model_Zaurus_SLC7x0 ) 521 if ( d->m_model == Model_Zaurus_SLC7x0 )
621 { 522 {
622 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 523 //qDebug( "using special treatment for devices with the corgi backlight interface" );
623 // special treatment for devices with the corgi backlight interface 524 // special treatment for devices with the corgi backlight interface
624 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 525 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
625 { 526 {
626 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 527 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
627 char writeCommand[100]; 528 char writeCommand[100];
628 const int count = sprintf( writeCommand, "0x%x\n", value ); 529 const int count = sprintf( writeCommand, "0x%x\n", value );
629 res = ( ::write ( fd, writeCommand, count ) != -1 ); 530 res = ( ::write ( fd, writeCommand, count ) != -1 );
630 ::close ( fd ); 531 ::close ( fd );
631 } 532 }
632 return res; 533 return res;
633 } 534 }
634 else 535 else
635 { 536 {
636 // standard treatment for devices with the dumb embedix frontlight interface 537 // standard treatment for devices with the dumb embedix frontlight interface
637 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 538 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
638 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 539 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
639 if ( bright && !bl ) 540 if ( bright && !bl )
640 bl = 1; 541 bl = 1;
641 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 542 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
642 ::close ( fd ); 543 ::close ( fd );
643 } 544 }
644 } 545 }
645 } 546 }
646 else 547 else
647 { 548 {
648 // special treatment for the OpenZaurus unified interface 549 // special treatment for the OpenZaurus unified interface
649 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 550 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
650 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 551 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
651 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 552 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
652 ::close ( fd ); 553 ::close ( fd );
653 } 554 }
654 } 555 }
655 return res; 556 return res;
656} 557}
657 558
658bool Zaurus::suspend() 559bool Zaurus::suspend()
659{ 560{
660 qDebug("ODevice::suspend"); 561 qDebug("ODevice::suspend");
661 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 562 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
662 return false; 563 return false;
663 564
664 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 565 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
665 return false; 566 return false;
666 567
667 bool res = false; 568 bool res = false;
668 569
669 struct timeval tvs, tvn; 570 struct timeval tvs, tvn;
670 ::gettimeofday ( &tvs, 0 ); 571 ::gettimeofday ( &tvs, 0 );
671 572
672 ::sync(); // flush fs caches 573 ::sync(); // flush fs caches
673 res = ( ::system ( "apm --suspend" ) == 0 ); 574 res = ( ::system ( "apm --suspend" ) == 0 );
674 575
675 // This is needed because the iPAQ apm implementation is asynchronous and we 576 // This is needed because the iPAQ apm implementation is asynchronous and we
676 // can not be sure when exactly the device is really suspended 577 // can not be sure when exactly the device is really suspended
677 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 578 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
678 579
679 if ( res ) { 580 if ( res ) {
680 do { // Yes, wait 15 seconds. This APM bug sucks big time. 581 do { // Yes, wait 15 seconds. This APM bug sucks big time.
681 ::usleep ( 200 * 1000 ); 582 ::usleep ( 200 * 1000 );
682 ::gettimeofday ( &tvn, 0 ); 583 ::gettimeofday ( &tvn, 0 );
683 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 584 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
684 } 585 }
685 586
686 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 587 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
687 return res; 588 return res;
688} 589}
689 590
690 591
691Transformation Zaurus::rotation() const 592Transformation Zaurus::rotation() const
692{ 593{
693 Transformation rot; 594 Transformation rot;
694 int handle = 0; 595 int handle = 0;
695 int retval = 0; 596 int retval = 0;
696 597
697 switch ( d->m_model ) { 598 switch ( d->m_model ) {
698 case Model_Zaurus_SLC7x0: 599 case Model_Zaurus_SLC7x0:
699 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 600 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
700 if (handle == -1) { 601 if (handle == -1) {
701 return Rot270; 602 return Rot270;
702 } else { 603 } else {
703 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 604 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
704 ::close (handle); 605 ::close (handle);
705 606
706 if (retval == 2 ) 607 if (retval == 2 )
707 rot = Rot0; 608 rot = Rot0;
708 else 609 else
709 rot = Rot270; 610 rot = Rot270;
710 } 611 }
711 break; 612 break;
712 case Model_Zaurus_SLA300: 613 case Model_Zaurus_SLA300:
713 case Model_Zaurus_SLB600: 614 case Model_Zaurus_SLB600:
714 case Model_Zaurus_SL5500: 615 case Model_Zaurus_SL5500:
715 case Model_Zaurus_SL5000: 616 case Model_Zaurus_SL5000:
716 default: 617 default:
717 rot = d->m_rotation; 618 rot = d->m_rotation;
718 break; 619 break;
719 } 620 }
720 621
721 return rot; 622 return rot;
722} 623}
723ODirection Zaurus::direction() const 624ODirection Zaurus::direction() const
724{ 625{
725 ODirection dir; 626 ODirection dir;
726 int handle = 0; 627 int handle = 0;
727 int retval = 0; 628 int retval = 0;
728 switch ( d->m_model ) { 629 switch ( d->m_model ) {
729 case Model_Zaurus_SLC7x0: 630 case Model_Zaurus_SLC7x0:
730 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 631 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
731 if (handle == -1) { 632 if (handle == -1) {
732 dir = CW; 633 dir = CW;
733 } else { 634 } else {
734 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 635 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
735 ::close (handle); 636 ::close (handle);
736 if (retval == 2 ) 637 if (retval == 2 )
737 dir = CCW; 638 dir = CCW;
738 else 639 else
739 dir = CW; 640 dir = CW;
740 } 641 }
741 break; 642 break;
742 case Model_Zaurus_SLA300: 643 case Model_Zaurus_SLA300:
743 case Model_Zaurus_SLB600: 644 case Model_Zaurus_SLB600:
744 case Model_Zaurus_SL5500: 645 case Model_Zaurus_SL5500:
745 case Model_Zaurus_SL5000: 646 case Model_Zaurus_SL5000:
746 default: 647 default:
747 dir = d->m_direction; 648 dir = d->m_direction;
748 break; 649 break;
749 } 650 }
750 return dir; 651 return dir;
751 652
752} 653}
753 654
754int Zaurus::displayBrightnessResolution() const 655int Zaurus::displayBrightnessResolution() const
755{ 656{
756 if (m_embedix) 657 if (m_embedix)
757 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 658 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
758 else 659 else
759 return 256; 660 return 256;
760} 661}
761 662
762bool Zaurus::hasHingeSensor() const 663bool Zaurus::hasHingeSensor() const
763{ 664{
764 return d->m_model == Model_Zaurus_SLC7x0; 665 return d->m_model == Model_Zaurus_SLC7x0;
765} 666}
766 667
767OHingeStatus Zaurus::readHingeSensor() 668OHingeStatus Zaurus::readHingeSensor()
768{ 669{
769 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 670 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
770 if (handle == -1) 671 if (handle == -1)
771 { 672 {
772 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 673 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
773 return CASE_UNKNOWN; 674 return CASE_UNKNOWN;
774 } 675 }
775 else 676 else
776 { 677 {
777 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 678 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
778 ::close (handle); 679 ::close (handle);
779 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 680 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
780 { 681 {
781 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 682 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
782 return static_cast<OHingeStatus>( retval ); 683 return static_cast<OHingeStatus>( retval );
783 } 684 }
784 else 685 else
785 { 686 {
786 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 687 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
787 return CASE_UNKNOWN; 688 return CASE_UNKNOWN;
788 } 689 }
789 } 690 }
790} 691}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
new file mode 100644
index 0000000..c07fe07
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -0,0 +1,96 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS
32
33#include <opie2/odevice.h>
34
35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif
38
39// _IO and friends are only defined in kernel headers ...
40
41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
42
43#define OD_IO(type,number) OD_IOC(0,type,number,0)
44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
47
48using namespace Opie;
49
50class Zaurus : public ODevice
51{
52
53 protected:
54 virtual void init();
55 virtual void initButtons();
56
57 public:
58 virtual bool setSoftSuspend ( bool soft );
59
60 virtual bool setDisplayBrightness ( int b );
61 virtual int displayBrightnessResolution() const;
62
63 virtual void alarmSound();
64 virtual void keySound();
65 virtual void touchSound();
66
67 virtual QValueList <OLed> ledList() const;
68 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
69 virtual OLedState ledState( OLed led ) const;
70 virtual bool setLedState( OLed led, OLedState st );
71
72 virtual bool hasHingeSensor() const;
73 virtual OHingeStatus readHingeSensor();
74
75 virtual bool suspend();
76 virtual Transformation rotation() const;
77 virtual ODirection direction() const;
78
79 protected:
80 virtual void buzzer ( int snd );
81
82 OLedState m_leds [1];
83 bool m_embedix;
84};
85
86struct z_button {
87 Qt::Key code;
88 char *utext;
89 char *pix;
90 char *fpressedservice;
91 char *fpressedaction;
92 char *fheldservice;
93 char *fheldaction;
94};
95
96#endif
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index 97e8146..98d315f 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,49 +1,55 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 oconfig.h \ 5 oconfig.h \
6 odebug.h \ 6 odebug.h \
7 odevice.h \ 7 odevice.h \
8 odevicebutton.h \ 8 odevicebutton.h \
9 odevice_ipaq.h \
10 odevice_jornada.h \
11 odevice_ramses.h \
12 odevice_simpad.h \
13 odevice_zaurus.h \
14 odevice_yopy.h \
9 oglobal.h \ 15 oglobal.h \
10 oglobalsettings.h \ 16 oglobalsettings.h \
11 oprocess.h \ 17 oprocess.h \
12 oprocctrl.h \ 18 oprocctrl.h \
13 ostorageinfo.h 19 ostorageinfo.h
14 20
15SOURCES = oapplication.cpp \ 21SOURCES = oapplication.cpp \
16 oconfig.cpp \ 22 oconfig.cpp \
17 odebug.cpp \ 23 odebug.cpp \
18 odevice.cpp \ 24 odevice.cpp \
19 odevicebutton.cpp \ 25 odevicebutton.cpp \
20 odevice_ipaq.cpp \ 26 odevice_ipaq.cpp \
21 odevice_jornada.cpp \ 27 odevice_jornada.cpp \
22 odevice_ramses.cpp \ 28 odevice_ramses.cpp \
23 odevice_simpad.cpp \ 29 odevice_simpad.cpp \
24 odevice_zaurus.cpp \ 30 odevice_zaurus.cpp \
25 odevice_yopy.cpp \ 31 odevice_yopy.cpp \
26 oglobal.cpp \ 32 oglobal.cpp \
27 oglobalsettings.cpp \ 33 oglobalsettings.cpp \
28 oprocess.cpp \ 34 oprocess.cpp \
29 oprocctrl.cpp \ 35 oprocctrl.cpp \
30 ostorageinfo.cpp 36 ostorageinfo.cpp
31 37
32INTERFACES = 38INTERFACES =
33TARGET = opiecore2 39TARGET = opiecore2
34VERSION = 1.8.3 40VERSION = 1.8.3
35INCLUDEPATH += $(OPIEDIR)/include 41INCLUDEPATH += $(OPIEDIR)/include
36DEPENDPATH += $(OPIEDIR)/include 42DEPENDPATH += $(OPIEDIR)/include
37MOC_DIR = moc 43MOC_DIR = moc
38OBJECTS_DIR = obj 44OBJECTS_DIR = obj
39 45
40 46
41!contains( platform, x11 ) { 47!contains( platform, x11 ) {
42 LIBS = -lqpe 48 LIBS = -lqpe
43 include ( $(OPIEDIR)/include.pro ) 49 include ( $(OPIEDIR)/include.pro )
44} 50}
45 51
46contains( platform, x11 ) { 52contains( platform, x11 ) {
47 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 53 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
48} 54}
49 55