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