summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.h1
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
2 files changed, 5 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 762d3f1..cb7a83f 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,361 +1,362 @@
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#include <qstrlist.h> 41#include <qstrlist.h>
42#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
43 43
44namespace Opie{ 44namespace Opie{
45namespace Core{ 45namespace Core{
46 46
47 class ODeviceData; 47 class ODeviceData;
48/** 48/**
49 * The available devices 49 * The available devices
50 */ 50 */
51enum OModel { 51enum OModel {
52 Model_Unknown, // = 0 52 Model_Unknown, // = 0
53 53
54 Model_Series_Mask = 0xff000000, 54 Model_Series_Mask = 0xff000000,
55 55
56 Model_iPAQ = ( 1 << 24 ), 56 Model_iPAQ = ( 1 << 24 ),
57 57
58 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 58 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
59 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 59 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
60 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 60 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
61 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 61 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
62 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 62 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
63 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 63 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
64 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 64 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
65 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 65 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
66 66
67 Model_Jornada = ( 6 << 24 ), 67 Model_Jornada = ( 6 << 24 ),
68 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 68 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
69 69
70 Model_Zaurus = ( 2 << 24 ), 70 Model_Zaurus = ( 2 << 24 ),
71 71
72 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 72 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
73 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 73 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
74 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 74 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
75 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 75 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
76 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 76 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
77 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ),
77 78
78 Model_SIMpad = ( 3 << 24 ), 79 Model_SIMpad = ( 3 << 24 ),
79 80
80 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 81 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
81 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 82 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
82 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 83 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
83 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 84 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
84 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 85 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
85 86
86 Model_Ramses = ( 4 << 24 ), 87 Model_Ramses = ( 4 << 24 ),
87 88
88 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 89 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
89 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 90 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
90 91
91 Model_Yopy = ( 5 << 24 ), 92 Model_Yopy = ( 5 << 24 ),
92 93
93 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 94 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
94 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 95 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
95 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 96 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
96 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 97 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
97 98
98 Model_Beagle = ( 6 << 24 ), 99 Model_Beagle = ( 6 << 24 ),
99 100
100 Model_Beagle_All = ( Model_Beagle | 0xffffff ), 101 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
101 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), 102 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
102 103
103}; 104};
104 105
105/** 106/**
106 * The vendor of the device 107 * The vendor of the device
107 */ 108 */
108enum OVendor { 109enum OVendor {
109 Vendor_Unknown, 110 Vendor_Unknown,
110 111
111 Vendor_HP, 112 Vendor_HP,
112 Vendor_Sharp, 113 Vendor_Sharp,
113 Vendor_SIEMENS, 114 Vendor_SIEMENS,
114 Vendor_MundN, 115 Vendor_MundN,
115 Vendor_GMate, 116 Vendor_GMate,
116 Vendor_MasterIA, 117 Vendor_MasterIA,
117}; 118};
118 119
119/** 120/**
120 * The System used 121 * The System used
121 */ 122 */
122enum OSystem { 123enum OSystem {
123 System_Unknown, 124 System_Unknown,
124 125
125 System_Familiar, 126 System_Familiar,
126 System_Zaurus, 127 System_Zaurus,
127 System_OpenZaurus, 128 System_OpenZaurus,
128 System_Linupy, 129 System_Linupy,
129 System_OpenEmbedded, 130 System_OpenEmbedded,
130}; 131};
131 132
132typedef struct { 133typedef struct {
133 OSystem system; 134 OSystem system;
134 char* sysstr; 135 char* sysstr;
135 char* sysvfile; 136 char* sysvfile;
136} ODistribution; 137} ODistribution;
137 138
138extern ODistribution distributions[]; 139extern ODistribution distributions[];
139 140
140 141
141enum OLedState { 142enum OLedState {
142 Led_Off, 143 Led_Off,
143 Led_On, 144 Led_On,
144 Led_BlinkSlow, 145 Led_BlinkSlow,
145 Led_BlinkFast 146 Led_BlinkFast
146}; 147};
147 148
148enum OLed { 149enum OLed {
149 Led_Mail, 150 Led_Mail,
150 Led_Power, 151 Led_Power,
151 Led_BlueTooth 152 Led_BlueTooth
152}; 153};
153 154
154enum OHardKey { 155enum OHardKey {
155 HardKey_Datebook = Qt::Key_F9, 156 HardKey_Datebook = Qt::Key_F9,
156 HardKey_Contacts = Qt::Key_F10, 157 HardKey_Contacts = Qt::Key_F10,
157 HardKey_Menu = Qt::Key_F11, 158 HardKey_Menu = Qt::Key_F11,
158 HardKey_Home = Qt::Key_F12, 159 HardKey_Home = Qt::Key_F12,
159 HardKey_Mail = Qt::Key_F13, 160 HardKey_Mail = Qt::Key_F13,
160 HardKey_Record = Qt::Key_F24, 161 HardKey_Record = Qt::Key_F24,
161 HardKey_Suspend = Qt::Key_F34, 162 HardKey_Suspend = Qt::Key_F34,
162 HardKey_Backlight = Qt::Key_F35, 163 HardKey_Backlight = Qt::Key_F35,
163 HardKey_Action = Qt::Key_F10, 164 HardKey_Action = Qt::Key_F10,
164 HardKey_OK = Qt::Key_F11, 165 HardKey_OK = Qt::Key_F11,
165 HardKey_End = Qt::Key_F12, 166 HardKey_End = Qt::Key_F12,
166}; 167};
167 168
168enum ODirection { 169enum ODirection {
169 CW = 0, 170 CW = 0,
170 CCW = 1, 171 CCW = 1,
171 Flip = 2, 172 Flip = 2,
172}; 173};
173 174
174enum OHingeStatus { 175enum OHingeStatus {
175 CASE_CLOSED = 3, 176 CASE_CLOSED = 3,
176 CASE_PORTRAIT = 2, 177 CASE_PORTRAIT = 2,
177 CASE_LANDSCAPE = 0, 178 CASE_LANDSCAPE = 0,
178 CASE_UNKNOWN = 1, 179 CASE_UNKNOWN = 1,
179}; 180};
180 181
181/* default button for qvfb or such 182/* default button for qvfb or such
182 * see odevice.cpp for details. 183 * see odevice.cpp for details.
183 * hint: manage a user defined button for qvfb? 184 * hint: manage a user defined button for qvfb?
184 * alwin 185 * alwin
185 */ 186 */
186struct default_button { 187struct default_button {
187 Qt::Key code; 188 Qt::Key code;
188 char *utext; 189 char *utext;
189 char *pix; 190 char *pix;
190 char *fpressedservice; 191 char *fpressedservice;
191 char *fpressedaction; 192 char *fpressedaction;
192 char *fheldservice; 193 char *fheldservice;
193 char *fheldaction; 194 char *fheldaction;
194}; 195};
195 196
196/** 197/**
197 * A singleton which gives informations about device specefic option 198 * A singleton which gives informations about device specefic option
198 * like the Hardware used, LEDs, the Base Distribution and 199 * like the Hardware used, LEDs, the Base Distribution and
199 * hardware key mappings. 200 * hardware key mappings.
200 * 201 *
201 * @short A small class for device specefic options 202 * @short A small class for device specefic options
202 * @see QObject 203 * @see QObject
203 * @author Robert Griebl 204 * @author Robert Griebl
204 * @version 1.0 205 * @version 1.0
205 */ 206 */
206class ODevice : public QObject 207class ODevice : public QObject
207{ 208{
208 Q_OBJECT 209 Q_OBJECT
209 210
210private: 211private:
211 /* disable copy */ 212 /* disable copy */
212 ODevice ( const ODevice & ); 213 ODevice ( const ODevice & );
213 214
214protected: 215protected:
215 ODevice(); 216 ODevice();
216 virtual void init(const QString&); 217 virtual void init(const QString&);
217 virtual void initButtons(); 218 virtual void initButtons();
218 static void sendSuspendmsg(); 219 static void sendSuspendmsg();
219 220
220 ODeviceData *d; 221 ODeviceData *d;
221 222
222public: 223public:
223 // sandman do we want to allow destructions? -zecke? 224 // sandman do we want to allow destructions? -zecke?
224 virtual ~ODevice(); 225 virtual ~ODevice();
225 226
226 static ODevice *inst(); 227 static ODevice *inst();
227 228
228 // information 229 // information
229 230
230 QString modelString() const; 231 QString modelString() const;
231 OModel model() const; 232 OModel model() const;
232 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 233 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
233 234
234 QString vendorString() const; 235 QString vendorString() const;
235 OVendor vendor() const; 236 OVendor vendor() const;
236 237
237 QString systemString() const; 238 QString systemString() const;
238 OSystem system() const; 239 OSystem system() const;
239 240
240 QString systemVersionString() const; 241 QString systemVersionString() const;
241 242
242 virtual Transformation rotation() const; 243 virtual Transformation rotation() const;
243 virtual ODirection direction() const; 244 virtual ODirection direction() const;
244 245
245 // system 246 // system
246 247
247 virtual bool setSoftSuspend ( bool on ); 248 virtual bool setSoftSuspend ( bool on );
248 virtual bool suspend(); 249 virtual bool suspend();
249 250
250 virtual bool setDisplayStatus ( bool on ); 251 virtual bool setDisplayStatus ( bool on );
251 virtual bool setDisplayBrightness ( int brightness ); 252 virtual bool setDisplayBrightness ( int brightness );
252 virtual int displayBrightnessResolution() const; 253 virtual int displayBrightnessResolution() const;
253 virtual bool setDisplayContrast ( int contrast ); 254 virtual bool setDisplayContrast ( int contrast );
254 virtual int displayContrastResolution() const; 255 virtual int displayContrastResolution() const;
255 256
256 // don't add new virtual methods, use this: 257 // don't add new virtual methods, use this:
257 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 258 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
258 // and in your subclass do do overwrite 259 // and in your subclass do do overwrite
259 // protected virtual int virtual_hook(int, void *) 260 // protected virtual int virtual_hook(int, void *)
260 // which is defined below 261 // which is defined below
261 262
262 // input / output 263 // input / output
263 virtual void playAlarmSound(); 264 virtual void playAlarmSound();
264 virtual void playKeySound(); 265 virtual void playKeySound();
265 virtual void playTouchSound(); 266 virtual void playTouchSound();
266 267
267 virtual QValueList <OLed> ledList() const; 268 virtual QValueList <OLed> ledList() const;
268 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 269 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
269 virtual OLedState ledState ( OLed led ) const; 270 virtual OLedState ledState ( OLed led ) const;
270 virtual bool setLedState ( OLed led, OLedState st ); 271 virtual bool setLedState ( OLed led, OLedState st );
271 272
272 virtual bool hasLightSensor() const; 273 virtual bool hasLightSensor() const;
273 virtual int readLightSensor(); 274 virtual int readLightSensor();
274 virtual int lightSensorResolution() const; 275 virtual int lightSensorResolution() const;
275 276
276 virtual bool hasHingeSensor() const; 277 virtual bool hasHingeSensor() const;
277 virtual OHingeStatus readHingeSensor(); 278 virtual OHingeStatus readHingeSensor();
278 279
279 const QStrList &allowedCpuFrequencies() const; 280 const QStrList &allowedCpuFrequencies() const;
280 bool setCurrentCpuFrequency(uint index); 281 bool setCurrentCpuFrequency(uint index);
281 282
282 /** 283 /**
283 * Returns the available buttons on this device. The number and location 284 * Returns the available buttons on this device. The number and location
284 * of buttons will vary depending on the device. Button numbers will be assigned 285 * of buttons will vary depending on the device. Button numbers will be assigned
285 * by the device manufacturer and will be from most preferred button to least preffered 286 * by the device manufacturer and will be from most preferred button to least preffered
286 * button. Note that this list only contains "user mappable" buttons. 287 * button. Note that this list only contains "user mappable" buttons.
287 * 288 *
288 * @todo Make method const and take care of calling initButtons or make that const too 289 * @todo Make method const and take care of calling initButtons or make that const too
289 * 290 *
290 */ 291 */
291 const QValueList<ODeviceButton> &buttons(); 292 const QValueList<ODeviceButton> &buttons();
292 293
293 /** 294 /**
294 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 295 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
295 * returns 0L 296 * returns 0L
296 */ 297 */
297 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 298 const ODeviceButton *buttonForKeycode ( ushort keyCode );
298 299
299 /** 300 /**
300 * Reassigns the pressed action for \a button. To return to the factory 301 * Reassigns the pressed action for \a button. To return to the factory
301 * default pass an empty string as \a qcopMessage. 302 * default pass an empty string as \a qcopMessage.
302 */ 303 */
303 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 304 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
304 305
305 /** 306 /**
306 * Reassigns the held action for \a button. To return to the factory 307 * Reassigns the held action for \a button. To return to the factory
307 * default pass an empty string as \a qcopMessage. 308 * default pass an empty string as \a qcopMessage.
308 */ 309 */
309 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 310 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
310 311
311 /** 312 /**
312 * How long (in ms) you have to press a button for a "hold" action 313 * How long (in ms) you have to press a button for a "hold" action
313 */ 314 */
314 uint buttonHoldTime() const; 315 uint buttonHoldTime() const;
315 316
316signals: 317signals:
317 void buttonMappingChanged(); 318 void buttonMappingChanged();
318 319
319private slots: 320private slots:
320 void systemMessage ( const QCString &, const QByteArray & ); 321 void systemMessage ( const QCString &, const QByteArray & );
321 322
322protected: 323protected:
323 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 324 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
324 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 325 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
325 void reloadButtonMapping(); 326 void reloadButtonMapping();
326 /* ugly virtual hook */ 327 /* ugly virtual hook */
327 virtual void virtual_hook( int id, void* data ); 328 virtual void virtual_hook( int id, void* data );
328}; 329};
329 330
330class ODeviceData { 331class ODeviceData {
331 332
332 public: 333 public:
333 QString m_vendorstr; 334 QString m_vendorstr;
334 OVendor m_vendor; 335 OVendor m_vendor;
335 336
336 QString m_modelstr; 337 QString m_modelstr;
337 OModel m_model; 338 OModel m_model;
338 339
339 QString m_systemstr; 340 QString m_systemstr;
340 OSystem m_system; 341 OSystem m_system;
341 342
342 QString m_sysverstr; 343 QString m_sysverstr;
343 344
344 Transformation m_rotation; 345 Transformation m_rotation;
345 ODirection m_direction; 346 ODirection m_direction;
346 347
347 QValueList <ODeviceButton> *m_buttons; 348 QValueList <ODeviceButton> *m_buttons;
348 uint m_holdtime; 349 uint m_holdtime;
349 QStrList *m_cpu_frequencies; 350 QStrList *m_cpu_frequencies;
350}; 351};
351 352
352extern bool isQWS(); 353extern bool isQWS();
353extern QCString makeChannel ( const char *str ); 354extern QCString makeChannel ( const char *str );
354} 355}
355} 356}
356 357
357 358
358 359
359 360
360#endif 361#endif
361 362
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 6ac3157..47682bb 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,678 +1,682 @@
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#include "odevice_zaurus.h" 30#include "odevice_zaurus.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/resource.h> 40#include <qpe/resource.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/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "opiemail", "raise()", 78 "opiemail", "raise()",
79 "opiemail", "newMail()" }, 79 "opiemail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
106// class up into individual classes. We need three classes 106// class up into individual classes. We need three classes
107// 107//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
111// 111//
112// Only question right now is: Do we really need to do it? Because as soon 112// Only question right now is: Do we really need to do it? Because as soon
113// as the OpenZaurus kernel is ready, there will be a unified interface for all 113// as the OpenZaurus kernel is ready, there will be a unified interface for all
114// Zaurus models (concerning apm, backlight, buttons, etc.) 114// Zaurus models (concerning apm, backlight, buttons, etc.)
115// 115//
116// Comments? - mickeyl. 116// Comments? - mickeyl.
117 117
118void Zaurus::init(const QString& cpu_info) 118void Zaurus::init(const QString& cpu_info)
119{ 119{
120 // generic distribution code already scanned /etc/issue at that point - 120 // generic distribution code already scanned /etc/issue at that point -
121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
122 if ( d->m_sysverstr.contains( "embedix", false ) ) 122 if ( d->m_sysverstr.contains( "embedix", false ) )
123 { 123 {
124 d->m_vendorstr = "Sharp"; 124 d->m_vendorstr = "Sharp";
125 d->m_vendor = Vendor_Sharp; 125 d->m_vendor = Vendor_Sharp;
126 d->m_systemstr = "Zaurus"; 126 d->m_systemstr = "Zaurus";
127 d->m_system = System_Zaurus; 127 d->m_system = System_Zaurus;
128 m_embedix = true; 128 m_embedix = true;
129 } 129 }
130 else 130 else
131 { 131 {
132 d->m_vendorstr = "OpenZaurus Team"; 132 d->m_vendorstr = "OpenZaurus Team";
133 d->m_systemstr = "OpenZaurus"; 133 d->m_systemstr = "OpenZaurus";
134 d->m_system = System_OpenZaurus; 134 d->m_system = System_OpenZaurus;
135 // sysver already gathered 135 // sysver already gathered
136 136
137 // Openzaurus sometimes uses the embedix kernel, check if this is one 137 // Openzaurus sometimes uses the embedix kernel, check if this is one
138 FILE *uname = popen("uname -r", "r"); 138 FILE *uname = popen("uname -r", "r");
139 QFile f; 139 QFile f;
140 QString line; 140 QString line;
141 if ( f.open(IO_ReadOnly, uname) ) { 141 if ( f.open(IO_ReadOnly, uname) ) {
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 line = ts. readLine(); 143 line = ts. readLine();
144 int loc = line. find ( "embedix" ); 144 int loc = line. find ( "embedix" );
145 if ( loc != -1 ) 145 if ( loc != -1 )
146 m_embedix = true; 146 m_embedix = true;
147 else 147 else
148 m_embedix = false; 148 m_embedix = false;
149 f.close(); 149 f.close();
150 } 150 }
151 pclose(uname); 151 pclose(uname);
152 } 152 }
153 153
154 // check the Zaurus model 154 // check the Zaurus model
155 QString model; 155 QString model;
156 int loc = cpu_info.find( ":" ); 156 int loc = cpu_info.find( ":" );
157 if ( loc != -1 ) 157 if ( loc != -1 )
158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
159 else 159 else
160 model = cpu_info; 160 model = cpu_info;
161 161
162 if ( model == "SHARP Corgi" ) { 162 if ( model == "SHARP Corgi" ) {
163 d->m_model = Model_Zaurus_SLC7x0; 163 d->m_model = Model_Zaurus_SLC7x0;
164 d->m_modelstr = "Zaurus SL-C700"; 164 d->m_modelstr = "Zaurus SL-C700";
165 } else if ( model == "SHARP Shepherd" ) { 165 } else if ( model == "SHARP Shepherd" ) {
166 d->m_model = Model_Zaurus_SLC7x0; 166 d->m_model = Model_Zaurus_SLC7x0;
167 d->m_modelstr = "Zaurus SL-C750"; 167 d->m_modelstr = "Zaurus SL-C750";
168 } else if ( model == "SHARP Husky" ) { 168 } else if ( model == "SHARP Husky" ) {
169 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
170 d->m_modelstr = "Zaurus SL-C760"; 170 d->m_modelstr = "Zaurus SL-C760";
171 } else if ( model == "SHARP Poodle" ) { 171 } else if ( model == "SHARP Poodle" ) {
172 d->m_model = Model_Zaurus_SLB600; 172 d->m_model = Model_Zaurus_SLB600;
173 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 173 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
174 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 174 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
175 d->m_model = Model_Zaurus_SL5500; 175 d->m_model = Model_Zaurus_SL5500;
176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
177 } else if ( model == "SHARP Tosa" ) {
178 d->m_model = Model_Zaurus_SL6000;
179 d->m_modelstr = "Zaurus SL-6000";
177 } else { 180 } else {
178 d->m_model = Model_Zaurus_SL5500; 181 d->m_model = Model_Zaurus_SL5500;
179 d->m_modelstr = "Unkown Zaurus"; 182 d->m_modelstr = "Unkown Zaurus";
180 } 183 }
181 184
182 // set initial rotation 185 // set initial rotation
183 186
184 bool flipstate = false; 187 bool flipstate = false;
185 switch ( d->m_model ) { 188 switch ( d->m_model ) {
189 case Model_Zaurus_SL6000:
186 case Model_Zaurus_SLA300: 190 case Model_Zaurus_SLA300:
187 d->m_rotation = Rot0; 191 d->m_rotation = Rot0;
188 break; 192 break;
189 case Model_Zaurus_SLC7x0: 193 case Model_Zaurus_SLC7x0:
190 d->m_rotation = rotation(); 194 d->m_rotation = rotation();
191 d->m_direction = direction(); 195 d->m_direction = direction();
192 break; 196 break;
193 case Model_Zaurus_SLB600: 197 case Model_Zaurus_SLB600:
194 case Model_Zaurus_SL5500: 198 case Model_Zaurus_SL5500:
195 case Model_Zaurus_SL5000: 199 case Model_Zaurus_SL5000:
196 default: 200 default:
197 d->m_rotation = Rot270; 201 d->m_rotation = Rot270;
198 break; 202 break;
199 } 203 }
200 m_leds [0] = Led_Off; 204 m_leds [0] = Led_Off;
201} 205}
202 206
203void Zaurus::initButtons() 207void Zaurus::initButtons()
204{ 208{
205 if ( d->m_buttons ) 209 if ( d->m_buttons )
206 return; 210 return;
207 211
208 d->m_buttons = new QValueList <ODeviceButton>; 212 d->m_buttons = new QValueList <ODeviceButton>;
209 213
210 struct z_button * pz_buttons; 214 struct z_button * pz_buttons;
211 int buttoncount; 215 int buttoncount;
212 switch ( d->m_model ) { 216 switch ( d->m_model ) {
213 case Model_Zaurus_SLC7x0: 217 case Model_Zaurus_SLC7x0:
214 pz_buttons = z_buttons_c700; 218 pz_buttons = z_buttons_c700;
215 buttoncount = ARRAY_SIZE(z_buttons_c700); 219 buttoncount = ARRAY_SIZE(z_buttons_c700);
216 break; 220 break;
217 default: 221 default:
218 pz_buttons = z_buttons; 222 pz_buttons = z_buttons;
219 buttoncount = ARRAY_SIZE(z_buttons); 223 buttoncount = ARRAY_SIZE(z_buttons);
220 break; 224 break;
221 } 225 }
222 226
223 for ( int i = 0; i < buttoncount; i++ ) { 227 for ( int i = 0; i < buttoncount; i++ ) {
224 struct z_button *zb = pz_buttons + i; 228 struct z_button *zb = pz_buttons + i;
225 ODeviceButton b; 229 ODeviceButton b;
226 230
227 b. setKeycode ( zb->code ); 231 b. setKeycode ( zb->code );
228 b. setUserText ( QObject::tr ( "Button", zb->utext )); 232 b. setUserText ( QObject::tr ( "Button", zb->utext ));
229 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 233 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
230 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 234 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
231 zb->fpressedaction )); 235 zb->fpressedaction ));
232 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 236 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
233 zb->fheldaction )); 237 zb->fheldaction ));
234 238
235 d->m_buttons->append ( b ); 239 d->m_buttons->append ( b );
236 } 240 }
237 241
238 reloadButtonMapping(); 242 reloadButtonMapping();
239 243
240 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 244 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
241 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), 245 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
242 this, SLOT( systemMessage(const QCString&,const QByteArray&))); 246 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
243} 247}
244 248
245#include <unistd.h> 249#include <unistd.h>
246#include <fcntl.h> 250#include <fcntl.h>
247#include <sys/ioctl.h> 251#include <sys/ioctl.h>
248 252
249//#include <asm/sharp_char.h> // including kernel headers is evil ... 253//#include <asm/sharp_char.h> // including kernel headers is evil ...
250 254
251#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 255#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
252 256
253 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 257 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
254#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 258#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
255 259
256#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 260#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
257#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 261#define SHARP_BUZ_KEYSOUND 2 /* key sound */
258#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 262#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
259 263
260/* --- for SHARP_BUZZER device --- */ 264/* --- for SHARP_BUZZER device --- */
261 265
262 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 266 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
263//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 267//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
264 268
265#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 269#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
266#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 270#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
267#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 271#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
268#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 272#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
269#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 273#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
270 274
271//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 275//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
272//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 276//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
273 277
274//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 278//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
275//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 279//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
276//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 280//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
277//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 281//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
278//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 282//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
279//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 283//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
280//#define SHARP_PDA_APPSTART 9 /* application start */ 284//#define SHARP_PDA_APPSTART 9 /* application start */
281//#define SHARP_PDA_APPQUIT 10 /* application ends */ 285//#define SHARP_PDA_APPQUIT 10 /* application ends */
282 286
283//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 287//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
284//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 288//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
285//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 289//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
286//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 290//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
287// 291//
288 292
289 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 293 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
290#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 294#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
291 295
292#define SHARP_IOCTL_GET_ROTATION 0x413c 296#define SHARP_IOCTL_GET_ROTATION 0x413c
293 297
294typedef struct sharp_led_status { 298typedef struct sharp_led_status {
295int which; /* select which LED status is wanted. */ 299int which; /* select which LED status is wanted. */
296int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 300int status; /* set new led status if you call SHARP_LED_SETSTATUS */
297} sharp_led_status; 301} sharp_led_status;
298 302
299#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 303#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
300 304
301#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 305#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
302#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 306#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
303#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 307#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
304 308
305// #include <asm/sharp_apm.h> // including kernel headers is evil ... 309// #include <asm/sharp_apm.h> // including kernel headers is evil ...
306 310
307#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 311#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
308#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 312#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
309#define APM_EVT_POWER_BUTTON (1 << 0) 313#define APM_EVT_POWER_BUTTON (1 << 0)
310 314
311#define FL_IOCTL_STEP_CONTRAST 100 315#define FL_IOCTL_STEP_CONTRAST 100
312 316
313 317
314void Zaurus::buzzer ( int sound ) 318void Zaurus::buzzer ( int sound )
315{ 319{
316#ifndef QT_NO_SOUND 320#ifndef QT_NO_SOUND
317 QString soundname; 321 QString soundname;
318 322
319 // Not all devices have real sound 323 // Not all devices have real sound
320 if ( d->m_model == Model_Zaurus_SLC7x0 324 if ( d->m_model == Model_Zaurus_SLC7x0
321 || d->m_model == Model_Zaurus_SLB600 ){ 325 || d->m_model == Model_Zaurus_SLB600 ){
322 326
323 switch ( sound ){ 327 switch ( sound ){
324 case SHARP_BUZ_SCHEDULE_ALARM: 328 case SHARP_BUZ_SCHEDULE_ALARM:
325 soundname = "alarm"; 329 soundname = "alarm";
326 break; 330 break;
327 case SHARP_BUZ_TOUCHSOUND: 331 case SHARP_BUZ_TOUCHSOUND:
328 soundname = "touchsound"; 332 soundname = "touchsound";
329 break; 333 break;
330 case SHARP_BUZ_KEYSOUND: 334 case SHARP_BUZ_KEYSOUND:
331 soundname = "keysound"; 335 soundname = "keysound";
332 break; 336 break;
333 default: 337 default:
334 soundname = "alarm"; 338 soundname = "alarm";
335 339
336 } 340 }
337 } 341 }
338 342
339 // If a soundname is defined, we expect that this device has 343 // If a soundname is defined, we expect that this device has
340 // sound capabilities.. Otherwise we expect to have the buzzer 344 // sound capabilities.. Otherwise we expect to have the buzzer
341 // device.. 345 // device..
342 if ( !soundname.isEmpty() ){ 346 if ( !soundname.isEmpty() ){
343 int fd; 347 int fd;
344 int vol; 348 int vol;
345 bool vol_reset = false; 349 bool vol_reset = false;
346 350
347 Sound snd ( soundname ); 351 Sound snd ( soundname );
348 352
349 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 353 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
350 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 354 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
351 Config cfg ( "qpe" ); 355 Config cfg ( "qpe" );
352 cfg. setGroup ( "Volume" ); 356 cfg. setGroup ( "Volume" );
353 357
354 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 358 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
355 if ( volalarm < 0 ) 359 if ( volalarm < 0 )
356 volalarm = 0; 360 volalarm = 0;
357 else if ( volalarm > 100 ) 361 else if ( volalarm > 100 )
358 volalarm = 100; 362 volalarm = 100;
359 volalarm |= ( volalarm << 8 ); 363 volalarm |= ( volalarm << 8 );
360 364
361 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 365 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
362 vol_reset = true; 366 vol_reset = true;
363 } 367 }
364 } 368 }
365 369
366 snd. play(); 370 snd. play();
367 while ( !snd. isFinished()) 371 while ( !snd. isFinished())
368 qApp->processEvents(); 372 qApp->processEvents();
369 373
370 if ( fd >= 0 ) { 374 if ( fd >= 0 ) {
371 if ( vol_reset ) 375 if ( vol_reset )
372 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 376 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
373 ::close ( fd ); 377 ::close ( fd );
374 } 378 }
375 } else { 379 } else {
376 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 380 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
377 381
378 if ( fd >= 0 ) { 382 if ( fd >= 0 ) {
379 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 383 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
380 ::close ( fd ); 384 ::close ( fd );
381 } 385 }
382 386
383 } 387 }
384#endif 388#endif
385} 389}
386 390
387 391
388void Zaurus::playAlarmSound() 392void Zaurus::playAlarmSound()
389{ 393{
390 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 394 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
391} 395}
392 396
393void Zaurus::playTouchSound() 397void Zaurus::playTouchSound()
394{ 398{
395 buzzer ( SHARP_BUZ_TOUCHSOUND ); 399 buzzer ( SHARP_BUZ_TOUCHSOUND );
396} 400}
397 401
398void Zaurus::playKeySound() 402void Zaurus::playKeySound()
399{ 403{
400 buzzer ( SHARP_BUZ_KEYSOUND ); 404 buzzer ( SHARP_BUZ_KEYSOUND );
401} 405}
402 406
403 407
404QValueList <OLed> Zaurus::ledList() const 408QValueList <OLed> Zaurus::ledList() const
405{ 409{
406 QValueList <OLed> vl; 410 QValueList <OLed> vl;
407 vl << Led_Mail; 411 vl << Led_Mail;
408 return vl; 412 return vl;
409} 413}
410 414
411QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 415QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
412{ 416{
413 QValueList <OLedState> vl; 417 QValueList <OLedState> vl;
414 418
415 if ( l == Led_Mail ) 419 if ( l == Led_Mail )
416 vl << Led_Off << Led_On << Led_BlinkSlow; 420 vl << Led_Off << Led_On << Led_BlinkSlow;
417 return vl; 421 return vl;
418} 422}
419 423
420OLedState Zaurus::ledState ( OLed which ) const 424OLedState Zaurus::ledState ( OLed which ) const
421{ 425{
422 if ( which == Led_Mail ) 426 if ( which == Led_Mail )
423 return m_leds [0]; 427 return m_leds [0];
424 else 428 else
425 return Led_Off; 429 return Led_Off;
426} 430}
427 431
428bool Zaurus::setLedState ( OLed which, OLedState st ) 432bool Zaurus::setLedState ( OLed which, OLedState st )
429{ 433{
430 if (!m_embedix) // Currently not supported on non_embedix kernels 434 if (!m_embedix) // Currently not supported on non_embedix kernels
431 return false; 435 return false;
432 436
433 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 437 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
434 438
435 if ( which == Led_Mail ) { 439 if ( which == Led_Mail ) {
436 if ( fd >= 0 ) { 440 if ( fd >= 0 ) {
437 struct sharp_led_status leds; 441 struct sharp_led_status leds;
438 ::memset ( &leds, 0, sizeof( leds )); 442 ::memset ( &leds, 0, sizeof( leds ));
439 leds. which = SHARP_LED_MAIL_EXISTS; 443 leds. which = SHARP_LED_MAIL_EXISTS;
440 bool ok = true; 444 bool ok = true;
441 445
442 switch ( st ) { 446 switch ( st ) {
443 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 447 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
444 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 448 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
445 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 449 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
446 default : ok = false; 450 default : ok = false;
447 } 451 }
448 452
449 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 453 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
450 m_leds [0] = st; 454 m_leds [0] = st;
451 return true; 455 return true;
452 } 456 }
453 } 457 }
454 } 458 }
455 return false; 459 return false;
456} 460}
457 461
458bool Zaurus::setSoftSuspend ( bool soft ) 462bool Zaurus::setSoftSuspend ( bool soft )
459{ 463{
460 if (!m_embedix) { 464 if (!m_embedix) {
461 /* non-Embedix kernels dont have kernel autosuspend */ 465 /* non-Embedix kernels dont have kernel autosuspend */
462 return ODevice::setSoftSuspend( soft ); 466 return ODevice::setSoftSuspend( soft );
463 } 467 }
464 468
465 bool res = false; 469 bool res = false;
466 int fd; 470 int fd;
467 471
468 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 472 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
469 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 473 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
470 474
471 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 475 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
472 476
473 if ( sources >= 0 ) { 477 if ( sources >= 0 ) {
474 if ( soft ) 478 if ( soft )
475 sources &= ~APM_EVT_POWER_BUTTON; 479 sources &= ~APM_EVT_POWER_BUTTON;
476 else 480 else
477 sources |= APM_EVT_POWER_BUTTON; 481 sources |= APM_EVT_POWER_BUTTON;
478 482
479 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 483 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
480 res = true; 484 res = true;
481 else 485 else
482 perror ( "APM_IOCGEVTSRC" ); 486 perror ( "APM_IOCGEVTSRC" );
483 } 487 }
484 else 488 else
485 perror ( "APM_IOCGEVTSRC" ); 489 perror ( "APM_IOCGEVTSRC" );
486 490
487 ::close ( fd ); 491 ::close ( fd );
488 } 492 }
489 else 493 else
490 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 494 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
491 495
492 return res; 496 return res;
493} 497}
494 498
495 499
496bool Zaurus::setDisplayBrightness ( int bright ) 500bool Zaurus::setDisplayBrightness ( int bright )
497{ 501{
498 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 502 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
499 bool res = false; 503 bool res = false;
500 int fd; 504 int fd;
501 505
502 if ( bright > 255 ) bright = 255; 506 if ( bright > 255 ) bright = 255;
503 if ( bright < 0 ) bright = 0; 507 if ( bright < 0 ) bright = 0;
504 508
505 if ( m_embedix ) 509 if ( m_embedix )
506 { 510 {
507 if ( d->m_model == Model_Zaurus_SLC7x0 ) 511 if ( d->m_model == Model_Zaurus_SLC7x0 )
508 { 512 {
509 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 513 //qDebug( "using special treatment for devices with the corgi backlight interface" );
510 // special treatment for devices with the corgi backlight interface 514 // special treatment for devices with the corgi backlight interface
511 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 515 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
512 { 516 {
513 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 517 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
514 char writeCommand[100]; 518 char writeCommand[100];
515 const int count = sprintf( writeCommand, "0x%x\n", value ); 519 const int count = sprintf( writeCommand, "0x%x\n", value );
516 res = ( ::write ( fd, writeCommand, count ) != -1 ); 520 res = ( ::write ( fd, writeCommand, count ) != -1 );
517 ::close ( fd ); 521 ::close ( fd );
518 } 522 }
519 return res; 523 return res;
520 } 524 }
521 else 525 else
522 { 526 {
523 // standard treatment for devices with the dumb embedix frontlight interface 527 // standard treatment for devices with the dumb embedix frontlight interface
524 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 528 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
525 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 529 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
526 if ( bright && !bl ) 530 if ( bright && !bl )
527 bl = 1; 531 bl = 1;
528 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 532 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
529 ::close ( fd ); 533 ::close ( fd );
530 } 534 }
531 } 535 }
532 } 536 }
533 else 537 else
534 { 538 {
535 // special treatment for the OpenZaurus unified interface 539 // special treatment for the OpenZaurus unified interface
536 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 540 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
537 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 541 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
538 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 542 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
539 ::close ( fd ); 543 ::close ( fd );
540 } 544 }
541 } 545 }
542 return res; 546 return res;
543} 547}
544 548
545bool Zaurus::suspend() 549bool Zaurus::suspend()
546{ 550{
547 qDebug("ODevice::suspend"); 551 qDebug("ODevice::suspend");
548 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 552 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
549 return false; 553 return false;
550 554
551 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 555 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
552 return false; 556 return false;
553 557
554 bool res = false; 558 bool res = false;
555 ODevice::sendSuspendmsg(); 559 ODevice::sendSuspendmsg();
556 560
557 struct timeval tvs, tvn; 561 struct timeval tvs, tvn;
558 ::gettimeofday ( &tvs, 0 ); 562 ::gettimeofday ( &tvs, 0 );
559 563
560 ::sync(); // flush fs caches 564 ::sync(); // flush fs caches
561 res = ( ::system ( "apm --suspend" ) == 0 ); 565 res = ( ::system ( "apm --suspend" ) == 0 );
562 566
563 // This is needed because the iPAQ apm implementation is asynchronous and we 567 // This is needed because the iPAQ apm implementation is asynchronous and we
564 // can not be sure when exactly the device is really suspended 568 // can not be sure when exactly the device is really suspended
565 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 569 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
566 570
567 if ( res ) { 571 if ( res ) {
568 do { // Yes, wait 15 seconds. This APM bug sucks big time. 572 do { // Yes, wait 15 seconds. This APM bug sucks big time.
569 ::usleep ( 200 * 1000 ); 573 ::usleep ( 200 * 1000 );
570 ::gettimeofday ( &tvn, 0 ); 574 ::gettimeofday ( &tvn, 0 );
571 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 575 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
572 } 576 }
573 577
574 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 578 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
575 return res; 579 return res;
576} 580}
577 581
578 582
579Transformation Zaurus::rotation() const 583Transformation Zaurus::rotation() const
580{ 584{
581 Transformation rot; 585 Transformation rot;
582 int handle = 0; 586 int handle = 0;
583 int retval = 0; 587 int retval = 0;
584 588
585 switch ( d->m_model ) { 589 switch ( d->m_model ) {
586 case Model_Zaurus_SLC7x0: 590 case Model_Zaurus_SLC7x0:
587 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 591 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
588 if (handle == -1) { 592 if (handle == -1) {
589 return Rot270; 593 return Rot270;
590 } else { 594 } else {
591 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 595 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
592 ::close (handle); 596 ::close (handle);
593 597
594 if (retval == 2 ) 598 if (retval == 2 )
595 rot = Rot0; 599 rot = Rot0;
596 else 600 else
597 rot = Rot270; 601 rot = Rot270;
598 } 602 }
599 break; 603 break;
600 case Model_Zaurus_SLA300: 604 case Model_Zaurus_SLA300:
601 case Model_Zaurus_SLB600: 605 case Model_Zaurus_SLB600:
602 case Model_Zaurus_SL5500: 606 case Model_Zaurus_SL5500:
603 case Model_Zaurus_SL5000: 607 case Model_Zaurus_SL5000:
604 default: 608 default:
605 rot = d->m_rotation; 609 rot = d->m_rotation;
606 break; 610 break;
607 } 611 }
608 612
609 return rot; 613 return rot;
610} 614}
611ODirection Zaurus::direction() const 615ODirection Zaurus::direction() const
612{ 616{
613 ODirection dir; 617 ODirection dir;
614 int handle = 0; 618 int handle = 0;
615 int retval = 0; 619 int retval = 0;
616 switch ( d->m_model ) { 620 switch ( d->m_model ) {
617 case Model_Zaurus_SLC7x0: 621 case Model_Zaurus_SLC7x0:
618 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 622 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
619 if (handle == -1) { 623 if (handle == -1) {
620 dir = CW; 624 dir = CW;
621 } else { 625 } else {
622 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 626 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
623 ::close (handle); 627 ::close (handle);
624 if (retval == 2 ) 628 if (retval == 2 )
625 dir = CCW; 629 dir = CCW;
626 else 630 else
627 dir = CW; 631 dir = CW;
628 } 632 }
629 break; 633 break;
630 case Model_Zaurus_SLA300: 634 case Model_Zaurus_SLA300:
631 case Model_Zaurus_SLB600: 635 case Model_Zaurus_SLB600:
632 case Model_Zaurus_SL5500: 636 case Model_Zaurus_SL5500:
633 case Model_Zaurus_SL5000: 637 case Model_Zaurus_SL5000:
634 default: 638 default:
635 dir = d->m_direction; 639 dir = d->m_direction;
636 break; 640 break;
637 } 641 }
638 return dir; 642 return dir;
639 643
640} 644}
641 645
642int Zaurus::displayBrightnessResolution() const 646int Zaurus::displayBrightnessResolution() const
643{ 647{
644 if (m_embedix) 648 if (m_embedix)
645 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 649 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
646 else 650 else
647 return 256; 651 return 256;
648} 652}
649 653
650bool Zaurus::hasHingeSensor() const 654bool Zaurus::hasHingeSensor() const
651{ 655{
652 return d->m_model == Model_Zaurus_SLC7x0; 656 return d->m_model == Model_Zaurus_SLC7x0;
653} 657}
654 658
655OHingeStatus Zaurus::readHingeSensor() 659OHingeStatus Zaurus::readHingeSensor()
656{ 660{
657 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 661 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
658 if (handle == -1) 662 if (handle == -1)
659 { 663 {
660 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 664 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
661 return CASE_UNKNOWN; 665 return CASE_UNKNOWN;
662 } 666 }
663 else 667 else
664 { 668 {
665 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 669 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
666 ::close (handle); 670 ::close (handle);
667 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 671 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
668 { 672 {
669 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 673 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
670 return static_cast<OHingeStatus>( retval ); 674 return static_cast<OHingeStatus>( retval );
671 } 675 }
672 else 676 else
673 { 677 {
674 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 678 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
675 return CASE_UNKNOWN; 679 return CASE_UNKNOWN;
676 } 680 }
677 } 681 }
678} 682}