summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-23 13:28:27 (UTC)
committer mickeyl <mickeyl>2003-05-23 13:28:27 (UTC)
commitf6d7ed30f034b318d77f36f81b0aa4588cea63fb (patch) (unidiff)
tree8083be660da5876e555686475dd8f5f8a024d7bf
parentcbacd38e4b8e0e706fa43cd3e88041217c6fdaf9 (diff)
downloadopie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.zip
opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.tar.gz
opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.tar.bz2
more handling of SIMpad specifica
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 103104f..02f13b5 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1762 +1,1800 @@
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#ifndef ARRAY_SIZE 42#ifndef ARRAY_SIZE
43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44#endif 44#endif
45 45
46// _IO and friends are only defined in kernel headers ... 46// _IO and friends are only defined in kernel headers ...
47 47
48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
49 49
50#define OD_IO(type,number) OD_IOC(0,type,number,0) 50#define OD_IO(type,number) OD_IOC(0,type,number,0)
51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
54 54
55using namespace Opie; 55using namespace Opie;
56 56
57class ODeviceData { 57class ODeviceData {
58public: 58public:
59 QString m_vendorstr; 59 QString m_vendorstr;
60 OVendor m_vendor; 60 OVendor m_vendor;
61 61
62 QString m_modelstr; 62 QString m_modelstr;
63 OModel m_model; 63 OModel m_model;
64 64
65 QString m_systemstr; 65 QString m_systemstr;
66 OSystem m_system; 66 OSystem m_system;
67 67
68 QString m_sysverstr; 68 QString m_sysverstr;
69 69
70 Transformation m_rotation; 70 Transformation m_rotation;
71 ODirection m_direction; 71 ODirection m_direction;
72 72
73 QValueList <ODeviceButton> *m_buttons; 73 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 74 uint m_holdtime;
75}; 75};
76 76
77 77
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 79protected:
80 virtual void init ( ); 80 virtual void init ( );
81 virtual void initButtons ( ); 81 virtual void initButtons ( );
82 82
83public: 83public:
84 virtual bool setSoftSuspend ( bool soft ); 84 virtual bool setSoftSuspend ( bool soft );
85 85
86 virtual bool setDisplayBrightness ( int b ); 86 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 87 virtual int displayBrightnessResolution ( ) const;
88 88
89 virtual void alarmSound ( ); 89 virtual void alarmSound ( );
90 90
91 virtual QValueList <OLed> ledList ( ) const; 91 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 92 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 93 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
95 95
96 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
99 99
100protected: 100protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
103 103
104 int m_power_timer; 104 int m_power_timer;
105 105
106 OLedState m_leds [2]; 106 OLedState m_leds [2];
107}; 107};
108 108
109class Zaurus : public ODevice { 109class Zaurus : public ODevice {
110protected: 110protected:
111 virtual void init ( ); 111 virtual void init ( );
112 virtual void initButtons ( ); 112 virtual void initButtons ( );
113 113
114public: 114public:
115 virtual bool setSoftSuspend ( bool soft ); 115 virtual bool setSoftSuspend ( bool soft );
116 116
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 119
120 virtual void alarmSound ( ); 120 virtual void alarmSound ( );
121 virtual void keySound ( ); 121 virtual void keySound ( );
122 virtual void touchSound ( ); 122 virtual void touchSound ( );
123 123
124 virtual QValueList <OLed> ledList ( ) const; 124 virtual QValueList <OLed> ledList ( ) const;
125 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 125 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
126 virtual OLedState ledState ( OLed led ) const; 126 virtual OLedState ledState ( OLed led ) const;
127 virtual bool setLedState ( OLed led, OLedState st ); 127 virtual bool setLedState ( OLed led, OLedState st );
128 128
129protected: 129protected:
130 virtual void buzzer ( int snd ); 130 virtual void buzzer ( int snd );
131 131
132 OLedState m_leds [1]; 132 OLedState m_leds [1];
133}; 133};
134 134
135class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 135class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
136protected: 136protected:
137 virtual void init ( ); 137 virtual void init ( );
138 virtual void initButtons ( ); 138 virtual void initButtons ( );
139 139
140public: 140public:
141 virtual bool setSoftSuspend ( bool soft ); 141 virtual bool setSoftSuspend ( bool soft );
142 virtual bool suspend();
142 143
144 virtual bool setDisplayStatus( bool on );
143 virtual bool setDisplayBrightness ( int b ); 145 virtual bool setDisplayBrightness ( int b );
144 virtual int displayBrightnessResolution ( ) const; 146 virtual int displayBrightnessResolution ( ) const;
145 147
146 virtual void alarmSound ( ); 148 virtual void alarmSound ( );
147 149
148 virtual QValueList <OLed> ledList ( ) const; 150 virtual QValueList <OLed> ledList ( ) const;
149 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 151 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
150 virtual OLedState ledState ( OLed led ) const; 152 virtual OLedState ledState ( OLed led ) const;
151 virtual bool setLedState ( OLed led, OLedState st ); 153 virtual bool setLedState ( OLed led, OLedState st );
152 154
153protected: 155protected:
154 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 156 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
155 virtual void timerEvent ( QTimerEvent *te ); 157 virtual void timerEvent ( QTimerEvent *te );
156 158
157 int m_power_timer; 159 int m_power_timer;
158 160
159 OLedState m_leds [1]; //FIXME check if really only one 161 OLedState m_leds [1]; //FIXME check if really only one
160}; 162};
161 163
162struct i_button { 164struct i_button {
163 uint model; 165 uint model;
164 Qt::Key code; 166 Qt::Key code;
165 char *utext; 167 char *utext;
166 char *pix; 168 char *pix;
167 char *fpressedservice; 169 char *fpressedservice;
168 char *fpressedaction; 170 char *fpressedaction;
169 char *fheldservice; 171 char *fheldservice;
170 char *fheldaction; 172 char *fheldaction;
171} ipaq_buttons [] = { 173} ipaq_buttons [] = {
172 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 174 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
173 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 175 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
174 "devicebuttons/ipaq_calendar", 176 "devicebuttons/ipaq_calendar",
175 "datebook", "nextView()", 177 "datebook", "nextView()",
176 "today", "raise()" }, 178 "today", "raise()" },
177 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 179 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
178 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 180 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
179 "devicebuttons/ipaq_contact", 181 "devicebuttons/ipaq_contact",
180 "addressbook", "raise()", 182 "addressbook", "raise()",
181 "addressbook", "beamBusinessCard()" }, 183 "addressbook", "beamBusinessCard()" },
182 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 184 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
183 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 185 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
184 "devicebuttons/ipaq_menu", 186 "devicebuttons/ipaq_menu",
185 "QPE/TaskBar", "toggleMenu()", 187 "QPE/TaskBar", "toggleMenu()",
186 "QPE/TaskBar", "toggleStartMenu()" }, 188 "QPE/TaskBar", "toggleStartMenu()" },
187 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 189 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
188 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 190 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
189 "devicebuttons/ipaq_mail", 191 "devicebuttons/ipaq_mail",
190 "mail", "raise()", 192 "mail", "raise()",
191 "mail", "newMail()" }, 193 "mail", "newMail()" },
192 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 194 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
193 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 195 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
194 "devicebuttons/ipaq_home", 196 "devicebuttons/ipaq_home",
195 "QPE/Launcher", "home()", 197 "QPE/Launcher", "home()",
196 "buttonsettings", "raise()" }, 198 "buttonsettings", "raise()" },
197 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 199 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
198 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 200 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
199 "devicebuttons/ipaq_record", 201 "devicebuttons/ipaq_record",
200 "QPE/VMemo", "toggleRecord()", 202 "QPE/VMemo", "toggleRecord()",
201 "sound", "raise()" }, 203 "sound", "raise()" },
202}; 204};
203 205
204struct z_button { 206struct z_button {
205 Qt::Key code; 207 Qt::Key code;
206 char *utext; 208 char *utext;
207 char *pix; 209 char *pix;
208 char *fpressedservice; 210 char *fpressedservice;
209 char *fpressedaction; 211 char *fpressedaction;
210 char *fheldservice; 212 char *fheldservice;
211 char *fheldaction; 213 char *fheldaction;
212} z_buttons [] = { 214} z_buttons [] = {
213 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 215 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
214 "devicebuttons/z_calendar", 216 "devicebuttons/z_calendar",
215 "datebook", "nextView()", 217 "datebook", "nextView()",
216 "today", "raise()" }, 218 "today", "raise()" },
217 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 219 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
218 "devicebuttons/z_contact", 220 "devicebuttons/z_contact",
219 "addressbook", "raise()", 221 "addressbook", "raise()",
220 "addressbook", "beamBusinessCard()" }, 222 "addressbook", "beamBusinessCard()" },
221 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 223 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
222 "devicebuttons/z_home", 224 "devicebuttons/z_home",
223 "QPE/Launcher", "home()", 225 "QPE/Launcher", "home()",
224 "buttonsettings", "raise()" }, 226 "buttonsettings", "raise()" },
225 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 227 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
226 "devicebuttons/z_menu", 228 "devicebuttons/z_menu",
227 "QPE/TaskBar", "toggleMenu()", 229 "QPE/TaskBar", "toggleMenu()",
228 "QPE/TaskBar", "toggleStartMenu()" }, 230 "QPE/TaskBar", "toggleStartMenu()" },
229 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 231 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
230 "devicebuttons/z_mail", 232 "devicebuttons/z_mail",
231 "mail", "raise()", 233 "mail", "raise()",
232 "mail", "newMail()" }, 234 "mail", "newMail()" },
233}; 235};
234 236
235struct z_button z_buttons_c700 [] = { 237struct z_button z_buttons_c700 [] = {
236 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 238 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
237 "devicebuttons/z_calendar", 239 "devicebuttons/z_calendar",
238 "datebook", "nextView()", 240 "datebook", "nextView()",
239 "today", "raise()" }, 241 "today", "raise()" },
240 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 242 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
241 "devicebuttons/z_contact", 243 "devicebuttons/z_contact",
242 "addressbook", "raise()", 244 "addressbook", "raise()",
243 "addressbook", "beamBusinessCard()" }, 245 "addressbook", "beamBusinessCard()" },
244 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 246 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
245 "devicebuttons/z_home", 247 "devicebuttons/z_home",
246 "QPE/Launcher", "home()", 248 "QPE/Launcher", "home()",
247 "buttonsettings", "raise()" }, 249 "buttonsettings", "raise()" },
248 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 250 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
249 "devicebuttons/z_menu", 251 "devicebuttons/z_menu",
250 "QPE/TaskBar", "toggleMenu()", 252 "QPE/TaskBar", "toggleMenu()",
251 "QPE/TaskBar", "toggleStartMenu()" }, 253 "QPE/TaskBar", "toggleStartMenu()" },
252 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 254 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
253 "", 255 "",
254 "QPE/Rotation", "flip()", 256 "QPE/Rotation", "flip()",
255 "QPE/Rotation", "flip()" }, 257 "QPE/Rotation", "flip()" },
256}; 258};
257 259
258struct s_button { 260struct s_button {
259 uint model; 261 uint model;
260 Qt::Key code; 262 Qt::Key code;
261 char *utext; 263 char *utext;
262 char *pix; 264 char *pix;
263 char *fpressedservice; 265 char *fpressedservice;
264 char *fpressedaction; 266 char *fpressedaction;
265 char *fheldservice; 267 char *fheldservice;
266 char *fheldaction; 268 char *fheldaction;
267} simpad_buttons [] = { 269} simpad_buttons [] = {
268 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 270 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
269 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 271 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
270 "devicebuttons/simpad_menu", 272 "devicebuttons/simpad_menu",
271 "QPE/TaskBar", "toggleMenu()", 273 "QPE/TaskBar", "toggleMenu()",
272 "QPE/TaskBar", "toggleStartMenu()" }, 274 "QPE/TaskBar", "toggleStartMenu()" },
273 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 275 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
274 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 276 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
275 "devicebuttons/ipaq_home", 277 "devicebuttons/ipaq_home",
276 "QPE/Launcher", "home()", 278 "QPE/Launcher", "home()",
277 "buttonsettings", "raise()" }, 279 "buttonsettings", "raise()" },
278}; 280};
279 281
280static QCString makeChannel ( const char *str ) 282static QCString makeChannel ( const char *str )
281{ 283{
282 if ( str && !::strchr ( str, '/' )) 284 if ( str && !::strchr ( str, '/' ))
283 return QCString ( "QPE/Application/" ) + str; 285 return QCString ( "QPE/Application/" ) + str;
284 else 286 else
285 return str; 287 return str;
286} 288}
287 289
288static inline bool isQWS() 290static inline bool isQWS()
289{ 291{
290 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 292 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
291} 293}
292 294
293ODevice *ODevice::inst ( ) 295ODevice *ODevice::inst ( )
294{ 296{
295 static ODevice *dev = 0; 297 static ODevice *dev = 0;
296 298
297 if ( !dev ) { 299 if ( !dev ) {
298 if ( QFile::exists ( "/proc/hal/model" )) 300 if ( QFile::exists ( "/proc/hal/model" ))
299 dev = new iPAQ ( ); 301 dev = new iPAQ ( );
300 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 302 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
301 dev = new Zaurus ( ); 303 dev = new Zaurus ( );
302 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 304 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
303 dev = new SIMpad ( ); 305 dev = new SIMpad ( );
304 else 306 else
305 dev = new ODevice ( ); 307 dev = new ODevice ( );
306 308
307 dev-> init ( ); 309 dev-> init ( );
308 } 310 }
309 return dev; 311 return dev;
310} 312}
311 313
312 314
313/************************************************** 315/**************************************************
314 * 316 *
315 * common 317 * common
316 * 318 *
317 **************************************************/ 319 **************************************************/
318 320
319 321
320ODevice::ODevice ( ) 322ODevice::ODevice ( )
321{ 323{
322 d = new ODeviceData; 324 d = new ODeviceData;
323 325
324 d-> m_modelstr = "Unknown"; 326 d-> m_modelstr = "Unknown";
325 d-> m_model = Model_Unknown; 327 d-> m_model = Model_Unknown;
326 d-> m_vendorstr = "Unknown"; 328 d-> m_vendorstr = "Unknown";
327 d-> m_vendor = Vendor_Unknown; 329 d-> m_vendor = Vendor_Unknown;
328 d-> m_systemstr = "Unknown"; 330 d-> m_systemstr = "Unknown";
329 d-> m_system = System_Unknown; 331 d-> m_system = System_Unknown;
330 d-> m_sysverstr = "0.0"; 332 d-> m_sysverstr = "0.0";
331 d-> m_rotation = Rot0; 333 d-> m_rotation = Rot0;
332 d-> m_direction = CW; 334 d-> m_direction = CW;
333 335
334 d-> m_holdtime = 1000; // 1000ms 336 d-> m_holdtime = 1000; // 1000ms
335 d-> m_buttons = 0; 337 d-> m_buttons = 0;
336} 338}
337 339
338void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 340void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
339{ 341{
340 if ( msg == "deviceButtonMappingChanged()" ) { 342 if ( msg == "deviceButtonMappingChanged()" ) {
341 reloadButtonMapping ( ); 343 reloadButtonMapping ( );
342 } 344 }
343} 345}
344 346
345void ODevice::init ( ) 347void ODevice::init ( )
346{ 348{
347} 349}
348 350
349/** 351/**
350 * This method initialises the button mapping 352 * This method initialises the button mapping
351 */ 353 */
352void ODevice::initButtons ( ) 354void ODevice::initButtons ( )
353{ 355{
354 if ( d-> m_buttons ) 356 if ( d-> m_buttons )
355 return; 357 return;
356 358
357 // Simulation uses iPAQ 3660 device buttons 359 // Simulation uses iPAQ 3660 device buttons
358 360
359 qDebug ( "init Buttons" ); 361 qDebug ( "init Buttons" );
360 d-> m_buttons = new QValueList <ODeviceButton>; 362 d-> m_buttons = new QValueList <ODeviceButton>;
361 363
362 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 364 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
363 i_button *ib = ipaq_buttons + i; 365 i_button *ib = ipaq_buttons + i;
364 ODeviceButton b; 366 ODeviceButton b;
365 367
366 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 368 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
367 b. setKeycode ( ib-> code ); 369 b. setKeycode ( ib-> code );
368 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 370 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
369 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 371 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
370 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 372 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
371 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 373 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
372 d-> m_buttons-> append ( b ); 374 d-> m_buttons-> append ( b );
373 } 375 }
374 } 376 }
375 reloadButtonMapping ( ); 377 reloadButtonMapping ( );
376 378
377 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 379 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
378 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 380 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
379} 381}
380 382
381ODevice::~ODevice ( ) 383ODevice::~ODevice ( )
382{ 384{
383 delete d; 385 delete d;
384} 386}
385 387
386bool ODevice::setSoftSuspend ( bool /*soft*/ ) 388bool ODevice::setSoftSuspend ( bool /*soft*/ )
387{ 389{
388 return false; 390 return false;
389} 391}
390 392
391//#include <linux/apm_bios.h> 393//#include <linux/apm_bios.h>
392 394
393#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 395#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
394 396
395/** 397/**
396 * This method will try to suspend the device 398 * This method will try to suspend the device
397 * It only works if the user is the QWS Server and the apm application 399 * It only works if the user is the QWS Server and the apm application
398 * is installed. 400 * is installed.
399 * It tries to suspend and then waits some time cause some distributions 401 * It tries to suspend and then waits some time cause some distributions
400 * do have asynchronus apm implementations. 402 * do have asynchronus apm implementations.
401 * This method will either fail and return false or it'll suspend the 403 * This method will either fail and return false or it'll suspend the
402 * device and return once the device got woken up 404 * device and return once the device got woken up
403 * 405 *
404 * @return if the device got suspended 406 * @return if the device got suspended
405 */ 407 */
406bool ODevice::suspend ( ) 408bool ODevice::suspend ( )
407{ 409{
408 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 410 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
409 return false; 411 return false;
410 412
411 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 413 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
412 return false; 414 return false;
413 415
414 bool res = false; 416 bool res = false;
415 417
416 struct timeval tvs, tvn; 418 struct timeval tvs, tvn;
417 ::gettimeofday ( &tvs, 0 ); 419 ::gettimeofday ( &tvs, 0 );
418 420
419 ::sync ( ); // flush fs caches 421 ::sync ( ); // flush fs caches
420 res = ( ::system ( "apm --suspend" ) == 0 ); 422 res = ( ::system ( "apm --suspend" ) == 0 );
421 423
422 // This is needed because the iPAQ apm implementation is asynchronous and we 424 // This is needed because the iPAQ apm implementation is asynchronous and we
423 // can not be sure when exactly the device is really suspended 425 // can not be sure when exactly the device is really suspended
424 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 426 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
425 427
426 if ( res ) { 428 if ( res ) {
427 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 429 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
428 ::usleep ( 200 * 1000 ); 430 ::usleep ( 200 * 1000 );
429 ::gettimeofday ( &tvn, 0 ); 431 ::gettimeofday ( &tvn, 0 );
430 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 432 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
431 } 433 }
432 434
433 return res; 435 return res;
434} 436}
435 437
436//#include <linux/fb.h> better not rely on kernel headers in userspace ... 438//#include <linux/fb.h> better not rely on kernel headers in userspace ...
437 439
438#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 440#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
439 441
440/* VESA Blanking Levels */ 442/* VESA Blanking Levels */
441#define VESA_NO_BLANKING 0 443#define VESA_NO_BLANKING 0
442#define VESA_VSYNC_SUSPEND 1 444#define VESA_VSYNC_SUSPEND 1
443#define VESA_HSYNC_SUSPEND 2 445#define VESA_HSYNC_SUSPEND 2
444#define VESA_POWERDOWN 3 446#define VESA_POWERDOWN 3
445 447
446/** 448/**
447 * This sets the display on or off 449 * This sets the display on or off
448 */ 450 */
449bool ODevice::setDisplayStatus ( bool on ) 451bool ODevice::setDisplayStatus ( bool on )
450{ 452{
451 if ( d-> m_model == Model_Unknown ) 453 if ( d-> m_model == Model_Unknown )
452 return false; 454 return false;
453 455
454 bool res = false; 456 bool res = false;
455 int fd; 457 int fd;
456 458
457 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 459 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
458 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 460 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
459 ::close ( fd ); 461 ::close ( fd );
460 } 462 }
461 return res; 463 return res;
462} 464}
463 465
464/** 466/**
465 * This sets the display brightness 467 * This sets the display brightness
466 * @return success or failure 468 * @return success or failure
467 */ 469 */
468bool ODevice::setDisplayBrightness ( int p) 470bool ODevice::setDisplayBrightness ( int p)
469{ 471{
470 Q_UNUSED( p ) 472 Q_UNUSED( p )
471 return false; 473 return false;
472} 474}
473 475
474int ODevice::displayBrightnessResolution ( ) const 476int ODevice::displayBrightnessResolution ( ) const
475{ 477{
476 return 16; 478 return 16;
477} 479}
478 480
479/** 481/**
480 * This returns the vendor as string 482 * This returns the vendor as string
481 * @return Vendor as QString 483 * @return Vendor as QString
482 */ 484 */
483QString ODevice::vendorString ( ) const 485QString ODevice::vendorString ( ) const
484{ 486{
485 return d-> m_vendorstr; 487 return d-> m_vendorstr;
486} 488}
487 489
488/** 490/**
489 * This returns the vendor as one of the values of OVendor 491 * This returns the vendor as one of the values of OVendor
490 * @return OVendor 492 * @return OVendor
491 */ 493 */
492OVendor ODevice::vendor ( ) const 494OVendor ODevice::vendor ( ) const
493{ 495{
494 return d-> m_vendor; 496 return d-> m_vendor;
495} 497}
496 498
497/** 499/**
498 * This returns the model as a string 500 * This returns the model as a string
499 * @return A string representing the model 501 * @return A string representing the model
500 */ 502 */
501QString ODevice::modelString ( ) const 503QString ODevice::modelString ( ) const
502{ 504{
503 return d-> m_modelstr; 505 return d-> m_modelstr;
504} 506}
505 507
506/** 508/**
507 * This does return the OModel used 509 * This does return the OModel used
508 */ 510 */
509OModel ODevice::model ( ) const 511OModel ODevice::model ( ) const
510{ 512{
511 return d-> m_model; 513 return d-> m_model;
512} 514}
513 515
514/** 516/**
515 * This does return the systen name 517 * This does return the systen name
516 */ 518 */
517QString ODevice::systemString ( ) const 519QString ODevice::systemString ( ) const
518{ 520{
519 return d-> m_systemstr; 521 return d-> m_systemstr;
520} 522}
521 523
522/** 524/**
523 * Return System as OSystem value 525 * Return System as OSystem value
524 */ 526 */
525OSystem ODevice::system ( ) const 527OSystem ODevice::system ( ) const
526{ 528{
527 return d-> m_system; 529 return d-> m_system;
528} 530}
529 531
530/** 532/**
531 * @return the version string of the base system 533 * @return the version string of the base system
532 */ 534 */
533QString ODevice::systemVersionString ( ) const 535QString ODevice::systemVersionString ( ) const
534{ 536{
535 return d-> m_sysverstr; 537 return d-> m_sysverstr;
536} 538}
537 539
538/** 540/**
539 * @return the current Transformation 541 * @return the current Transformation
540 */ 542 */
541Transformation ODevice::rotation ( ) const 543Transformation ODevice::rotation ( ) const
542{ 544{
543 return d-> m_rotation; 545 return d-> m_rotation;
544} 546}
545 547
546/** 548/**
547 * @return the current rotation direction 549 * @return the current rotation direction
548 */ 550 */
549ODirection ODevice::direction ( ) const 551ODirection ODevice::direction ( ) const
550{ 552{
551 return d-> m_direction; 553 return d-> m_direction;
552} 554}
553 555
554/** 556/**
555 * This plays an alarmSound 557 * This plays an alarmSound
556 */ 558 */
557void ODevice::alarmSound ( ) 559void ODevice::alarmSound ( )
558{ 560{
559#ifndef QT_NO_SOUND 561#ifndef QT_NO_SOUND
560 static Sound snd ( "alarm" ); 562 static Sound snd ( "alarm" );
561 563
562 if ( snd. isFinished ( )) 564 if ( snd. isFinished ( ))
563 snd. play ( ); 565 snd. play ( );
564#endif 566#endif
565} 567}
566 568
567/** 569/**
568 * This plays a key sound 570 * This plays a key sound
569 */ 571 */
570void ODevice::keySound ( ) 572void ODevice::keySound ( )
571{ 573{
572#ifndef QT_NO_SOUND 574#ifndef QT_NO_SOUND
573 static Sound snd ( "keysound" ); 575 static Sound snd ( "keysound" );
574 576
575 if ( snd. isFinished ( )) 577 if ( snd. isFinished ( ))
576 snd. play ( ); 578 snd. play ( );
577#endif 579#endif
578} 580}
579 581
580/** 582/**
581 * This plays a touch sound 583 * This plays a touch sound
582 */ 584 */
583void ODevice::touchSound ( ) 585void ODevice::touchSound ( )
584{ 586{
585 587
586#ifndef QT_NO_SOUND 588#ifndef QT_NO_SOUND
587 static Sound snd ( "touchsound" ); 589 static Sound snd ( "touchsound" );
588 590
589 if ( snd. isFinished ( )) 591 if ( snd. isFinished ( ))
590 snd. play ( ); 592 snd. play ( );
591#endif 593#endif
592} 594}
593 595
594/** 596/**
595 * This method will return a list of leds 597 * This method will return a list of leds
596 * available on this device 598 * available on this device
597 * @return a list of LEDs. 599 * @return a list of LEDs.
598 */ 600 */
599QValueList <OLed> ODevice::ledList ( ) const 601QValueList <OLed> ODevice::ledList ( ) const
600{ 602{
601 return QValueList <OLed> ( ); 603 return QValueList <OLed> ( );
602} 604}
603 605
604/** 606/**
605 * This does return the state of the LEDs 607 * This does return the state of the LEDs
606 */ 608 */
607QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 609QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
608{ 610{
609 return QValueList <OLedState> ( ); 611 return QValueList <OLedState> ( );
610} 612}
611 613
612/** 614/**
613 * @return the state for a given OLed 615 * @return the state for a given OLed
614 */ 616 */
615OLedState ODevice::ledState ( OLed /*which*/ ) const 617OLedState ODevice::ledState ( OLed /*which*/ ) const
616{ 618{
617 return Led_Off; 619 return Led_Off;
618} 620}
619 621
620/** 622/**
621 * Set the state for a LED 623 * Set the state for a LED
622 * @param which Which OLed to use 624 * @param which Which OLed to use
623 * @param st The state to set 625 * @param st The state to set
624 * @return success or failure 626 * @return success or failure
625 */ 627 */
626bool ODevice::setLedState ( OLed which, OLedState st ) 628bool ODevice::setLedState ( OLed which, OLedState st )
627{ 629{
628 Q_UNUSED( which ) 630 Q_UNUSED( which )
629 Q_UNUSED( st ) 631 Q_UNUSED( st )
630 return false; 632 return false;
631} 633}
632 634
633/** 635/**
634 * @return if the device has a light sensor 636 * @return if the device has a light sensor
635 */ 637 */
636bool ODevice::hasLightSensor ( ) const 638bool ODevice::hasLightSensor ( ) const
637{ 639{
638 return false; 640 return false;
639} 641}
640 642
641/** 643/**
642 * @return a value from the light senso 644 * @return a value from the light senso
643 */ 645 */
644int ODevice::readLightSensor ( ) 646int ODevice::readLightSensor ( )
645{ 647{
646 return -1; 648 return -1;
647} 649}
648 650
649/** 651/**
650 * @return the light sensor resolution whatever that is ;) 652 * @return the light sensor resolution whatever that is ;)
651 */ 653 */
652int ODevice::lightSensorResolution ( ) const 654int ODevice::lightSensorResolution ( ) const
653{ 655{
654 return 0; 656 return 0;
655} 657}
656 658
657/** 659/**
658 * @return a list of hardware buttons 660 * @return a list of hardware buttons
659 */ 661 */
660const QValueList <ODeviceButton> &ODevice::buttons ( ) 662const QValueList <ODeviceButton> &ODevice::buttons ( )
661{ 663{
662 initButtons ( ); 664 initButtons ( );
663 665
664 return *d-> m_buttons; 666 return *d-> m_buttons;
665} 667}
666 668
667/** 669/**
668 * @return The amount of time that would count as a hold 670 * @return The amount of time that would count as a hold
669 */ 671 */
670uint ODevice::buttonHoldTime ( ) const 672uint ODevice::buttonHoldTime ( ) const
671{ 673{
672 return d-> m_holdtime; 674 return d-> m_holdtime;
673} 675}
674 676
675/** 677/**
676 * This method return a ODeviceButton for a key code 678 * This method return a ODeviceButton for a key code
677 * or 0 if no special hardware button is available for the device 679 * or 0 if no special hardware button is available for the device
678 * 680 *
679 * @return The devicebutton or 0l 681 * @return The devicebutton or 0l
680 * @see ODeviceButton 682 * @see ODeviceButton
681 */ 683 */
682const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 684const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
683{ 685{
684 initButtons ( ); 686 initButtons ( );
685 687
686 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 688 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
687 if ( (*it). keycode ( ) == code ) 689 if ( (*it). keycode ( ) == code )
688 return &(*it); 690 return &(*it);
689 } 691 }
690 return 0; 692 return 0;
691} 693}
692 694
693void ODevice::reloadButtonMapping ( ) 695void ODevice::reloadButtonMapping ( )
694{ 696{
695 initButtons ( ); 697 initButtons ( );
696 698
697 Config cfg ( "ButtonSettings" ); 699 Config cfg ( "ButtonSettings" );
698 700
699 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 701 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
700 ODeviceButton &b = ( *d-> m_buttons ) [i]; 702 ODeviceButton &b = ( *d-> m_buttons ) [i];
701 QString group = "Button" + QString::number ( i ); 703 QString group = "Button" + QString::number ( i );
702 704
703 QCString pch, hch; 705 QCString pch, hch;
704 QCString pm, hm; 706 QCString pm, hm;
705 QByteArray pdata, hdata; 707 QByteArray pdata, hdata;
706 708
707 if ( cfg. hasGroup ( group )) { 709 if ( cfg. hasGroup ( group )) {
708 cfg. setGroup ( group ); 710 cfg. setGroup ( group );
709 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 711 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
710 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 712 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
711 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 713 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
712 714
713 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 715 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
714 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 716 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
715 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 717 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
716 } 718 }
717 719
718 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 720 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
719 721
720 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 722 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
721 } 723 }
722} 724}
723 725
724void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 726void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
725{ 727{
726 initButtons ( ); 728 initButtons ( );
727 729
728 QString mb_chan; 730 QString mb_chan;
729 731
730 if ( button >= (int) d-> m_buttons-> count ( )) 732 if ( button >= (int) d-> m_buttons-> count ( ))
731 return; 733 return;
732 734
733 ODeviceButton &b = ( *d-> m_buttons ) [button]; 735 ODeviceButton &b = ( *d-> m_buttons ) [button];
734 b. setPressedAction ( action ); 736 b. setPressedAction ( action );
735 737
736 mb_chan=b. pressedAction ( ). channel ( ); 738 mb_chan=b. pressedAction ( ). channel ( );
737 739
738 Config buttonFile ( "ButtonSettings" ); 740 Config buttonFile ( "ButtonSettings" );
739 buttonFile. setGroup ( "Button" + QString::number ( button )); 741 buttonFile. setGroup ( "Button" + QString::number ( button ));
740 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 742 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
741 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 743 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
742 744
743 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 745 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
744 746
745 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 747 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
746} 748}
747 749
748void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 750void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
749{ 751{
750 initButtons ( ); 752 initButtons ( );
751 753
752 if ( button >= (int) d-> m_buttons-> count ( )) 754 if ( button >= (int) d-> m_buttons-> count ( ))
753 return; 755 return;
754 756
755 ODeviceButton &b = ( *d-> m_buttons ) [button]; 757 ODeviceButton &b = ( *d-> m_buttons ) [button];
756 b. setHeldAction ( action ); 758 b. setHeldAction ( action );
757 759
758 Config buttonFile ( "ButtonSettings" ); 760 Config buttonFile ( "ButtonSettings" );
759 buttonFile. setGroup ( "Button" + QString::number ( button )); 761 buttonFile. setGroup ( "Button" + QString::number ( button ));
760 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 762 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
761 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 763 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
762 764
763 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 765 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
764 766
765 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 767 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
766} 768}
767 769
768 770
769 771
770 772
771/************************************************** 773/**************************************************
772 * 774 *
773 * iPAQ 775 * iPAQ
774 * 776 *
775 **************************************************/ 777 **************************************************/
776 778
777void iPAQ::init ( ) 779void iPAQ::init ( )
778{ 780{
779 d-> m_vendorstr = "HP"; 781 d-> m_vendorstr = "HP";
780 d-> m_vendor = Vendor_HP; 782 d-> m_vendor = Vendor_HP;
781 783
782 QFile f ( "/proc/hal/model" ); 784 QFile f ( "/proc/hal/model" );
783 785
784 if ( f. open ( IO_ReadOnly )) { 786 if ( f. open ( IO_ReadOnly )) {
785 QTextStream ts ( &f ); 787 QTextStream ts ( &f );
786 788
787 d-> m_modelstr = "H" + ts. readLine ( ); 789 d-> m_modelstr = "H" + ts. readLine ( );
788 790
789 if ( d-> m_modelstr == "H3100" ) 791 if ( d-> m_modelstr == "H3100" )
790 d-> m_model = Model_iPAQ_H31xx; 792 d-> m_model = Model_iPAQ_H31xx;
791 else if ( d-> m_modelstr == "H3600" ) 793 else if ( d-> m_modelstr == "H3600" )
792 d-> m_model = Model_iPAQ_H36xx; 794 d-> m_model = Model_iPAQ_H36xx;
793 else if ( d-> m_modelstr == "H3700" ) 795 else if ( d-> m_modelstr == "H3700" )
794 d-> m_model = Model_iPAQ_H37xx; 796 d-> m_model = Model_iPAQ_H37xx;
795 else if ( d-> m_modelstr == "H3800" ) 797 else if ( d-> m_modelstr == "H3800" )
796 d-> m_model = Model_iPAQ_H38xx; 798 d-> m_model = Model_iPAQ_H38xx;
797 else if ( d-> m_modelstr == "H3900" ) 799 else if ( d-> m_modelstr == "H3900" )
798 d-> m_model = Model_iPAQ_H39xx; 800 d-> m_model = Model_iPAQ_H39xx;
799 else 801 else
800 d-> m_model = Model_Unknown; 802 d-> m_model = Model_Unknown;
801 803
802 f. close ( ); 804 f. close ( );
803 } 805 }
804 806
805 switch ( d-> m_model ) { 807 switch ( d-> m_model ) {
806 case Model_iPAQ_H31xx: 808 case Model_iPAQ_H31xx:
807 case Model_iPAQ_H38xx: 809 case Model_iPAQ_H38xx:
808 d-> m_rotation = Rot90; 810 d-> m_rotation = Rot90;
809 break; 811 break;
810 case Model_iPAQ_H36xx: 812 case Model_iPAQ_H36xx:
811 case Model_iPAQ_H37xx: 813 case Model_iPAQ_H37xx:
812 case Model_iPAQ_H39xx: 814 case Model_iPAQ_H39xx:
813 default: 815 default:
814 d-> m_rotation = Rot270; 816 d-> m_rotation = Rot270;
815 break; 817 break;
816 } 818 }
817 819
818 f. setName ( "/etc/familiar-version" ); 820 f. setName ( "/etc/familiar-version" );
819 if ( f. open ( IO_ReadOnly )) { 821 if ( f. open ( IO_ReadOnly )) {
820 d-> m_systemstr = "Familiar"; 822 d-> m_systemstr = "Familiar";
821 d-> m_system = System_Familiar; 823 d-> m_system = System_Familiar;
822 824
823 QTextStream ts ( &f ); 825 QTextStream ts ( &f );
824 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 826 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
825 827
826 f. close ( ); 828 f. close ( );
827 } else { 829 } else {
828 f. setName ( "/etc/oz_version" ); 830 f. setName ( "/etc/oz_version" );
829 831
830 if ( f. open ( IO_ReadOnly )) { 832 if ( f. open ( IO_ReadOnly )) {
831 d-> m_systemstr = "OpenEmbedded/iPaq"; 833 d-> m_systemstr = "OpenEmbedded/iPaq";
832 d-> m_system = System_Familiar; 834 d-> m_system = System_Familiar;
833 835
834 QTextStream ts ( &f ); 836 QTextStream ts ( &f );
835 ts.setDevice ( &f ); 837 ts.setDevice ( &f );
836 d-> m_sysverstr = ts. readLine ( ); 838 d-> m_sysverstr = ts. readLine ( );
837 f. close ( ); 839 f. close ( );
838 } 840 }
839 } 841 }
840 842
841 843
842 844
843 845
844 846
845 m_leds [0] = m_leds [1] = Led_Off; 847 m_leds [0] = m_leds [1] = Led_Off;
846 848
847 m_power_timer = 0; 849 m_power_timer = 0;
848 850
849} 851}
850 852
851void iPAQ::initButtons ( ) 853void iPAQ::initButtons ( )
852{ 854{
853 if ( d-> m_buttons ) 855 if ( d-> m_buttons )
854 return; 856 return;
855 857
856 if ( isQWS( ) ) 858 if ( isQWS( ) )
857 QWSServer::setKeyboardFilter ( this ); 859 QWSServer::setKeyboardFilter ( this );
858 860
859 d-> m_buttons = new QValueList <ODeviceButton>; 861 d-> m_buttons = new QValueList <ODeviceButton>;
860 862
861 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 863 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
862 i_button *ib = ipaq_buttons + i; 864 i_button *ib = ipaq_buttons + i;
863 ODeviceButton b; 865 ODeviceButton b;
864 866
865 if (( ib-> model & d-> m_model ) == d-> m_model ) { 867 if (( ib-> model & d-> m_model ) == d-> m_model ) {
866 b. setKeycode ( ib-> code ); 868 b. setKeycode ( ib-> code );
867 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 869 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
868 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 870 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
869 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 871 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
870 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 872 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
871 873
872 d-> m_buttons-> append ( b ); 874 d-> m_buttons-> append ( b );
873 } 875 }
874 } 876 }
875 reloadButtonMapping ( ); 877 reloadButtonMapping ( );
876 878
877 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 879 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
878 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 880 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
879} 881}
880 882
881 883
882//#include <linux/h3600_ts.h> // including kernel headers is evil ... 884//#include <linux/h3600_ts.h> // including kernel headers is evil ...
883 885
884typedef struct { 886typedef struct {
885 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 887 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
886 unsigned char TotalTime; /* Units of 5 seconds */ 888 unsigned char TotalTime; /* Units of 5 seconds */
887 unsigned char OnTime; /* units of 100m/s */ 889 unsigned char OnTime; /* units of 100m/s */
888 unsigned char OffTime; /* units of 100m/s */ 890 unsigned char OffTime; /* units of 100m/s */
889} LED_IN; 891} LED_IN;
890 892
891typedef struct { 893typedef struct {
892 unsigned char mode; 894 unsigned char mode;
893 unsigned char pwr; 895 unsigned char pwr;
894 unsigned char brightness; 896 unsigned char brightness;
895} FLITE_IN; 897} FLITE_IN;
896 898
897#define LED_ON OD_IOW( 'f', 5, LED_IN ) 899#define LED_ON OD_IOW( 'f', 5, LED_IN )
898#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 900#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
899 901
900 902
901QValueList <OLed> iPAQ::ledList ( ) const 903QValueList <OLed> iPAQ::ledList ( ) const
902{ 904{
903 QValueList <OLed> vl; 905 QValueList <OLed> vl;
904 vl << Led_Power; 906 vl << Led_Power;
905 907
906 if ( d-> m_model == Model_iPAQ_H38xx ) 908 if ( d-> m_model == Model_iPAQ_H38xx )
907 vl << Led_BlueTooth; 909 vl << Led_BlueTooth;
908 return vl; 910 return vl;
909} 911}
910 912
911QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 913QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
912{ 914{
913 QValueList <OLedState> vl; 915 QValueList <OLedState> vl;
914 916
915 if ( l == Led_Power ) 917 if ( l == Led_Power )
916 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 918 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
917 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 919 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
918 vl << Led_Off; // << Led_On << ??? 920 vl << Led_Off; // << Led_On << ???
919 921
920 return vl; 922 return vl;
921} 923}
922 924
923OLedState iPAQ::ledState ( OLed l ) const 925OLedState iPAQ::ledState ( OLed l ) const
924{ 926{
925 switch ( l ) { 927 switch ( l ) {
926 case Led_Power: 928 case Led_Power:
927 return m_leds [0]; 929 return m_leds [0];
928 case Led_BlueTooth: 930 case Led_BlueTooth:
929 return m_leds [1]; 931 return m_leds [1];
930 default: 932 default:
931 return Led_Off; 933 return Led_Off;
932 } 934 }
933} 935}
934 936
935bool iPAQ::setLedState ( OLed l, OLedState st ) 937bool iPAQ::setLedState ( OLed l, OLedState st )
936{ 938{
937 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 939 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
938 940
939 if ( l == Led_Power ) { 941 if ( l == Led_Power ) {
940 if ( fd >= 0 ) { 942 if ( fd >= 0 ) {
941 LED_IN leds; 943 LED_IN leds;
942 ::memset ( &leds, 0, sizeof( leds )); 944 ::memset ( &leds, 0, sizeof( leds ));
943 leds. TotalTime = 0; 945 leds. TotalTime = 0;
944 leds. OnTime = 0; 946 leds. OnTime = 0;
945 leds. OffTime = 1; 947 leds. OffTime = 1;
946 leds. OffOnBlink = 2; 948 leds. OffOnBlink = 2;
947 949
948 switch ( st ) { 950 switch ( st ) {
949 case Led_Off : leds. OffOnBlink = 0; break; 951 case Led_Off : leds. OffOnBlink = 0; break;
950 case Led_On : leds. OffOnBlink = 1; break; 952 case Led_On : leds. OffOnBlink = 1; break;
951 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 953 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
952 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 954 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
953 } 955 }
954 956
955 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 957 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
956 m_leds [0] = st; 958 m_leds [0] = st;
957 return true; 959 return true;
958 } 960 }
959 } 961 }
960 } 962 }
961 return false; 963 return false;
962} 964}
963 965
964 966
965bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 967bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
966{ 968{
967 int newkeycode = keycode; 969 int newkeycode = keycode;
968 970
969 switch ( keycode ) { 971 switch ( keycode ) {
970 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 972 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
971 case HardKey_Menu: { 973 case HardKey_Menu: {
972 if (( d-> m_model == Model_iPAQ_H38xx ) || 974 if (( d-> m_model == Model_iPAQ_H38xx ) ||
973 ( d-> m_model == Model_iPAQ_H39xx )) { 975 ( d-> m_model == Model_iPAQ_H39xx )) {
974 newkeycode = HardKey_Mail; 976 newkeycode = HardKey_Mail;
975 } 977 }
976 break; 978 break;
977 } 979 }
978 980
979 // Rotate cursor keys 180° 981 // Rotate cursor keys 180°
980 case Key_Left : 982 case Key_Left :
981 case Key_Right: 983 case Key_Right:
982 case Key_Up : 984 case Key_Up :
983 case Key_Down : { 985 case Key_Down : {
984 if (( d-> m_model == Model_iPAQ_H31xx ) || 986 if (( d-> m_model == Model_iPAQ_H31xx ) ||
985 ( d-> m_model == Model_iPAQ_H38xx )) { 987 ( d-> m_model == Model_iPAQ_H38xx )) {
986 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 988 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
987 } 989 }
988 break; 990 break;
989 } 991 }
990 992
991 // map Power Button short/long press to F34/F35 993 // map Power Button short/long press to F34/F35
992 case Key_SysReq: { 994 case Key_SysReq: {
993 if ( isPress ) { 995 if ( isPress ) {
994 if ( m_power_timer ) 996 if ( m_power_timer )
995 killTimer ( m_power_timer ); 997 killTimer ( m_power_timer );
996 m_power_timer = startTimer ( 500 ); 998 m_power_timer = startTimer ( 500 );
997 } 999 }
998 else if ( m_power_timer ) { 1000 else if ( m_power_timer ) {
999 killTimer ( m_power_timer ); 1001 killTimer ( m_power_timer );
1000 m_power_timer = 0; 1002 m_power_timer = 0;
1001 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1003 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1002 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1004 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1003 } 1005 }
1004 newkeycode = Key_unknown; 1006 newkeycode = Key_unknown;
1005 break; 1007 break;
1006 } 1008 }
1007 } 1009 }
1008 1010
1009 if ( newkeycode != keycode ) { 1011 if ( newkeycode != keycode ) {
1010 if ( newkeycode != Key_unknown ) 1012 if ( newkeycode != Key_unknown )
1011 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1013 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1012 return true; 1014 return true;
1013 } 1015 }
1014 else 1016 else
1015 return false; 1017 return false;
1016} 1018}
1017 1019
1018void iPAQ::timerEvent ( QTimerEvent * ) 1020void iPAQ::timerEvent ( QTimerEvent * )
1019{ 1021{
1020 killTimer ( m_power_timer ); 1022 killTimer ( m_power_timer );
1021 m_power_timer = 0; 1023 m_power_timer = 0;
1022 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1024 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1023 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1025 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1024} 1026}
1025 1027
1026 1028
1027void iPAQ::alarmSound ( ) 1029void iPAQ::alarmSound ( )
1028{ 1030{
1029#ifndef QT_NO_SOUND 1031#ifndef QT_NO_SOUND
1030 static Sound snd ( "alarm" ); 1032 static Sound snd ( "alarm" );
1031 int fd; 1033 int fd;
1032 int vol; 1034 int vol;
1033 bool vol_reset = false; 1035 bool vol_reset = false;
1034 1036
1035 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1037 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1036 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1038 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1037 Config cfg ( "qpe" ); 1039 Config cfg ( "qpe" );
1038 cfg. setGroup ( "Volume" ); 1040 cfg. setGroup ( "Volume" );
1039 1041
1040 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1042 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1041 if ( volalarm < 0 ) 1043 if ( volalarm < 0 )
1042 volalarm = 0; 1044 volalarm = 0;
1043 else if ( volalarm > 100 ) 1045 else if ( volalarm > 100 )
1044 volalarm = 100; 1046 volalarm = 100;
1045 volalarm |= ( volalarm << 8 ); 1047 volalarm |= ( volalarm << 8 );
1046 1048
1047 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1049 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1048 vol_reset = true; 1050 vol_reset = true;
1049 } 1051 }
1050 } 1052 }
1051 1053
1052 snd. play ( ); 1054 snd. play ( );
1053 while ( !snd. isFinished ( )) 1055 while ( !snd. isFinished ( ))
1054 qApp-> processEvents ( ); 1056 qApp-> processEvents ( );
1055 1057
1056 if ( fd >= 0 ) { 1058 if ( fd >= 0 ) {
1057 if ( vol_reset ) 1059 if ( vol_reset )
1058 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1060 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1059 ::close ( fd ); 1061 ::close ( fd );
1060 } 1062 }
1061#endif 1063#endif
1062} 1064}
1063 1065
1064 1066
1065bool iPAQ::setSoftSuspend ( bool soft ) 1067bool iPAQ::setSoftSuspend ( bool soft )
1066{ 1068{
1067 bool res = false; 1069 bool res = false;
1068 int fd; 1070 int fd;
1069 1071
1070 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1072 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1071 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1073 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1072 res = true; 1074 res = true;
1073 else 1075 else
1074 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1076 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1075 1077
1076 ::close ( fd ); 1078 ::close ( fd );
1077 } 1079 }
1078 else 1080 else
1079 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1081 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1080 1082
1081 return res; 1083 return res;
1082} 1084}
1083 1085
1084 1086
1085bool iPAQ::setDisplayBrightness ( int bright ) 1087bool iPAQ::setDisplayBrightness ( int bright )
1086{ 1088{
1087 bool res = false; 1089 bool res = false;
1088 int fd; 1090 int fd;
1089 1091
1090 if ( bright > 255 ) 1092 if ( bright > 255 )
1091 bright = 255; 1093 bright = 255;
1092 if ( bright < 0 ) 1094 if ( bright < 0 )
1093 bright = 0; 1095 bright = 0;
1094 1096
1095 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1097 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1096 FLITE_IN bl; 1098 FLITE_IN bl;
1097 bl. mode = 1; 1099 bl. mode = 1;
1098 bl. pwr = bright ? 1 : 0; 1100 bl. pwr = bright ? 1 : 0;
1099 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1101 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1100 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1102 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1101 ::close ( fd ); 1103 ::close ( fd );
1102 } 1104 }
1103 return res; 1105 return res;
1104} 1106}
1105 1107
1106int iPAQ::displayBrightnessResolution ( ) const 1108int iPAQ::displayBrightnessResolution ( ) const
1107{ 1109{
1108 switch ( model ( )) { 1110 switch ( model ( )) {
1109 case Model_iPAQ_H31xx: 1111 case Model_iPAQ_H31xx:
1110 case Model_iPAQ_H36xx: 1112 case Model_iPAQ_H36xx:
1111 case Model_iPAQ_H37xx: 1113 case Model_iPAQ_H37xx:
1112 return 128; // really 256, but >128 could damage the LCD 1114 return 128; // really 256, but >128 could damage the LCD
1113 1115
1114 case Model_iPAQ_H38xx: 1116 case Model_iPAQ_H38xx:
1115 case Model_iPAQ_H39xx: 1117 case Model_iPAQ_H39xx:
1116 return 64; 1118 return 64;
1117 1119
1118 default: 1120 default:
1119 return 2; 1121 return 2;
1120 } 1122 }
1121} 1123}
1122 1124
1123 1125
1124bool iPAQ::hasLightSensor ( ) const 1126bool iPAQ::hasLightSensor ( ) const
1125{ 1127{
1126 return true; 1128 return true;
1127} 1129}
1128 1130
1129int iPAQ::readLightSensor ( ) 1131int iPAQ::readLightSensor ( )
1130{ 1132{
1131 int fd; 1133 int fd;
1132 int val = -1; 1134 int val = -1;
1133 1135
1134 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1136 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1135 char buffer [8]; 1137 char buffer [8];
1136 1138
1137 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1139 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1138 char *endptr; 1140 char *endptr;
1139 1141
1140 buffer [4] = 0; 1142 buffer [4] = 0;
1141 val = ::strtol ( buffer + 2, &endptr, 16 ); 1143 val = ::strtol ( buffer + 2, &endptr, 16 );
1142 1144
1143 if ( *endptr != 0 ) 1145 if ( *endptr != 0 )
1144 val = -1; 1146 val = -1;
1145 } 1147 }
1146 ::close ( fd ); 1148 ::close ( fd );
1147 } 1149 }
1148 1150
1149 return val; 1151 return val;
1150} 1152}
1151 1153
1152int iPAQ::lightSensorResolution ( ) const 1154int iPAQ::lightSensorResolution ( ) const
1153{ 1155{
1154 return 256; 1156 return 256;
1155} 1157}
1156 1158
1157/************************************************** 1159/**************************************************
1158 * 1160 *
1159 * Zaurus 1161 * Zaurus
1160 * 1162 *
1161 **************************************************/ 1163 **************************************************/
1162 1164
1163 1165
1164 1166
1165void Zaurus::init ( ) 1167void Zaurus::init ( )
1166{ 1168{
1167 d-> m_vendorstr = "Sharp"; 1169 d-> m_vendorstr = "Sharp";
1168 d-> m_vendor = Vendor_Sharp; 1170 d-> m_vendor = Vendor_Sharp;
1169 1171
1170 QFile f ( "/proc/filesystems" ); 1172 QFile f ( "/proc/filesystems" );
1171 QString model; 1173 QString model;
1172 1174
1173 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1175 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1174 d-> m_vendorstr = "OpenZaurus Team"; 1176 d-> m_vendorstr = "OpenZaurus Team";
1175 d-> m_systemstr = "OpenZaurus"; 1177 d-> m_systemstr = "OpenZaurus";
1176 d-> m_system = System_OpenZaurus; 1178 d-> m_system = System_OpenZaurus;
1177 1179
1178 f. close ( ); 1180 f. close ( );
1179 1181
1180 f. setName ( "/etc/oz_version" ); 1182 f. setName ( "/etc/oz_version" );
1181 if ( f. open ( IO_ReadOnly )) { 1183 if ( f. open ( IO_ReadOnly )) {
1182 QTextStream ts ( &f ); 1184 QTextStream ts ( &f );
1183 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1185 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1184 f. close ( ); 1186 f. close ( );
1185 } 1187 }
1186 } 1188 }
1187 else { 1189 else {
1188 d-> m_systemstr = "Zaurus"; 1190 d-> m_systemstr = "Zaurus";
1189 d-> m_system = System_Zaurus; 1191 d-> m_system = System_Zaurus;
1190 } 1192 }
1191 1193
1192 f. setName ( "/proc/cpuinfo" ); 1194 f. setName ( "/proc/cpuinfo" );
1193 if ( f. open ( IO_ReadOnly ) ) { 1195 if ( f. open ( IO_ReadOnly ) ) {
1194 QTextStream ts ( &f ); 1196 QTextStream ts ( &f );
1195 QString line; 1197 QString line;
1196 while( line = ts. readLine ( ) ) { 1198 while( line = ts. readLine ( ) ) {
1197 if ( line. left ( 8 ) == "Hardware" ) 1199 if ( line. left ( 8 ) == "Hardware" )
1198 break; 1200 break;
1199 } 1201 }
1200 int loc = line. find ( ":" ); 1202 int loc = line. find ( ":" );
1201 if ( loc != -1 ) 1203 if ( loc != -1 )
1202 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1204 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1203 } 1205 }
1204 1206
1205 if ( model == "SHARP Corgi" ) { 1207 if ( model == "SHARP Corgi" ) {
1206 d-> m_model = Model_Zaurus_SLC700; 1208 d-> m_model = Model_Zaurus_SLC700;
1207 d-> m_modelstr = "Zaurus SL-C700"; 1209 d-> m_modelstr = "Zaurus SL-C700";
1208 } else if ( model == "SHARP Poodle" ) { 1210 } else if ( model == "SHARP Poodle" ) {
1209 d-> m_model = Model_Zaurus_SLB600; 1211 d-> m_model = Model_Zaurus_SLB600;
1210 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1212 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1211 } else if ( model = "Sharp-Collie" ) { 1213 } else if ( model = "Sharp-Collie" ) {
1212 d-> m_model = Model_Zaurus_SL5500; 1214 d-> m_model = Model_Zaurus_SL5500;
1213 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1215 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1214 } else { 1216 } else {
1215 d-> m_model = Model_Zaurus_SL5500; 1217 d-> m_model = Model_Zaurus_SL5500;
1216 d-> m_modelstr = "Zaurus (Model unknown)"; 1218 d-> m_modelstr = "Zaurus (Model unknown)";
1217 } 1219 }
1218 1220
1219 bool flipstate = false; 1221 bool flipstate = false;
1220 switch ( d-> m_model ) { 1222 switch ( d-> m_model ) {
1221 case Model_Zaurus_SLA300: 1223 case Model_Zaurus_SLA300:
1222 d-> m_rotation = Rot0; 1224 d-> m_rotation = Rot0;
1223 break; 1225 break;
1224 case Model_Zaurus_SLC700: 1226 case Model_Zaurus_SLC700:
1225 // Note: need to 1) set flipstate based on physical screen orientation 1227 // Note: need to 1) set flipstate based on physical screen orientation
1226 // and 2) check to see if the user overrode the rotation direction 1228 // and 2) check to see if the user overrode the rotation direction
1227 // using appearance, and if so, remove that item from the Config to 1229 // using appearance, and if so, remove that item from the Config to
1228 // ensure the rotate applet flips us back to the previous state. 1230 // ensure the rotate applet flips us back to the previous state.
1229 if ( flipstate ) { 1231 if ( flipstate ) {
1230 // 480x640 1232 // 480x640
1231 d-> m_rotation = Rot0; 1233 d-> m_rotation = Rot0;
1232 d-> m_direction = CW; 1234 d-> m_direction = CW;
1233 } else { 1235 } else {
1234 // 640x480 1236 // 640x480
1235 d-> m_rotation = Rot270; 1237 d-> m_rotation = Rot270;
1236 d-> m_direction = CCW; 1238 d-> m_direction = CCW;
1237 } 1239 }
1238 break; 1240 break;
1239 case Model_Zaurus_SLB600: 1241 case Model_Zaurus_SLB600:
1240 case Model_Zaurus_SL5500: 1242 case Model_Zaurus_SL5500:
1241 case Model_Zaurus_SL5000: 1243 case Model_Zaurus_SL5000:
1242 default: 1244 default:
1243 d-> m_rotation = Rot270; 1245 d-> m_rotation = Rot270;
1244 break; 1246 break;
1245 } 1247 }
1246 m_leds [0] = Led_Off; 1248 m_leds [0] = Led_Off;
1247} 1249}
1248 1250
1249void Zaurus::initButtons ( ) 1251void Zaurus::initButtons ( )
1250{ 1252{
1251 if ( d-> m_buttons ) 1253 if ( d-> m_buttons )
1252 return; 1254 return;
1253 1255
1254 d-> m_buttons = new QValueList <ODeviceButton>; 1256 d-> m_buttons = new QValueList <ODeviceButton>;
1255 1257
1256 struct z_button * pz_buttons; 1258 struct z_button * pz_buttons;
1257 int buttoncount; 1259 int buttoncount;
1258 switch ( d-> m_model ) { 1260 switch ( d-> m_model ) {
1259 case Model_Zaurus_SLC700: 1261 case Model_Zaurus_SLC700:
1260 pz_buttons = z_buttons_c700; 1262 pz_buttons = z_buttons_c700;
1261 buttoncount = ARRAY_SIZE(z_buttons_c700); 1263 buttoncount = ARRAY_SIZE(z_buttons_c700);
1262 break; 1264 break;
1263 default: 1265 default:
1264 pz_buttons = z_buttons; 1266 pz_buttons = z_buttons;
1265 buttoncount = ARRAY_SIZE(z_buttons); 1267 buttoncount = ARRAY_SIZE(z_buttons);
1266 break; 1268 break;
1267 } 1269 }
1268 1270
1269 for ( int i = 0; i < buttoncount; i++ ) { 1271 for ( int i = 0; i < buttoncount; i++ ) {
1270 struct z_button *zb = pz_buttons + i; 1272 struct z_button *zb = pz_buttons + i;
1271 ODeviceButton b; 1273 ODeviceButton b;
1272 1274
1273 b. setKeycode ( zb-> code ); 1275 b. setKeycode ( zb-> code );
1274 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1276 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1275 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1277 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1276 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1277 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1278 1280
1279 d-> m_buttons-> append ( b ); 1281 d-> m_buttons-> append ( b );
1280 } 1282 }
1281 1283
1282 reloadButtonMapping ( ); 1284 reloadButtonMapping ( );
1283 1285
1284 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1286 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1285 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1287 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1286} 1288}
1287 1289
1288#include <unistd.h> 1290#include <unistd.h>
1289#include <fcntl.h> 1291#include <fcntl.h>
1290#include <sys/ioctl.h> 1292#include <sys/ioctl.h>
1291 1293
1292//#include <asm/sharp_char.h> // including kernel headers is evil ... 1294//#include <asm/sharp_char.h> // including kernel headers is evil ...
1293 1295
1294#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1296#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1295 1297
1296 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1298 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1297#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1299#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1298 1300
1299#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1301#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1300#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1302#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1301#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1303#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1302 1304
1303/* --- for SHARP_BUZZER device --- */ 1305/* --- for SHARP_BUZZER device --- */
1304 1306
1305 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1307 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1306//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1308//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1307 1309
1308#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1310#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1309#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1311#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1310#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1312#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1311#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1313#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1312#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1314#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1313 1315
1314//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1316//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1315//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1317//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1316 1318
1317//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1319//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1318//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1320//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1319//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1321//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1320//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1322//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1321//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1323//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1322//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1324//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1323//#define SHARP_PDA_APPSTART 9 /* application start */ 1325//#define SHARP_PDA_APPSTART 9 /* application start */
1324//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1326//#define SHARP_PDA_APPQUIT 10 /* application ends */
1325 1327
1326//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1328//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1327//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1329//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1328//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1330//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1329//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1331//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1330// 1332//
1331 1333
1332 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1334 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1333#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1335#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1334 1336
1335typedef struct sharp_led_status { 1337typedef struct sharp_led_status {
1336 int which; /* select which LED status is wanted. */ 1338 int which; /* select which LED status is wanted. */
1337 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1339 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1338} sharp_led_status; 1340} sharp_led_status;
1339 1341
1340#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1342#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1341 1343
1342#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1344#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1343#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1345#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1344#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1346#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1345 1347
1346// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1348// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1347 1349
1348#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1350#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1349#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1351#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1350#define APM_EVT_POWER_BUTTON (1 << 0) 1352#define APM_EVT_POWER_BUTTON (1 << 0)
1351 1353
1352#define FL_IOCTL_STEP_CONTRAST 100 1354#define FL_IOCTL_STEP_CONTRAST 100
1353 1355
1354 1356
1355void Zaurus::buzzer ( int sound ) 1357void Zaurus::buzzer ( int sound )
1356{ 1358{
1357 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1359 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1358 1360
1359 if ( fd >= 0 ) { 1361 if ( fd >= 0 ) {
1360 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1362 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1361 ::close ( fd ); 1363 ::close ( fd );
1362 } 1364 }
1363} 1365}
1364 1366
1365 1367
1366void Zaurus::alarmSound ( ) 1368void Zaurus::alarmSound ( )
1367{ 1369{
1368 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1370 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1369} 1371}
1370 1372
1371void Zaurus::touchSound ( ) 1373void Zaurus::touchSound ( )
1372{ 1374{
1373 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1375 buzzer ( SHARP_BUZ_TOUCHSOUND );
1374} 1376}
1375 1377
1376void Zaurus::keySound ( ) 1378void Zaurus::keySound ( )
1377{ 1379{
1378 buzzer ( SHARP_BUZ_KEYSOUND ); 1380 buzzer ( SHARP_BUZ_KEYSOUND );
1379} 1381}
1380 1382
1381 1383
1382QValueList <OLed> Zaurus::ledList ( ) const 1384QValueList <OLed> Zaurus::ledList ( ) const
1383{ 1385{
1384 QValueList <OLed> vl; 1386 QValueList <OLed> vl;
1385 vl << Led_Mail; 1387 vl << Led_Mail;
1386 return vl; 1388 return vl;
1387} 1389}
1388 1390
1389QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1391QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1390{ 1392{
1391 QValueList <OLedState> vl; 1393 QValueList <OLedState> vl;
1392 1394
1393 if ( l == Led_Mail ) 1395 if ( l == Led_Mail )
1394 vl << Led_Off << Led_On << Led_BlinkSlow; 1396 vl << Led_Off << Led_On << Led_BlinkSlow;
1395 return vl; 1397 return vl;
1396} 1398}
1397 1399
1398OLedState Zaurus::ledState ( OLed which ) const 1400OLedState Zaurus::ledState ( OLed which ) const
1399{ 1401{
1400 if ( which == Led_Mail ) 1402 if ( which == Led_Mail )
1401 return m_leds [0]; 1403 return m_leds [0];
1402 else 1404 else
1403 return Led_Off; 1405 return Led_Off;
1404} 1406}
1405 1407
1406bool Zaurus::setLedState ( OLed which, OLedState st ) 1408bool Zaurus::setLedState ( OLed which, OLedState st )
1407{ 1409{
1408 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1410 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1409 1411
1410 if ( which == Led_Mail ) { 1412 if ( which == Led_Mail ) {
1411 if ( fd >= 0 ) { 1413 if ( fd >= 0 ) {
1412 struct sharp_led_status leds; 1414 struct sharp_led_status leds;
1413 ::memset ( &leds, 0, sizeof( leds )); 1415 ::memset ( &leds, 0, sizeof( leds ));
1414 leds. which = SHARP_LED_MAIL_EXISTS; 1416 leds. which = SHARP_LED_MAIL_EXISTS;
1415 bool ok = true; 1417 bool ok = true;
1416 1418
1417 switch ( st ) { 1419 switch ( st ) {
1418 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1420 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1419 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1421 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1420 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1422 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1421 default : ok = false; 1423 default : ok = false;
1422 } 1424 }
1423 1425
1424 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1426 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1425 m_leds [0] = st; 1427 m_leds [0] = st;
1426 return true; 1428 return true;
1427 } 1429 }
1428 } 1430 }
1429 } 1431 }
1430 return false; 1432 return false;
1431} 1433}
1432 1434
1433bool Zaurus::setSoftSuspend ( bool soft ) 1435bool Zaurus::setSoftSuspend ( bool soft )
1434{ 1436{
1435 bool res = false; 1437 bool res = false;
1436 int fd; 1438 int fd;
1437 1439
1438 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1440 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1439 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1441 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1440 1442
1441 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1443 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1442 1444
1443 if ( sources >= 0 ) { 1445 if ( sources >= 0 ) {
1444 if ( soft ) 1446 if ( soft )
1445 sources &= ~APM_EVT_POWER_BUTTON; 1447 sources &= ~APM_EVT_POWER_BUTTON;
1446 else 1448 else
1447 sources |= APM_EVT_POWER_BUTTON; 1449 sources |= APM_EVT_POWER_BUTTON;
1448 1450
1449 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1451 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1450 res = true; 1452 res = true;
1451 else 1453 else
1452 perror ( "APM_IOCGEVTSRC" ); 1454 perror ( "APM_IOCGEVTSRC" );
1453 } 1455 }
1454 else 1456 else
1455 perror ( "APM_IOCGEVTSRC" ); 1457 perror ( "APM_IOCGEVTSRC" );
1456 1458
1457 ::close ( fd ); 1459 ::close ( fd );
1458 } 1460 }
1459 else 1461 else
1460 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1462 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1461 1463
1462 return res; 1464 return res;
1463} 1465}
1464 1466
1465 1467
1466bool Zaurus::setDisplayBrightness ( int bright ) 1468bool Zaurus::setDisplayBrightness ( int bright )
1467{ 1469{
1468 bool res = false; 1470 bool res = false;
1469 int fd; 1471 int fd;
1470 1472
1471 if ( bright > 255 ) 1473 if ( bright > 255 )
1472 bright = 255; 1474 bright = 255;
1473 if ( bright < 0 ) 1475 if ( bright < 0 )
1474 bright = 0; 1476 bright = 0;
1475 1477
1476 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1478 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1477 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1479 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1478 if ( bright && !bl ) 1480 if ( bright && !bl )
1479 bl = 1; 1481 bl = 1;
1480 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1482 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1481 ::close ( fd ); 1483 ::close ( fd );
1482 } 1484 }
1483 return res; 1485 return res;
1484} 1486}
1485 1487
1486 1488
1487int Zaurus::displayBrightnessResolution ( ) const 1489int Zaurus::displayBrightnessResolution ( ) const
1488{ 1490{
1489 return 5; 1491 return 5;
1490} 1492}
1491 1493
1492 1494
1493/************************************************** 1495/**************************************************
1494 * 1496 *
1495 * SIMpad 1497 * SIMpad
1496 * 1498 *
1497 **************************************************/ 1499 **************************************************/
1498 1500
1499void SIMpad::init ( ) 1501void SIMpad::init ( )
1500{ 1502{
1501 d-> m_vendorstr = "SIEMENS"; 1503 d-> m_vendorstr = "SIEMENS";
1502 d-> m_vendor = Vendor_SIEMENS; 1504 d-> m_vendor = Vendor_SIEMENS;
1503 1505
1504 QFile f ( "/proc/hal/model" ); 1506 QFile f ( "/proc/hal/model" );
1505 1507
1506 //TODO Implement model checking 1508 //TODO Implement model checking
1507 //FIXME For now we assume an SL4 1509 //FIXME For now we assume an SL4
1508 1510
1509 d-> m_modelstr = "SL4"; 1511 d-> m_modelstr = "SL4";
1510 d-> m_model = Model_SIMpad_SL4; 1512 d-> m_model = Model_SIMpad_SL4;
1511 1513
1512 switch ( d-> m_model ) { 1514 switch ( d-> m_model ) {
1513 default: 1515 default:
1514 d-> m_rotation = Rot270; 1516 d-> m_rotation = Rot270;
1515 break; 1517 break;
1516 } 1518 }
1517 1519
1518 f. setName ( "/etc/familiar-version" ); 1520 f. setName ( "/etc/familiar-version" );
1519 if ( f. open ( IO_ReadOnly )) { 1521 if ( f. open ( IO_ReadOnly )) {
1520 d-> m_systemstr = "Familiar"; 1522 d-> m_systemstr = "Familiar";
1521 d-> m_system = System_Familiar; 1523 d-> m_system = System_Familiar;
1522 1524
1523 QTextStream ts ( &f ); 1525 QTextStream ts ( &f );
1524 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1526 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1525 1527
1526 f. close ( ); 1528 f. close ( );
1527 } else { 1529 } else {
1528 f. setName ( "/etc/oz_version" ); 1530 f. setName ( "/etc/oz_version" );
1529 1531
1530 if ( f. open ( IO_ReadOnly )) { 1532 if ( f. open ( IO_ReadOnly )) {
1531 d-> m_systemstr = "OpenEmbedded/SIMpad"; 1533 d-> m_systemstr = "OpenEmbedded/SIMpad";
1532 d-> m_system = System_OpenZaurus; 1534 d-> m_system = System_OpenZaurus;
1533 1535
1534 QTextStream ts ( &f ); 1536 QTextStream ts ( &f );
1535 ts.setDevice ( &f ); 1537 ts.setDevice ( &f );
1536 d-> m_sysverstr = ts. readLine ( ); 1538 d-> m_sysverstr = ts. readLine ( );
1537 f. close ( ); 1539 f. close ( );
1538 } 1540 }
1539 } 1541 }
1540 1542
1541 m_leds [0] = m_leds [1] = Led_Off; 1543 m_leds [0] = m_leds [1] = Led_Off;
1542 1544
1543 m_power_timer = 0; 1545 m_power_timer = 0;
1544 1546
1545} 1547}
1546 1548
1547void SIMpad::initButtons ( ) 1549void SIMpad::initButtons ( )
1548{ 1550{
1549 if ( d-> m_buttons ) 1551 if ( d-> m_buttons )
1550 return; 1552 return;
1551 1553
1552 if ( isQWS( ) ) 1554 if ( isQWS( ) )
1553 QWSServer::setKeyboardFilter ( this ); 1555 QWSServer::setKeyboardFilter ( this );
1554 1556
1555 d-> m_buttons = new QValueList <ODeviceButton>; 1557 d-> m_buttons = new QValueList <ODeviceButton>;
1556 1558
1557 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 1559 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
1558 s_button *sb = simpad_buttons + i; 1560 s_button *sb = simpad_buttons + i;
1559 ODeviceButton b; 1561 ODeviceButton b;
1560 1562
1561 if (( sb-> model & d-> m_model ) == d-> m_model ) { 1563 if (( sb-> model & d-> m_model ) == d-> m_model ) {
1562 b. setKeycode ( sb-> code ); 1564 b. setKeycode ( sb-> code );
1563 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 1565 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
1564 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 1566 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
1565 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 1567 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
1566 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 1568 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
1567 1569
1568 d-> m_buttons-> append ( b ); 1570 d-> m_buttons-> append ( b );
1569 } 1571 }
1570 } 1572 }
1571 reloadButtonMapping ( ); 1573 reloadButtonMapping ( );
1572 1574
1573 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1575 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1574 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1576 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1575} 1577}
1576 1578
1577// SIMpad boardcontrol register CS3 1579// SIMpad boardcontrol register CS3
1578#define SIMPAD_BOARDCONTROL "/proc/cs3" 1580#define SIMPAD_BOARDCONTROL "/proc/cs3"
1579#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 1581#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
1580#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 1582#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
1581#define SIMPAD_EN1 0x0004 // This is only for EPROM's 1583#define SIMPAD_EN1 0x0004 // This is only for EPROM's
1582#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 1584#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
1583#define SIMPAD_DISPLAY_ON 0x0010 1585#define SIMPAD_DISPLAY_ON 0x0010
1584#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 1586#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
1585#define SIMPAD_MQ_RESET 0x0040 1587#define SIMPAD_MQ_RESET 0x0040
1586#define SIMPAD_PCMCIA_RESET 0x0080 1588#define SIMPAD_PCMCIA_RESET 0x0080
1587#define SIMPAD_DECT_POWER_ON 0x0100 1589#define SIMPAD_DECT_POWER_ON 0x0100
1588#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 1590#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
1589#define SIMPAD_RS232_ON 0x0400 1591#define SIMPAD_RS232_ON 0x0400
1590#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 1592#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
1591#define SIMPAD_LED2_ON 0x1000 1593#define SIMPAD_LED2_ON 0x1000
1592#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 1594#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
1593#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 1595#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
1594#define SIMPAD_RESET_SIMCARD 0x8000 1596#define SIMPAD_RESET_SIMCARD 0x8000
1595 1597
1596//SIMpad touchscreen backlight strength control 1598//SIMpad touchscreen backlight strength control
1597#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 1599#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
1598#define SIMPAD_BACKLIGHT_MASK 0x00a10044 1600#define SIMPAD_BACKLIGHT_MASK 0x00a10044
1599 1601
1600QValueList <OLed> SIMpad::ledList ( ) const 1602QValueList <OLed> SIMpad::ledList ( ) const
1601{ 1603{
1602 QValueList <OLed> vl; 1604 QValueList <OLed> vl;
1603 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 1605 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
1604 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 1606 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
1605 return vl; 1607 return vl;
1606} 1608}
1607 1609
1608QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 1610QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
1609{ 1611{
1610 QValueList <OLedState> vl; 1612 QValueList <OLedState> vl;
1611 1613
1612 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 1614 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
1613 vl << Led_Off << Led_On; 1615 vl << Led_Off << Led_On;
1614 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 1616 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
1615 //vl << Led_Off; 1617 //vl << Led_Off;
1616 return vl; 1618 return vl;
1617} 1619}
1618 1620
1619OLedState SIMpad::ledState ( OLed l ) const 1621OLedState SIMpad::ledState ( OLed l ) const
1620{ 1622{
1621 switch ( l ) { 1623 switch ( l ) {
1622 case Led_Power: 1624 case Led_Power:
1623 return m_leds [0]; 1625 return m_leds [0];
1624 //case Led_Mail: 1626 //case Led_Mail:
1625 //return m_leds [1]; 1627 //return m_leds [1];
1626 default: 1628 default:
1627 return Led_Off; 1629 return Led_Off;
1628 } 1630 }
1629} 1631}
1630 1632
1631bool SIMpad::setLedState ( OLed l, OLedState st ) 1633bool SIMpad::setLedState ( OLed l, OLedState st )
1632{ 1634{
1633 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 1635 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
1634 1636
1635 if ( l == Led_Power ) { 1637 if ( l == Led_Power ) {
1636 if ( fd >= 0 ) { 1638 if ( fd >= 0 ) {
1637 LED_IN leds; 1639 LED_IN leds;
1638 ::memset ( &leds, 0, sizeof( leds )); 1640 ::memset ( &leds, 0, sizeof( leds ));
1639 leds. TotalTime = 0; 1641 leds. TotalTime = 0;
1640 leds. OnTime = 0; 1642 leds. OnTime = 0;
1641 leds. OffTime = 1; 1643 leds. OffTime = 1;
1642 leds. OffOnBlink = 2; 1644 leds. OffOnBlink = 2;
1643 1645
1644 switch ( st ) { 1646 switch ( st ) {
1645 case Led_Off : leds. OffOnBlink = 0; break; 1647 case Led_Off : leds. OffOnBlink = 0; break;
1646 case Led_On : leds. OffOnBlink = 1; break; 1648 case Led_On : leds. OffOnBlink = 1; break;
1647 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1649 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1648 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1650 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1649 } 1651 }
1650 1652
1651 { 1653 {
1652 /*TODO Implement this like that: 1654 /*TODO Implement this like that:
1653 read from cs3 1655 read from cs3
1654 && with SIMPAD_LED2_ON 1656 && with SIMPAD_LED2_ON
1655 write to cs3 */ 1657 write to cs3 */
1656 m_leds [0] = st; 1658 m_leds [0] = st;
1657 return true; 1659 return true;
1658 } 1660 }
1659 } 1661 }
1660 } 1662 }
1661 return false; 1663 return false;
1662} 1664}
1663 1665
1664 1666
1665bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1667bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1666{ 1668{
1667 //TODO 1669 //TODO
1668 return false; 1670 return false;
1669} 1671}
1670 1672
1671void SIMpad::timerEvent ( QTimerEvent * ) 1673void SIMpad::timerEvent ( QTimerEvent * )
1672{ 1674{
1673 killTimer ( m_power_timer ); 1675 killTimer ( m_power_timer );
1674 m_power_timer = 0; 1676 m_power_timer = 0;
1675 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1677 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1676 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1678 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1677} 1679}
1678 1680
1679 1681
1680void SIMpad::alarmSound ( ) 1682void SIMpad::alarmSound ( )
1681{ 1683{
1682#ifndef QT_NO_SOUND 1684#ifndef QT_NO_SOUND
1683 static Sound snd ( "alarm" ); 1685 static Sound snd ( "alarm" );
1684 int fd; 1686 int fd;
1685 int vol; 1687 int vol;
1686 bool vol_reset = false; 1688 bool vol_reset = false;
1687 1689
1688 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1690 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1689 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1691 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1690 Config cfg ( "qpe" ); 1692 Config cfg ( "qpe" );
1691 cfg. setGroup ( "Volume" ); 1693 cfg. setGroup ( "Volume" );
1692 1694
1693 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1695 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1694 if ( volalarm < 0 ) 1696 if ( volalarm < 0 )
1695 volalarm = 0; 1697 volalarm = 0;
1696 else if ( volalarm > 100 ) 1698 else if ( volalarm > 100 )
1697 volalarm = 100; 1699 volalarm = 100;
1698 volalarm |= ( volalarm << 8 ); 1700 volalarm |= ( volalarm << 8 );
1699 1701
1700 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1702 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1701 vol_reset = true; 1703 vol_reset = true;
1702 } 1704 }
1703 } 1705 }
1704 1706
1705 snd. play ( ); 1707 snd. play ( );
1706 while ( !snd. isFinished ( )) 1708 while ( !snd. isFinished ( ))
1707 qApp-> processEvents ( ); 1709 qApp-> processEvents ( );
1708 1710
1709 if ( fd >= 0 ) { 1711 if ( fd >= 0 ) {
1710 if ( vol_reset ) 1712 if ( vol_reset )
1711 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1713 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1712 ::close ( fd ); 1714 ::close ( fd );
1713 } 1715 }
1714#endif 1716#endif
1715} 1717}
1716 1718
1717 1719
1720bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1721{
1722 qDebug( "ODevice for SIMpad: suspend()" );
1723 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1724 return false;
1725
1726 bool res = false;
1727
1728 struct timeval tvs, tvn;
1729 ::gettimeofday ( &tvs, 0 );
1730
1731 ::sync ( ); // flush fs caches
1732 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
1733
1734 return res;
1735}
1736
1737
1718bool SIMpad::setSoftSuspend ( bool soft ) 1738bool SIMpad::setSoftSuspend ( bool soft )
1719{ 1739{
1720 //TODO 1740 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1721 return false; 1741 return false;
1722} 1742}
1723 1743
1724 1744
1745bool SIMpad::setDisplayStatus ( bool on )
1746{
1747 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1748
1749 bool res = false;
1750 int fd;
1751
1752 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1753
1754 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
1755 res = ( ::system( (const char*) cmdline ) == 0 );
1756 ::close ( fd );
1757 }
1758 return res;
1759}
1760
1761
1725bool SIMpad::setDisplayBrightness ( int bright ) 1762bool SIMpad::setDisplayBrightness ( int bright )
1726{ 1763{
1764 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1727 bool res = false; 1765 bool res = false;
1728 int fd; 1766 int fd;
1729 1767
1730 if ( bright > 255 ) 1768 if ( bright > 255 )
1731 bright = 255; 1769 bright = 255;
1732 if ( bright < 0 ) 1770 if ( bright < 0 )
1733 bright = 0; 1771 bright = 0;
1734 1772
1735 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1773 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1736 int value = 255 - bright; 1774 int value = 255 - bright;
1737 const int mask = SIMPAD_BACKLIGHT_MASK; 1775 const int mask = SIMPAD_BACKLIGHT_MASK;
1738 value = value << 8; 1776 value = value << 8;
1739 value += mask; 1777 value += mask;
1740 char writeCommand[100]; 1778 char writeCommand[100];
1741 const int count = sprintf( writeCommand, "0x%x\n", value ); 1779 const int count = sprintf( writeCommand, "0x%x\n", value );
1742 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1780 res = ( ::write ( fd, writeCommand, count ) != -1 );
1743 ::close ( fd ); 1781 ::close ( fd );
1744 } 1782 }
1745 return res; 1783 return res;
1746} 1784}
1747 1785
1748 1786
1749int SIMpad::displayBrightnessResolution ( ) const 1787int SIMpad::displayBrightnessResolution ( ) const
1750{ 1788{
1751 switch ( model ( )) { 1789 switch ( model ( )) {
1752 case Model_SIMpad_CL4: 1790 case Model_SIMpad_CL4:
1753 case Model_SIMpad_SL4: 1791 case Model_SIMpad_SL4:
1754 case Model_SIMpad_SLC: 1792 case Model_SIMpad_SLC:
1755 case Model_SIMpad_TSinus: 1793 case Model_SIMpad_TSinus:
1756 return 255; //TODO find out if this is save 1794 return 255; //TODO find out if this is save
1757 1795
1758 default: 1796 default:
1759 return 2; 1797 return 2;
1760 } 1798 }
1761} 1799}
1762 1800