summaryrefslogtreecommitdiff
authorzecke <zecke>2005-10-06 18:58:40 (UTC)
committer zecke <zecke>2005-10-06 18:58:40 (UTC)
commit0bad2116a1ceed19956b94889cb034781f35146d (patch) (unidiff)
treea1131b9e026cdf5533c4da6a7f49fcbb139b4e09
parent31777172abf127e00594790e4365dfad8772b100 (diff)
downloadopie-0bad2116a1ceed19956b94889cb034781f35146d.zip
opie-0bad2116a1ceed19956b94889cb034781f35146d.tar.gz
opie-0bad2116a1ceed19956b94889cb034781f35146d.tar.bz2
ODevice patch from #1701 gor hp1940
-Allocate device number -Some implementation
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.h1
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp8
2 files changed, 8 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 492c97b..c70d2af 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,391 +1,392 @@
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 73
73 Model_Jornada = ( 6 << 16 ), 74 Model_Jornada = ( 6 << 16 ),
74 Model_Jornada_56x = ( Model_Jornada | 0x0001 ), 75 Model_Jornada_56x = ( Model_Jornada | 0x0001 ),
75 Model_Jornada_720 = ( Model_Jornada | 0x0002 ), 76 Model_Jornada_720 = ( Model_Jornada | 0x0002 ),
76 77
77 Model_Zaurus = ( 2 << 16 ), 78 Model_Zaurus = ( 2 << 16 ),
78 79
79 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), 80 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ),
80 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), 81 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ),
81 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), 82 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ),
82 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), 83 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ),
83 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), 84 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ),
84 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ), 85 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ),
85 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ), 86 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ),
86 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ), 87 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ),
87 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ), 88 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ),
88 89
89 Model_SIMpad = ( 3 << 16 ), 90 Model_SIMpad = ( 3 << 16 ),
90 91
91 Model_SIMpad_All = ( Model_SIMpad | 0xffff ), 92 Model_SIMpad_All = ( Model_SIMpad | 0xffff ),
92 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), 93 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ),
93 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), 94 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ),
94 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), 95 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ),
95 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), 96 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ),
96 97
97 Model_Ramses = ( 4 << 16 ), 98 Model_Ramses = ( 4 << 16 ),
98 99
99 Model_Ramses_All = ( Model_Ramses | 0xffff ), 100 Model_Ramses_All = ( Model_Ramses | 0xffff ),
100 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), 101 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ),
101 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), 102 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ),
102 103
103 Model_Yopy = ( 5 << 16 ), 104 Model_Yopy = ( 5 << 16 ),
104 105
105 Model_Yopy_All = ( Model_Yopy | 0xffff ), 106 Model_Yopy_All = ( Model_Yopy | 0xffff ),
106 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), 107 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ),
107 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), 108 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ),
108 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), 109 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ),
109 110
110 Model_Beagle = ( 6 << 16 ), 111 Model_Beagle = ( 6 << 16 ),
111 112
112 Model_Beagle_All = ( Model_Beagle | 0xffff ), 113 Model_Beagle_All = ( Model_Beagle | 0xffff ),
113 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), 114 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ),
114 115
115 Model_GenuineIntel = ( 7 << 16 ), 116 Model_GenuineIntel = ( 7 << 16 ),
116 117
117 Model_MyPal = ( 8 << 16 ), 118 Model_MyPal = ( 8 << 16 ),
118 119
119 Model_MyPal_All = ( Model_MyPal | 0xffff ), 120 Model_MyPal_All = ( Model_MyPal | 0xffff ),
120 Model_MyPal_620 = ( Model_MyPal | 0x0001 ), 121 Model_MyPal_620 = ( Model_MyPal | 0x0001 ),
121 Model_MyPal_716 = ( Model_MyPal | 0x0002 ), 122 Model_MyPal_716 = ( Model_MyPal | 0x0002 ),
122 Model_MyPal_730 = ( Model_MyPal | 0x0003 ) 123 Model_MyPal_730 = ( Model_MyPal | 0x0003 )
123}; 124};
124 125
125/** 126/**
126 * The vendor of the device 127 * The vendor of the device
127 */ 128 */
128enum OVendor { 129enum OVendor {
129 Vendor_Unknown, 130 Vendor_Unknown,
130 131
131 Vendor_HP, 132 Vendor_HP,
132 Vendor_Sharp, 133 Vendor_Sharp,
133 Vendor_SIEMENS, 134 Vendor_SIEMENS,
134 Vendor_MundN, 135 Vendor_MundN,
135 Vendor_GMate, 136 Vendor_GMate,
136 Vendor_MasterIA, 137 Vendor_MasterIA,
137 Vendor_GenuineIntel, 138 Vendor_GenuineIntel,
138 Vendor_Asus 139 Vendor_Asus
139}; 140};
140 141
141/** 142/**
142 * The System used 143 * The System used
143 */ 144 */
144enum OSystem { 145enum OSystem {
145 System_Unknown, 146 System_Unknown,
146 147
147 System_Familiar, 148 System_Familiar,
148 System_Zaurus, 149 System_Zaurus,
149 System_OpenZaurus, 150 System_OpenZaurus,
150 System_Linupy, 151 System_Linupy,
151 System_OpenEmbedded, 152 System_OpenEmbedded,
152 System_PC 153 System_PC
153}; 154};
154 155
155typedef struct { 156typedef struct {
156 OSystem system; 157 OSystem system;
157 char* sysstr; 158 char* sysstr;
158 char* sysvfile; 159 char* sysvfile;
159} ODistribution; 160} ODistribution;
160 161
161extern ODistribution distributions[]; 162extern ODistribution distributions[];
162 163
163 164
164enum OLedState { 165enum OLedState {
165 Led_Off, 166 Led_Off,
166 Led_On, 167 Led_On,
167 Led_BlinkSlow, 168 Led_BlinkSlow,
168 Led_BlinkFast 169 Led_BlinkFast
169}; 170};
170 171
171enum OLed { 172enum OLed {
172 Led_Mail, 173 Led_Mail,
173 Led_Power, 174 Led_Power,
174 Led_BlueTooth 175 Led_BlueTooth
175}; 176};
176 177
177enum OHardKey { 178enum OHardKey {
178 HardKey_Datebook = Qt::Key_F9, 179 HardKey_Datebook = Qt::Key_F9,
179 HardKey_Contacts = Qt::Key_F10, 180 HardKey_Contacts = Qt::Key_F10,
180 HardKey_Menu = Qt::Key_F11, 181 HardKey_Menu = Qt::Key_F11,
181 HardKey_Home = Qt::Key_F12, 182 HardKey_Home = Qt::Key_F12,
182 HardKey_Mail = Qt::Key_F13, 183 HardKey_Mail = Qt::Key_F13,
183 HardKey_Record = Qt::Key_F24, 184 HardKey_Record = Qt::Key_F24,
184 HardKey_Suspend = Qt::Key_F34, 185 HardKey_Suspend = Qt::Key_F34,
185 HardKey_Backlight = Qt::Key_F35, 186 HardKey_Backlight = Qt::Key_F35,
186 HardKey_Action = Qt::Key_F10, 187 HardKey_Action = Qt::Key_F10,
187 HardKey_OK = Qt::Key_F11, 188 HardKey_OK = Qt::Key_F11,
188 HardKey_End = Qt::Key_F12, 189 HardKey_End = Qt::Key_F12,
189}; 190};
190 191
191enum ODirection { 192enum ODirection {
192 CW = 0, 193 CW = 0,
193 CCW = 1, 194 CCW = 1,
194 Flip = 2, 195 Flip = 2,
195}; 196};
196 197
197enum OHingeStatus { 198enum OHingeStatus {
198 CASE_CLOSED = 3, 199 CASE_CLOSED = 3,
199 CASE_PORTRAIT = 2, 200 CASE_PORTRAIT = 2,
200 CASE_LANDSCAPE = 0, 201 CASE_LANDSCAPE = 0,
201 CASE_UNKNOWN = 1, 202 CASE_UNKNOWN = 1,
202}; 203};
203 204
204/* default button for qvfb or such 205/* default button for qvfb or such
205 * see odevice.cpp for details. 206 * see odevice.cpp for details.
206 * hint: manage a user defined button for qvfb? 207 * hint: manage a user defined button for qvfb?
207 * alwin 208 * alwin
208 */ 209 */
209struct default_button { 210struct default_button {
210 Qt::Key code; 211 Qt::Key code;
211 char *utext; 212 char *utext;
212 char *pix; 213 char *pix;
213 char *fpressedservice; 214 char *fpressedservice;
214 char *fpressedaction; 215 char *fpressedaction;
215 char *fheldservice; 216 char *fheldservice;
216 char *fheldaction; 217 char *fheldaction;
217}; 218};
218 219
219/** 220/**
220 * A singleton which gives informations about device specefic option 221 * A singleton which gives informations about device specefic option
221 * like the Hardware used, LEDs, the Base Distribution and 222 * like the Hardware used, LEDs, the Base Distribution and
222 * hardware key mappings. 223 * hardware key mappings.
223 * 224 *
224 * @short A small class for device specific options 225 * @short A small class for device specific options
225 * @see QObject 226 * @see QObject
226 * @author Robert Griebl 227 * @author Robert Griebl
227 * @version 1.0 228 * @version 1.0
228 */ 229 */
229class ODevice : public QObject 230class ODevice : public QObject
230{ 231{
231 Q_OBJECT 232 Q_OBJECT
232 233
233private: 234private:
234 /* disable copy */ 235 /* disable copy */
235 ODevice ( const ODevice & ); 236 ODevice ( const ODevice & );
236 237
237protected: 238protected:
238 ODevice(); 239 ODevice();
239 virtual void init(const QString&); 240 virtual void init(const QString&);
240 virtual void initButtons(); 241 virtual void initButtons();
241 static void sendSuspendmsg(); 242 static void sendSuspendmsg();
242 243
243 ODeviceData *d; 244 ODeviceData *d;
244 245
245public: 246public:
246 // sandman do we want to allow destructions? -zecke? 247 // sandman do we want to allow destructions? -zecke?
247 virtual ~ODevice(); 248 virtual ~ODevice();
248 static ODevice *inst(); 249 static ODevice *inst();
249 250
250 // information 251 // information
251 QString modelString() const; 252 QString modelString() const;
252 OModel model() const; 253 OModel model() const;
253 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 254 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
254 255
255 QString vendorString() const; 256 QString vendorString() const;
256 OVendor vendor() const; 257 OVendor vendor() const;
257 258
258 QString systemString() const; 259 QString systemString() const;
259 OSystem system() const; 260 OSystem system() const;
260 261
261 QString systemVersionString() const; 262 QString systemVersionString() const;
262 263
263 virtual Transformation rotation() const; 264 virtual Transformation rotation() const;
264 virtual ODirection direction() const; 265 virtual ODirection direction() const;
265 266
266 QString qteDriver() const; 267 QString qteDriver() const;
267 268
268 // system 269 // system
269 virtual bool suspend(); 270 virtual bool suspend();
270 271
271 virtual bool setDisplayStatus ( bool on ); 272 virtual bool setDisplayStatus ( bool on );
272 virtual bool setDisplayBrightness ( int brightness ); 273 virtual bool setDisplayBrightness ( int brightness );
273 virtual int displayBrightnessResolution() const; 274 virtual int displayBrightnessResolution() const;
274 virtual bool setDisplayContrast ( int contrast ); 275 virtual bool setDisplayContrast ( int contrast );
275 virtual int displayContrastResolution() const; 276 virtual int displayContrastResolution() const;
276 277
277 // don't add new virtual methods, use this: 278 // don't add new virtual methods, use this:
278 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 279 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
279 // and in your subclass do overwrite 280 // and in your subclass do overwrite
280 // protected virtual int virtual_hook(int, void *) 281 // protected virtual int virtual_hook(int, void *)
281 // which is defined below 282 // which is defined below
282 283
283 // input / output 284 // input / output
284 virtual void playAlarmSound(); 285 virtual void playAlarmSound();
285 virtual void playKeySound(); 286 virtual void playKeySound();
286 virtual void playTouchSound(); 287 virtual void playTouchSound();
287 288
288 virtual QValueList <OLed> ledList() const; 289 virtual QValueList <OLed> ledList() const;
289 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 290 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
290 virtual OLedState ledState ( OLed led ) const; 291 virtual OLedState ledState ( OLed led ) const;
291 virtual bool setLedState ( OLed led, OLedState st ); 292 virtual bool setLedState ( OLed led, OLedState st );
292 293
293 virtual bool hasLightSensor() const; 294 virtual bool hasLightSensor() const;
294 virtual int readLightSensor(); 295 virtual int readLightSensor();
295 virtual int lightSensorResolution() const; 296 virtual int lightSensorResolution() const;
296 297
297 virtual bool hasHingeSensor() const; 298 virtual bool hasHingeSensor() const;
298 virtual OHingeStatus readHingeSensor()const; 299 virtual OHingeStatus readHingeSensor()const;
299 300
300 const QStrList &allowedCpuFrequencies() const; 301 const QStrList &allowedCpuFrequencies() const;
301 bool setCurrentCpuFrequency(uint index); 302 bool setCurrentCpuFrequency(uint index);
302 303
303 /** 304 /**
304 * Returns the available buttons on this device. The number and location 305 * Returns the available buttons on this device. The number and location
305 * of buttons will vary depending on the device. Button numbers will be assigned 306 * of buttons will vary depending on the device. Button numbers will be assigned
306 * by the device manufacturer and will be from most preferred button to least preffered 307 * by the device manufacturer and will be from most preferred button to least preffered
307 * button. Note that this list only contains "user mappable" buttons. 308 * button. Note that this list only contains "user mappable" buttons.
308 * 309 *
309 * @todo Make method const and take care of calling initButtons or make that const too 310 * @todo Make method const and take care of calling initButtons or make that const too
310 * 311 *
311 */ 312 */
312 const QValueList<ODeviceButton> &buttons(); 313 const QValueList<ODeviceButton> &buttons();
313 314
314 /** 315 /**
315 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 316 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
316 * returns 0L 317 * returns 0L
317 */ 318 */
318 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 319 const ODeviceButton *buttonForKeycode ( ushort keyCode );
319 320
320 /** 321 /**
321 * Reassigns the pressed action for \a button. To return to the factory 322 * Reassigns the pressed action for \a button. To return to the factory
322 * default pass an empty string as \a qcopMessage. 323 * default pass an empty string as \a qcopMessage.
323 */ 324 */
324 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 325 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
325 326
326 /** 327 /**
327 * Reassigns the held action for \a button. To return to the factory 328 * Reassigns the held action for \a button. To return to the factory
328 * default pass an empty string as \a qcopMessage. 329 * default pass an empty string as \a qcopMessage.
329 */ 330 */
330 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 331 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
331 332
332 /** 333 /**
333 * How long (in ms) you have to press a button for a "hold" action 334 * How long (in ms) you have to press a button for a "hold" action
334 */ 335 */
335 uint buttonHoldTime() const; 336 uint buttonHoldTime() const;
336 337
337signals: 338signals:
338 void buttonMappingChanged(); 339 void buttonMappingChanged();
339 340
340private slots: 341private slots:
341 void systemMessage ( const QCString &, const QByteArray & ); 342 void systemMessage ( const QCString &, const QByteArray & );
342 void playingStopped(); 343 void playingStopped();
343 344
344protected: 345protected:
345 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 346 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
346 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 347 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
347 void reloadButtonMapping(); 348 void reloadButtonMapping();
348 void changeMixerForAlarm( int mixer, const char* file, Sound *snd); 349 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
349 350
350 /* ugly virtual hook */ 351 /* ugly virtual hook */
351 virtual void virtual_hook( int id, void* data ); 352 virtual void virtual_hook( int id, void* data );
352}; 353};
353 354
354class ODeviceData { 355class ODeviceData {
355 356
356 public: 357 public:
357 QString m_vendorstr; 358 QString m_vendorstr;
358 OVendor m_vendor; 359 OVendor m_vendor;
359 360
360 QString m_modelstr; 361 QString m_modelstr;
361 OModel m_model; 362 OModel m_model;
362 363
363 QString m_systemstr; 364 QString m_systemstr;
364 OSystem m_system; 365 OSystem m_system;
365 366
366 QString m_sysverstr; 367 QString m_sysverstr;
367 368
368 Transformation m_rotation; 369 Transformation m_rotation;
369 ODirection m_direction; 370 ODirection m_direction;
370 371
371 QString m_qteDriver; 372 QString m_qteDriver;
372 373
373 QValueList <ODeviceButton> *m_buttons; 374 QValueList <ODeviceButton> *m_buttons;
374 uint m_holdtime; 375 uint m_holdtime;
375 QStrList *m_cpu_frequencies; 376 QStrList *m_cpu_frequencies;
376 bool m_initializedButtonQcop : 1; 377 bool m_initializedButtonQcop : 1;
377 378
378 /* values for changeMixerForAlarm */ 379 /* values for changeMixerForAlarm */
379 int m_sound, m_vol, m_mixer; 380 int m_sound, m_vol, m_mixer;
380}; 381};
381 382
382extern bool isQWS(); 383extern bool isQWS();
383extern QCString makeChannel ( const char *str ); 384extern QCString makeChannel ( const char *str );
384} 385}
385} 386}
386 387
387 388
388 389
389 390
390#endif 391#endif
391 392
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 3cc6cec..52da2d9 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,458 +1,464 @@
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" )
155 d->m_model = Model_iPAQ_H1940;
154 else 156 else
155 d->m_model = Model_Unknown; 157 d->m_model = Model_Unknown;
156 158
157 switch ( d->m_model ) { 159 switch ( d->m_model ) {
158 case Model_iPAQ_H31xx: 160 case Model_iPAQ_H31xx:
159 case Model_iPAQ_H38xx: 161 case Model_iPAQ_H38xx:
160 d->m_rotation = Rot90; 162 d->m_rotation = Rot90;
161 break; 163 break;
162 case Model_iPAQ_H5xxx: 164 case Model_iPAQ_H5xxx:
163 case Model_iPAQ_H22xx: 165 case Model_iPAQ_H22xx:
164 case Model_iPAQ_H191x: 166 case Model_iPAQ_H191x:
167 case Model_iPAQ_H1940:
165 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
166 break; 169 break;
167 case Model_iPAQ_H36xx: 170 case Model_iPAQ_H36xx:
168 case Model_iPAQ_H37xx: 171 case Model_iPAQ_H37xx:
169 case Model_iPAQ_H39xx: 172 case Model_iPAQ_H39xx:
170 default: 173 default:
171 d->m_rotation = Rot270; 174 d->m_rotation = Rot270;
172 break; 175 break;
173 176
174 } 177 }
175 178
176 m_leds [0] = m_leds [1] = Led_Off; 179 m_leds [0] = m_leds [1] = Led_Off;
177 180
178 m_power_timer = 0; 181 m_power_timer = 0;
179 182
180} 183}
181 184
182void iPAQ::initButtons() 185void iPAQ::initButtons()
183{ 186{
184 if ( d->m_buttons ) 187 if ( d->m_buttons )
185 return; 188 return;
186 189
187 if ( isQWS( ) ) { 190 if ( isQWS( ) ) {
188 addPreHandler(this); 191 addPreHandler(this);
189 } 192 }
190 193
191 d->m_buttons = new QValueList <ODeviceButton>; 194 d->m_buttons = new QValueList <ODeviceButton>;
192 195
193 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 196 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
194 i_button *ib = ipaq_buttons + i; 197 i_button *ib = ipaq_buttons + i;
195 ODeviceButton b; 198 ODeviceButton b;
196 199
197 if (( ib->model & d->m_model ) == d->m_model ) { 200 if (( ib->model & d->m_model ) == d->m_model ) {
198 b. setKeycode ( ib->code ); 201 b. setKeycode ( ib->code );
199 b. setUserText ( QObject::tr ( "Button", ib->utext )); 202 b. setUserText ( QObject::tr ( "Button", ib->utext ));
200 b. setPixmap ( OResource::loadPixmap ( ib->pix )); 203 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
201 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 204 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
202 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 205 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
203 206
204 d->m_buttons->append ( b ); 207 d->m_buttons->append ( b );
205 } 208 }
206 } 209 }
207 reloadButtonMapping(); 210 reloadButtonMapping();
208} 211}
209 212
210QValueList <OLed> iPAQ::ledList() const 213QValueList <OLed> iPAQ::ledList() const
211{ 214{
212 QValueList <OLed> vl; 215 QValueList <OLed> vl;
213 vl << Led_Power; 216 vl << Led_Power;
214 217
215 if ( d->m_model == Model_iPAQ_H38xx ) 218 if ( d->m_model == Model_iPAQ_H38xx )
216 vl << Led_BlueTooth; 219 vl << Led_BlueTooth;
217 return vl; 220 return vl;
218} 221}
219 222
220QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 223QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
221{ 224{
222 QValueList <OLedState> vl; 225 QValueList <OLedState> vl;
223 226
224 if ( l == Led_Power ) 227 if ( l == Led_Power )
225 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 228 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
226 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 229 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
227 vl << Led_Off; // << Led_On << ??? 230 vl << Led_Off; // << Led_On << ???
228 231
229 return vl; 232 return vl;
230} 233}
231 234
232OLedState iPAQ::ledState ( OLed l ) const 235OLedState iPAQ::ledState ( OLed l ) const
233{ 236{
234 switch ( l ) { 237 switch ( l ) {
235 case Led_Power: 238 case Led_Power:
236 return m_leds [0]; 239 return m_leds [0];
237 case Led_BlueTooth: 240 case Led_BlueTooth:
238 return m_leds [1]; 241 return m_leds [1];
239 default: 242 default:
240 return Led_Off; 243 return Led_Off;
241 } 244 }
242} 245}
243 246
244bool iPAQ::setLedState ( OLed l, OLedState st ) 247bool iPAQ::setLedState ( OLed l, OLedState st )
245{ 248{
246 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 249 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
247 250
248 if ( l == Led_Power ) { 251 if ( l == Led_Power ) {
249 if ( fd >= 0 ) { 252 if ( fd >= 0 ) {
250 LED_IN leds; 253 LED_IN leds;
251 ::memset ( &leds, 0, sizeof( leds )); 254 ::memset ( &leds, 0, sizeof( leds ));
252 leds. TotalTime = 0; 255 leds. TotalTime = 0;
253 leds. OnTime = 0; 256 leds. OnTime = 0;
254 leds. OffTime = 1; 257 leds. OffTime = 1;
255 leds. OffOnBlink = 2; 258 leds. OffOnBlink = 2;
256 259
257 switch ( st ) { 260 switch ( st ) {
258 case Led_Off : leds. OffOnBlink = 0; break; 261 case Led_Off : leds. OffOnBlink = 0; break;
259 case Led_On : leds. OffOnBlink = 1; break; 262 case Led_On : leds. OffOnBlink = 1; break;
260 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 263 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
261 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 264 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
262 } 265 }
263 266
264 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 267 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
265 m_leds [0] = st; 268 m_leds [0] = st;
266 return true; 269 return true;
267 } 270 }
268 } 271 }
269 } 272 }
270 return false; 273 return false;
271} 274}
272 275
273 276
274bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 277bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
275{ 278{
276 int newkeycode = keycode; 279 int newkeycode = keycode;
277 280
278 switch ( keycode ) { 281 switch ( keycode ) {
279 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 282 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
280 case HardKey_Menu: { 283 case HardKey_Menu: {
281 if (( d->m_model == Model_iPAQ_H38xx ) || 284 if (( d->m_model == Model_iPAQ_H38xx ) ||
282 ( d->m_model == Model_iPAQ_H39xx ) || 285 ( d->m_model == Model_iPAQ_H39xx ) ||
283 ( d->m_model == Model_iPAQ_H5xxx)) { 286 ( d->m_model == Model_iPAQ_H5xxx)) {
284 newkeycode = HardKey_Mail; 287 newkeycode = HardKey_Mail;
285 } 288 }
286 break; 289 break;
287 } 290 }
288 291
289 // Rotate cursor keys 180 or 270 292 // Rotate cursor keys 180 or 270
290 case Key_Left : 293 case Key_Left :
291 case Key_Right: 294 case Key_Right:
292 case Key_Up : 295 case Key_Up :
293 case Key_Down : { 296 case Key_Down : {
294 if (( d->m_model == Model_iPAQ_H31xx ) || 297 if (( d->m_model == Model_iPAQ_H31xx ) ||
295 ( d->m_model == Model_iPAQ_H38xx )) { 298 ( d->m_model == Model_iPAQ_H38xx )) {
296 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 299 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
297 } 300 }
298 // Rotate the cursor keys by 270 301 // Rotate the cursor keys by 270
299 // keycode - Key_Left = position of the button starting from left clockwise 302 // keycode - Key_Left = position of the button starting from left clockwise
300 // add the rotation to it and modolo. No we've the original offset 303 // add the rotation to it and modolo. No we've the original offset
301 // add the offset to the Key_Left key 304 // add the offset to the Key_Left key
302 if (( d->m_model == Model_iPAQ_H5xxx ) || 305 if (( d->m_model == Model_iPAQ_H5xxx ) ||
303 ( d->m_model == Model_iPAQ_H191x )) 306 ( d->m_model == Model_iPAQ_H191x ) ||
307 ( d->m_model == Model_iPAQ_H1940 ))
304 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 308 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
305 break; 309 break;
306 } 310 }
307 311
308 // map Power Button short/long press to F34/F35 312 // map Power Button short/long press to F34/F35
309 case Key_SysReq: { 313 case Key_SysReq: {
310 if ( isPress ) { 314 if ( isPress ) {
311 if ( m_power_timer ) 315 if ( m_power_timer )
312 killTimer ( m_power_timer ); 316 killTimer ( m_power_timer );
313 m_power_timer = startTimer ( 500 ); 317 m_power_timer = startTimer ( 500 );
314 } 318 }
315 else if ( m_power_timer ) { 319 else if ( m_power_timer ) {
316 killTimer ( m_power_timer ); 320 killTimer ( m_power_timer );
317 m_power_timer = 0; 321 m_power_timer = 0;
318 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 322 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
319 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 323 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
320 } 324 }
321 newkeycode = Key_unknown; 325 newkeycode = Key_unknown;
322 break; 326 break;
323 } 327 }
324 } 328 }
325 329
326 if ( newkeycode != keycode ) { 330 if ( newkeycode != keycode ) {
327 if ( newkeycode != Key_unknown ) 331 if ( newkeycode != Key_unknown )
328 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 332 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
329 return true; 333 return true;
330 } 334 }
331 else 335 else
332 return false; 336 return false;
333} 337}
334 338
335void iPAQ::timerEvent ( QTimerEvent * ) 339void iPAQ::timerEvent ( QTimerEvent * )
336{ 340{
337 killTimer ( m_power_timer ); 341 killTimer ( m_power_timer );
338 m_power_timer = 0; 342 m_power_timer = 0;
339 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 343 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
340 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 344 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
341} 345}
342 346
343 347
344void iPAQ::playAlarmSound() 348void iPAQ::playAlarmSound()
345{ 349{
346#ifndef QT_NO_SOUND 350#ifndef QT_NO_SOUND
347 static Sound snd ( "alarm" ); 351 static Sound snd ( "alarm" );
348 if(!snd.isFinished()) 352 if(!snd.isFinished())
349 return; 353 return;
350 354
351 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 355 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
352 snd. play(); 356 snd. play();
353#endif 357#endif
354} 358}
355 359
356bool iPAQ::setDisplayBrightness ( int bright ) 360bool iPAQ::setDisplayBrightness ( int bright )
357{ 361{
358 bool res = false; 362 bool res = false;
359 int fd; 363 int fd;
360 364
361 if ( bright > 255 ) 365 if ( bright > 255 )
362 bright = 255; 366 bright = 255;
363 if ( bright < 0 ) 367 if ( bright < 0 )
364 bright = 0; 368 bright = 0;
365 369
366 QString cmdline; 370 QString cmdline;
367 371
368 switch ( model()) { 372 switch ( model()) {
369 case Model_iPAQ_H191x: 373 case Model_iPAQ_H191x:
370 if ( !bright ) 374 if ( !bright )
371 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); 375 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
372 else 376 else
373 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); 377 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
374 // No Global::shellQuote as we gurantee it to be sane 378 // No Global::shellQuote as we gurantee it to be sane
375 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 379 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
376 break; 380 break;
377 default: 381 default:
378 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 382 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
379 FLITE_IN bl; 383 FLITE_IN bl;
380 bl. mode = 1; 384 bl. mode = 1;
381 bl. pwr = bright ? 1 : 0; 385 bl. pwr = bright ? 1 : 0;
382 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 386 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
383 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 387 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
384 ::close ( fd ); 388 ::close ( fd );
385 } 389 }
386 } 390 }
387 return res; 391 return res;
388} 392}
389 393
390int iPAQ::displayBrightnessResolution() const 394int iPAQ::displayBrightnessResolution() const
391{ 395{
392 switch ( model()) { 396 switch ( model()) {
393 case Model_iPAQ_H31xx: 397 case Model_iPAQ_H31xx:
394 case Model_iPAQ_H36xx: 398 case Model_iPAQ_H36xx:
395 case Model_iPAQ_H37xx: 399 case Model_iPAQ_H37xx:
396 return 128; // really 256, but >128 could damage the LCD 400 return 128; // really 256, but >128 could damage the LCD
397 401
398 case Model_iPAQ_H38xx: 402 case Model_iPAQ_H38xx:
399 case Model_iPAQ_H39xx: 403 case Model_iPAQ_H39xx:
400 return 64; 404 return 64;
401 case Model_iPAQ_H5xxx: 405 case Model_iPAQ_H5xxx:
402 return 255; 406 return 255;
403 case Model_iPAQ_H191x: 407 case Model_iPAQ_H191x:
404 return 183; 408 return 183;
409 case Model_iPAQ_H191x:
410 return 44;
405 default: 411 default:
406 return 2; 412 return 2;
407 } 413 }
408} 414}
409 415
410bool iPAQ::setDisplayStatus ( bool on ) 416bool iPAQ::setDisplayStatus ( bool on )
411{ 417{
412 bool res = false; 418 bool res = false;
413 419
414 QString cmdline; 420 QString cmdline;
415 421
416 if ( model() == Model_iPAQ_H191x ) { 422 if ( model() == Model_iPAQ_H191x ) {
417 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" ); 423 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" );
418 } else { 424 } else {
419 return OAbstractMobileDevice::setDisplayStatus(on); 425 return OAbstractMobileDevice::setDisplayStatus(on);
420 } 426 }
421 427
422 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 428 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
423 429
424 return res; 430 return res;
425} 431}
426 432
427bool iPAQ::hasLightSensor() const 433bool iPAQ::hasLightSensor() const
428{ 434{
429 return true; 435 return true;
430} 436}
431 437
432int iPAQ::readLightSensor() 438int iPAQ::readLightSensor()
433{ 439{
434 int fd; 440 int fd;
435 int val = -1; 441 int val = -1;
436 442
437 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 443 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
438 char buffer [8]; 444 char buffer [8];
439 445
440 if ( ::read ( fd, buffer, 5 ) == 5 ) { 446 if ( ::read ( fd, buffer, 5 ) == 5 ) {
441 char *endptr; 447 char *endptr;
442 448
443 buffer [4] = 0; 449 buffer [4] = 0;
444 val = ::strtol ( buffer + 2, &endptr, 16 ); 450 val = ::strtol ( buffer + 2, &endptr, 16 );
445 451
446 if ( *endptr != 0 ) 452 if ( *endptr != 0 )
447 val = -1; 453 val = -1;
448 } 454 }
449 ::close ( fd ); 455 ::close ( fd );
450 } 456 }
451 457
452 return val; 458 return val;
453} 459}
454 460
455int iPAQ::lightSensorResolution() const 461int iPAQ::lightSensorResolution() const
456{ 462{
457 return 256; 463 return 256;
458} 464}