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