summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 78eb416..9e97c56 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,510 +1,510 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
41 41
42 42
43// _IO and friends are only defined in kernel headers ... 43// _IO and friends are only defined in kernel headers ...
44 44
45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
46 46
47#define OD_IO(type,number) OD_IOC(0,type,number,0) 47#define OD_IO(type,number) OD_IOC(0,type,number,0)
48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
51 51
52using namespace Opie; 52using namespace Opie;
53 53
54class ODeviceData { 54class ODeviceData {
55public: 55public:
56 bool m_qwsserver; 56 bool m_qwsserver;
57 57
58 QString m_vendorstr; 58 QString m_vendorstr;
59 OVendor m_vendor; 59 OVendor m_vendor;
60 60
61 QString m_modelstr; 61 QString m_modelstr;
62 OModel m_model; 62 OModel m_model;
63 63
64 QString m_systemstr; 64 QString m_systemstr;
65 OSystem m_system; 65 OSystem m_system;
66 66
67 QString m_sysverstr; 67 QString m_sysverstr;
68 68
69 Transformation m_rotation; 69 Transformation m_rotation;
70 70
71 QValueList <ODeviceButton> m_buttons; 71 QValueList <ODeviceButton> m_buttons;
72 uint m_holdtime; 72 uint m_holdtime;
73}; 73};
74 74
75 75
76class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 76class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
77protected: 77protected:
78 virtual void init ( ); 78 virtual void init ( );
79 79
80public: 80public:
81 virtual bool setSoftSuspend ( bool soft ); 81 virtual bool setSoftSuspend ( bool soft );
82 82
83 virtual bool setDisplayBrightness ( int b ); 83 virtual bool setDisplayBrightness ( int b );
84 virtual int displayBrightnessResolution ( ) const; 84 virtual int displayBrightnessResolution ( ) const;
85 85
86 virtual void alarmSound ( ); 86 virtual void alarmSound ( );
87 87
88 virtual QValueList <OLed> ledList ( ) const; 88 virtual QValueList <OLed> ledList ( ) const;
89 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 89 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
90 virtual OLedState ledState ( OLed led ) const; 90 virtual OLedState ledState ( OLed led ) const;
91 virtual bool setLedState ( OLed led, OLedState st ); 91 virtual bool setLedState ( OLed led, OLedState st );
92 92
93 virtual bool hasLightSensor ( ) const; 93 virtual bool hasLightSensor ( ) const;
94 virtual int readLightSensor ( ); 94 virtual int readLightSensor ( );
95 virtual int lightSensorResolution ( ) const; 95 virtual int lightSensorResolution ( ) const;
96 96
97protected: 97protected:
98 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 98 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
99 virtual void timerEvent ( QTimerEvent *te ); 99 virtual void timerEvent ( QTimerEvent *te );
100 100
101 int m_power_timer; 101 int m_power_timer;
102 102
103 OLedState m_leds [2]; 103 OLedState m_leds [2];
104}; 104};
105 105
106class Zaurus : public ODevice { 106class Zaurus : public ODevice {
107protected: 107protected:
108 virtual void init ( ); 108 virtual void init ( );
109 109
110 public: 110 public:
111 virtual bool setSoftSuspend ( bool soft ); 111 virtual bool setSoftSuspend ( bool soft );
112 112
113 virtual bool setDisplayBrightness ( int b ); 113 virtual bool setDisplayBrightness ( int b );
114 virtual int displayBrightnessResolution ( ) const; 114 virtual int displayBrightnessResolution ( ) const;
115 115
116 virtual void alarmSound ( ); 116 virtual void alarmSound ( );
117 virtual void keySound ( ); 117 virtual void keySound ( );
118 virtual void touchSound ( ); 118 virtual void touchSound ( );
119 119
120 virtual QValueList <OLed> ledList ( ) const; 120 virtual QValueList <OLed> ledList ( ) const;
121 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 121 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
122 virtual OLedState ledState ( OLed led ) const; 122 virtual OLedState ledState ( OLed led ) const;
123 virtual bool setLedState ( OLed led, OLedState st ); 123 virtual bool setLedState ( OLed led, OLedState st );
124 124
125protected: 125protected:
126 virtual void buzzer ( int snd ); 126 virtual void buzzer ( int snd );
127 127
128 OLedState m_leds [1]; 128 OLedState m_leds [1];
129}; 129};
130 130
131 131
132struct i_button { 132struct i_button {
133 uint model; 133 uint model;
134 Qt::Key code; 134 Qt::Key code;
135 char *utext; 135 char *utext;
136 char *pix; 136 char *pix;
137 char *fpressedservice; 137 char *fpressedservice;
138 char *fpressedaction; 138 char *fpressedaction;
139 char *fheldservice; 139 char *fheldservice;
140 char *fheldaction; 140 char *fheldaction;
141} ipaq_buttons [] = { 141} ipaq_buttons [] = {
142 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 142 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
143 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 143 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
144 "devicebuttons/ipaq_calendar", 144 "devicebuttons/ipaq_calendar",
145 "datebook", "nextView()", 145 "datebook", "nextView()",
146 "today", "raise()" }, 146 "today", "raise()" },
147 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 147 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
148 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 148 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
149 "devicebuttons/ipaq_contact", 149 "devicebuttons/ipaq_contact",
150 "addressbook", "raise()", 150 "addressbook", "raise()",
151 "addressbook", "beamBusinessCard()" }, 151 "addressbook", "beamBusinessCard()" },
152 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 152 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
153 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 153 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
154 "devicebuttons/ipaq_menu", 154 "devicebuttons/ipaq_menu",
155 "QPE/TaskBar", "toggleMenu()", 155 "QPE/TaskBar", "toggleMenu()",
156 "QPE/TaskBar", "toggleStartMenu()" }, 156 "QPE/TaskBar", "toggleStartMenu()" },
157 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 157 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
158 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 158 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
159 "devicebuttons/ipaq_mail", 159 "devicebuttons/ipaq_mail",
160 "mail", "raise()", 160 "mail", "raise()",
161 "mail", "newMail()" }, 161 "mail", "newMail()" },
162 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 162 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
163 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 163 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
164 "devicebuttons/ipaq_home", 164 "devicebuttons/ipaq_home",
165 "QPE/Launcher", "home()", 165 "QPE/Launcher", "home()",
166 "buttonsettings", "raise()" }, 166 "buttonsettings", "raise()" },
167 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 167 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
168 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 168 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
169 "devicebuttons/ipaq_record", 169 "devicebuttons/ipaq_record",
170 "QPE/VMemo", "toggleRecord()", 170 "QPE/VMemo", "toggleRecord()",
171 "sound", "raise()" }, 171 "sound", "raise()" },
172}; 172};
173 173
174struct z_button { 174struct z_button {
175 Qt::Key code; 175 Qt::Key code;
176 char *utext; 176 char *utext;
177 char *pix; 177 char *pix;
178 char *fpressedservice; 178 char *fpressedservice;
179 char *fpressedaction; 179 char *fpressedaction;
180 char *fheldservice; 180 char *fheldservice;
181 char *fheldaction; 181 char *fheldaction;
182} z_buttons [] = { 182} z_buttons [] = {
183 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 183 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
184 "devicebuttons/z_calendar", 184 "devicebuttons/z_calendar",
185 "datebook", "nextView()", 185 "datebook", "nextView()",
186 "today", "raise()" }, 186 "today", "raise()" },
187 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 187 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
188 "devicebuttons/z_contact", 188 "devicebuttons/z_contact",
189 "addressbook", "raise()", 189 "addressbook", "raise()",
190 "addressbook", "beamBusinessCard()" }, 190 "addressbook", "beamBusinessCard()" },
191 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 191 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
192 "devicebuttons/z_home", 192 "devicebuttons/z_home",
193 "QPE/Launcher", "home()", 193 "QPE/Launcher", "home()",
194 "buttonsettings", "raise()" }, 194 "buttonsettings", "raise()" },
195 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 195 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
196 "devicebuttons/z_menu", 196 "devicebuttons/z_menu",
197 "QPE/TaskBar", "toggleMenu()", 197 "QPE/TaskBar", "toggleMenu()",
198 "QPE/TaskBar", "toggleStartMenu()" }, 198 "QPE/TaskBar", "toggleStartMenu()" },
199 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 199 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
200 "devicebuttons/z_mail", 200 "devicebuttons/z_mail",
201 "mail", "raise()", 201 "mail", "raise()",
202 "mail", "newMail()" }, 202 "mail", "newMail()" },
203}; 203};
204 204
205static QCString makeChannel ( const char *str ) 205static QCString makeChannel ( const char *str )
206{ 206{
207 if ( str && !::strchr ( str, '/' )) 207 if ( str && !::strchr ( str, '/' ))
208 return QCString ( "QPE/Application/" ) + str; 208 return QCString ( "QPE/Application/" ) + str;
209 else 209 else
210 return str; 210 return str;
211} 211}
212 212
213 213
214 214
215 215
216ODevice *ODevice::inst ( ) 216ODevice *ODevice::inst ( )
217{ 217{
218 static ODevice *dev = 0; 218 static ODevice *dev = 0;
219 219
220 if ( !dev ) { 220 if ( !dev ) {
221 if ( QFile::exists ( "/proc/hal/model" )) 221 if ( QFile::exists ( "/proc/hal/model" ))
222 dev = new iPAQ ( ); 222 dev = new iPAQ ( );
223 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 223 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
224 dev = new Zaurus ( ); 224 dev = new Zaurus ( );
225 else 225 else
226 dev = new ODevice ( ); 226 dev = new ODevice ( );
227 227
228 dev-> init ( ); 228 dev-> init ( );
229 } 229 }
230 return dev; 230 return dev;
231} 231}
232 232
233 233
234/************************************************** 234/**************************************************
235 * 235 *
236 * common 236 * common
237 * 237 *
238 **************************************************/ 238 **************************************************/
239 239
240 240
241ODevice::ODevice ( ) 241ODevice::ODevice ( )
242{ 242{
243 d = new ODeviceData; 243 d = new ODeviceData;
244 244
245 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 245 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
246 246
247 d-> m_modelstr = "Unknown"; 247 d-> m_modelstr = "Unknown";
248 d-> m_model = Model_Unknown; 248 d-> m_model = Model_Unknown;
249 d-> m_vendorstr = "Unknown"; 249 d-> m_vendorstr = "Unknown";
250 d-> m_vendor = Vendor_Unknown; 250 d-> m_vendor = Vendor_Unknown;
251 d-> m_systemstr = "Unknown"; 251 d-> m_systemstr = "Unknown";
252 d-> m_system = System_Unknown; 252 d-> m_system = System_Unknown;
253 d-> m_sysverstr = "0.0"; 253 d-> m_sysverstr = "0.0";
254 d-> m_rotation = None; 254 d-> m_rotation = Rot0;
255 255
256 d-> m_holdtime = 1000; // 1000ms 256 d-> m_holdtime = 1000; // 1000ms
257 257
258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
260} 260}
261 261
262void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 262void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
263{ 263{
264 if ( msg == "deviceButtonMappingChanged()" ) { 264 if ( msg == "deviceButtonMappingChanged()" ) {
265 reloadButtonMapping ( ); 265 reloadButtonMapping ( );
266 } 266 }
267} 267}
268 268
269void ODevice::init ( ) 269void ODevice::init ( )
270{ 270{
271 // Simulation uses iPAQ 3660 device buttons 271 // Simulation uses iPAQ 3660 device buttons
272 272
273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
274 i_button *ib = ipaq_buttons + i; 274 i_button *ib = ipaq_buttons + i;
275 ODeviceButton b; 275 ODeviceButton b;
276 276
277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
278 b. setKeycode ( ib-> code ); 278 b. setKeycode ( ib-> code );
279 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 279 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
280 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 280 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
283 283
284 d-> m_buttons. append ( b ); 284 d-> m_buttons. append ( b );
285 } 285 }
286 } 286 }
287 reloadButtonMapping ( ); 287 reloadButtonMapping ( );
288} 288}
289 289
290ODevice::~ODevice ( ) 290ODevice::~ODevice ( )
291{ 291{
292 delete d; 292 delete d;
293} 293}
294 294
295bool ODevice::setSoftSuspend ( bool /*soft*/ ) 295bool ODevice::setSoftSuspend ( bool /*soft*/ )
296{ 296{
297 return false; 297 return false;
298} 298}
299 299
300//#include <linux/apm_bios.h> 300//#include <linux/apm_bios.h>
301 301
302#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 302#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
303 303
304 304
305bool ODevice::suspend ( ) 305bool ODevice::suspend ( )
306{ 306{
307 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 307 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
308 return false; 308 return false;
309 309
310 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 310 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
311 return false; 311 return false;
312 312
313 bool res = false; 313 bool res = false;
314 314
315 struct timeval tvs, tvn; 315 struct timeval tvs, tvn;
316 ::gettimeofday ( &tvs, 0 ); 316 ::gettimeofday ( &tvs, 0 );
317 317
318 ::sync ( ); // flush fs caches 318 ::sync ( ); // flush fs caches
319 res = ( ::system ( "apm --suspend" ) == 0 ); 319 res = ( ::system ( "apm --suspend" ) == 0 );
320 320
321 // This is needed because the iPAQ apm implementation is asynchronous and we 321 // This is needed because the iPAQ apm implementation is asynchronous and we
322 // can not be sure when exactly the device is really suspended 322 // can not be sure when exactly the device is really suspended
323 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 323 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
324 324
325 if ( res ) { 325 if ( res ) {
326 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 326 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
327 ::usleep ( 200 * 1000 ); 327 ::usleep ( 200 * 1000 );
328 ::gettimeofday ( &tvn, 0 ); 328 ::gettimeofday ( &tvn, 0 );
329 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 329 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
330 } 330 }
331 331
332 return res; 332 return res;
333} 333}
334 334
335//#include <linux/fb.h> better not rely on kernel headers in userspace ... 335//#include <linux/fb.h> better not rely on kernel headers in userspace ...
336 336
337#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 337#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
338 338
339/* VESA Blanking Levels */ 339/* VESA Blanking Levels */
340#define VESA_NO_BLANKING 0 340#define VESA_NO_BLANKING 0
341#define VESA_VSYNC_SUSPEND 1 341#define VESA_VSYNC_SUSPEND 1
342#define VESA_HSYNC_SUSPEND 2 342#define VESA_HSYNC_SUSPEND 2
343#define VESA_POWERDOWN 3 343#define VESA_POWERDOWN 3
344 344
345 345
346bool ODevice::setDisplayStatus ( bool on ) 346bool ODevice::setDisplayStatus ( bool on )
347{ 347{
348 if ( d-> m_model == Model_Unknown ) 348 if ( d-> m_model == Model_Unknown )
349 return false; 349 return false;
350 350
351 bool res = false; 351 bool res = false;
352 int fd; 352 int fd;
353 353
354 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 354 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
355 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 355 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
356 ::close ( fd ); 356 ::close ( fd );
357 } 357 }
358 return res; 358 return res;
359} 359}
360 360
361bool ODevice::setDisplayBrightness ( int ) 361bool ODevice::setDisplayBrightness ( int )
362{ 362{
363 return false; 363 return false;
364} 364}
365 365
366int ODevice::displayBrightnessResolution ( ) const 366int ODevice::displayBrightnessResolution ( ) const
367{ 367{
368 return 16; 368 return 16;
369} 369}
370 370
371QString ODevice::vendorString ( ) const 371QString ODevice::vendorString ( ) const
372{ 372{
373 return d-> m_vendorstr; 373 return d-> m_vendorstr;
374} 374}
375 375
376OVendor ODevice::vendor ( ) const 376OVendor ODevice::vendor ( ) const
377{ 377{
378 return d-> m_vendor; 378 return d-> m_vendor;
379} 379}
380 380
381QString ODevice::modelString ( ) const 381QString ODevice::modelString ( ) const
382{ 382{
383 return d-> m_modelstr; 383 return d-> m_modelstr;
384} 384}
385 385
386OModel ODevice::model ( ) const 386OModel ODevice::model ( ) const
387{ 387{
388 return d-> m_model; 388 return d-> m_model;
389} 389}
390 390
391QString ODevice::systemString ( ) const 391QString ODevice::systemString ( ) const
392{ 392{
393 return d-> m_systemstr; 393 return d-> m_systemstr;
394} 394}
395 395
396OSystem ODevice::system ( ) const 396OSystem ODevice::system ( ) const
397{ 397{
398 return d-> m_system; 398 return d-> m_system;
399} 399}
400 400
401QString ODevice::systemVersionString ( ) const 401QString ODevice::systemVersionString ( ) const
402{ 402{
403 return d-> m_sysverstr; 403 return d-> m_sysverstr;
404} 404}
405 405
406Transformation ODevice::rotation ( ) const 406Transformation ODevice::rotation ( ) const
407{ 407{
408 return d-> m_rotation; 408 return d-> m_rotation;
409} 409}
410 410
411void ODevice::alarmSound ( ) 411void ODevice::alarmSound ( )
412{ 412{
413#ifndef QT_NO_SOUND 413#ifndef QT_NO_SOUND
414 static Sound snd ( "alarm" ); 414 static Sound snd ( "alarm" );
415 415
416 if ( snd. isFinished ( )) 416 if ( snd. isFinished ( ))
417 snd. play ( ); 417 snd. play ( );
418#endif 418#endif
419} 419}
420 420
421void ODevice::keySound ( ) 421void ODevice::keySound ( )
422{ 422{
423#ifndef QT_NO_SOUND 423#ifndef QT_NO_SOUND
424 static Sound snd ( "keysound" ); 424 static Sound snd ( "keysound" );
425 425
426 if ( snd. isFinished ( )) 426 if ( snd. isFinished ( ))
427 snd. play ( ); 427 snd. play ( );
428#endif 428#endif
429} 429}
430 430
431void ODevice::touchSound ( ) 431void ODevice::touchSound ( )
432{ 432{
433 433
434#ifndef QT_NO_SOUND 434#ifndef QT_NO_SOUND
435 static Sound snd ( "touchsound" ); 435 static Sound snd ( "touchsound" );
436 436
437 if ( snd. isFinished ( )) 437 if ( snd. isFinished ( ))
438 snd. play ( ); 438 snd. play ( );
439#endif 439#endif
440} 440}
441 441
442 442
443QValueList <OLed> ODevice::ledList ( ) const 443QValueList <OLed> ODevice::ledList ( ) const
444{ 444{
445 return QValueList <OLed> ( ); 445 return QValueList <OLed> ( );
446} 446}
447 447
448QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 448QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
449{ 449{
450 return QValueList <OLedState> ( ); 450 return QValueList <OLedState> ( );
451} 451}
452 452
453OLedState ODevice::ledState ( OLed /*which*/ ) const 453OLedState ODevice::ledState ( OLed /*which*/ ) const
454{ 454{
455 return Led_Off; 455 return Led_Off;
456} 456}
457 457
458bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 458bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
459{ 459{
460 return false; 460 return false;
461} 461}
462 462
463bool ODevice::hasLightSensor ( ) const 463bool ODevice::hasLightSensor ( ) const
464{ 464{
465 return false; 465 return false;
466} 466}
467 467
468int ODevice::readLightSensor ( ) 468int ODevice::readLightSensor ( )
469{ 469{
470 return -1; 470 return -1;
471} 471}
472 472
473int ODevice::lightSensorResolution ( ) const 473int ODevice::lightSensorResolution ( ) const
474{ 474{
475 return 0; 475 return 0;
476} 476}
477 477
478const QValueList <ODeviceButton> &ODevice::buttons ( ) const 478const QValueList <ODeviceButton> &ODevice::buttons ( ) const
479{ 479{
480 return d-> m_buttons; 480 return d-> m_buttons;
481} 481}
482 482
483uint ODevice::buttonHoldTime ( ) const 483uint ODevice::buttonHoldTime ( ) const
484{ 484{
485 return d-> m_holdtime; 485 return d-> m_holdtime;
486} 486}
487 487
488const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 488const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
489{ 489{
490 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { 490 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
491 if ( (*it). keycode ( ) == code ) 491 if ( (*it). keycode ( ) == code )
492 return &(*it); 492 return &(*it);
493 } 493 }
494 return 0; 494 return 0;
495} 495}
496 496
497void ODevice::reloadButtonMapping ( ) 497void ODevice::reloadButtonMapping ( )
498{ 498{
499 Config cfg ( "ButtonSettings" ); 499 Config cfg ( "ButtonSettings" );
500 500
501 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { 501 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
502 ODeviceButton &b = d-> m_buttons [i]; 502 ODeviceButton &b = d-> m_buttons [i];
503 QString group = "Button" + QString::number ( i ); 503 QString group = "Button" + QString::number ( i );
504 504
505 QCString pch, hch; 505 QCString pch, hch;
506 QCString pm, hm; 506 QCString pm, hm;
507 QByteArray pdata, hdata; 507 QByteArray pdata, hdata;
508 508
509 if ( cfg. hasGroup ( group )) { 509 if ( cfg. hasGroup ( group )) {
510 cfg. setGroup ( group ); 510 cfg. setGroup ( group );