summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp8
-rw-r--r--libopie/odevice.h2
2 files changed, 3 insertions, 7 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index f93d1ed..a3c30cb 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1176 +1,1172 @@
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_F11, 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 = "Unkown";
248 d-> m_vendor = Vendor_Unknown; 248 d-> m_vendor = Vendor_Unknown;
249 d-> m_systemstr = "Unkown"; 249 d-> m_systemstr = "Unkown";
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 qDebug ( "%d: %d", i, ib-> model );
610
611 if (( ib-> model & d-> m_model ) == d-> m_model ) { 609 if (( ib-> model & d-> m_model ) == d-> m_model ) {
612 b. setKeycode ( ib-> code ); 610 b. setKeycode ( ib-> code );
613 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 611 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
614 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 612 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
615 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 613 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
616 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 614 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
617 615
618 d-> m_buttons. append ( b ); 616 d-> m_buttons. append ( b );
619
620 qDebug ( "code: %d", ib-> code );
621 } 617 }
622 } 618 }
623 reloadButtonMapping ( ); 619 reloadButtonMapping ( );
624 620
625 if ( d-> m_qwsserver ) 621 if ( d-> m_qwsserver )
626 QWSServer::setKeyboardFilter ( this ); 622 QWSServer::setKeyboardFilter ( this );
627} 623}
628 624
629//#include <linux/h3600_ts.h> // including kernel headers is evil ... 625//#include <linux/h3600_ts.h> // including kernel headers is evil ...
630 626
631typedef struct { 627typedef struct {
632 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 628 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
633 unsigned char TotalTime; /* Units of 5 seconds */ 629 unsigned char TotalTime; /* Units of 5 seconds */
634 unsigned char OnTime; /* units of 100m/s */ 630 unsigned char OnTime; /* units of 100m/s */
635 unsigned char OffTime; /* units of 100m/s */ 631 unsigned char OffTime; /* units of 100m/s */
636} LED_IN; 632} LED_IN;
637 633
638typedef struct { 634typedef struct {
639 unsigned char mode; 635 unsigned char mode;
640 unsigned char pwr; 636 unsigned char pwr;
641 unsigned char brightness; 637 unsigned char brightness;
642} FLITE_IN; 638} FLITE_IN;
643 639
644#define LED_ON OD_IOW( 'f', 5, LED_IN ) 640#define LED_ON OD_IOW( 'f', 5, LED_IN )
645#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 641#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
646 642
647 643
648 644
649QValueList <OLed> iPAQ::ledList ( ) const 645QValueList <OLed> iPAQ::ledList ( ) const
650{ 646{
651 QValueList <OLed> vl; 647 QValueList <OLed> vl;
652 vl << Led_Power; 648 vl << Led_Power;
653 649
654 if ( d-> m_model == Model_iPAQ_H38xx ) 650 if ( d-> m_model == Model_iPAQ_H38xx )
655 vl << Led_BlueTooth; 651 vl << Led_BlueTooth;
656 return vl; 652 return vl;
657} 653}
658 654
659QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 655QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
660{ 656{
661 QValueList <OLedState> vl; 657 QValueList <OLedState> vl;
662 658
663 if ( l == Led_Power ) 659 if ( l == Led_Power )
664 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 660 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
665 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 661 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
666 vl << Led_Off; // << Led_On << ??? 662 vl << Led_Off; // << Led_On << ???
667 663
668 return vl; 664 return vl;
669} 665}
670 666
671OLedState iPAQ::ledState ( OLed l ) const 667OLedState iPAQ::ledState ( OLed l ) const
672 { 668 {
673 switch ( l ) { 669 switch ( l ) {
674 case Led_Power: 670 case Led_Power:
675 return m_leds [0]; 671 return m_leds [0];
676 case Led_BlueTooth: 672 case Led_BlueTooth:
677 return m_leds [1]; 673 return m_leds [1];
678 default: 674 default:
679 return Led_Off; 675 return Led_Off;
680 } 676 }
681} 677}
682 678
683bool iPAQ::setLedState ( OLed l, OLedState st ) 679bool iPAQ::setLedState ( OLed l, OLedState st )
684{ 680{
685 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 681 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
686 682
687 if ( l == Led_Power ) { 683 if ( l == Led_Power ) {
688 if ( fd >= 0 ) { 684 if ( fd >= 0 ) {
689 LED_IN leds; 685 LED_IN leds;
690 ::memset ( &leds, 0, sizeof( leds )); 686 ::memset ( &leds, 0, sizeof( leds ));
691 leds. TotalTime = 0; 687 leds. TotalTime = 0;
692 leds. OnTime = 0; 688 leds. OnTime = 0;
693 leds. OffTime = 1; 689 leds. OffTime = 1;
694 leds. OffOnBlink = 2; 690 leds. OffOnBlink = 2;
695 691
696 switch ( st ) { 692 switch ( st ) {
697 case Led_Off : leds. OffOnBlink = 0; break; 693 case Led_Off : leds. OffOnBlink = 0; break;
698 case Led_On : leds. OffOnBlink = 1; break; 694 case Led_On : leds. OffOnBlink = 1; break;
699 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 695 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
700 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 696 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
701 } 697 }
702 698
703 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 699 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
704 m_leds [0] = st; 700 m_leds [0] = st;
705 return true; 701 return true;
706 } 702 }
707 } 703 }
708 } 704 }
709 return false; 705 return false;
710} 706}
711 707
712 708
713bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 709bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
714{ 710{
715 int newkeycode = keycode; 711 int newkeycode = keycode;
716 712
717 switch ( keycode ) { 713 switch ( keycode ) {
718 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 714 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
719 case HardKey_Menu: { 715 case HardKey_Menu: {
720 if (( d-> m_model == Model_iPAQ_H38xx ) || 716 if (( d-> m_model == Model_iPAQ_H38xx ) ||
721 ( d-> m_model == Model_iPAQ_H39xx )) { 717 ( d-> m_model == Model_iPAQ_H39xx )) {
722 newkeycode = HardKey_Mail; 718 newkeycode = HardKey_Mail;
723 } 719 }
724 break; 720 break;
725 } 721 }
726 722
727 // Rotate cursor keys 180° 723 // Rotate cursor keys 180°
728 case Key_Left : 724 case Key_Left :
729 case Key_Right: 725 case Key_Right:
730 case Key_Up : 726 case Key_Up :
731 case Key_Down : { 727 case Key_Down : {
732 if (( d-> m_model == Model_iPAQ_H31xx ) || 728 if (( d-> m_model == Model_iPAQ_H31xx ) ||
733 ( d-> m_model == Model_iPAQ_H38xx )) { 729 ( d-> m_model == Model_iPAQ_H38xx )) {
734 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 730 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
735 } 731 }
736 break; 732 break;
737 } 733 }
738 734
739 // map Power Button short/long press to F34/F35 735 // map Power Button short/long press to F34/F35
740 case Key_SysReq: { 736 case Key_SysReq: {
741 if ( isPress ) { 737 if ( isPress ) {
742 if ( m_power_timer ) 738 if ( m_power_timer )
743 killTimer ( m_power_timer ); 739 killTimer ( m_power_timer );
744 m_power_timer = startTimer ( 500 ); 740 m_power_timer = startTimer ( 500 );
745 } 741 }
746 else if ( m_power_timer ) { 742 else if ( m_power_timer ) {
747 killTimer ( m_power_timer ); 743 killTimer ( m_power_timer );
748 m_power_timer = 0; 744 m_power_timer = 0;
749 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 745 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
750 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 746 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
751 } 747 }
752 newkeycode = Key_unknown; 748 newkeycode = Key_unknown;
753 break; 749 break;
754 } 750 }
755 } 751 }
756 752
757 if ( newkeycode != keycode ) { 753 kif ( newkeycode != keycode ) {
758 if ( newkeycode != Key_unknown ) 754 if ( newkeycode != Key_unknown )
759 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 755 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
760 return true; 756 return true;
761 } 757 }
762 else 758 else
763 return false; 759 return false;
764} 760}
765 761
766void iPAQ::timerEvent ( QTimerEvent * ) 762void iPAQ::timerEvent ( QTimerEvent * )
767{ 763{
768 killTimer ( m_power_timer ); 764 killTimer ( m_power_timer );
769 m_power_timer = 0; 765 m_power_timer = 0;
770 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 766 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
771 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 767 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
772} 768}
773 769
774 770
775void iPAQ::alarmSound ( ) 771void iPAQ::alarmSound ( )
776{ 772{
777#ifndef QT_NO_SOUND 773#ifndef QT_NO_SOUND
778 static Sound snd ( "alarm" ); 774 static Sound snd ( "alarm" );
779 int fd; 775 int fd;
780 int vol; 776 int vol;
781 bool vol_reset = false; 777 bool vol_reset = false;
782 778
783 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 779 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
784 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 780 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
785 Config cfg ( "qpe" ); 781 Config cfg ( "qpe" );
786 cfg. setGroup ( "Volume" ); 782 cfg. setGroup ( "Volume" );
787 783
788 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 784 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
789 if ( volalarm < 0 ) 785 if ( volalarm < 0 )
790 volalarm = 0; 786 volalarm = 0;
791 else if ( volalarm > 100 ) 787 else if ( volalarm > 100 )
792 volalarm = 100; 788 volalarm = 100;
793 volalarm |= ( volalarm << 8 ); 789 volalarm |= ( volalarm << 8 );
794 790
795 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 791 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
796 vol_reset = true; 792 vol_reset = true;
797 } 793 }
798 } 794 }
799 795
800 snd. play ( ); 796 snd. play ( );
801 while ( !snd. isFinished ( )) 797 while ( !snd. isFinished ( ))
802 qApp-> processEvents ( ); 798 qApp-> processEvents ( );
803 799
804 if ( fd >= 0 ) { 800 if ( fd >= 0 ) {
805 if ( vol_reset ) 801 if ( vol_reset )
806 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 802 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
807 ::close ( fd ); 803 ::close ( fd );
808 } 804 }
809#endif 805#endif
810} 806}
811 807
812 808
813bool iPAQ::setSoftSuspend ( bool soft ) 809bool iPAQ::setSoftSuspend ( bool soft )
814{ 810{
815 bool res = false; 811 bool res = false;
816 int fd; 812 int fd;
817 813
818 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 814 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
819 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 815 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
820 res = true; 816 res = true;
821 else 817 else
822 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 818 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
823 819
824 ::close ( fd ); 820 ::close ( fd );
825 } 821 }
826 else 822 else
827 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 823 ::perror ( "/proc/sys/ts/suspend_button_mode" );
828 824
829 return res; 825 return res;
830} 826}
831 827
832 828
833bool iPAQ::setDisplayBrightness ( int bright ) 829bool iPAQ::setDisplayBrightness ( int bright )
834{ 830{
835 bool res = false; 831 bool res = false;
836 int fd; 832 int fd;
837 833
838 if ( bright > 255 ) 834 if ( bright > 255 )
839 bright = 255; 835 bright = 255;
840 if ( bright < 0 ) 836 if ( bright < 0 )
841 bright = 0; 837 bright = 0;
842 838
843 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 839 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
844 FLITE_IN bl; 840 FLITE_IN bl;
845 bl. mode = 1; 841 bl. mode = 1;
846 bl. pwr = bright ? 1 : 0; 842 bl. pwr = bright ? 1 : 0;
847 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 843 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
848 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 844 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
849 ::close ( fd ); 845 ::close ( fd );
850 } 846 }
851 return res; 847 return res;
852} 848}
853 849
854int iPAQ::displayBrightnessResolution ( ) const 850int iPAQ::displayBrightnessResolution ( ) const
855{ 851{
856 switch ( model ( )) { 852 switch ( model ( )) {
857 case Model_iPAQ_H31xx: 853 case Model_iPAQ_H31xx:
858 case Model_iPAQ_H36xx: 854 case Model_iPAQ_H36xx:
859 case Model_iPAQ_H37xx: 855 case Model_iPAQ_H37xx:
860 return 128; // really 256, but >128 could damage the LCD 856 return 128; // really 256, but >128 could damage the LCD
861 857
862 case Model_iPAQ_H38xx: 858 case Model_iPAQ_H38xx:
863 case Model_iPAQ_H39xx: 859 case Model_iPAQ_H39xx:
864 return 64; 860 return 64;
865 861
866 default: 862 default:
867 return 2; 863 return 2;
868 } 864 }
869} 865}
870 866
871 867
872bool iPAQ::hasLightSensor ( ) const 868bool iPAQ::hasLightSensor ( ) const
873{ 869{
874 return true; 870 return true;
875} 871}
876 872
877int iPAQ::readLightSensor ( ) 873int iPAQ::readLightSensor ( )
878{ 874{
879 int fd; 875 int fd;
880 int val = -1; 876 int val = -1;
881 877
882 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 878 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
883 char buffer [8]; 879 char buffer [8];
884 880
885 if ( ::read ( fd, buffer, 5 ) == 5 ) { 881 if ( ::read ( fd, buffer, 5 ) == 5 ) {
886 char *endptr; 882 char *endptr;
887 883
888 buffer [4] = 0; 884 buffer [4] = 0;
889 val = ::strtol ( buffer + 2, &endptr, 16 ); 885 val = ::strtol ( buffer + 2, &endptr, 16 );
890 886
891 if ( *endptr != 0 ) 887 if ( *endptr != 0 )
892 val = -1; 888 val = -1;
893 } 889 }
894 ::close ( fd ); 890 ::close ( fd );
895 } 891 }
896 892
897 return val; 893 return val;
898} 894}
899 895
900int iPAQ::lightSensorResolution ( ) const 896int iPAQ::lightSensorResolution ( ) const
901{ 897{
902 return 256; 898 return 256;
903} 899}
904 900
905/************************************************** 901/**************************************************
906 * 902 *
907 * Zaurus 903 * Zaurus
908 * 904 *
909 **************************************************/ 905 **************************************************/
910 906
911 907
912 908
913void Zaurus::init ( ) 909void Zaurus::init ( )
914{ 910{
915 d-> m_vendorstr = "Sharp"; 911 d-> m_vendorstr = "Sharp";
916 d-> m_vendor = Vendor_Sharp; 912 d-> m_vendor = Vendor_Sharp;
917 913
918 QFile f ( "/proc/filesystems" ); 914 QFile f ( "/proc/filesystems" );
919 915
920 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 916 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
921 d-> m_vendorstr = "OpenZaurus Team"; 917 d-> m_vendorstr = "OpenZaurus Team";
922 d-> m_systemstr = "OpenZaurus"; 918 d-> m_systemstr = "OpenZaurus";
923 d-> m_system = System_OpenZaurus; 919 d-> m_system = System_OpenZaurus;
924 920
925 f. close ( ); 921 f. close ( );
926 922
927 f. setName ( "/etc/oz_version" ); 923 f. setName ( "/etc/oz_version" );
928 if ( f. open ( IO_ReadOnly )) { 924 if ( f. open ( IO_ReadOnly )) {
929 QTextStream ts ( &f ); 925 QTextStream ts ( &f );
930 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 926 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
931 f. close ( ); 927 f. close ( );
932 } 928 }
933 } 929 }
934 else { 930 else {
935 d-> m_systemstr = "Zaurus"; 931 d-> m_systemstr = "Zaurus";
936 d-> m_system = System_Zaurus; 932 d-> m_system = System_Zaurus;
937 } 933 }
938 934
939 f. setName ( "/proc/deviceinfo/product" ); 935 f. setName ( "/proc/deviceinfo/product" );
940 if ( f. open ( IO_ReadOnly ) ) { 936 if ( f. open ( IO_ReadOnly ) ) {
941 QTextStream ts ( &f ); 937 QTextStream ts ( &f );
942 QString model = ts. readLine ( ); 938 QString model = ts. readLine ( );
943 f. close ( ); 939 f. close ( );
944 if ( model == "SL-5000D" ) { 940 if ( model == "SL-5000D" ) {
945 d-> m_model = Model_Zaurus_SL5000; 941 d-> m_model = Model_Zaurus_SL5000;
946 d-> m_modelstr = "Zaurus SL-5000D"; 942 d-> m_modelstr = "Zaurus SL-5000D";
947 } else if ( model == "SL-5500" ) { 943 } else if ( model == "SL-5500" ) {
948 d-> m_model = Model_Zaurus_SL5500; 944 d-> m_model = Model_Zaurus_SL5500;
949 d-> m_modelstr = "Zaurus SL-5500"; 945 d-> m_modelstr = "Zaurus SL-5500";
950 } 946 }
951 } 947 }
952 else { 948 else {
953 d-> m_model = Model_Zaurus_SL5000; 949 d-> m_model = Model_Zaurus_SL5000;
954 d-> m_modelstr = "Zaurus SL-5000D (unverified)"; 950 d-> m_modelstr = "Zaurus SL-5000D (unverified)";
955 } 951 }
956 952
957 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { 953 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
958 z_button *zb = z_buttons + i; 954 z_button *zb = z_buttons + i;
959 ODeviceButton b; 955 ODeviceButton b;
960 956
961 b. setKeycode ( zb-> code ); 957 b. setKeycode ( zb-> code );
962 b. setUserText ( qApp-> translate ( "Button", zb-> utext )); 958 b. setUserText ( qApp-> translate ( "Button", zb-> utext ));
963 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 959 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
964 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 960 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
965 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 961 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
966 962
967 d-> m_buttons. append ( b ); 963 d-> m_buttons. append ( b );
968 } 964 }
969 reloadButtonMapping ( ); 965 reloadButtonMapping ( );
970 966
971 m_leds [0] = Led_Off; 967 m_leds [0] = Led_Off;
972} 968}
973 969
974#include <unistd.h> 970#include <unistd.h>
975#include <fcntl.h> 971#include <fcntl.h>
976#include <sys/ioctl.h> 972#include <sys/ioctl.h>
977 973
978//#include <asm/sharp_char.h> // including kernel headers is evil ... 974//#include <asm/sharp_char.h> // including kernel headers is evil ...
979 975
980#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 976#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
981 977
982 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 978 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
983#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 979#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
984 980
985#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 981#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
986#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 982#define SHARP_BUZ_KEYSOUND 2 /* key sound */
987#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 983#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
988 984
989/* --- for SHARP_BUZZER device --- */ 985/* --- for SHARP_BUZZER device --- */
990 986
991 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 987 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
992//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 988//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
993 989
994#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 990#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
995#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 991#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
996#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 992#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
997#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 993#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
998#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 994#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
999 995
1000//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 996//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1001//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 997//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1002 998
1003//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 999//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1004//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1000//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1005//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1001//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1006//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1002//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1007//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1003//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1008//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1004//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1009//#define SHARP_PDA_APPSTART 9 /* application start */ 1005//#define SHARP_PDA_APPSTART 9 /* application start */
1010//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1006//#define SHARP_PDA_APPQUIT 10 /* application ends */
1011 1007
1012//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1008//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1013//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1009//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1014//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1010//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1015//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1011//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1016// 1012//
1017 1013
1018 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1014 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1019#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1015#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1020 1016
1021typedef struct sharp_led_status { 1017typedef struct sharp_led_status {
1022 int which; /* select which LED status is wanted. */ 1018 int which; /* select which LED status is wanted. */
1023 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1019 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1024} sharp_led_status; 1020} sharp_led_status;
1025 1021
1026#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1022#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1027 1023
1028#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1024#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1029#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1025#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1030#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1026#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1031 1027
1032// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1028// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1033 1029
1034#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1030#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1035#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1031#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1036#define APM_EVT_POWER_BUTTON (1 << 0) 1032#define APM_EVT_POWER_BUTTON (1 << 0)
1037 1033
1038#define FL_IOCTL_STEP_CONTRAST 100 1034#define FL_IOCTL_STEP_CONTRAST 100
1039 1035
1040 1036
1041void Zaurus::buzzer ( int sound ) 1037void Zaurus::buzzer ( int sound )
1042{ 1038{
1043 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 1039 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
1044 1040
1045 if ( fd >= 0 ) 1041 if ( fd >= 0 )
1046 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1042 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1047} 1043}
1048 1044
1049 1045
1050void Zaurus::alarmSound ( ) 1046void Zaurus::alarmSound ( )
1051{ 1047{
1052 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1048 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1053} 1049}
1054 1050
1055void Zaurus::touchSound ( ) 1051void Zaurus::touchSound ( )
1056{ 1052{
1057 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1053 buzzer ( SHARP_BUZ_TOUCHSOUND );
1058} 1054}
1059 1055
1060void Zaurus::keySound ( ) 1056void Zaurus::keySound ( )
1061{ 1057{
1062 buzzer ( SHARP_BUZ_KEYSOUND ); 1058 buzzer ( SHARP_BUZ_KEYSOUND );
1063} 1059}
1064 1060
1065 1061
1066QValueList <OLed> Zaurus::ledList ( ) const 1062QValueList <OLed> Zaurus::ledList ( ) const
1067{ 1063{
1068 QValueList <OLed> vl; 1064 QValueList <OLed> vl;
1069 vl << Led_Mail; 1065 vl << Led_Mail;
1070 return vl; 1066 return vl;
1071} 1067}
1072 1068
1073QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1069QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1074{ 1070{
1075 QValueList <OLedState> vl; 1071 QValueList <OLedState> vl;
1076 1072
1077 if ( l == Led_Mail ) 1073 if ( l == Led_Mail )
1078 vl << Led_Off << Led_On << Led_BlinkSlow; 1074 vl << Led_Off << Led_On << Led_BlinkSlow;
1079 return vl; 1075 return vl;
1080} 1076}
1081 1077
1082OLedState Zaurus::ledState ( OLed which ) const 1078OLedState Zaurus::ledState ( OLed which ) const
1083{ 1079{
1084 if ( which == Led_Mail ) 1080 if ( which == Led_Mail )
1085 return m_leds [0]; 1081 return m_leds [0];
1086 else 1082 else
1087 return Led_Off; 1083 return Led_Off;
1088} 1084}
1089 1085
1090bool Zaurus::setLedState ( OLed which, OLedState st ) 1086bool Zaurus::setLedState ( OLed which, OLedState st )
1091{ 1087{
1092 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1088 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1093 1089
1094 if ( which == Led_Mail ) { 1090 if ( which == Led_Mail ) {
1095 if ( fd >= 0 ) { 1091 if ( fd >= 0 ) {
1096 struct sharp_led_status leds; 1092 struct sharp_led_status leds;
1097 ::memset ( &leds, 0, sizeof( leds )); 1093 ::memset ( &leds, 0, sizeof( leds ));
1098 leds. which = SHARP_LED_MAIL_EXISTS; 1094 leds. which = SHARP_LED_MAIL_EXISTS;
1099 bool ok = true; 1095 bool ok = true;
1100 1096
1101 switch ( st ) { 1097 switch ( st ) {
1102 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1098 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1103 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1099 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1104 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1100 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1105 default : ok = false; 1101 default : ok = false;
1106 } 1102 }
1107 1103
1108 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1104 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1109 m_leds [0] = st; 1105 m_leds [0] = st;
1110 return true; 1106 return true;
1111 } 1107 }
1112 } 1108 }
1113 } 1109 }
1114 return false; 1110 return false;
1115} 1111}
1116 1112
1117bool Zaurus::setSoftSuspend ( bool soft ) 1113bool Zaurus::setSoftSuspend ( bool soft )
1118{ 1114{
1119 bool res = false; 1115 bool res = false;
1120 int fd; 1116 int fd;
1121 1117
1122 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1118 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1123 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1119 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1124 1120
1125 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1121 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1126 1122
1127 if ( sources >= 0 ) { 1123 if ( sources >= 0 ) {
1128 if ( soft ) 1124 if ( soft )
1129 sources &= ~APM_EVT_POWER_BUTTON; 1125 sources &= ~APM_EVT_POWER_BUTTON;
1130 else 1126 else
1131 sources |= APM_EVT_POWER_BUTTON; 1127 sources |= APM_EVT_POWER_BUTTON;
1132 1128
1133 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1129 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1134 res = true; 1130 res = true;
1135 else 1131 else
1136 perror ( "APM_IOCGEVTSRC" ); 1132 perror ( "APM_IOCGEVTSRC" );
1137 } 1133 }
1138 else 1134 else
1139 perror ( "APM_IOCGEVTSRC" ); 1135 perror ( "APM_IOCGEVTSRC" );
1140 1136
1141 ::close ( fd ); 1137 ::close ( fd );
1142 } 1138 }
1143 else 1139 else
1144 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1140 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1145 1141
1146 return res; 1142 return res;
1147} 1143}
1148 1144
1149 1145
1150bool Zaurus::setDisplayBrightness ( int bright ) 1146bool Zaurus::setDisplayBrightness ( int bright )
1151{ 1147{
1152 bool res = false; 1148 bool res = false;
1153 int fd; 1149 int fd;
1154 1150
1155 if ( bright > 255 ) 1151 if ( bright > 255 )
1156 bright = 255; 1152 bright = 255;
1157 if ( bright < 0 ) 1153 if ( bright < 0 )
1158 bright = 0; 1154 bright = 0;
1159 1155
1160 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1156 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1161 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1157 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1162 if ( bright && !bl ) 1158 if ( bright && !bl )
1163 bl = 1; 1159 bl = 1;
1164 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1160 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1165 ::close ( fd ); 1161 ::close ( fd );
1166 } 1162 }
1167 return res; 1163 return res;
1168} 1164}
1169 1165
1170 1166
1171int Zaurus::displayBrightnessResolution ( ) const 1167int Zaurus::displayBrightnessResolution ( ) const
1172{ 1168{
1173 return 5; 1169 return 5;
1174} 1170}
1175 1171
1176 1172
diff --git a/libopie/odevice.h b/libopie/odevice.h
index ce62f1a..54b85a2 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,194 +1,194 @@
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#ifndef _LIBOPIE_ODEVICE_H_ 20#ifndef _LIBOPIE_ODEVICE_H_
21#define _LIBOPIE_ODEVICE_H_ 21#define _LIBOPIE_ODEVICE_H_
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qnamespace.h> 25#include <qnamespace.h>
26 26
27#include <opie/odevicebutton.h> 27#include <opie/odevicebutton.h>
28 28
29class ODeviceData; 29class ODeviceData;
30 30
31namespace Opie { 31namespace Opie {
32 32
33enum OModel { 33enum OModel {
34 Model_Unknown, 34 Model_Unknown,
35 35
36 Model_Series_Mask = 0xff000000, 36 Model_Series_Mask = 0xff000000,
37 37
38 Model_iPAQ = ( 1 << 24 ), 38 Model_iPAQ = ( 1 << 24 ),
39 39
40 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 40 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
41 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 41 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
42 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 42 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
43 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 43 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
44 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 44 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
45 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 45 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
46 46
47 Model_Zaurus = ( 2 << 24 ), 47 Model_Zaurus = ( 2 << 24 ),
48 48
49 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 49 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
50 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 50 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
51}; 51};
52 52
53 enum OVendor { 53 enum OVendor {
54 Vendor_Unknown, 54 Vendor_Unknown,
55 55
56 Vendor_HP, 56 Vendor_HP,
57 Vendor_Sharp 57 Vendor_Sharp
58 }; 58 };
59 59
60enum OSystem { 60enum OSystem {
61 System_Unknown, 61 System_Unknown,
62 62
63 System_Familiar, 63 System_Familiar,
64 System_Zaurus, 64 System_Zaurus,
65 System_OpenZaurus 65 System_OpenZaurus
66}; 66};
67 67
68enum OLedState { 68enum OLedState {
69 Led_Off, 69 Led_Off,
70 Led_On, 70 Led_On,
71 Led_BlinkSlow, 71 Led_BlinkSlow,
72 Led_BlinkFast 72 Led_BlinkFast
73}; 73};
74 74
75enum OLed { 75enum OLed {
76 Led_Mail, 76 Led_Mail,
77 Led_Power, 77 Led_Power,
78 Led_BlueTooth 78 Led_BlueTooth
79}; 79};
80 80
81enum OHardKey { 81enum OHardKey {
82 HardKey_Datebook = Qt::Key_F9, 82 HardKey_Datebook = Qt::Key_F9,
83 HardKey_Contacts = Qt::Key_F10, 83 HardKey_Contacts = Qt::Key_F10,
84 HardKey_Menu = Qt::Key_F11, 84 HardKey_Menu = Qt::Key_F11,
85 HardKey_Home = Qt::Key_F12, 85 HardKey_Home = Qt::Key_F12,
86 HardKey_Mail = Qt::Key_F14, 86 HardKey_Mail = Qt::Key_F13,
87 HardKey_Record = Qt::Key_F24, 87 HardKey_Record = Qt::Key_F24,
88 HardKey_Suspend = Qt::Key_F34, 88 HardKey_Suspend = Qt::Key_F34,
89 HardKey_Backlight = Qt::Key_F35, 89 HardKey_Backlight = Qt::Key_F35,
90}; 90};
91 91
92 92
93class ODevice : public QObject { 93class ODevice : public QObject {
94 Q_OBJECT 94 Q_OBJECT
95 95
96private: 96private:
97 ODevice ( const ODevice & ); 97 ODevice ( const ODevice & );
98 98
99protected: 99protected:
100 ODevice ( ); 100 ODevice ( );
101 virtual void init ( ); 101 virtual void init ( );
102 102
103 ODeviceData *d; 103 ODeviceData *d;
104 104
105public: 105public:
106 virtual ~ODevice ( ); 106 virtual ~ODevice ( );
107 107
108 static ODevice *inst ( ); 108 static ODevice *inst ( );
109 109
110 110
111 111
112// information 112// information
113 113
114 QString modelString ( ) const; 114 QString modelString ( ) const;
115 OModel model ( ) const; 115 OModel model ( ) const;
116 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 116 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
117 117
118 QString vendorString ( ) const; 118 QString vendorString ( ) const;
119 OVendor vendor ( ) const; 119 OVendor vendor ( ) const;
120 120
121 QString systemString ( ) const; 121 QString systemString ( ) const;
122 OSystem system ( ) const; 122 OSystem system ( ) const;
123 123
124 QString systemVersionString ( ) const; 124 QString systemVersionString ( ) const;
125 125
126 // system 126 // system
127 127
128 virtual bool setSoftSuspend ( bool on ); 128 virtual bool setSoftSuspend ( bool on );
129 virtual bool suspend ( ); 129 virtual bool suspend ( );
130 130
131 virtual bool setDisplayStatus ( bool on ); 131 virtual bool setDisplayStatus ( bool on );
132 virtual bool setDisplayBrightness ( int brightness ); 132 virtual bool setDisplayBrightness ( int brightness );
133 virtual int displayBrightnessResolution ( ) const; 133 virtual int displayBrightnessResolution ( ) const;
134 134
135// input / output 135// input / output
136 136
137 virtual void alarmSound ( ); 137 virtual void alarmSound ( );
138 virtual void keySound ( ); 138 virtual void keySound ( );
139 virtual void touchSound ( ); 139 virtual void touchSound ( );
140 140
141 virtual QValueList <OLed> ledList ( ) const; 141 virtual QValueList <OLed> ledList ( ) const;
142 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 142 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
143 virtual OLedState ledState ( OLed led ) const; 143 virtual OLedState ledState ( OLed led ) const;
144 virtual bool setLedState ( OLed led, OLedState st ); 144 virtual bool setLedState ( OLed led, OLedState st );
145 145
146 virtual bool hasLightSensor ( ) const; 146 virtual bool hasLightSensor ( ) const;
147 virtual int readLightSensor ( ); 147 virtual int readLightSensor ( );
148 virtual int lightSensorResolution ( ) const; 148 virtual int lightSensorResolution ( ) const;
149 149
150 /** 150 /**
151 * Returns the available buttons on this device. The number and location 151 * Returns the available buttons on this device. The number and location
152 * of buttons will vary depending on the device. Button numbers will be assigned 152 * of buttons will vary depending on the device. Button numbers will be assigned
153 * by the device manufacturer and will be from most preferred button to least preffered 153 * by the device manufacturer and will be from most preferred button to least preffered
154 * button. Note that this list only contains "user mappable" buttons. 154 * button. Note that this list only contains "user mappable" buttons.
155 */ 155 */
156 const QValueList<ODeviceButton> &buttons ( ) const; 156 const QValueList<ODeviceButton> &buttons ( ) const;
157 157
158 /** 158 /**
159 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 159 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
160 * returns 0L 160 * returns 0L
161 */ 161 */
162 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 162 const ODeviceButton *buttonForKeycode ( ushort keyCode );
163 163
164 /** 164 /**
165 * Reassigns the pressed action for \a button. To return to the factory 165 * Reassigns the pressed action for \a button. To return to the factory
166 * default pass an empty string as \a qcopMessage. 166 * default pass an empty string as \a qcopMessage.
167 */ 167 */
168 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 168 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
169 169
170 /** 170 /**
171 * Reassigns the held action for \a button. To return to the factory 171 * Reassigns the held action for \a button. To return to the factory
172 * default pass an empty string as \a qcopMessage. 172 * default pass an empty string as \a qcopMessage.
173 */ 173 */
174 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 174 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
175 175
176 /** 176 /**
177 * How long (in ms) you have to press a button for a "hold" action 177 * How long (in ms) you have to press a button for a "hold" action
178 */ 178 */
179 uint buttonHoldTime ( ) const; 179 uint buttonHoldTime ( ) const;
180 180
181 signals: 181 signals:
182 void buttonMappingChanged ( ); 182 void buttonMappingChanged ( );
183 183
184 private slots: 184 private slots:
185 void systemMessage ( const QCString &, const QByteArray & ); 185 void systemMessage ( const QCString &, const QByteArray & );
186 186
187protected: 187protected:
188 void reloadButtonMapping ( ); 188 void reloadButtonMapping ( );
189}; 189};
190 190
191} 191}
192 192
193#endif 193#endif
194 194