summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 0e620ba..d39d72f 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,633 +1,633 @@
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 QValueList <ODeviceButton> m_buttons; 69 QValueList <ODeviceButton> m_buttons;
70 uint m_holdtime; 70 uint m_holdtime;
71}; 71};
72 72
73 73
74class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 74class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
75protected: 75protected:
76 virtual void init ( ); 76 virtual void init ( );
77 77
78public: 78public:
79 virtual bool setSoftSuspend ( bool soft ); 79 virtual bool setSoftSuspend ( bool soft );
80 80
81 virtual bool setDisplayBrightness ( int b ); 81 virtual bool setDisplayBrightness ( int b );
82 virtual int displayBrightnessResolution ( ) const; 82 virtual int displayBrightnessResolution ( ) const;
83 83
84 virtual void alarmSound ( ); 84 virtual void alarmSound ( );
85 85
86 virtual QValueList <OLed> ledList ( ) const; 86 virtual QValueList <OLed> ledList ( ) const;
87 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 87 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
88 virtual OLedState ledState ( OLed led ) const; 88 virtual OLedState ledState ( OLed led ) const;
89 virtual bool setLedState ( OLed led, OLedState st ); 89 virtual bool setLedState ( OLed led, OLedState st );
90 90
91 virtual bool hasLightSensor ( ) const; 91 virtual bool hasLightSensor ( ) const;
92 virtual int readLightSensor ( ); 92 virtual int readLightSensor ( );
93 virtual int lightSensorResolution ( ) const; 93 virtual int lightSensorResolution ( ) const;
94 94
95protected: 95protected:
96 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 96 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
97 virtual void timerEvent ( QTimerEvent *te ); 97 virtual void timerEvent ( QTimerEvent *te );
98 98
99 int m_power_timer; 99 int m_power_timer;
100 100
101 OLedState m_leds [2]; 101 OLedState m_leds [2];
102}; 102};
103 103
104class Zaurus : public ODevice { 104class Zaurus : public ODevice {
105protected: 105protected:
106 virtual void init ( ); 106 virtual void init ( );
107 107
108 public: 108 public:
109 virtual bool setSoftSuspend ( bool soft ); 109 virtual bool setSoftSuspend ( bool soft );
110 110
111 virtual bool setDisplayBrightness ( int b ); 111 virtual bool setDisplayBrightness ( int b );
112 virtual int displayBrightnessResolution ( ) const; 112 virtual int displayBrightnessResolution ( ) const;
113 113
114 virtual void alarmSound ( ); 114 virtual void alarmSound ( );
115 virtual void keySound ( ); 115 virtual void keySound ( );
116 virtual void touchSound ( ); 116 virtual void touchSound ( );
117 117
118 virtual QValueList <OLed> ledList ( ) const; 118 virtual QValueList <OLed> ledList ( ) const;
119 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 119 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
120 virtual OLedState ledState ( OLed led ) const; 120 virtual OLedState ledState ( OLed led ) const;
121 virtual bool setLedState ( OLed led, OLedState st ); 121 virtual bool setLedState ( OLed led, OLedState st );
122 122
123protected: 123protected:
124 virtual void buzzer ( int snd ); 124 virtual void buzzer ( int snd );
125 125
126 OLedState m_leds [1]; 126 OLedState m_leds [1];
127}; 127};
128 128
129 129
130struct i_button { 130struct i_button {
131 uint model; 131 uint model;
132 Qt::Key code; 132 Qt::Key code;
133 char *utext; 133 char *utext;
134 char *pix; 134 char *pix;
135 char *fpressedservice; 135 char *fpressedservice;
136 char *fpressedaction; 136 char *fpressedaction;
137 char *fheldservice; 137 char *fheldservice;
138 char *fheldaction; 138 char *fheldaction;
139} ipaq_buttons [] = { 139} ipaq_buttons [] = {
140 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 140 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
141 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 141 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
142 "devicebuttons/ipaq_calendar", 142 "devicebuttons/ipaq_calendar",
143 "datebook", "nextView()", 143 "datebook", "nextView()",
144 "today", "raise()" }, 144 "today", "raise()" },
145 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 145 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
146 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 146 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
147 "devicebuttons/ipaq_contact", 147 "devicebuttons/ipaq_contact",
148 "addressbook", "raise()", 148 "addressbook", "raise()",
149 "addressbook", "beamBusinessCard()" }, 149 "addressbook", "beamBusinessCard()" },
150 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 150 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
151 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 151 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
152 "devicebuttons/ipaq_menu", 152 "devicebuttons/ipaq_menu",
153 "QPE/TaskBar", "toggleMenu()", 153 "QPE/TaskBar", "toggleMenu()",
154 "QPE/TaskBar", "toggleStartMenu()" }, 154 "QPE/TaskBar", "toggleStartMenu()" },
155 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 155 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
156 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 156 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
157 "devicebuttons/ipaq_mail", 157 "devicebuttons/ipaq_mail",
158 "mail", "raise()", 158 "mail", "raise()",
159 "mail", "newMail()" }, 159 "mail", "newMail()" },
160 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 160 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
161 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 161 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
162 "devicebuttons/ipaq_home", 162 "devicebuttons/ipaq_home",
163 "QPE/Launcher", "home()", 163 "QPE/Launcher", "home()",
164 "buttonsettings", "raise()" }, 164 "buttonsettings", "raise()" },
165 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 165 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
166 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 166 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
167 "devicebuttons/ipaq_record", 167 "devicebuttons/ipaq_record",
168 "QPE/VMemo", "toggleRecord()", 168 "QPE/VMemo", "toggleRecord()",
169 "sound", "raise()" }, 169 "sound", "raise()" },
170}; 170};
171 171
172struct z_button { 172struct z_button {
173 Qt::Key code; 173 Qt::Key code;
174 char *utext; 174 char *utext;
175 char *pix; 175 char *pix;
176 char *fpressedservice; 176 char *fpressedservice;
177 char *fpressedaction; 177 char *fpressedaction;
178 char *fheldservice; 178 char *fheldservice;
179 char *fheldaction; 179 char *fheldaction;
180} z_buttons [] = { 180} z_buttons [] = {
181 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 181 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
182 "devicebuttons/z_calendar", 182 "devicebuttons/z_calendar",
183 "datebook", "nextView()", 183 "datebook", "nextView()",
184 "today", "raise()" }, 184 "today", "raise()" },
185 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 185 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
186 "devicebuttons/z_contact", 186 "devicebuttons/z_contact",
187 "addressbook", "raise()", 187 "addressbook", "raise()",
188 "addressbook", "beamBusinessCard()" }, 188 "addressbook", "beamBusinessCard()" },
189 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 189 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
190 "devicebuttons/z_home", 190 "devicebuttons/z_home",
191 "QPE/Launcher", "home()", 191 "QPE/Launcher", "home()",
192 "buttonsettings", "raise()" }, 192 "buttonsettings", "raise()" },
193 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 193 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
194 "devicebuttons/z_menu", 194 "devicebuttons/z_menu",
195 "QPE/TaskBar", "toggleMenu()", 195 "QPE/TaskBar", "toggleMenu()",
196 "QPE/TaskBar", "toggleStartMenu()" }, 196 "QPE/TaskBar", "toggleStartMenu()" },
197 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 197 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
198 "devicebuttons/z_mail", 198 "devicebuttons/z_mail",
199 "mail", "raise()", 199 "mail", "raise()",
200 "mail", "newMail()" }, 200 "mail", "newMail()" },
201}; 201};
202 202
203static QCString makeChannel ( const char *str ) 203static QCString makeChannel ( const char *str )
204{ 204{
205 if ( str && !::strchr ( str, '/' )) 205 if ( str && !::strchr ( str, '/' ))
206 return QCString ( "QPE/Application/" ) + str; 206 return QCString ( "QPE/Application/" ) + str;
207 else 207 else
208 return str; 208 return str;
209} 209}
210 210
211 211
212 212
213 213
214ODevice *ODevice::inst ( ) 214ODevice *ODevice::inst ( )
215{ 215{
216 static ODevice *dev = 0; 216 static ODevice *dev = 0;
217 217
218 if ( !dev ) { 218 if ( !dev ) {
219 if ( QFile::exists ( "/proc/hal/model" )) 219 if ( QFile::exists ( "/proc/hal/model" ))
220 dev = new iPAQ ( ); 220 dev = new iPAQ ( );
221 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 221 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
222 dev = new Zaurus ( ); 222 dev = new Zaurus ( );
223 else 223 else
224 dev = new ODevice ( ); 224 dev = new ODevice ( );
225 225
226 dev-> init ( ); 226 dev-> init ( );
227 } 227 }
228 return dev; 228 return dev;
229} 229}
230 230
231 231
232/************************************************** 232/**************************************************
233 * 233 *
234 * common 234 * common
235 * 235 *
236 **************************************************/ 236 **************************************************/
237 237
238 238
239ODevice::ODevice ( ) 239ODevice::ODevice ( )
240{ 240{
241 d = new ODeviceData; 241 d = new ODeviceData;
242 242
243 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 243 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
244 244
245 d-> m_modelstr = "Unknown"; 245 d-> m_modelstr = "Unknown";
246 d-> m_model = Model_Unknown; 246 d-> m_model = Model_Unknown;
247 d-> m_vendorstr = "Unkown"; 247 d-> m_vendorstr = "Unknown";
248 d-> m_vendor = Vendor_Unknown; 248 d-> m_vendor = Vendor_Unknown;
249 d-> m_systemstr = "Unkown"; 249 d-> m_systemstr = "Unknown";
250 d-> m_system = System_Unknown; 250 d-> m_system = System_Unknown;
251 d-> m_sysverstr = "0.0"; 251 d-> m_sysverstr = "0.0";
252 252
253 d-> m_holdtime = 1000; // 1000ms 253 d-> m_holdtime = 1000; // 1000ms
254 254
255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
256 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 256 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
257} 257}
258 258
259void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 259void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
260{ 260{
261 if ( msg == "deviceButtonMappingChanged()" ) { 261 if ( msg == "deviceButtonMappingChanged()" ) {
262 reloadButtonMapping ( ); 262 reloadButtonMapping ( );
263 } 263 }
264} 264}
265 265
266void ODevice::init ( ) 266void ODevice::init ( )
267{ 267{
268 // Simulation uses iPAQ 3660 device buttons 268 // Simulation uses iPAQ 3660 device buttons
269 269
270 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 270 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
271 i_button *ib = ipaq_buttons + i; 271 i_button *ib = ipaq_buttons + i;
272 ODeviceButton b; 272 ODeviceButton b;
273 273
274 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 274 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
275 b. setKeycode ( ib-> code ); 275 b. setKeycode ( ib-> code );
276 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 276 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
277 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 277 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
280 280
281 d-> m_buttons. append ( b ); 281 d-> m_buttons. append ( b );
282 } 282 }
283 } 283 }
284 reloadButtonMapping ( ); 284 reloadButtonMapping ( );
285} 285}
286 286
287ODevice::~ODevice ( ) 287ODevice::~ODevice ( )
288{ 288{
289 delete d; 289 delete d;
290} 290}
291 291
292bool ODevice::setSoftSuspend ( bool /*soft*/ ) 292bool ODevice::setSoftSuspend ( bool /*soft*/ )
293{ 293{
294 return false; 294 return false;
295} 295}
296 296
297//#include <linux/apm_bios.h> 297//#include <linux/apm_bios.h>
298 298
299#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 299#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
300 300
301 301
302bool ODevice::suspend ( ) 302bool ODevice::suspend ( )
303{ 303{
304 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 304 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
305 return false; 305 return false;
306 306
307 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 307 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
308 return false; 308 return false;
309 309
310 bool res = false; 310 bool res = false;
311 311
312 struct timeval tvs, tvn; 312 struct timeval tvs, tvn;
313 ::gettimeofday ( &tvs, 0 ); 313 ::gettimeofday ( &tvs, 0 );
314 314
315 ::sync ( ); // flush fs caches 315 ::sync ( ); // flush fs caches
316 res = ( ::system ( "apm --suspend" ) == 0 ); 316 res = ( ::system ( "apm --suspend" ) == 0 );
317 317
318 // This is needed because the iPAQ apm implementation is asynchronous and we 318 // This is needed because the iPAQ apm implementation is asynchronous and we
319 // can not be sure when exactly the device is really suspended 319 // can not be sure when exactly the device is really suspended
320 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 320 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
321 321
322 if ( res ) { 322 if ( res ) {
323 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 323 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
324 ::usleep ( 200 * 1000 ); 324 ::usleep ( 200 * 1000 );
325 ::gettimeofday ( &tvn, 0 ); 325 ::gettimeofday ( &tvn, 0 );
326 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 326 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
327 } 327 }
328 328
329 return res; 329 return res;
330} 330}
331 331
332//#include <linux/fb.h> better not rely on kernel headers in userspace ... 332//#include <linux/fb.h> better not rely on kernel headers in userspace ...
333 333
334#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 334#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
335 335
336/* VESA Blanking Levels */ 336/* VESA Blanking Levels */
337#define VESA_NO_BLANKING 0 337#define VESA_NO_BLANKING 0
338#define VESA_VSYNC_SUSPEND 1 338#define VESA_VSYNC_SUSPEND 1
339#define VESA_HSYNC_SUSPEND 2 339#define VESA_HSYNC_SUSPEND 2
340#define VESA_POWERDOWN 3 340#define VESA_POWERDOWN 3
341 341
342 342
343bool ODevice::setDisplayStatus ( bool on ) 343bool ODevice::setDisplayStatus ( bool on )
344{ 344{
345 if ( d-> m_model == Model_Unknown ) 345 if ( d-> m_model == Model_Unknown )
346 return false; 346 return false;
347 347
348 bool res = false; 348 bool res = false;
349 int fd; 349 int fd;
350 350
351 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 351 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
352 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 352 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
353 ::close ( fd ); 353 ::close ( fd );
354 } 354 }
355 return res; 355 return res;
356} 356}
357 357
358bool ODevice::setDisplayBrightness ( int ) 358bool ODevice::setDisplayBrightness ( int )
359{ 359{
360 return false; 360 return false;
361} 361}
362 362
363int ODevice::displayBrightnessResolution ( ) const 363int ODevice::displayBrightnessResolution ( ) const
364{ 364{
365 return 16; 365 return 16;
366} 366}
367 367
368QString ODevice::vendorString ( ) const 368QString ODevice::vendorString ( ) const
369{ 369{
370 return d-> m_vendorstr; 370 return d-> m_vendorstr;
371} 371}
372 372
373OVendor ODevice::vendor ( ) const 373OVendor ODevice::vendor ( ) const
374{ 374{
375 return d-> m_vendor; 375 return d-> m_vendor;
376} 376}
377 377
378QString ODevice::modelString ( ) const 378QString ODevice::modelString ( ) const
379{ 379{
380 return d-> m_modelstr; 380 return d-> m_modelstr;
381} 381}
382 382
383OModel ODevice::model ( ) const 383OModel ODevice::model ( ) const
384{ 384{
385 return d-> m_model; 385 return d-> m_model;
386} 386}
387 387
388QString ODevice::systemString ( ) const 388QString ODevice::systemString ( ) const
389{ 389{
390 return d-> m_systemstr; 390 return d-> m_systemstr;
391} 391}
392 392
393OSystem ODevice::system ( ) const 393OSystem ODevice::system ( ) const
394{ 394{
395 return d-> m_system; 395 return d-> m_system;
396} 396}
397 397
398QString ODevice::systemVersionString ( ) const 398QString ODevice::systemVersionString ( ) const
399{ 399{
400 return d-> m_sysverstr; 400 return d-> m_sysverstr;
401} 401}
402 402
403void ODevice::alarmSound ( ) 403void ODevice::alarmSound ( )
404{ 404{
405#ifndef QT_NO_SOUND 405#ifndef QT_NO_SOUND
406 static Sound snd ( "alarm" ); 406 static Sound snd ( "alarm" );
407 407
408 if ( snd. isFinished ( )) 408 if ( snd. isFinished ( ))
409 snd. play ( ); 409 snd. play ( );
410#endif 410#endif
411} 411}
412 412
413void ODevice::keySound ( ) 413void ODevice::keySound ( )
414{ 414{
415#ifndef QT_NO_SOUND 415#ifndef QT_NO_SOUND
416 static Sound snd ( "keysound" ); 416 static Sound snd ( "keysound" );
417 417
418 if ( snd. isFinished ( )) 418 if ( snd. isFinished ( ))
419 snd. play ( ); 419 snd. play ( );
420#endif 420#endif
421} 421}
422 422
423void ODevice::touchSound ( ) 423void ODevice::touchSound ( )
424{ 424{
425 425
426#ifndef QT_NO_SOUND 426#ifndef QT_NO_SOUND
427 static Sound snd ( "touchsound" ); 427 static Sound snd ( "touchsound" );
428 428
429 if ( snd. isFinished ( )) 429 if ( snd. isFinished ( ))
430 snd. play ( ); 430 snd. play ( );
431#endif 431#endif
432} 432}
433 433
434 434
435QValueList <OLed> ODevice::ledList ( ) const 435QValueList <OLed> ODevice::ledList ( ) const
436{ 436{
437 return QValueList <OLed> ( ); 437 return QValueList <OLed> ( );
438} 438}
439 439
440QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 440QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
441{ 441{
442 return QValueList <OLedState> ( ); 442 return QValueList <OLedState> ( );
443} 443}
444 444
445OLedState ODevice::ledState ( OLed /*which*/ ) const 445OLedState ODevice::ledState ( OLed /*which*/ ) const
446{ 446{
447 return Led_Off; 447 return Led_Off;
448} 448}
449 449
450bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 450bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
451{ 451{
452 return false; 452 return false;
453} 453}
454 454
455bool ODevice::hasLightSensor ( ) const 455bool ODevice::hasLightSensor ( ) const
456{ 456{
457 return false; 457 return false;
458} 458}
459 459
460int ODevice::readLightSensor ( ) 460int ODevice::readLightSensor ( )
461{ 461{
462 return -1; 462 return -1;
463} 463}
464 464
465int ODevice::lightSensorResolution ( ) const 465int ODevice::lightSensorResolution ( ) const
466{ 466{
467 return 0; 467 return 0;
468} 468}
469 469
470const QValueList <ODeviceButton> &ODevice::buttons ( ) const 470const QValueList <ODeviceButton> &ODevice::buttons ( ) const
471{ 471{
472 return d-> m_buttons; 472 return d-> m_buttons;
473} 473}
474 474
475uint ODevice::buttonHoldTime ( ) const 475uint ODevice::buttonHoldTime ( ) const
476{ 476{
477 return d-> m_holdtime; 477 return d-> m_holdtime;
478} 478}
479 479
480const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 480const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
481{ 481{
482 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { 482 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
483 if ( (*it). keycode ( ) == code ) 483 if ( (*it). keycode ( ) == code )
484 return &(*it); 484 return &(*it);
485 } 485 }
486 return 0; 486 return 0;
487} 487}
488 488
489void ODevice::reloadButtonMapping ( ) 489void ODevice::reloadButtonMapping ( )
490{ 490{
491 Config cfg ( "ButtonSettings" ); 491 Config cfg ( "ButtonSettings" );
492 492
493 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { 493 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
494 ODeviceButton &b = d-> m_buttons [i]; 494 ODeviceButton &b = d-> m_buttons [i];
495 QString group = "Button" + QString::number ( i ); 495 QString group = "Button" + QString::number ( i );
496 496
497 QCString pch, hch; 497 QCString pch, hch;
498 QCString pm, hm; 498 QCString pm, hm;
499 QByteArray pdata, hdata; 499 QByteArray pdata, hdata;
500 500
501 if ( cfg. hasGroup ( group )) { 501 if ( cfg. hasGroup ( group )) {
502 cfg. setGroup ( group ); 502 cfg. setGroup ( group );
503 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 503 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
504 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 504 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
505 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 505 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
506 506
507 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 507 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
508 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 508 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
509 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 509 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
510 } 510 }
511 511
512 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 512 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
513 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 513 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
514 } 514 }
515} 515}
516 516
517void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 517void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
518{ 518{
519 if ( button >= (int) d-> m_buttons. count ( )) 519 if ( button >= (int) d-> m_buttons. count ( ))
520 return; 520 return;
521 521
522 ODeviceButton &b = d-> m_buttons [button]; 522 ODeviceButton &b = d-> m_buttons [button];
523 b. setPressedAction ( action ); 523 b. setPressedAction ( action );
524 524
525 Config buttonFile ( "ButtonSettings" ); 525 Config buttonFile ( "ButtonSettings" );
526 buttonFile. setGroup ( "Button" + QString::number ( button )); 526 buttonFile. setGroup ( "Button" + QString::number ( button ));
527 buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); 527 buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( ));
528 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 528 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
529 529
530 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 530 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
531 531
532 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 532 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
533} 533}
534 534
535void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 535void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
536{ 536{
537 if ( button >= (int) d-> m_buttons. count ( )) 537 if ( button >= (int) d-> m_buttons. count ( ))
538 return; 538 return;
539 539
540 ODeviceButton &b = d-> m_buttons [button]; 540 ODeviceButton &b = d-> m_buttons [button];
541 b. setHeldAction ( action ); 541 b. setHeldAction ( action );
542 542
543 Config buttonFile ( "ButtonSettings" ); 543 Config buttonFile ( "ButtonSettings" );
544 buttonFile. setGroup ( "Button" + QString::number ( button )); 544 buttonFile. setGroup ( "Button" + QString::number ( button ));
545 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 545 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
546 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 546 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
547 547
548 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 548 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
549 549
550 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 550 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
551} 551}
552 552
553 553
554 554
555 555
556/************************************************** 556/**************************************************
557 * 557 *
558 * iPAQ 558 * iPAQ
559 * 559 *
560 **************************************************/ 560 **************************************************/
561 561
562void iPAQ::init ( ) 562void iPAQ::init ( )
563{ 563{
564 d-> m_vendorstr = "HP"; 564 d-> m_vendorstr = "HP";
565 d-> m_vendor = Vendor_HP; 565 d-> m_vendor = Vendor_HP;
566 566
567 QFile f ( "/proc/hal/model" ); 567 QFile f ( "/proc/hal/model" );
568 568
569 if ( f. open ( IO_ReadOnly )) { 569 if ( f. open ( IO_ReadOnly )) {
570 QTextStream ts ( &f ); 570 QTextStream ts ( &f );
571 571
572 d-> m_modelstr = "H" + ts. readLine ( ); 572 d-> m_modelstr = "H" + ts. readLine ( );
573 573
574 if ( d-> m_modelstr == "H3100" ) 574 if ( d-> m_modelstr == "H3100" )
575 d-> m_model = Model_iPAQ_H31xx; 575 d-> m_model = Model_iPAQ_H31xx;
576 else if ( d-> m_modelstr == "H3600" ) 576 else if ( d-> m_modelstr == "H3600" )
577 d-> m_model = Model_iPAQ_H36xx; 577 d-> m_model = Model_iPAQ_H36xx;
578 else if ( d-> m_modelstr == "H3700" ) 578 else if ( d-> m_modelstr == "H3700" )
579 d-> m_model = Model_iPAQ_H37xx; 579 d-> m_model = Model_iPAQ_H37xx;
580 else if ( d-> m_modelstr == "H3800" ) 580 else if ( d-> m_modelstr == "H3800" )
581 d-> m_model = Model_iPAQ_H38xx; 581 d-> m_model = Model_iPAQ_H38xx;
582 else if ( d-> m_modelstr == "H3900" ) 582 else if ( d-> m_modelstr == "H3900" )
583 d-> m_model = Model_iPAQ_H39xx; 583 d-> m_model = Model_iPAQ_H39xx;
584 else 584 else
585 d-> m_model = Model_Unknown; 585 d-> m_model = Model_Unknown;
586 586
587 f. close ( ); 587 f. close ( );
588 } 588 }
589 589
590 f. setName ( "/etc/familiar-version" ); 590 f. setName ( "/etc/familiar-version" );
591 if ( f. open ( IO_ReadOnly )) { 591 if ( f. open ( IO_ReadOnly )) {
592 d-> m_systemstr = "Familiar"; 592 d-> m_systemstr = "Familiar";
593 d-> m_system = System_Familiar; 593 d-> m_system = System_Familiar;
594 594
595 QTextStream ts ( &f ); 595 QTextStream ts ( &f );
596 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 596 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
597 597
598 f. close ( ); 598 f. close ( );
599 } 599 }
600 600
601 m_leds [0] = m_leds [1] = Led_Off; 601 m_leds [0] = m_leds [1] = Led_Off;
602 602
603 m_power_timer = 0; 603 m_power_timer = 0;
604 604
605 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 605 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
606 i_button *ib = ipaq_buttons + i; 606 i_button *ib = ipaq_buttons + i;
607 ODeviceButton b; 607 ODeviceButton b;
608 608
609 if (( ib-> model & d-> m_model ) == d-> m_model ) { 609 if (( ib-> model & d-> m_model ) == d-> m_model ) {
610 b. setKeycode ( ib-> code ); 610 b. setKeycode ( ib-> code );
611 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 611 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
612 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 612 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
613 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 613 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
614 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 614 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
615 615
616 d-> m_buttons. append ( b ); 616 d-> m_buttons. append ( b );
617 } 617 }
618 } 618 }
619 reloadButtonMapping ( ); 619 reloadButtonMapping ( );
620 620
621 if ( d-> m_qwsserver ) 621 if ( d-> m_qwsserver )
622 QWSServer::setKeyboardFilter ( this ); 622 QWSServer::setKeyboardFilter ( this );
623} 623}
624 624
625//#include <linux/h3600_ts.h> // including kernel headers is evil ... 625//#include <linux/h3600_ts.h> // including kernel headers is evil ...
626 626
627typedef struct { 627typedef struct {
628 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 628 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
629 unsigned char TotalTime; /* Units of 5 seconds */ 629 unsigned char TotalTime; /* Units of 5 seconds */
630 unsigned char OnTime; /* units of 100m/s */ 630 unsigned char OnTime; /* units of 100m/s */
631 unsigned char OffTime; /* units of 100m/s */ 631 unsigned char OffTime; /* units of 100m/s */
632} LED_IN; 632} LED_IN;
633 633