summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.h2
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp13
2 files changed, 14 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 0c78277..2566979 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,397 +1,397 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41 41
42 42
43#include <qstrlist.h> 43#include <qstrlist.h>
44#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
45 45
46 46
47class Sound; 47class Sound;
48 48
49namespace Opie{ 49namespace Opie{
50namespace Core{ 50namespace Core{
51 51
52class ODeviceData; 52class ODeviceData;
53/** 53/**
54 * The available devices 54 * The available devices
55 */ 55 */
56enum OModel { 56enum OModel {
57 Model_Unknown, // = 0 57 Model_Unknown, // = 0
58 58
59 Model_Series_Mask = 0xffff0000, 59 Model_Series_Mask = 0xffff0000,
60 60
61 Model_iPAQ = ( 1 << 16 ), 61 Model_iPAQ = ( 1 << 16 ),
62 62
63 Model_iPAQ_All = ( Model_iPAQ | 0xffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffff ),
64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ),
65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ),
66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ),
67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ),
68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ),
69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ),
70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ),
71 Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), 71 Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ),
72 Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), 72 Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ),
73 73 Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ),
74 Model_Jornada = ( 6 << 16 ), 74 Model_Jornada = ( 6 << 16 ),
75 Model_Jornada_56x = ( Model_Jornada | 0x0001 ), 75 Model_Jornada_56x = ( Model_Jornada | 0x0001 ),
76 Model_Jornada_720 = ( Model_Jornada | 0x0002 ), 76 Model_Jornada_720 = ( Model_Jornada | 0x0002 ),
77 77
78 Model_Zaurus = ( 2 << 16 ), 78 Model_Zaurus = ( 2 << 16 ),
79 79
80 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), 80 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ),
81 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), 81 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ),
82 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), 82 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ),
83 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), 83 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ),
84 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), 84 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ),
85 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ), 85 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ),
86 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ), 86 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ),
87 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ), 87 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ),
88 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ), 88 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ),
89 89
90 Model_SIMpad = ( 3 << 16 ), 90 Model_SIMpad = ( 3 << 16 ),
91 91
92 Model_SIMpad_All = ( Model_SIMpad | 0xffff ), 92 Model_SIMpad_All = ( Model_SIMpad | 0xffff ),
93 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), 93 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ),
94 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), 94 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ),
95 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), 95 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ),
96 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), 96 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ),
97 97
98 Model_Ramses = ( 4 << 16 ), 98 Model_Ramses = ( 4 << 16 ),
99 99
100 Model_Ramses_All = ( Model_Ramses | 0xffff ), 100 Model_Ramses_All = ( Model_Ramses | 0xffff ),
101 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), 101 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ),
102 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), 102 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ),
103 103
104 Model_Yopy = ( 5 << 16 ), 104 Model_Yopy = ( 5 << 16 ),
105 105
106 Model_Yopy_All = ( Model_Yopy | 0xffff ), 106 Model_Yopy_All = ( Model_Yopy | 0xffff ),
107 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), 107 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ),
108 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), 108 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ),
109 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), 109 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ),
110 110
111 Model_Beagle = ( 6 << 16 ), 111 Model_Beagle = ( 6 << 16 ),
112 112
113 Model_Beagle_All = ( Model_Beagle | 0xffff ), 113 Model_Beagle_All = ( Model_Beagle | 0xffff ),
114 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), 114 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ),
115 115
116 Model_GenuineIntel = ( 7 << 16 ), 116 Model_GenuineIntel = ( 7 << 16 ),
117 117
118 Model_MyPal = ( 8 << 16 ), 118 Model_MyPal = ( 8 << 16 ),
119 119
120 Model_MyPal_All = ( Model_MyPal | 0xffff ), 120 Model_MyPal_All = ( Model_MyPal | 0xffff ),
121 Model_MyPal_620 = ( Model_MyPal | 0x0001 ), 121 Model_MyPal_620 = ( Model_MyPal | 0x0001 ),
122 Model_MyPal_716 = ( Model_MyPal | 0x0002 ), 122 Model_MyPal_716 = ( Model_MyPal | 0x0002 ),
123 Model_MyPal_730 = ( Model_MyPal | 0x0003 ), 123 Model_MyPal_730 = ( Model_MyPal | 0x0003 ),
124 124
125 Model_HTC = ( 9 << 16 ), 125 Model_HTC = ( 9 << 16 ),
126 Model_HTC_All = ( Model_HTC | 0xffff ), 126 Model_HTC_All = ( Model_HTC | 0xffff ),
127 Model_HTC_Universal = ( Model_HTC | 0x0001 ) 127 Model_HTC_Universal = ( Model_HTC | 0x0001 )
128}; 128};
129 129
130/** 130/**
131 * The vendor of the device 131 * The vendor of the device
132 */ 132 */
133enum OVendor { 133enum OVendor {
134 Vendor_Unknown, 134 Vendor_Unknown,
135 135
136 Vendor_HP, 136 Vendor_HP,
137 Vendor_Sharp, 137 Vendor_Sharp,
138 Vendor_SIEMENS, 138 Vendor_SIEMENS,
139 Vendor_MundN, 139 Vendor_MundN,
140 Vendor_GMate, 140 Vendor_GMate,
141 Vendor_MasterIA, 141 Vendor_MasterIA,
142 Vendor_GenuineIntel, 142 Vendor_GenuineIntel,
143 Vendor_Asus, 143 Vendor_Asus,
144 Vendor_HTC 144 Vendor_HTC
145}; 145};
146 146
147/** 147/**
148 * The System used 148 * The System used
149 */ 149 */
150enum OSystem { 150enum OSystem {
151 System_Unknown, 151 System_Unknown,
152 152
153 System_Familiar, 153 System_Familiar,
154 System_Zaurus, 154 System_Zaurus,
155 System_OpenZaurus, 155 System_OpenZaurus,
156 System_Linupy, 156 System_Linupy,
157 System_OpenEmbedded, 157 System_OpenEmbedded,
158 System_PC 158 System_PC
159}; 159};
160 160
161typedef struct { 161typedef struct {
162 OSystem system; 162 OSystem system;
163 char* sysstr; 163 char* sysstr;
164 char* sysvfile; 164 char* sysvfile;
165} ODistribution; 165} ODistribution;
166 166
167extern ODistribution distributions[]; 167extern ODistribution distributions[];
168 168
169 169
170enum OLedState { 170enum OLedState {
171 Led_Off, 171 Led_Off,
172 Led_On, 172 Led_On,
173 Led_BlinkSlow, 173 Led_BlinkSlow,
174 Led_BlinkFast 174 Led_BlinkFast
175}; 175};
176 176
177enum OLed { 177enum OLed {
178 Led_Mail, 178 Led_Mail,
179 Led_Power, 179 Led_Power,
180 Led_BlueTooth 180 Led_BlueTooth
181}; 181};
182 182
183enum OHardKey { 183enum OHardKey {
184 HardKey_Datebook = Qt::Key_F9, 184 HardKey_Datebook = Qt::Key_F9,
185 HardKey_Contacts = Qt::Key_F10, 185 HardKey_Contacts = Qt::Key_F10,
186 HardKey_Menu = Qt::Key_F11, 186 HardKey_Menu = Qt::Key_F11,
187 HardKey_Home = Qt::Key_F12, 187 HardKey_Home = Qt::Key_F12,
188 HardKey_Mail = Qt::Key_F13, 188 HardKey_Mail = Qt::Key_F13,
189 HardKey_Record = Qt::Key_F24, 189 HardKey_Record = Qt::Key_F24,
190 HardKey_Suspend = Qt::Key_F34, 190 HardKey_Suspend = Qt::Key_F34,
191 HardKey_Backlight = Qt::Key_F35, 191 HardKey_Backlight = Qt::Key_F35,
192 HardKey_Action = Qt::Key_F10, 192 HardKey_Action = Qt::Key_F10,
193 HardKey_OK = Qt::Key_F11, 193 HardKey_OK = Qt::Key_F11,
194 HardKey_End = Qt::Key_F12, 194 HardKey_End = Qt::Key_F12,
195}; 195};
196 196
197enum ODirection { 197enum ODirection {
198 CW = 0, 198 CW = 0,
199 CCW = 1, 199 CCW = 1,
200 Flip = 2, 200 Flip = 2,
201}; 201};
202 202
203enum OHingeStatus { 203enum OHingeStatus {
204 CASE_CLOSED = 3, 204 CASE_CLOSED = 3,
205 CASE_PORTRAIT = 2, 205 CASE_PORTRAIT = 2,
206 CASE_LANDSCAPE = 0, 206 CASE_LANDSCAPE = 0,
207 CASE_UNKNOWN = 1, 207 CASE_UNKNOWN = 1,
208}; 208};
209 209
210/* default button for qvfb or such 210/* default button for qvfb or such
211 * see odevice.cpp for details. 211 * see odevice.cpp for details.
212 * hint: manage a user defined button for qvfb? 212 * hint: manage a user defined button for qvfb?
213 * alwin 213 * alwin
214 */ 214 */
215struct default_button { 215struct default_button {
216 Qt::Key code; 216 Qt::Key code;
217 char *utext; 217 char *utext;
218 char *pix; 218 char *pix;
219 char *fpressedservice; 219 char *fpressedservice;
220 char *fpressedaction; 220 char *fpressedaction;
221 char *fheldservice; 221 char *fheldservice;
222 char *fheldaction; 222 char *fheldaction;
223}; 223};
224 224
225/** 225/**
226 * A singleton which gives informations about device specefic option 226 * A singleton which gives informations about device specefic option
227 * like the Hardware used, LEDs, the Base Distribution and 227 * like the Hardware used, LEDs, the Base Distribution and
228 * hardware key mappings. 228 * hardware key mappings.
229 * 229 *
230 * @short A small class for device specific options 230 * @short A small class for device specific options
231 * @see QObject 231 * @see QObject
232 * @author Robert Griebl 232 * @author Robert Griebl
233 * @version 1.0 233 * @version 1.0
234 */ 234 */
235class ODevice : public QObject 235class ODevice : public QObject
236{ 236{
237 Q_OBJECT 237 Q_OBJECT
238 238
239private: 239private:
240 /* disable copy */ 240 /* disable copy */
241 ODevice ( const ODevice & ); 241 ODevice ( const ODevice & );
242 242
243protected: 243protected:
244 ODevice(); 244 ODevice();
245 virtual void init(const QString&); 245 virtual void init(const QString&);
246 virtual void initButtons(); 246 virtual void initButtons();
247 static void sendSuspendmsg(); 247 static void sendSuspendmsg();
248 248
249 ODeviceData *d; 249 ODeviceData *d;
250 250
251public: 251public:
252 // sandman do we want to allow destructions? -zecke? 252 // sandman do we want to allow destructions? -zecke?
253 virtual ~ODevice(); 253 virtual ~ODevice();
254 static ODevice *inst(); 254 static ODevice *inst();
255 255
256 // information 256 // information
257 QString modelString() const; 257 QString modelString() const;
258 OModel model() const; 258 OModel model() const;
259 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 259 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
260 260
261 QString vendorString() const; 261 QString vendorString() const;
262 OVendor vendor() const; 262 OVendor vendor() const;
263 263
264 QString systemString() const; 264 QString systemString() const;
265 OSystem system() const; 265 OSystem system() const;
266 266
267 QString systemVersionString() const; 267 QString systemVersionString() const;
268 268
269 virtual Transformation rotation() const; 269 virtual Transformation rotation() const;
270 virtual ODirection direction() const; 270 virtual ODirection direction() const;
271 271
272 QString qteDriver() const; 272 QString qteDriver() const;
273 273
274 // system 274 // system
275 virtual bool suspend(); 275 virtual bool suspend();
276 276
277 virtual bool setDisplayStatus ( bool on ); 277 virtual bool setDisplayStatus ( bool on );
278 virtual bool setDisplayBrightness ( int brightness ); 278 virtual bool setDisplayBrightness ( int brightness );
279 virtual int displayBrightnessResolution() const; 279 virtual int displayBrightnessResolution() const;
280 virtual bool setDisplayContrast ( int contrast ); 280 virtual bool setDisplayContrast ( int contrast );
281 virtual int displayContrastResolution() const; 281 virtual int displayContrastResolution() const;
282 282
283 // don't add new virtual methods, use this: 283 // don't add new virtual methods, use this:
284 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 284 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
285 // and in your subclass do overwrite 285 // and in your subclass do overwrite
286 // protected virtual int virtual_hook(int, void *) 286 // protected virtual int virtual_hook(int, void *)
287 // which is defined below 287 // which is defined below
288 288
289 // input / output 289 // input / output
290 virtual void playAlarmSound(); 290 virtual void playAlarmSound();
291 virtual void playKeySound(); 291 virtual void playKeySound();
292 virtual void playTouchSound(); 292 virtual void playTouchSound();
293 293
294 virtual QValueList <OLed> ledList() const; 294 virtual QValueList <OLed> ledList() const;
295 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 295 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
296 virtual OLedState ledState ( OLed led ) const; 296 virtual OLedState ledState ( OLed led ) const;
297 virtual bool setLedState ( OLed led, OLedState st ); 297 virtual bool setLedState ( OLed led, OLedState st );
298 298
299 virtual bool hasLightSensor() const; 299 virtual bool hasLightSensor() const;
300 virtual int readLightSensor(); 300 virtual int readLightSensor();
301 virtual int lightSensorResolution() const; 301 virtual int lightSensorResolution() const;
302 302
303 virtual bool hasHingeSensor() const; 303 virtual bool hasHingeSensor() const;
304 virtual OHingeStatus readHingeSensor()const; 304 virtual OHingeStatus readHingeSensor()const;
305 305
306 const QStrList &allowedCpuFrequencies() const; 306 const QStrList &allowedCpuFrequencies() const;
307 bool setCurrentCpuFrequency(uint index); 307 bool setCurrentCpuFrequency(uint index);
308 308
309 /** 309 /**
310 * Returns the available buttons on this device. The number and location 310 * Returns the available buttons on this device. The number and location
311 * of buttons will vary depending on the device. Button numbers will be assigned 311 * of buttons will vary depending on the device. Button numbers will be assigned
312 * by the device manufacturer and will be from most preferred button to least preffered 312 * by the device manufacturer and will be from most preferred button to least preffered
313 * button. Note that this list only contains "user mappable" buttons. 313 * button. Note that this list only contains "user mappable" buttons.
314 * 314 *
315 * @todo Make method const and take care of calling initButtons or make that const too 315 * @todo Make method const and take care of calling initButtons or make that const too
316 * 316 *
317 */ 317 */
318 const QValueList<ODeviceButton> &buttons(); 318 const QValueList<ODeviceButton> &buttons();
319 319
320 /** 320 /**
321 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 321 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
322 * returns 0L 322 * returns 0L
323 */ 323 */
324 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 324 const ODeviceButton *buttonForKeycode ( ushort keyCode );
325 325
326 /** 326 /**
327 * Reassigns the pressed action for \a button. To return to the factory 327 * Reassigns the pressed action for \a button. To return to the factory
328 * default pass an empty string as \a qcopMessage. 328 * default pass an empty string as \a qcopMessage.
329 */ 329 */
330 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 330 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
331 331
332 /** 332 /**
333 * Reassigns the held action for \a button. To return to the factory 333 * Reassigns the held action for \a button. To return to the factory
334 * default pass an empty string as \a qcopMessage. 334 * default pass an empty string as \a qcopMessage.
335 */ 335 */
336 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 336 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
337 337
338 /** 338 /**
339 * How long (in ms) you have to press a button for a "hold" action 339 * How long (in ms) you have to press a button for a "hold" action
340 */ 340 */
341 uint buttonHoldTime() const; 341 uint buttonHoldTime() const;
342 342
343signals: 343signals:
344 void buttonMappingChanged(); 344 void buttonMappingChanged();
345 345
346private slots: 346private slots:
347 void systemMessage ( const QCString &, const QByteArray & ); 347 void systemMessage ( const QCString &, const QByteArray & );
348 void playingStopped(); 348 void playingStopped();
349 349
350protected: 350protected:
351 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 351 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
352 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 352 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
353 void reloadButtonMapping(); 353 void reloadButtonMapping();
354 void changeMixerForAlarm( int mixer, const char* file, Sound *snd); 354 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
355 355
356 /* ugly virtual hook */ 356 /* ugly virtual hook */
357 virtual void virtual_hook( int id, void* data ); 357 virtual void virtual_hook( int id, void* data );
358}; 358};
359 359
360class ODeviceData { 360class ODeviceData {
361 361
362 public: 362 public:
363 QString m_vendorstr; 363 QString m_vendorstr;
364 OVendor m_vendor; 364 OVendor m_vendor;
365 365
366 QString m_modelstr; 366 QString m_modelstr;
367 OModel m_model; 367 OModel m_model;
368 368
369 QString m_systemstr; 369 QString m_systemstr;
370 OSystem m_system; 370 OSystem m_system;
371 371
372 QString m_sysverstr; 372 QString m_sysverstr;
373 373
374 Transformation m_rotation; 374 Transformation m_rotation;
375 ODirection m_direction; 375 ODirection m_direction;
376 376
377 QString m_qteDriver; 377 QString m_qteDriver;
378 378
379 QValueList <ODeviceButton> *m_buttons; 379 QValueList <ODeviceButton> *m_buttons;
380 uint m_holdtime; 380 uint m_holdtime;
381 QStrList *m_cpu_frequencies; 381 QStrList *m_cpu_frequencies;
382 bool m_initializedButtonQcop : 1; 382 bool m_initializedButtonQcop : 1;
383 383
384 /* values for changeMixerForAlarm */ 384 /* values for changeMixerForAlarm */
385 int m_sound, m_vol, m_mixer; 385 int m_sound, m_vol, m_mixer;
386}; 386};
387 387
388extern bool isQWS(); 388extern bool isQWS();
389extern QCString makeChannel ( const char *str ); 389extern QCString makeChannel ( const char *str );
390} 390}
391} 391}
392 392
393 393
394 394
395 395
396#endif 396#endif
397 397
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index a221e23..e6e3145 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,468 +1,481 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/sound.h> 40#include <qpe/sound.h>
41#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
42 42
43#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44#include <opie2/oresource.h> 44#include <opie2/oresource.h>
45 45
46/* STD */ 46/* STD */
47#include <fcntl.h> 47#include <fcntl.h>
48#include <math.h> 48#include <math.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <signal.h> 50#include <signal.h>
51#include <sys/ioctl.h> 51#include <sys/ioctl.h>
52#include <sys/time.h> 52#include <sys/time.h>
53#include <unistd.h> 53#include <unistd.h>
54#ifndef QT_NO_SOUND 54#ifndef QT_NO_SOUND
55#include <linux/soundcard.h> 55#include <linux/soundcard.h>
56#endif 56#endif
57 57
58 58
59using namespace Opie::Core; 59using namespace Opie::Core;
60using namespace Opie::Core::Internal; 60using namespace Opie::Core::Internal;
61 61
62/* KERNEL */ 62/* KERNEL */
63#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 63#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
64 64
65#define OD_IO(type,number) OD_IOC(0,type,number,0) 65#define OD_IO(type,number) OD_IOC(0,type,number,0)
66#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 66#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
67#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 67#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
68#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 68#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
69 69
70typedef struct { 70typedef struct {
71 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 71 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
72 unsigned char TotalTime; /* Units of 5 seconds */ 72 unsigned char TotalTime; /* Units of 5 seconds */
73 unsigned char OnTime; /* units of 100m/s */ 73 unsigned char OnTime; /* units of 100m/s */
74 unsigned char OffTime; /* units of 100m/s */ 74 unsigned char OffTime; /* units of 100m/s */
75} LED_IN; 75} LED_IN;
76 76
77typedef struct { 77typedef struct {
78 unsigned char mode; 78 unsigned char mode;
79 unsigned char pwr; 79 unsigned char pwr;
80 unsigned char brightness; 80 unsigned char brightness;
81} FLITE_IN; 81} FLITE_IN;
82 82
83#define LED_ON OD_IOW( 'f', 5, LED_IN ) 83#define LED_ON OD_IOW( 'f', 5, LED_IN )
84#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 84#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
85 85
86struct i_button ipaq_buttons [] = { 86struct i_button ipaq_buttons [] = {
87 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 87 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x,
88 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 88 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
89 "devicebuttons/ipaq_calendar", 89 "devicebuttons/ipaq_calendar",
90 "datebook", "nextView()", 90 "datebook", "nextView()",
91 "today", "raise()" }, 91 "today", "raise()" },
92 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 92 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x,
93 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 93 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
94 "devicebuttons/ipaq_contact", 94 "devicebuttons/ipaq_contact",
95 "addressbook", "raise()", 95 "addressbook", "raise()",
96 "addressbook", "beamBusinessCard()" }, 96 "addressbook", "beamBusinessCard()" },
97 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 97 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
98 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 98 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
99 "devicebuttons/ipaq_menu", 99 "devicebuttons/ipaq_menu",
100 "QPE/TaskBar", "toggleMenu()", 100 "QPE/TaskBar", "toggleMenu()",
101 "QPE/TaskBar", "toggleStartMenu()" }, 101 "QPE/TaskBar", "toggleStartMenu()" },
102 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 102 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
103 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 103 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
104 "devicebuttons/ipaq_mail", 104 "devicebuttons/ipaq_mail",
105 "opiemail", "raise()", 105 "opiemail", "raise()",
106 "opiemail", "newMail()" }, 106 "opiemail", "newMail()" },
107 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 107 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x,
108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
109 "devicebuttons/ipaq_home", 109 "devicebuttons/ipaq_home",
110 "QPE/Launcher", "home()", 110 "QPE/Launcher", "home()",
111 "buttonsettings", "raise()" }, 111 "buttonsettings", "raise()" },
112 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 112 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
113 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 113 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
114 "devicebuttons/ipaq_record", 114 "devicebuttons/ipaq_record",
115 "QPE/VMemo", "toggleRecord()", 115 "QPE/VMemo", "toggleRecord()",
116 "sound", "raise()" }, 116 "sound", "raise()" },
117 117
118 { Model_iPAQ_H191x, 118 { Model_iPAQ_H191x,
119 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"), 119 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"),
120 "devicebuttons/ipaq_mail", 120 "devicebuttons/ipaq_mail",
121 "opiemail", "raise()", 121 "opiemail", "raise()",
122 "opiemail", "newMail()" }, 122 "opiemail", "newMail()" },
123 { Model_iPAQ_H191x, 123 { Model_iPAQ_H191x,
124 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"), 124 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"),
125 "devicebuttons/ipaq_record", 125 "devicebuttons/ipaq_record",
126 "QPE/VMemo", "toggleRecord()", 126 "QPE/VMemo", "toggleRecord()",
127 "sound", "raise()" }, 127 "sound", "raise()" },
128 128
129}; 129};
130 130
131void iPAQ::init(const QString& model) 131void iPAQ::init(const QString& model)
132{ 132{
133 d->m_vendorstr = "HP"; 133 d->m_vendorstr = "HP";
134 d->m_vendor = Vendor_HP; 134 d->m_vendor = Vendor_HP;
135 135
136 d->m_modelstr = model.mid(model.findRev('H')); 136 d->m_modelstr = model.mid(model.findRev('H'));
137 137
138 if ( d->m_modelstr == "H3100" ) 138 if ( d->m_modelstr == "H3100" )
139 d->m_model = Model_iPAQ_H31xx; 139 d->m_model = Model_iPAQ_H31xx;
140 else if ( d->m_modelstr == "H3600" ) 140 else if ( d->m_modelstr == "H3600" )
141 d->m_model = Model_iPAQ_H36xx; 141 d->m_model = Model_iPAQ_H36xx;
142 else if ( d->m_modelstr == "H3700" ) 142 else if ( d->m_modelstr == "H3700" )
143 d->m_model = Model_iPAQ_H37xx; 143 d->m_model = Model_iPAQ_H37xx;
144 else if ( d->m_modelstr == "H3800" ) 144 else if ( d->m_modelstr == "H3800" )
145 d->m_model = Model_iPAQ_H38xx; 145 d->m_model = Model_iPAQ_H38xx;
146 else if ( d->m_modelstr == "H3900" ) 146 else if ( d->m_modelstr == "H3900" )
147 d->m_model = Model_iPAQ_H39xx; 147 d->m_model = Model_iPAQ_H39xx;
148 else if ( d->m_modelstr == "H5400" ) 148 else if ( d->m_modelstr == "H5400" )
149 d->m_model = Model_iPAQ_H5xxx; 149 d->m_model = Model_iPAQ_H5xxx;
150 else if ( d->m_modelstr == "H2200" ) 150 else if ( d->m_modelstr == "H2200" )
151 d->m_model = Model_iPAQ_H22xx; 151 d->m_model = Model_iPAQ_H22xx;
152 else if ( d->m_modelstr == "H1910" ) 152 else if ( d->m_modelstr == "H1910" )
153 d->m_model = Model_iPAQ_H191x; 153 d->m_model = Model_iPAQ_H191x;
154 else if ( d->m_modelstr == "H1940" ) 154 else if ( d->m_modelstr == "H1940" )
155 d->m_model = Model_iPAQ_H1940; 155 d->m_model = Model_iPAQ_H1940;
156 else if ( d->m_modelstr == "HX4700" )
157 d->m_model = Model_iPAQ_HX4700;
158
156 else 159 else
157 d->m_model = Model_Unknown; 160 d->m_model = Model_Unknown;
158 161
159 switch ( d->m_model ) { 162 switch ( d->m_model ) {
160 case Model_iPAQ_H31xx: 163 case Model_iPAQ_H31xx:
161 case Model_iPAQ_H38xx: 164 case Model_iPAQ_H38xx:
162 d->m_rotation = Rot90; 165 d->m_rotation = Rot90;
163 break; 166 break;
164 case Model_iPAQ_H5xxx: 167 case Model_iPAQ_H5xxx:
165 case Model_iPAQ_H22xx: 168 case Model_iPAQ_H22xx:
166 case Model_iPAQ_H191x: 169 case Model_iPAQ_H191x:
167 case Model_iPAQ_H1940: 170 case Model_iPAQ_H1940:
171 case Model_iPAQ_HX4700:
168 d->m_rotation = Rot0; 172 d->m_rotation = Rot0;
169 break; 173 break;
170 case Model_iPAQ_H36xx: 174 case Model_iPAQ_H36xx:
171 case Model_iPAQ_H37xx: 175 case Model_iPAQ_H37xx:
172 case Model_iPAQ_H39xx: 176 case Model_iPAQ_H39xx:
173 default: 177 default:
174 d->m_rotation = Rot270; 178 d->m_rotation = Rot270;
175 break; 179 break;
176 180
177 } 181 }
178 182
179 m_leds [0] = m_leds [1] = Led_Off; 183 m_leds [0] = m_leds [1] = Led_Off;
180 184
181 m_power_timer = 0; 185 m_power_timer = 0;
182 186
183} 187}
184 188
185void iPAQ::initButtons() 189void iPAQ::initButtons()
186{ 190{
187 if ( d->m_buttons ) 191 if ( d->m_buttons )
188 return; 192 return;
189 193
190 if ( isQWS( ) ) { 194 if ( isQWS( ) ) {
191 addPreHandler(this); 195 addPreHandler(this);
192 } 196 }
193 197
194 d->m_buttons = new QValueList <ODeviceButton>; 198 d->m_buttons = new QValueList <ODeviceButton>;
195 199
196 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 200 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
197 i_button *ib = ipaq_buttons + i; 201 i_button *ib = ipaq_buttons + i;
198 ODeviceButton b; 202 ODeviceButton b;
199 203
200 if (( ib->model & d->m_model ) == d->m_model ) { 204 if (( ib->model & d->m_model ) == d->m_model ) {
201 b. setKeycode ( ib->code ); 205 b. setKeycode ( ib->code );
202 b. setUserText ( QObject::tr ( "Button", ib->utext )); 206 b. setUserText ( QObject::tr ( "Button", ib->utext ));
203 b. setPixmap ( OResource::loadPixmap ( ib->pix )); 207 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
204 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 208 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
205 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 209 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
206 210
207 d->m_buttons->append ( b ); 211 d->m_buttons->append ( b );
208 } 212 }
209 } 213 }
210 reloadButtonMapping(); 214 reloadButtonMapping();
211} 215}
212 216
213QValueList <OLed> iPAQ::ledList() const 217QValueList <OLed> iPAQ::ledList() const
214{ 218{
215 QValueList <OLed> vl; 219 QValueList <OLed> vl;
216 vl << Led_Power; 220 vl << Led_Power;
217 221
218 if ( d->m_model == Model_iPAQ_H38xx ) 222 if ( d->m_model == Model_iPAQ_H38xx )
219 vl << Led_BlueTooth; 223 vl << Led_BlueTooth;
220 return vl; 224 return vl;
221} 225}
222 226
223QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 227QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
224{ 228{
225 QValueList <OLedState> vl; 229 QValueList <OLedState> vl;
226 230
227 if ( l == Led_Power ) 231 if ( l == Led_Power )
228 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 232 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
229 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 233 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
230 vl << Led_Off; // << Led_On << ??? 234 vl << Led_Off; // << Led_On << ???
231 235
232 return vl; 236 return vl;
233} 237}
234 238
235OLedState iPAQ::ledState ( OLed l ) const 239OLedState iPAQ::ledState ( OLed l ) const
236{ 240{
237 switch ( l ) { 241 switch ( l ) {
238 case Led_Power: 242 case Led_Power:
239 return m_leds [0]; 243 return m_leds [0];
240 case Led_BlueTooth: 244 case Led_BlueTooth:
241 return m_leds [1]; 245 return m_leds [1];
242 default: 246 default:
243 return Led_Off; 247 return Led_Off;
244 } 248 }
245} 249}
246 250
247bool iPAQ::setLedState ( OLed l, OLedState st ) 251bool iPAQ::setLedState ( OLed l, OLedState st )
248{ 252{
249 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 253 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
250 254
251 if ( l == Led_Power ) { 255 if ( l == Led_Power ) {
252 if ( fd >= 0 ) { 256 if ( fd >= 0 ) {
253 LED_IN leds; 257 LED_IN leds;
254 ::memset ( &leds, 0, sizeof( leds )); 258 ::memset ( &leds, 0, sizeof( leds ));
255 leds. TotalTime = 0; 259 leds. TotalTime = 0;
256 leds. OnTime = 0; 260 leds. OnTime = 0;
257 leds. OffTime = 1; 261 leds. OffTime = 1;
258 leds. OffOnBlink = 2; 262 leds. OffOnBlink = 2;
259 263
260 switch ( st ) { 264 switch ( st ) {
261 case Led_Off : leds. OffOnBlink = 0; break; 265 case Led_Off : leds. OffOnBlink = 0; break;
262 case Led_On : leds. OffOnBlink = 1; break; 266 case Led_On : leds. OffOnBlink = 1; break;
263 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 267 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
264 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 268 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
265 } 269 }
266 270
267 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 271 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
268 m_leds [0] = st; 272 m_leds [0] = st;
269 return true; 273 return true;
270 } 274 }
271 } 275 }
272 } 276 }
273 return false; 277 return false;
274} 278}
275 279
276 280
277bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 281bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
278{ 282{
279 int newkeycode = keycode; 283 int newkeycode = keycode;
280 284
281 switch ( keycode ) { 285 switch ( keycode ) {
282 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 286 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
283 case HardKey_Menu: { 287 case HardKey_Menu: {
284 if (( d->m_model == Model_iPAQ_H38xx ) || 288 if (( d->m_model == Model_iPAQ_H38xx ) ||
285 ( d->m_model == Model_iPAQ_H39xx ) || 289 ( d->m_model == Model_iPAQ_H39xx ) ||
286 ( d->m_model == Model_iPAQ_H5xxx)) { 290 ( d->m_model == Model_iPAQ_H5xxx)) {
287 newkeycode = HardKey_Mail; 291 newkeycode = HardKey_Mail;
288 } 292 }
289 break; 293 break;
290 } 294 }
291 295
292 // Rotate cursor keys 180 or 270 296 // Rotate cursor keys 180 or 270
293 case Key_Left : 297 case Key_Left :
294 case Key_Right: 298 case Key_Right:
295 case Key_Up : 299 case Key_Up :
296 case Key_Down : { 300 case Key_Down : {
297 if (( d->m_model == Model_iPAQ_H31xx ) || 301 if (( d->m_model == Model_iPAQ_H31xx ) ||
298 ( d->m_model == Model_iPAQ_H38xx )) { 302 ( d->m_model == Model_iPAQ_H38xx )) {
299 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 303 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
300 } 304 }
301 // Rotate the cursor keys by 270 305 // Rotate the cursor keys by 270
302 // keycode - Key_Left = position of the button starting from left clockwise 306 // keycode - Key_Left = position of the button starting from left clockwise
303 // add the rotation to it and modolo. No we've the original offset 307 // add the rotation to it and modolo. No we've the original offset
304 // add the offset to the Key_Left key 308 // add the offset to the Key_Left key
305 if (( d->m_model == Model_iPAQ_H5xxx ) || 309 if (( d->m_model == Model_iPAQ_H5xxx ) ||
306 ( d->m_model == Model_iPAQ_H191x ) || 310 ( d->m_model == Model_iPAQ_H191x ) ||
307 ( d->m_model == Model_iPAQ_H1940 )) 311 ( d->m_model == Model_iPAQ_H1940 ))
308 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 312 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
309 break; 313 break;
310 } 314 }
311 315
312 // map Power Button short/long press to F6 for h191x 316 // map Power Button short/long press to F6 for h191x
313 case Key_F6: 317 case Key_F6:
314 if ( d->m_model != Model_iPAQ_H191x ) 318 if ( d->m_model != Model_iPAQ_H191x )
315 break; 319 break;
316 // map Power Button short/long press to F34/F35 320 // map Power Button short/long press to F34/F35
317 case Key_SysReq: { 321 case Key_SysReq: {
318 if ( isPress ) { 322 if ( isPress ) {
319 if ( m_power_timer ) 323 if ( m_power_timer )
320 killTimer ( m_power_timer ); 324 killTimer ( m_power_timer );
321 m_power_timer = startTimer ( 500 ); 325 m_power_timer = startTimer ( 500 );
322 } 326 }
323 else if ( m_power_timer ) { 327 else if ( m_power_timer ) {
324 killTimer ( m_power_timer ); 328 killTimer ( m_power_timer );
325 m_power_timer = 0; 329 m_power_timer = 0;
326 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
327 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 331 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
328 } 332 }
329 newkeycode = Key_unknown; 333 newkeycode = Key_unknown;
330 break; 334 break;
331 } 335 }
332 } 336 }
333 337
334 if ( newkeycode != keycode ) { 338 if ( newkeycode != keycode ) {
335 if ( newkeycode != Key_unknown ) 339 if ( newkeycode != Key_unknown )
336 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 340 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
337 return true; 341 return true;
338 } 342 }
339 else 343 else
340 return false; 344 return false;
341} 345}
342 346
343void iPAQ::timerEvent ( QTimerEvent * ) 347void iPAQ::timerEvent ( QTimerEvent * )
344{ 348{
345 killTimer ( m_power_timer ); 349 killTimer ( m_power_timer );
346 m_power_timer = 0; 350 m_power_timer = 0;
347 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
348 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 352 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
349} 353}
350 354
351 355
352void iPAQ::playAlarmSound() 356void iPAQ::playAlarmSound()
353{ 357{
354#ifndef QT_NO_SOUND 358#ifndef QT_NO_SOUND
355 static Sound snd ( "alarm" ); 359 static Sound snd ( "alarm" );
356 if(!snd.isFinished()) 360 if(!snd.isFinished())
357 return; 361 return;
358 362
359 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 363 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
360 snd. play(); 364 snd. play();
361#endif 365#endif
362} 366}
363 367
364bool iPAQ::setDisplayBrightness ( int bright ) 368bool iPAQ::setDisplayBrightness ( int bright )
365{ 369{
366 bool res = false; 370 bool res = false;
367 int fd; 371 int fd;
368 372
369 if ( bright > 255 ) 373 if ( bright > 255 )
370 bright = 255; 374 bright = 255;
371 if ( bright < 0 ) 375 if ( bright < 0 )
372 bright = 0; 376 bright = 0;
373 377
374 QString cmdline; 378 QString cmdline;
375 379
376 switch ( model()) { 380 switch ( model()) {
377 case Model_iPAQ_H191x: 381 case Model_iPAQ_H191x:
378 if ( !bright ) 382 if ( !bright )
379 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); 383 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
380 else 384 else
381 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); 385 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
382 // No Global::shellQuote as we gurantee it to be sane 386 // No Global::shellQuote as we gurantee it to be sane
383 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 387 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
384 break; 388 break;
389
390 case Model_iPAQ_HX4700:
391 cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright );
392 // No Global::shellQuote as we gurantee it to be sane
393 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
394 break;
395
396
385 default: 397 default:
386 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 398 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
387 FLITE_IN bl; 399 FLITE_IN bl;
388 bl. mode = 1; 400 bl. mode = 1;
389 bl. pwr = bright ? 1 : 0; 401 bl. pwr = bright ? 1 : 0;
390 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 402 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
391 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 403 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
392 ::close ( fd ); 404 ::close ( fd );
393 } 405 }
394 } 406 }
395 return res; 407 return res;
396} 408}
397 409
398int iPAQ::displayBrightnessResolution() const 410int iPAQ::displayBrightnessResolution() const
399{ 411{
400 switch ( model()) { 412 switch ( model()) {
401 case Model_iPAQ_H31xx: 413 case Model_iPAQ_H31xx:
402 case Model_iPAQ_H36xx: 414 case Model_iPAQ_H36xx:
403 case Model_iPAQ_H37xx: 415 case Model_iPAQ_H37xx:
404 return 128; // really 256, but >128 could damage the LCD 416 return 128; // really 256, but >128 could damage the LCD
405 417
406 case Model_iPAQ_H38xx: 418 case Model_iPAQ_H38xx:
407 case Model_iPAQ_H39xx: 419 case Model_iPAQ_H39xx:
408 return 64; 420 return 64;
409 case Model_iPAQ_H5xxx: 421 case Model_iPAQ_H5xxx:
422 case Model_iPAQ_HX4700:
410 return 255; 423 return 255;
411 case Model_iPAQ_H191x: 424 case Model_iPAQ_H191x:
412 return 7; 425 return 7;
413 case Model_iPAQ_H1940: 426 case Model_iPAQ_H1940:
414 return 44; 427 return 44;
415 default: 428 default:
416 return 2; 429 return 2;
417 } 430 }
418} 431}
419 432
420bool iPAQ::setDisplayStatus ( bool on ) 433bool iPAQ::setDisplayStatus ( bool on )
421{ 434{
422 bool res = false; 435 bool res = false;
423 436
424 QString cmdline; 437 QString cmdline;
425 438
426 if ( model() == Model_iPAQ_H191x ) { 439 if ( model() == Model_iPAQ_H191x ) {
427 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 440 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
428 } else { 441 } else {
429 return OAbstractMobileDevice::setDisplayStatus(on); 442 return OAbstractMobileDevice::setDisplayStatus(on);
430 } 443 }
431 444
432 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 445 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
433 446
434 return res; 447 return res;
435} 448}
436 449
437bool iPAQ::hasLightSensor() const 450bool iPAQ::hasLightSensor() const
438{ 451{
439 return true; 452 return true;
440} 453}
441 454
442int iPAQ::readLightSensor() 455int iPAQ::readLightSensor()
443{ 456{
444 int fd; 457 int fd;
445 int val = -1; 458 int val = -1;
446 459
447 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 460 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
448 char buffer [8]; 461 char buffer [8];
449 462
450 if ( ::read ( fd, buffer, 5 ) == 5 ) { 463 if ( ::read ( fd, buffer, 5 ) == 5 ) {
451 char *endptr; 464 char *endptr;
452 465
453 buffer [4] = 0; 466 buffer [4] = 0;
454 val = ::strtol ( buffer + 2, &endptr, 16 ); 467 val = ::strtol ( buffer + 2, &endptr, 16 );
455 468
456 if ( *endptr != 0 ) 469 if ( *endptr != 0 )
457 val = -1; 470 val = -1;
458 } 471 }
459 ::close ( fd ); 472 ::close ( fd );
460 } 473 }
461 474
462 return val; 475 return val;
463} 476}
464 477
465int iPAQ::lightSensorResolution() const 478int iPAQ::lightSensorResolution() const
466{ 479{
467 return 256; 480 return 256;
468} 481}