summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-29 16:51:07 (UTC)
committer mickeyl <mickeyl>2003-12-29 16:51:07 (UTC)
commit8224dfc07a698d4c40cb240d315dc81b67512015 (patch) (unidiff)
tree0cdbb05aab54948421c873ccd25881caf1e474c5
parentdae677b6e29e2a0efb7128bcc4b0d87bf2b535dd (diff)
downloadopie-8224dfc07a698d4c40cb240d315dc81b67512015.zip
opie-8224dfc07a698d4c40cb240d315dc81b67512015.tar.gz
opie-8224dfc07a698d4c40cb240d315dc81b67512015.tar.bz2
- add fine granular backlight support for devices with the corgi backlight interface
- add hinge sensor framework for devices with hinge sensors
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp136
-rw-r--r--libopie/odevice.h14
2 files changed, 113 insertions, 37 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index e24e043..bc09e92 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,2592 +1,2658 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#ifndef QT_NO_SOUND 26#ifndef QT_NO_SOUND
27#include <linux/soundcard.h> 27#include <linux/soundcard.h>
28#endif 28#endif
29#include <math.h> 29#include <math.h>
30 30
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <qfile.h> 33#include <qfile.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
35#include <qpe/sound.h> 35#include <qpe/sound.h>
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39 39
40#include "odevice.h" 40#include "odevice.h"
41 41
42#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
43 43
44#ifndef ARRAY_SIZE 44#ifndef ARRAY_SIZE
45#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 45#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
46#endif 46#endif
47 47
48// _IO and friends are only defined in kernel headers ... 48// _IO and friends are only defined in kernel headers ...
49 49
50#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 50#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
51 51
52#define OD_IO(type,number) OD_IOC(0,type,number,0) 52#define OD_IO(type,number) OD_IOC(0,type,number,0)
53#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 53#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
54#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 54#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
55#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 55#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
56 56
57using namespace Opie; 57using namespace Opie;
58 58
59class ODeviceData { 59class ODeviceData {
60public: 60public:
61 QString m_vendorstr; 61 QString m_vendorstr;
62 OVendor m_vendor; 62 OVendor m_vendor;
63 63
64 QString m_modelstr; 64 QString m_modelstr;
65 OModel m_model; 65 OModel m_model;
66 66
67 QString m_systemstr; 67 QString m_systemstr;
68 OSystem m_system; 68 OSystem m_system;
69 69
70 QString m_sysverstr; 70 QString m_sysverstr;
71 71
72 Transformation m_rotation; 72 Transformation m_rotation;
73 ODirection m_direction; 73 ODirection m_direction;
74 74
75 QValueList <ODeviceButton> *m_buttons; 75 QValueList <ODeviceButton> *m_buttons;
76 uint m_holdtime; 76 uint m_holdtime;
77 QStrList *m_cpu_frequencies; 77 QStrList *m_cpu_frequencies;
78}; 78};
79 79
80class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 80class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
81protected: 81protected:
82 virtual void init ( ); 82 virtual void init ( );
83 virtual void initButtons ( ); 83 virtual void initButtons ( );
84 84
85public: 85public:
86 virtual bool setSoftSuspend ( bool soft ); 86 virtual bool setSoftSuspend ( bool soft );
87 87
88 virtual bool setDisplayBrightness ( int b ); 88 virtual bool setDisplayBrightness ( int b );
89 virtual int displayBrightnessResolution ( ) const; 89 virtual int displayBrightnessResolution ( ) const;
90 90
91 virtual void alarmSound ( ); 91 virtual void alarmSound ( );
92 92
93 virtual QValueList <OLed> ledList ( ) const; 93 virtual QValueList <OLed> ledList ( ) const;
94 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 94 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
95 virtual OLedState ledState ( OLed led ) const; 95 virtual OLedState ledState ( OLed led ) const;
96 virtual bool setLedState ( OLed led, OLedState st ); 96 virtual bool setLedState ( OLed led, OLedState st );
97 97
98 virtual bool hasLightSensor ( ) const; 98 virtual bool hasLightSensor ( ) const;
99 virtual int readLightSensor ( ); 99 virtual int readLightSensor ( );
100 virtual int lightSensorResolution ( ) const; 100 virtual int lightSensorResolution ( ) const;
101 101
102protected: 102protected:
103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
104 virtual void timerEvent ( QTimerEvent *te ); 104 virtual void timerEvent ( QTimerEvent *te );
105 105
106 int m_power_timer; 106 int m_power_timer;
107 107
108 OLedState m_leds [2]; 108 OLedState m_leds [2];
109}; 109};
110 110
111class Jornada : public ODevice { 111class Jornada : public ODevice {
112protected: 112protected:
113 virtual void init ( ); 113 virtual void init ( );
114 //virtual void initButtons ( ); 114 //virtual void initButtons ( );
115public: 115public:
116 virtual bool setSoftSuspend ( bool soft ); 116 virtual bool setSoftSuspend ( bool soft );
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 static bool isJornada(); 119 static bool isJornada();
120 120
121}; 121};
122 122
123class Zaurus : public ODevice { 123class Zaurus : public ODevice {
124protected: 124protected:
125 virtual void init ( ); 125 virtual void init ( );
126 virtual void initButtons ( ); 126 virtual void initButtons ( );
127 127
128public: 128public:
129 virtual bool setSoftSuspend ( bool soft ); 129 virtual bool setSoftSuspend ( bool soft );
130 130
131 virtual bool setDisplayBrightness ( int b ); 131 virtual bool setDisplayBrightness ( int b );
132 virtual int displayBrightnessResolution ( ) const; 132 virtual int displayBrightnessResolution ( ) const;
133 133
134 virtual void alarmSound ( ); 134 virtual void alarmSound ( );
135 virtual void keySound ( ); 135 virtual void keySound ( );
136 virtual void touchSound ( ); 136 virtual void touchSound ( );
137 137
138 virtual QValueList <OLed> ledList ( ) const; 138 virtual QValueList <OLed> ledList ( ) const;
139 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 139 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
140 virtual OLedState ledState ( OLed led ) const; 140 virtual OLedState ledState ( OLed led ) const;
141 virtual bool setLedState ( OLed led, OLedState st ); 141 virtual bool setLedState ( OLed led, OLedState st );
142 142
143 virtual bool hasHingeSensor() const;
144 virtual OHingeStatus readHingeSensor();
145
143 static bool isZaurus(); 146 static bool isZaurus();
144 147
145 // Does this break BC? 148 // Does this break BC?
146 virtual bool suspend ( ); 149 virtual bool suspend ( );
147 virtual Transformation rotation ( ) const; 150 virtual Transformation rotation ( ) const;
148 virtual ODirection direction ( ) const; 151 virtual ODirection direction ( ) const;
149 152
150protected: 153protected:
151 virtual void buzzer ( int snd ); 154 virtual void buzzer ( int snd );
152 155
153 OLedState m_leds [1]; 156 OLedState m_leds [1];
154 bool m_embedix; 157 bool m_embedix;
155}; 158};
156 159
157class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 160class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
158protected: 161protected:
159 virtual void init ( ); 162 virtual void init ( );
160 virtual void initButtons ( ); 163 virtual void initButtons ( );
161 164
162public: 165public:
163 virtual bool setSoftSuspend ( bool soft ); 166 virtual bool setSoftSuspend ( bool soft );
164 virtual bool suspend(); 167 virtual bool suspend();
165 168
166 virtual bool setDisplayStatus( bool on ); 169 virtual bool setDisplayStatus( bool on );
167 virtual bool setDisplayBrightness ( int b ); 170 virtual bool setDisplayBrightness ( int b );
168 virtual int displayBrightnessResolution ( ) const; 171 virtual int displayBrightnessResolution ( ) const;
169 172
170 virtual void alarmSound ( ); 173 virtual void alarmSound ( );
171 174
172 virtual QValueList <OLed> ledList ( ) const; 175 virtual QValueList <OLed> ledList ( ) const;
173 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 176 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
174 virtual OLedState ledState ( OLed led ) const; 177 virtual OLedState ledState ( OLed led ) const;
175 virtual bool setLedState ( OLed led, OLedState st ); 178 virtual bool setLedState ( OLed led, OLedState st );
176 179
177protected: 180protected:
178 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 181 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
179 virtual void timerEvent ( QTimerEvent *te ); 182 virtual void timerEvent ( QTimerEvent *te );
180 183
181 int m_power_timer; 184 int m_power_timer;
182 185
183 OLedState m_leds [1]; //FIXME check if really only one 186 OLedState m_leds [1]; //FIXME check if really only one
184}; 187};
185 188
186class Ramses : public ODevice, public QWSServer::KeyboardFilter { 189class Ramses : public ODevice, public QWSServer::KeyboardFilter {
187protected: 190protected:
188 virtual void init ( ); 191 virtual void init ( );
189 192
190public: 193public:
191 virtual bool setSoftSuspend ( bool soft ); 194 virtual bool setSoftSuspend ( bool soft );
192 virtual bool suspend ( ); 195 virtual bool suspend ( );
193 196
194 virtual bool setDisplayStatus( bool on ); 197 virtual bool setDisplayStatus( bool on );
195 virtual bool setDisplayBrightness ( int b ); 198 virtual bool setDisplayBrightness ( int b );
196 virtual int displayBrightnessResolution ( ) const; 199 virtual int displayBrightnessResolution ( ) const;
197 virtual bool setDisplayContrast ( int b ); 200 virtual bool setDisplayContrast ( int b );
198 virtual int displayContrastResolution ( ) const; 201 virtual int displayContrastResolution ( ) const;
199 202
200protected: 203protected:
201 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 204 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
202 virtual void timerEvent ( QTimerEvent *te ); 205 virtual void timerEvent ( QTimerEvent *te );
203 206
204 int m_power_timer; 207 int m_power_timer;
205}; 208};
206 209
207struct i_button { 210struct i_button {
208 uint model; 211 uint model;
209 Qt::Key code; 212 Qt::Key code;
210 char *utext; 213 char *utext;
211 char *pix; 214 char *pix;
212 char *fpressedservice; 215 char *fpressedservice;
213 char *fpressedaction; 216 char *fpressedaction;
214 char *fheldservice; 217 char *fheldservice;
215 char *fheldaction; 218 char *fheldaction;
216} ipaq_buttons [] = { 219} ipaq_buttons [] = {
217 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
218 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 221 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
219 "devicebuttons/ipaq_calendar", 222 "devicebuttons/ipaq_calendar",
220 "datebook", "nextView()", 223 "datebook", "nextView()",
221 "today", "raise()" }, 224 "today", "raise()" },
222 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 225 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
223 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 226 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
224 "devicebuttons/ipaq_contact", 227 "devicebuttons/ipaq_contact",
225 "addressbook", "raise()", 228 "addressbook", "raise()",
226 "addressbook", "beamBusinessCard()" }, 229 "addressbook", "beamBusinessCard()" },
227 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 230 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
228 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 231 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
229 "devicebuttons/ipaq_menu", 232 "devicebuttons/ipaq_menu",
230 "QPE/TaskBar", "toggleMenu()", 233 "QPE/TaskBar", "toggleMenu()",
231 "QPE/TaskBar", "toggleStartMenu()" }, 234 "QPE/TaskBar", "toggleStartMenu()" },
232 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 235 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
233 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 236 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
234 "devicebuttons/ipaq_mail", 237 "devicebuttons/ipaq_mail",
235 "mail", "raise()", 238 "mail", "raise()",
236 "mail", "newMail()" }, 239 "mail", "newMail()" },
237 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 240 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
238 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 241 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
239 "devicebuttons/ipaq_home", 242 "devicebuttons/ipaq_home",
240 "QPE/Launcher", "home()", 243 "QPE/Launcher", "home()",
241 "buttonsettings", "raise()" }, 244 "buttonsettings", "raise()" },
242 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 245 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
243 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 246 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
244 "devicebuttons/ipaq_record", 247 "devicebuttons/ipaq_record",
245 "QPE/VMemo", "toggleRecord()", 248 "QPE/VMemo", "toggleRecord()",
246 "sound", "raise()" }, 249 "sound", "raise()" },
247}; 250};
248 251
249struct z_button { 252struct z_button {
250 Qt::Key code; 253 Qt::Key code;
251 char *utext; 254 char *utext;
252 char *pix; 255 char *pix;
253 char *fpressedservice; 256 char *fpressedservice;
254 char *fpressedaction; 257 char *fpressedaction;
255 char *fheldservice; 258 char *fheldservice;
256 char *fheldaction; 259 char *fheldaction;
257} z_buttons [] = { 260} z_buttons [] = {
258 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 261 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
259 "devicebuttons/z_calendar", 262 "devicebuttons/z_calendar",
260 "datebook", "nextView()", 263 "datebook", "nextView()",
261 "today", "raise()" }, 264 "today", "raise()" },
262 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 265 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
263 "devicebuttons/z_contact", 266 "devicebuttons/z_contact",
264 "addressbook", "raise()", 267 "addressbook", "raise()",
265 "addressbook", "beamBusinessCard()" }, 268 "addressbook", "beamBusinessCard()" },
266 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 269 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
267 "devicebuttons/z_home", 270 "devicebuttons/z_home",
268 "QPE/Launcher", "home()", 271 "QPE/Launcher", "home()",
269 "buttonsettings", "raise()" }, 272 "buttonsettings", "raise()" },
270 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 273 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
271 "devicebuttons/z_menu", 274 "devicebuttons/z_menu",
272 "QPE/TaskBar", "toggleMenu()", 275 "QPE/TaskBar", "toggleMenu()",
273 "QPE/TaskBar", "toggleStartMenu()" }, 276 "QPE/TaskBar", "toggleStartMenu()" },
274 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 277 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
275 "devicebuttons/z_mail", 278 "devicebuttons/z_mail",
276 "mail", "raise()", 279 "mail", "raise()",
277 "mail", "newMail()" }, 280 "mail", "newMail()" },
278}; 281};
279 282
280struct z_button z_buttons_c700 [] = { 283struct z_button z_buttons_c700 [] = {
281 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 284 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
282 "devicebuttons/z_calendar", 285 "devicebuttons/z_calendar",
283 "datebook", "nextView()", 286 "datebook", "nextView()",
284 "today", "raise()" }, 287 "today", "raise()" },
285 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 288 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
286 "devicebuttons/z_contact", 289 "devicebuttons/z_contact",
287 "addressbook", "raise()", 290 "addressbook", "raise()",
288 "addressbook", "beamBusinessCard()" }, 291 "addressbook", "beamBusinessCard()" },
289 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 292 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
290 "devicebuttons/z_home", 293 "devicebuttons/z_home",
291 "QPE/Launcher", "home()", 294 "QPE/Launcher", "home()",
292 "buttonsettings", "raise()" }, 295 "buttonsettings", "raise()" },
293 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 296 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
294 "devicebuttons/z_menu", 297 "devicebuttons/z_menu",
295 "QPE/TaskBar", "toggleMenu()", 298 "QPE/TaskBar", "toggleMenu()",
296 "QPE/TaskBar", "toggleStartMenu()" }, 299 "QPE/TaskBar", "toggleStartMenu()" },
297 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 300 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
298 "", 301 "",
299 "QPE/Rotation", "rotateDefault()", 302 "QPE/Rotation", "rotateDefault()",
300 "QPE/Rotation", "rotateDefault()" }, 303 "QPE/Rotation", "rotateDefault()" },
301}; 304};
302 305
303struct s_button { 306struct s_button {
304 uint model; 307 uint model;
305 Qt::Key code; 308 Qt::Key code;
306 char *utext; 309 char *utext;
307 char *pix; 310 char *pix;
308 char *fpressedservice; 311 char *fpressedservice;
309 char *fpressedaction; 312 char *fpressedaction;
310 char *fheldservice; 313 char *fheldservice;
311 char *fheldaction; 314 char *fheldaction;
312} simpad_buttons [] = { 315} simpad_buttons [] = {
313 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
314 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 317 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
315 "devicebuttons/simpad_lower_up", 318 "devicebuttons/simpad_lower_up",
316 "datebook", "nextView()", 319 "datebook", "nextView()",
317 "today", "raise()" }, 320 "today", "raise()" },
318 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 321 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
319 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 322 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
320 "devicebuttons/simpad_lower_down", 323 "devicebuttons/simpad_lower_down",
321 "addressbook", "raise()", 324 "addressbook", "raise()",
322 "addressbook", "beamBusinessCard()" }, 325 "addressbook", "beamBusinessCard()" },
323 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 326 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
324 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 327 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
325 "devicebuttons/simpad_lower_right", 328 "devicebuttons/simpad_lower_right",
326 "QPE/TaskBar", "toggleMenu()", 329 "QPE/TaskBar", "toggleMenu()",
327 "QPE/TaskBar", "toggleStartMenu()" }, 330 "QPE/TaskBar", "toggleStartMenu()" },
328 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 331 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
329 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 332 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
330 "devicebuttons/simpad_lower_left", 333 "devicebuttons/simpad_lower_left",
331 "mail", "raise()", 334 "mail", "raise()",
332 "mail", "newMail()" }, 335 "mail", "newMail()" },
333 336
334 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 337 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
335 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 338 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
336 "devicebuttons/simpad_upper_up", 339 "devicebuttons/simpad_upper_up",
337 "QPE/Launcher", "home()", 340 "QPE/Launcher", "home()",
338 "buttonsettings", "raise()" }, 341 "buttonsettings", "raise()" },
339 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 342 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
340 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 343 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
341 "devicebuttons/simpad_upper_down", 344 "devicebuttons/simpad_upper_down",
342 "addressbook", "raise()", 345 "addressbook", "raise()",
343 "addressbook", "beamBusinessCard()" }, 346 "addressbook", "beamBusinessCard()" },
344 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 347 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
345 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 348 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
346 "devicebuttons/simpad_upper_right", 349 "devicebuttons/simpad_upper_right",
347 "QPE/TaskBar", "toggleMenu()", 350 "QPE/TaskBar", "toggleMenu()",
348 "QPE/TaskBar", "toggleStartMenu()" }, 351 "QPE/TaskBar", "toggleStartMenu()" },
349 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 352 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
350 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 353 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
351 "devicebuttons/simpad_upper_left", 354 "devicebuttons/simpad_upper_left",
352 "QPE/Rotation", "flip()", 355 "QPE/Rotation", "flip()",
353 "QPE/Rotation", "flip()" }, 356 "QPE/Rotation", "flip()" },
354 /* 357 /*
355 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 358 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
356 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 359 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
357 "devicebuttons/simpad_lower_upper", 360 "devicebuttons/simpad_lower_upper",
358 "QPE/Launcher", "home()", 361 "QPE/Launcher", "home()",
359 "buttonsettings", "raise()" }, 362 "buttonsettings", "raise()" },
360 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 363 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
361 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 364 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
362 "devicebuttons/simpad_upper_lower", 365 "devicebuttons/simpad_upper_lower",
363 "QPE/Launcher", "home()", 366 "QPE/Launcher", "home()",
364 "buttonsettings", "raise()" }, 367 "buttonsettings", "raise()" },
365 */ 368 */
366}; 369};
367 370
368struct r_button { 371struct r_button {
369 uint model; 372 uint model;
370 Qt::Key code; 373 Qt::Key code;
371 char *utext; 374 char *utext;
372 char *pix; 375 char *pix;
373 char *fpressedservice; 376 char *fpressedservice;
374 char *fpressedaction; 377 char *fpressedaction;
375 char *fheldservice; 378 char *fheldservice;
376 char *fheldaction; 379 char *fheldaction;
377} ramses_buttons [] = { 380} ramses_buttons [] = {
378 { Model_Ramses_MNCI, 381 { Model_Ramses_MNCI,
379 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 382 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
380 "devicebuttons/z_menu", 383 "devicebuttons/z_menu",
381 "QPE/TaskBar", "toggleMenu()", 384 "QPE/TaskBar", "toggleMenu()",
382 "QPE/TaskBar", "toggleStartMenu()" }, 385 "QPE/TaskBar", "toggleStartMenu()" },
383 { Model_Ramses_MNCI, 386 { Model_Ramses_MNCI,
384 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 387 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
385 "devicebuttons/ipaq_home", 388 "devicebuttons/ipaq_home",
386 "QPE/Launcher", "home()", 389 "QPE/Launcher", "home()",
387 "buttonsettings", "raise()" }, 390 "buttonsettings", "raise()" },
388}; 391};
389 392
390class Yopy : public ODevice { 393class Yopy : public ODevice {
391protected: 394protected:
392 virtual void init ( ); 395 virtual void init ( );
393 virtual void initButtons ( ); 396 virtual void initButtons ( );
394 397
395public: 398public:
396 virtual bool suspend ( ); 399 virtual bool suspend ( );
397 400
398 virtual bool setDisplayBrightness ( int b ); 401 virtual bool setDisplayBrightness ( int b );
399 virtual int displayBrightnessResolution ( ) const; 402 virtual int displayBrightnessResolution ( ) const;
400 403
401 static bool isYopy ( ); 404 static bool isYopy ( );
402}; 405};
403 406
404struct yopy_button { 407struct yopy_button {
405 Qt::Key code; 408 Qt::Key code;
406 char *utext; 409 char *utext;
407 char *pix; 410 char *pix;
408 char *fpressedservice; 411 char *fpressedservice;
409 char *fpressedaction; 412 char *fpressedaction;
410 char *fheldservice; 413 char *fheldservice;
411 char *fheldaction; 414 char *fheldaction;
412} yopy_buttons [] = { 415} yopy_buttons [] = {
413 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 416 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
414 "devicebuttons/yopy_action", 417 "devicebuttons/yopy_action",
415 "datebook", "nextView()", 418 "datebook", "nextView()",
416 "today", "raise()" }, 419 "today", "raise()" },
417 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 420 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
418 "devicebuttons/yopy_ok", 421 "devicebuttons/yopy_ok",
419 "addressbook", "raise()", 422 "addressbook", "raise()",
420 "addressbook", "beamBusinessCard()" }, 423 "addressbook", "beamBusinessCard()" },
421 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 424 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
422 "devicebuttons/yopy_end", 425 "devicebuttons/yopy_end",
423 "QPE/Launcher", "home()", 426 "QPE/Launcher", "home()",
424 "buttonsettings", "raise()" }, 427 "buttonsettings", "raise()" },
425}; 428};
426 429
427static QCString makeChannel ( const char *str ) 430static QCString makeChannel ( const char *str )
428{ 431{
429 if ( str && !::strchr ( str, '/' )) 432 if ( str && !::strchr ( str, '/' ))
430 return QCString ( "QPE/Application/" ) + str; 433 return QCString ( "QPE/Application/" ) + str;
431 else 434 else
432 return str; 435 return str;
433} 436}
434 437
435static inline bool isQWS() 438static inline bool isQWS()
436{ 439{
437 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 440 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
438} 441}
439 442
440ODevice *ODevice::inst ( ) 443ODevice *ODevice::inst ( )
441{ 444{
442 static ODevice *dev = 0; 445 static ODevice *dev = 0;
443 446
444 if ( !dev ) { 447 if ( !dev ) {
445 if ( QFile::exists ( "/proc/hal/model" )) 448 if ( QFile::exists ( "/proc/hal/model" ))
446 dev = new iPAQ ( ); 449 dev = new iPAQ ( );
447 else if ( Zaurus::isZaurus() ) 450 else if ( Zaurus::isZaurus() )
448 dev = new Zaurus ( ); 451 dev = new Zaurus ( );
449 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 452 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
450 dev = new SIMpad ( ); 453 dev = new SIMpad ( );
451 else if ( QFile::exists ( "/proc/sys/board/name" )) 454 else if ( QFile::exists ( "/proc/sys/board/name" ))
452 dev = new Ramses ( ); 455 dev = new Ramses ( );
453 else if ( Yopy::isYopy() ) 456 else if ( Yopy::isYopy() )
454 dev = new Yopy ( ); 457 dev = new Yopy ( );
455 else if ( Jornada::isJornada() ) 458 else if ( Jornada::isJornada() )
456 dev = new Jornada ( ); 459 dev = new Jornada ( );
457 else 460 else
458 dev = new ODevice ( ); 461 dev = new ODevice ( );
459 dev-> init ( ); 462 dev-> init ( );
460 } 463 }
461 return dev; 464 return dev;
462} 465}
463 466
464 467
465/************************************************** 468/**************************************************
466 * 469 *
467 * common 470 * common
468 * 471 *
469 **************************************************/ 472 **************************************************/
470 473
471 474
472ODevice::ODevice ( ) 475ODevice::ODevice ( )
473{ 476{
474 d = new ODeviceData; 477 d = new ODeviceData;
475 478
476 d-> m_modelstr = "Unknown"; 479 d-> m_modelstr = "Unknown";
477 d-> m_model = Model_Unknown; 480 d-> m_model = Model_Unknown;
478 d-> m_vendorstr = "Unknown"; 481 d-> m_vendorstr = "Unknown";
479 d-> m_vendor = Vendor_Unknown; 482 d-> m_vendor = Vendor_Unknown;
480 d-> m_systemstr = "Unknown"; 483 d-> m_systemstr = "Unknown";
481 d-> m_system = System_Unknown; 484 d-> m_system = System_Unknown;
482 d-> m_sysverstr = "0.0"; 485 d-> m_sysverstr = "0.0";
483 d-> m_rotation = Rot0; 486 d-> m_rotation = Rot0;
484 d-> m_direction = CW; 487 d-> m_direction = CW;
485 488
486 d-> m_holdtime = 1000; // 1000ms 489 d-> m_holdtime = 1000; // 1000ms
487 d-> m_buttons = 0; 490 d-> m_buttons = 0;
488 d-> m_cpu_frequencies = new QStrList; 491 d-> m_cpu_frequencies = new QStrList;
489} 492}
490 493
491void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 494void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
492{ 495{
493 if ( msg == "deviceButtonMappingChanged()" ) { 496 if ( msg == "deviceButtonMappingChanged()" ) {
494 reloadButtonMapping ( ); 497 reloadButtonMapping ( );
495 } 498 }
496} 499}
497 500
498void ODevice::init ( ) 501void ODevice::init ( )
499{ 502{
500} 503}
501 504
502/** 505/**
503 * This method initialises the button mapping 506 * This method initialises the button mapping
504 */ 507 */
505void ODevice::initButtons ( ) 508void ODevice::initButtons ( )
506{ 509{
507 if ( d-> m_buttons ) 510 if ( d-> m_buttons )
508 return; 511 return;
509 512
510 // Simulation uses iPAQ 3660 device buttons 513 // Simulation uses iPAQ 3660 device buttons
511 514
512 qDebug ( "init Buttons" ); 515 qDebug ( "init Buttons" );
513 d-> m_buttons = new QValueList <ODeviceButton>; 516 d-> m_buttons = new QValueList <ODeviceButton>;
514 517
515 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 518 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
516 i_button *ib = ipaq_buttons + i; 519 i_button *ib = ipaq_buttons + i;
517 ODeviceButton b; 520 ODeviceButton b;
518 521
519 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 522 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
520 b. setKeycode ( ib-> code ); 523 b. setKeycode ( ib-> code );
521 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 524 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
522 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 525 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
523 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 526 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
524 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 527 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
525 d-> m_buttons-> append ( b ); 528 d-> m_buttons-> append ( b );
526 } 529 }
527 } 530 }
528 reloadButtonMapping ( ); 531 reloadButtonMapping ( );
529 532
530 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 533 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
531 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 534 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
532} 535}
533 536
534ODevice::~ODevice ( ) 537ODevice::~ODevice ( )
535{ 538{
536// we leak m_devicebuttons and m_cpu_frequency 539// we leak m_devicebuttons and m_cpu_frequency
537// but it's a singleton and it is not so importantant 540// but it's a singleton and it is not so importantant
538// -zecke 541// -zecke
539 delete d; 542 delete d;
540} 543}
541 544
542bool ODevice::setSoftSuspend ( bool /*soft*/ ) 545bool ODevice::setSoftSuspend ( bool /*soft*/ )
543{ 546{
544 return false; 547 return false;
545} 548}
546 549
547//#include <linux/apm_bios.h> 550//#include <linux/apm_bios.h>
548 551
549#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 552#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
550 553
551/** 554/**
552 * This method will try to suspend the device 555 * This method will try to suspend the device
553 * It only works if the user is the QWS Server and the apm application 556 * It only works if the user is the QWS Server and the apm application
554 * is installed. 557 * is installed.
555 * It tries to suspend and then waits some time cause some distributions 558 * It tries to suspend and then waits some time cause some distributions
556 * do have asynchronus apm implementations. 559 * do have asynchronus apm implementations.
557 * This method will either fail and return false or it'll suspend the 560 * This method will either fail and return false or it'll suspend the
558 * device and return once the device got woken up 561 * device and return once the device got woken up
559 * 562 *
560 * @return if the device got suspended 563 * @return if the device got suspended
561 */ 564 */
562bool ODevice::suspend ( ) 565bool ODevice::suspend ( )
563{ 566{
564 qDebug("ODevice::suspend"); 567 qDebug("ODevice::suspend");
565 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 568 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
566 return false; 569 return false;
567 570
568 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 571 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
569 return false; 572 return false;
570 573
571 bool res = false; 574 bool res = false;
572 575
573 struct timeval tvs, tvn; 576 struct timeval tvs, tvn;
574 ::gettimeofday ( &tvs, 0 ); 577 ::gettimeofday ( &tvs, 0 );
575 578
576 ::sync ( ); // flush fs caches 579 ::sync ( ); // flush fs caches
577 res = ( ::system ( "apm --suspend" ) == 0 ); 580 res = ( ::system ( "apm --suspend" ) == 0 );
578 581
579 // This is needed because the iPAQ apm implementation is asynchronous and we 582 // This is needed because the iPAQ apm implementation is asynchronous and we
580 // can not be sure when exactly the device is really suspended 583 // can not be sure when exactly the device is really suspended
581 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 584 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
582 585
583 if ( res ) { 586 if ( res ) {
584 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 587 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
585 ::usleep ( 200 * 1000 ); 588 ::usleep ( 200 * 1000 );
586 ::gettimeofday ( &tvn, 0 ); 589 ::gettimeofday ( &tvn, 0 );
587 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 590 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
588 } 591 }
589 592
590 return res; 593 return res;
591} 594}
592 595
593//#include <linux/fb.h> better not rely on kernel headers in userspace ... 596//#include <linux/fb.h> better not rely on kernel headers in userspace ...
594 597
595#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 598#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
596 599
597/* VESA Blanking Levels */ 600/* VESA Blanking Levels */
598#define VESA_NO_BLANKING 0 601#define VESA_NO_BLANKING 0
599#define VESA_VSYNC_SUSPEND 1 602#define VESA_VSYNC_SUSPEND 1
600#define VESA_HSYNC_SUSPEND 2 603#define VESA_HSYNC_SUSPEND 2
601#define VESA_POWERDOWN 3 604#define VESA_POWERDOWN 3
602 605
603/** 606/**
604 * This sets the display on or off 607 * This sets the display on or off
605 */ 608 */
606bool ODevice::setDisplayStatus ( bool on ) 609bool ODevice::setDisplayStatus ( bool on )
607{ 610{
608 qDebug("ODevice::setDisplayStatus(%d)", on); 611 qDebug("ODevice::setDisplayStatus(%d)", on);
609 612
610 if ( d-> m_model == Model_Unknown ) 613 if ( d-> m_model == Model_Unknown )
611 return false; 614 return false;
612 615
613 bool res = false; 616 bool res = false;
614 int fd; 617 int fd;
615 618
616 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 619 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
617 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 620 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
618 ::close ( fd ); 621 ::close ( fd );
619 } 622 }
620 return res; 623 return res;
621} 624}
622 625
623/** 626/**
624 * This sets the display brightness 627 * This sets the display brightness
625 * 628 *
626 * @param p The brightness to be set on a scale from 0 to 255 629 * @param p The brightness to be set on a scale from 0 to 255
627 * @return success or failure 630 * @return success or failure
628 */ 631 */
629bool ODevice::setDisplayBrightness ( int p) 632bool ODevice::setDisplayBrightness ( int p)
630{ 633{
631 Q_UNUSED( p ) 634 Q_UNUSED( p )
632 return false; 635 return false;
633} 636}
634 637
635/** 638/**
636 * @return returns the number of steppings on the brightness slider 639 * @return returns the number of steppings on the brightness slider
637 * in the Light-'n-Power settings. 640 * in the Light-'n-Power settings.
638 */ 641 */
639int ODevice::displayBrightnessResolution ( ) const 642int ODevice::displayBrightnessResolution ( ) const
640{ 643{
641 return 16; 644 return 16;
642} 645}
643 646
644/** 647/**
645 * This sets the display contrast 648 * This sets the display contrast
646 * @param p The contrast to be set on a scale from 0 to 255 649 * @param p The contrast to be set on a scale from 0 to 255
647 * @return success or failure 650 * @return success or failure
648 */ 651 */
649bool ODevice::setDisplayContrast ( int p) 652bool ODevice::setDisplayContrast ( int p)
650{ 653{
651 Q_UNUSED( p ) 654 Q_UNUSED( p )
652 return false; 655 return false;
653} 656}
654 657
655/** 658/**
656 * @return return the max value for the brightness settings slider 659 * @return return the max value for the brightness settings slider
657 * or 0 if the device doesn't support setting of a contrast 660 * or 0 if the device doesn't support setting of a contrast
658 */ 661 */
659int ODevice::displayContrastResolution ( ) const 662int ODevice::displayContrastResolution ( ) const
660{ 663{
661 return 0; 664 return 0;
662} 665}
663 666
664/** 667/**
665 * This returns the vendor as string 668 * This returns the vendor as string
666 * @return Vendor as QString 669 * @return Vendor as QString
667 */ 670 */
668QString ODevice::vendorString ( ) const 671QString ODevice::vendorString ( ) const
669{ 672{
670 return d-> m_vendorstr; 673 return d-> m_vendorstr;
671} 674}
672 675
673/** 676/**
674 * This returns the vendor as one of the values of OVendor 677 * This returns the vendor as one of the values of OVendor
675 * @return OVendor 678 * @return OVendor
676 */ 679 */
677OVendor ODevice::vendor ( ) const 680OVendor ODevice::vendor ( ) const
678{ 681{
679 return d-> m_vendor; 682 return d-> m_vendor;
680} 683}
681 684
682/** 685/**
683 * This returns the model as a string 686 * This returns the model as a string
684 * @return A string representing the model 687 * @return A string representing the model
685 */ 688 */
686QString ODevice::modelString ( ) const 689QString ODevice::modelString ( ) const
687{ 690{
688 return d-> m_modelstr; 691 return d-> m_modelstr;
689} 692}
690 693
691/** 694/**
692 * This does return the OModel used 695 * This does return the OModel used
693 */ 696 */
694OModel ODevice::model ( ) const 697OModel ODevice::model ( ) const
695{ 698{
696 return d-> m_model; 699 return d-> m_model;
697} 700}
698 701
699/** 702/**
700 * This does return the systen name 703 * This does return the systen name
701 */ 704 */
702QString ODevice::systemString ( ) const 705QString ODevice::systemString ( ) const
703{ 706{
704 return d-> m_systemstr; 707 return d-> m_systemstr;
705} 708}
706 709
707/** 710/**
708 * Return System as OSystem value 711 * Return System as OSystem value
709 */ 712 */
710OSystem ODevice::system ( ) const 713OSystem ODevice::system ( ) const
711{ 714{
712 return d-> m_system; 715 return d-> m_system;
713} 716}
714 717
715/** 718/**
716 * @return the version string of the base system 719 * @return the version string of the base system
717 */ 720 */
718QString ODevice::systemVersionString ( ) const 721QString ODevice::systemVersionString ( ) const
719{ 722{
720 return d-> m_sysverstr; 723 return d-> m_sysverstr;
721} 724}
722 725
723/** 726/**
724 * @return the current Transformation 727 * @return the current Transformation
725 */ 728 */
726Transformation ODevice::rotation ( ) const 729Transformation ODevice::rotation ( ) const
727{ 730{
728 return d-> m_rotation; 731 return d-> m_rotation;
729} 732}
730 733
731/** 734/**
732 * @return the current rotation direction 735 * @return the current rotation direction
733 */ 736 */
734ODirection ODevice::direction ( ) const 737ODirection ODevice::direction ( ) const
735{ 738{
736 return d-> m_direction; 739 return d-> m_direction;
737} 740}
738 741
739/** 742/**
740 * This plays an alarmSound 743 * This plays an alarmSound
741 */ 744 */
742void ODevice::alarmSound ( ) 745void ODevice::alarmSound ( )
743{ 746{
744#ifndef QT_NO_SOUND 747#ifndef QT_NO_SOUND
745 static Sound snd ( "alarm" ); 748 static Sound snd ( "alarm" );
746 749
747 if ( snd. isFinished ( )) 750 if ( snd. isFinished ( ))
748 snd. play ( ); 751 snd. play ( );
749#endif 752#endif
750} 753}
751 754
752/** 755/**
753 * This plays a key sound 756 * This plays a key sound
754 */ 757 */
755void ODevice::keySound ( ) 758void ODevice::keySound ( )
756{ 759{
757#ifndef QT_NO_SOUND 760#ifndef QT_NO_SOUND
758 static Sound snd ( "keysound" ); 761 static Sound snd ( "keysound" );
759 762
760 if ( snd. isFinished ( )) 763 if ( snd. isFinished ( ))
761 snd. play ( ); 764 snd. play ( );
762#endif 765#endif
763} 766}
764 767
765/** 768/**
766 * This plays a touch sound 769 * This plays a touch sound
767 */ 770 */
768void ODevice::touchSound ( ) 771void ODevice::touchSound ( )
769{ 772{
770#ifndef QT_NO_SOUND 773#ifndef QT_NO_SOUND
771 static Sound snd ( "touchsound" ); 774 static Sound snd ( "touchsound" );
772 775
773 if ( snd. isFinished ( )) 776 if ( snd. isFinished ( ))
774 snd. play ( ); 777 snd. play ( );
775#endif 778#endif
776} 779}
777 780
778/** 781/**
779 * This method will return a list of leds 782 * This method will return a list of leds
780 * available on this device 783 * available on this device
781 * @return a list of LEDs. 784 * @return a list of LEDs.
782 */ 785 */
783QValueList <OLed> ODevice::ledList ( ) const 786QValueList <OLed> ODevice::ledList ( ) const
784{ 787{
785 return QValueList <OLed> ( ); 788 return QValueList <OLed> ( );
786} 789}
787 790
788/** 791/**
789 * This does return the state of the LEDs 792 * This does return the state of the LEDs
790 */ 793 */
791QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 794QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
792{ 795{
793 return QValueList <OLedState> ( ); 796 return QValueList <OLedState> ( );
794} 797}
795 798
796/** 799/**
797 * @return the state for a given OLed 800 * @return the state for a given OLed
798 */ 801 */
799OLedState ODevice::ledState ( OLed /*which*/ ) const 802OLedState ODevice::ledState ( OLed /*which*/ ) const
800{ 803{
801 return Led_Off; 804 return Led_Off;
802} 805}
803 806
804/** 807/**
805 * Set the state for a LED 808 * Set the state for a LED
806 * @param which Which OLed to use 809 * @param which Which OLed to use
807 * @param st The state to set 810 * @param st The state to set
808 * @return success or failure 811 * @return success or failure
809 */ 812 */
810bool ODevice::setLedState ( OLed which, OLedState st ) 813bool ODevice::setLedState ( OLed which, OLedState st )
811{ 814{
812 Q_UNUSED( which ) 815 Q_UNUSED( which )
813 Q_UNUSED( st ) 816 Q_UNUSED( st )
814 return false; 817 return false;
815} 818}
816 819
817/** 820/**
818 * @return if the device has a light sensor 821 * @return if the device has a light sensor
819 */ 822 */
820bool ODevice::hasLightSensor ( ) const 823bool ODevice::hasLightSensor ( ) const
821{ 824{
822 return false; 825 return false;
823} 826}
824 827
825/** 828/**
826 * @return a value from the light senso 829 * @return a value from the light sensor
827 */ 830 */
828int ODevice::readLightSensor ( ) 831int ODevice::readLightSensor ( )
829{ 832{
830 return -1; 833 return -1;
831} 834}
832 835
833/** 836/**
834 * @return the light sensor resolution whatever that is ;) 837 * @return the light sensor resolution
835 */ 838 */
836int ODevice::lightSensorResolution ( ) const 839int ODevice::lightSensorResolution ( ) const
837{ 840{
838 return 0; 841 return 0;
839} 842}
840 843
841/** 844/**
845 * @return if the device has a hinge sensor
846 */
847bool ODevice::hasHingeSensor ( ) const
848{
849 return false;
850}
851
852/**
853 * @return a value from the hinge sensor
854 */
855OHingeStatus ODevice::readHingeSensor ( )
856{
857 return CASE_UNKNOWN;
858}
859
860/**
842 * @return a list with CPU frequencies supported by the hardware 861 * @return a list with CPU frequencies supported by the hardware
843 */ 862 */
844const QStrList &ODevice::allowedCpuFrequencies ( ) const 863const QStrList &ODevice::allowedCpuFrequencies ( ) const
845{ 864{
846 return *d->m_cpu_frequencies; 865 return *d->m_cpu_frequencies;
847} 866}
848 867
849 868
850/** 869/**
851 * Set desired CPU frequency 870 * Set desired CPU frequency
852 * 871 *
853 * @param index index into d->m_cpu_frequencies of the frequency to be set 872 * @param index index into d->m_cpu_frequencies of the frequency to be set
854 */ 873 */
855bool ODevice::setCurrentCpuFrequency(uint index) 874bool ODevice::setCurrentCpuFrequency(uint index)
856{ 875{
857 if (index >= d->m_cpu_frequencies->count()) 876 if (index >= d->m_cpu_frequencies->count())
858 return false; 877 return false;
859 878
860 char *freq = d->m_cpu_frequencies->at(index); 879 char *freq = d->m_cpu_frequencies->at(index);
861 qWarning("set freq to %s", freq); 880 qWarning("set freq to %s", freq);
862 881
863 int fd; 882 int fd;
864 883
865 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 884 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
866 char writeCommand[50]; 885 char writeCommand[50];
867 const int count = sprintf(writeCommand, "%s\n", freq); 886 const int count = sprintf(writeCommand, "%s\n", freq);
868 int res = (::write(fd, writeCommand, count) != -1); 887 int res = (::write(fd, writeCommand, count) != -1);
869 ::close(fd); 888 ::close(fd);
870 return res; 889 return res;
871 } 890 }
872 891
873 return false; 892 return false;
874} 893}
875 894
876 895
877/** 896/**
878 * @return a list of hardware buttons 897 * @return a list of hardware buttons
879 */ 898 */
880const QValueList <ODeviceButton> &ODevice::buttons ( ) 899const QValueList <ODeviceButton> &ODevice::buttons ( )
881{ 900{
882 initButtons ( ); 901 initButtons ( );
883 902
884 return *d-> m_buttons; 903 return *d-> m_buttons;
885} 904}
886 905
887/** 906/**
888 * @return The amount of time that would count as a hold 907 * @return The amount of time that would count as a hold
889 */ 908 */
890uint ODevice::buttonHoldTime ( ) const 909uint ODevice::buttonHoldTime ( ) const
891{ 910{
892 return d-> m_holdtime; 911 return d-> m_holdtime;
893} 912}
894 913
895/** 914/**
896 * This method return a ODeviceButton for a key code 915 * This method return a ODeviceButton for a key code
897 * or 0 if no special hardware button is available for the device 916 * or 0 if no special hardware button is available for the device
898 * 917 *
899 * @return The devicebutton or 0l 918 * @return The devicebutton or 0l
900 * @see ODeviceButton 919 * @see ODeviceButton
901 */ 920 */
902const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 921const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
903{ 922{
904 initButtons ( ); 923 initButtons ( );
905 924
906 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 925 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
907 if ( (*it). keycode ( ) == code ) 926 if ( (*it). keycode ( ) == code )
908 return &(*it); 927 return &(*it);
909 } 928 }
910 return 0; 929 return 0;
911} 930}
912 931
913void ODevice::reloadButtonMapping ( ) 932void ODevice::reloadButtonMapping ( )
914{ 933{
915 initButtons ( ); 934 initButtons ( );
916 935
917 Config cfg ( "ButtonSettings" ); 936 Config cfg ( "ButtonSettings" );
918 937
919 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 938 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
920 ODeviceButton &b = ( *d-> m_buttons ) [i]; 939 ODeviceButton &b = ( *d-> m_buttons ) [i];
921 QString group = "Button" + QString::number ( i ); 940 QString group = "Button" + QString::number ( i );
922 941
923 QCString pch, hch; 942 QCString pch, hch;
924 QCString pm, hm; 943 QCString pm, hm;
925 QByteArray pdata, hdata; 944 QByteArray pdata, hdata;
926 945
927 if ( cfg. hasGroup ( group )) { 946 if ( cfg. hasGroup ( group )) {
928 cfg. setGroup ( group ); 947 cfg. setGroup ( group );
929 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 948 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
930 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 949 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
931 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 950 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
932 951
933 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 952 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
934 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 953 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
935 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 954 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
936 } 955 }
937 956
938 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 957 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
939 958
940 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 959 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
941 } 960 }
942} 961}
943 962
944void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 963void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
945{ 964{
946 initButtons ( ); 965 initButtons ( );
947 966
948 QString mb_chan; 967 QString mb_chan;
949 968
950 if ( button >= (int) d-> m_buttons-> count ( )) 969 if ( button >= (int) d-> m_buttons-> count ( ))
951 return; 970 return;
952 971
953 ODeviceButton &b = ( *d-> m_buttons ) [button]; 972 ODeviceButton &b = ( *d-> m_buttons ) [button];
954 b. setPressedAction ( action ); 973 b. setPressedAction ( action );
955 974
956 mb_chan=b. pressedAction ( ). channel ( ); 975 mb_chan=b. pressedAction ( ). channel ( );
957 976
958 Config buttonFile ( "ButtonSettings" ); 977 Config buttonFile ( "ButtonSettings" );
959 buttonFile. setGroup ( "Button" + QString::number ( button )); 978 buttonFile. setGroup ( "Button" + QString::number ( button ));
960 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 979 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
961 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 980 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
962 981
963 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 982 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
964 983
965 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 984 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
966} 985}
967 986
968void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 987void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
969{ 988{
970 initButtons ( ); 989 initButtons ( );
971 990
972 if ( button >= (int) d-> m_buttons-> count ( )) 991 if ( button >= (int) d-> m_buttons-> count ( ))
973 return; 992 return;
974 993
975 ODeviceButton &b = ( *d-> m_buttons ) [button]; 994 ODeviceButton &b = ( *d-> m_buttons ) [button];
976 b. setHeldAction ( action ); 995 b. setHeldAction ( action );
977 996
978 Config buttonFile ( "ButtonSettings" ); 997 Config buttonFile ( "ButtonSettings" );
979 buttonFile. setGroup ( "Button" + QString::number ( button )); 998 buttonFile. setGroup ( "Button" + QString::number ( button ));
980 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 999 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
981 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 1000 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
982 1001
983 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 1002 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
984 1003
985 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 1004 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
986} 1005}
987void ODevice::virtual_hook(int, void* ){ 1006void ODevice::virtual_hook(int, void* ){
988 1007
989} 1008}
990 1009
991/************************************************** 1010/**************************************************
992 * 1011 *
993 * Yopy 3500/3700 1012 * Yopy 3500/3700
994 * 1013 *
995 **************************************************/ 1014 **************************************************/
996 1015
997bool Yopy::isYopy ( ) 1016bool Yopy::isYopy ( )
998{ 1017{
999 QFile f( "/proc/cpuinfo" ); 1018 QFile f( "/proc/cpuinfo" );
1000 if ( f. open ( IO_ReadOnly ) ) { 1019 if ( f. open ( IO_ReadOnly ) ) {
1001 QTextStream ts ( &f ); 1020 QTextStream ts ( &f );
1002 QString line; 1021 QString line;
1003 while( line = ts. readLine ( ) ) { 1022 while( line = ts. readLine ( ) ) {
1004 if ( line. left ( 8 ) == "Hardware" ) { 1023 if ( line. left ( 8 ) == "Hardware" ) {
1005 int loc = line. find ( ":" ); 1024 int loc = line. find ( ":" );
1006 if ( loc != -1 ) { 1025 if ( loc != -1 ) {
1007 QString model = 1026 QString model =
1008 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1027 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1009 return ( model == "Yopy" ); 1028 return ( model == "Yopy" );
1010 } 1029 }
1011 } 1030 }
1012 } 1031 }
1013 } 1032 }
1014 return false; 1033 return false;
1015} 1034}
1016 1035
1017void Yopy::init ( ) 1036void Yopy::init ( )
1018{ 1037{
1019 d-> m_vendorstr = "G.Mate"; 1038 d-> m_vendorstr = "G.Mate";
1020 d-> m_vendor = Vendor_GMate; 1039 d-> m_vendor = Vendor_GMate;
1021 d-> m_modelstr = "Yopy3700"; 1040 d-> m_modelstr = "Yopy3700";
1022 d-> m_model = Model_Yopy_3700; 1041 d-> m_model = Model_Yopy_3700;
1023 d-> m_rotation = Rot0; 1042 d-> m_rotation = Rot0;
1024 1043
1025 d-> m_systemstr = "Linupy"; 1044 d-> m_systemstr = "Linupy";
1026 d-> m_system = System_Linupy; 1045 d-> m_system = System_Linupy;
1027 1046
1028 QFile f ( "/etc/issue" ); 1047 QFile f ( "/etc/issue" );
1029 if ( f. open ( IO_ReadOnly )) { 1048 if ( f. open ( IO_ReadOnly )) {
1030 QTextStream ts ( &f ); 1049 QTextStream ts ( &f );
1031 ts.readLine(); 1050 ts.readLine();
1032 d-> m_sysverstr = ts. readLine ( ); 1051 d-> m_sysverstr = ts. readLine ( );
1033 f. close ( ); 1052 f. close ( );
1034 } 1053 }
1035} 1054}
1036 1055
1037void Yopy::initButtons ( ) 1056void Yopy::initButtons ( )
1038{ 1057{
1039 if ( d-> m_buttons ) 1058 if ( d-> m_buttons )
1040 return; 1059 return;
1041 1060
1042 d-> m_buttons = new QValueList <ODeviceButton>; 1061 d-> m_buttons = new QValueList <ODeviceButton>;
1043 1062
1044 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1063 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1045 1064
1046 yopy_button *ib = yopy_buttons + i; 1065 yopy_button *ib = yopy_buttons + i;
1047 1066
1048 ODeviceButton b; 1067 ODeviceButton b;
1049 1068
1050 b. setKeycode ( ib-> code ); 1069 b. setKeycode ( ib-> code );
1051 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1070 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1052 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1071 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1053 b. setFactoryPresetPressedAction 1072 b. setFactoryPresetPressedAction
1054 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1073 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1055 b. setFactoryPresetHeldAction 1074 b. setFactoryPresetHeldAction
1056 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1075 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1057 1076
1058 d-> m_buttons-> append ( b ); 1077 d-> m_buttons-> append ( b );
1059 } 1078 }
1060 reloadButtonMapping ( ); 1079 reloadButtonMapping ( );
1061 1080
1062 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1081 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1063 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1082 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1064 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1083 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1065} 1084}
1066 1085
1067bool Yopy::suspend() 1086bool Yopy::suspend()
1068{ 1087{
1069 /* Opie for Yopy does not implement its own power management at the 1088 /* Opie for Yopy does not implement its own power management at the
1070 moment. The public version runs parallel to X, and relies on the 1089 moment. The public version runs parallel to X, and relies on the
1071 existing power management features. */ 1090 existing power management features. */
1072 return false; 1091 return false;
1073} 1092}
1074 1093
1075bool Yopy::setDisplayBrightness(int bright) 1094bool Yopy::setDisplayBrightness(int bright)
1076{ 1095{
1077 /* The code here works, but is disabled as the current version runs 1096 /* The code here works, but is disabled as the current version runs
1078 parallel to X, and relies on the existing backlight demon. */ 1097 parallel to X, and relies on the existing backlight demon. */
1079#if 0 1098#if 0
1080 if ( QFile::exists("/proc/sys/pm/light") ) { 1099 if ( QFile::exists("/proc/sys/pm/light") ) {
1081 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1100 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1082 if (fd >= 0 ) { 1101 if (fd >= 0 ) {
1083 if (bright) 1102 if (bright)
1084 ::write(fd, "1\n", 2); 1103 ::write(fd, "1\n", 2);
1085 else 1104 else
1086 ::write(fd, "0\n", 2); 1105 ::write(fd, "0\n", 2);
1087 ::close(fd); 1106 ::close(fd);
1088 return true; 1107 return true;
1089 } 1108 }
1090 } 1109 }
1091#endif 1110#endif
1092 return false; 1111 return false;
1093} 1112}
1094 1113
1095int Yopy::displayBrightnessResolution() const 1114int Yopy::displayBrightnessResolution() const
1096{ 1115{
1097 return 2; 1116 return 2;
1098} 1117}
1099 1118
1100/************************************************** 1119/**************************************************
1101 * 1120 *
1102 * iPAQ 1121 * iPAQ
1103 * 1122 *
1104 **************************************************/ 1123 **************************************************/
1105 1124
1106void iPAQ::init ( ) 1125void iPAQ::init ( )
1107{ 1126{
1108 d-> m_vendorstr = "HP"; 1127 d-> m_vendorstr = "HP";
1109 d-> m_vendor = Vendor_HP; 1128 d-> m_vendor = Vendor_HP;
1110 1129
1111 QFile f ( "/proc/hal/model" ); 1130 QFile f ( "/proc/hal/model" );
1112 1131
1113 if ( f. open ( IO_ReadOnly )) { 1132 if ( f. open ( IO_ReadOnly )) {
1114 QTextStream ts ( &f ); 1133 QTextStream ts ( &f );
1115 1134
1116 d-> m_modelstr = "H" + ts. readLine ( ); 1135 d-> m_modelstr = "H" + ts. readLine ( );
1117 1136
1118 if ( d-> m_modelstr == "H3100" ) 1137 if ( d-> m_modelstr == "H3100" )
1119 d-> m_model = Model_iPAQ_H31xx; 1138 d-> m_model = Model_iPAQ_H31xx;
1120 else if ( d-> m_modelstr == "H3600" ) 1139 else if ( d-> m_modelstr == "H3600" )
1121 d-> m_model = Model_iPAQ_H36xx; 1140 d-> m_model = Model_iPAQ_H36xx;
1122 else if ( d-> m_modelstr == "H3700" ) 1141 else if ( d-> m_modelstr == "H3700" )
1123 d-> m_model = Model_iPAQ_H37xx; 1142 d-> m_model = Model_iPAQ_H37xx;
1124 else if ( d-> m_modelstr == "H3800" ) 1143 else if ( d-> m_modelstr == "H3800" )
1125 d-> m_model = Model_iPAQ_H38xx; 1144 d-> m_model = Model_iPAQ_H38xx;
1126 else if ( d-> m_modelstr == "H3900" ) 1145 else if ( d-> m_modelstr == "H3900" )
1127 d-> m_model = Model_iPAQ_H39xx; 1146 d-> m_model = Model_iPAQ_H39xx;
1128 else if ( d-> m_modelstr == "H5400" ) 1147 else if ( d-> m_modelstr == "H5400" )
1129 d-> m_model = Model_iPAQ_H5xxx; 1148 d-> m_model = Model_iPAQ_H5xxx;
1130 else 1149 else
1131 d-> m_model = Model_Unknown; 1150 d-> m_model = Model_Unknown;
1132 1151
1133 f. close ( ); 1152 f. close ( );
1134 } 1153 }
1135 1154
1136 switch ( d-> m_model ) { 1155 switch ( d-> m_model ) {
1137 case Model_iPAQ_H31xx: 1156 case Model_iPAQ_H31xx:
1138 case Model_iPAQ_H38xx: 1157 case Model_iPAQ_H38xx:
1139 d-> m_rotation = Rot90; 1158 d-> m_rotation = Rot90;
1140 break; 1159 break;
1141 case Model_iPAQ_H36xx: 1160 case Model_iPAQ_H36xx:
1142 case Model_iPAQ_H37xx: 1161 case Model_iPAQ_H37xx:
1143 case Model_iPAQ_H39xx: 1162 case Model_iPAQ_H39xx:
1144 1163
1145 default: 1164 default:
1146 d-> m_rotation = Rot270; 1165 d-> m_rotation = Rot270;
1147 break; 1166 break;
1148 case Model_iPAQ_H5xxx: 1167 case Model_iPAQ_H5xxx:
1149 d-> m_rotation = Rot0; 1168 d-> m_rotation = Rot0;
1150 } 1169 }
1151 1170
1152 f. setName ( "/etc/familiar-version" ); 1171 f. setName ( "/etc/familiar-version" );
1153 if ( f. open ( IO_ReadOnly )) { 1172 if ( f. open ( IO_ReadOnly )) {
1154 d-> m_systemstr = "Familiar"; 1173 d-> m_systemstr = "Familiar";
1155 d-> m_system = System_Familiar; 1174 d-> m_system = System_Familiar;
1156 1175
1157 QTextStream ts ( &f ); 1176 QTextStream ts ( &f );
1158 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1177 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1159 1178
1160 f. close ( ); 1179 f. close ( );
1161 } else { 1180 } else {
1162 f. setName ( "/etc/oz_version" ); 1181 f. setName ( "/etc/oz_version" );
1163 1182
1164 if ( f. open ( IO_ReadOnly )) { 1183 if ( f. open ( IO_ReadOnly )) {
1165 d-> m_systemstr = "OpenEmbedded/iPaq"; 1184 d-> m_systemstr = "OpenEmbedded/iPaq";
1166 d-> m_system = System_Familiar; 1185 d-> m_system = System_Familiar;
1167 1186
1168 QTextStream ts ( &f ); 1187 QTextStream ts ( &f );
1169 ts.setDevice ( &f ); 1188 ts.setDevice ( &f );
1170 d-> m_sysverstr = ts. readLine ( ); 1189 d-> m_sysverstr = ts. readLine ( );
1171 f. close ( ); 1190 f. close ( );
1172 } 1191 }
1173 } 1192 }
1174 1193
1175 1194
1176 1195
1177 1196
1178 1197
1179 m_leds [0] = m_leds [1] = Led_Off; 1198 m_leds [0] = m_leds [1] = Led_Off;
1180 1199
1181 m_power_timer = 0; 1200 m_power_timer = 0;
1182 1201
1183} 1202}
1184 1203
1185void iPAQ::initButtons ( ) 1204void iPAQ::initButtons ( )
1186{ 1205{
1187 if ( d-> m_buttons ) 1206 if ( d-> m_buttons )
1188 return; 1207 return;
1189 1208
1190 if ( isQWS( ) ) 1209 if ( isQWS( ) )
1191 QWSServer::setKeyboardFilter ( this ); 1210 QWSServer::setKeyboardFilter ( this );
1192 1211
1193 d-> m_buttons = new QValueList <ODeviceButton>; 1212 d-> m_buttons = new QValueList <ODeviceButton>;
1194 1213
1195 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1214 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1196 i_button *ib = ipaq_buttons + i; 1215 i_button *ib = ipaq_buttons + i;
1197 ODeviceButton b; 1216 ODeviceButton b;
1198 1217
1199 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1218 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1200 b. setKeycode ( ib-> code ); 1219 b. setKeycode ( ib-> code );
1201 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1220 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1202 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1221 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1203 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1204 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1205 1224
1206 d-> m_buttons-> append ( b ); 1225 d-> m_buttons-> append ( b );
1207 } 1226 }
1208 } 1227 }
1209 reloadButtonMapping ( ); 1228 reloadButtonMapping ( );
1210 1229
1211 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1212 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1231 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1213} 1232}
1214 1233
1215 1234
1216//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1235//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1217 1236
1218typedef struct { 1237typedef struct {
1219 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1220 unsigned char TotalTime; /* Units of 5 seconds */ 1239 unsigned char TotalTime; /* Units of 5 seconds */
1221 unsigned char OnTime; /* units of 100m/s */ 1240 unsigned char OnTime; /* units of 100m/s */
1222 unsigned char OffTime; /* units of 100m/s */ 1241 unsigned char OffTime; /* units of 100m/s */
1223} LED_IN; 1242} LED_IN;
1224 1243
1225typedef struct { 1244typedef struct {
1226 unsigned char mode; 1245 unsigned char mode;
1227 unsigned char pwr; 1246 unsigned char pwr;
1228 unsigned char brightness; 1247 unsigned char brightness;
1229} FLITE_IN; 1248} FLITE_IN;
1230 1249
1231#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1250#define LED_ON OD_IOW( 'f', 5, LED_IN )
1232#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1251#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1233 1252
1234 1253
1235QValueList <OLed> iPAQ::ledList ( ) const 1254QValueList <OLed> iPAQ::ledList ( ) const
1236{ 1255{
1237 QValueList <OLed> vl; 1256 QValueList <OLed> vl;
1238 vl << Led_Power; 1257 vl << Led_Power;
1239 1258
1240 if ( d-> m_model == Model_iPAQ_H38xx ) 1259 if ( d-> m_model == Model_iPAQ_H38xx )
1241 vl << Led_BlueTooth; 1260 vl << Led_BlueTooth;
1242 return vl; 1261 return vl;
1243} 1262}
1244 1263
1245QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1264QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1246{ 1265{
1247 QValueList <OLedState> vl; 1266 QValueList <OLedState> vl;
1248 1267
1249 if ( l == Led_Power ) 1268 if ( l == Led_Power )
1250 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1269 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1251 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1270 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1252 vl << Led_Off; // << Led_On << ??? 1271 vl << Led_Off; // << Led_On << ???
1253 1272
1254 return vl; 1273 return vl;
1255} 1274}
1256 1275
1257OLedState iPAQ::ledState ( OLed l ) const 1276OLedState iPAQ::ledState ( OLed l ) const
1258{ 1277{
1259 switch ( l ) { 1278 switch ( l ) {
1260 case Led_Power: 1279 case Led_Power:
1261 return m_leds [0]; 1280 return m_leds [0];
1262 case Led_BlueTooth: 1281 case Led_BlueTooth:
1263 return m_leds [1]; 1282 return m_leds [1];
1264 default: 1283 default:
1265 return Led_Off; 1284 return Led_Off;
1266 } 1285 }
1267} 1286}
1268 1287
1269bool iPAQ::setLedState ( OLed l, OLedState st ) 1288bool iPAQ::setLedState ( OLed l, OLedState st )
1270{ 1289{
1271 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1290 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1272 1291
1273 if ( l == Led_Power ) { 1292 if ( l == Led_Power ) {
1274 if ( fd >= 0 ) { 1293 if ( fd >= 0 ) {
1275 LED_IN leds; 1294 LED_IN leds;
1276 ::memset ( &leds, 0, sizeof( leds )); 1295 ::memset ( &leds, 0, sizeof( leds ));
1277 leds. TotalTime = 0; 1296 leds. TotalTime = 0;
1278 leds. OnTime = 0; 1297 leds. OnTime = 0;
1279 leds. OffTime = 1; 1298 leds. OffTime = 1;
1280 leds. OffOnBlink = 2; 1299 leds. OffOnBlink = 2;
1281 1300
1282 switch ( st ) { 1301 switch ( st ) {
1283 case Led_Off : leds. OffOnBlink = 0; break; 1302 case Led_Off : leds. OffOnBlink = 0; break;
1284 case Led_On : leds. OffOnBlink = 1; break; 1303 case Led_On : leds. OffOnBlink = 1; break;
1285 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1304 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1286 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1305 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1287 } 1306 }
1288 1307
1289 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1308 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1290 m_leds [0] = st; 1309 m_leds [0] = st;
1291 return true; 1310 return true;
1292 } 1311 }
1293 } 1312 }
1294 } 1313 }
1295 return false; 1314 return false;
1296} 1315}
1297 1316
1298 1317
1299bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1318bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1300{ 1319{
1301 int newkeycode = keycode; 1320 int newkeycode = keycode;
1302 1321
1303 switch ( keycode ) { 1322 switch ( keycode ) {
1304 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1323 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1305 case HardKey_Menu: { 1324 case HardKey_Menu: {
1306 if (( d-> m_model == Model_iPAQ_H38xx ) || 1325 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1307 ( d-> m_model == Model_iPAQ_H39xx ) || 1326 ( d-> m_model == Model_iPAQ_H39xx ) ||
1308 ( d-> m_model == Model_iPAQ_H5xxx)) { 1327 ( d-> m_model == Model_iPAQ_H5xxx)) {
1309 newkeycode = HardKey_Mail; 1328 newkeycode = HardKey_Mail;
1310 } 1329 }
1311 break; 1330 break;
1312 } 1331 }
1313 1332
1314 // Rotate cursor keys 180° 1333 // Rotate cursor keys 180°
1315 case Key_Left : 1334 case Key_Left :
1316 case Key_Right: 1335 case Key_Right:
1317 case Key_Up : 1336 case Key_Up :
1318 case Key_Down : { 1337 case Key_Down : {
1319 if (( d-> m_model == Model_iPAQ_H31xx ) || 1338 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1320 ( d-> m_model == Model_iPAQ_H38xx )) { 1339 ( d-> m_model == Model_iPAQ_H38xx )) {
1321 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1340 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1322 } 1341 }
1323 break; 1342 break;
1324 } 1343 }
1325 1344
1326 // map Power Button short/long press to F34/F35 1345 // map Power Button short/long press to F34/F35
1327 case Key_SysReq: { 1346 case Key_SysReq: {
1328 if ( isPress ) { 1347 if ( isPress ) {
1329 if ( m_power_timer ) 1348 if ( m_power_timer )
1330 killTimer ( m_power_timer ); 1349 killTimer ( m_power_timer );
1331 m_power_timer = startTimer ( 500 ); 1350 m_power_timer = startTimer ( 500 );
1332 } 1351 }
1333 else if ( m_power_timer ) { 1352 else if ( m_power_timer ) {
1334 killTimer ( m_power_timer ); 1353 killTimer ( m_power_timer );
1335 m_power_timer = 0; 1354 m_power_timer = 0;
1336 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1355 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1337 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1356 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1338 } 1357 }
1339 newkeycode = Key_unknown; 1358 newkeycode = Key_unknown;
1340 break; 1359 break;
1341 } 1360 }
1342 } 1361 }
1343 1362
1344 if ( newkeycode != keycode ) { 1363 if ( newkeycode != keycode ) {
1345 if ( newkeycode != Key_unknown ) 1364 if ( newkeycode != Key_unknown )
1346 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1365 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1347 return true; 1366 return true;
1348 } 1367 }
1349 else 1368 else
1350 return false; 1369 return false;
1351} 1370}
1352 1371
1353void iPAQ::timerEvent ( QTimerEvent * ) 1372void iPAQ::timerEvent ( QTimerEvent * )
1354{ 1373{
1355 killTimer ( m_power_timer ); 1374 killTimer ( m_power_timer );
1356 m_power_timer = 0; 1375 m_power_timer = 0;
1357 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1376 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1358 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1377 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1359} 1378}
1360 1379
1361 1380
1362void iPAQ::alarmSound ( ) 1381void iPAQ::alarmSound ( )
1363{ 1382{
1364#ifndef QT_NO_SOUND 1383#ifndef QT_NO_SOUND
1365 static Sound snd ( "alarm" ); 1384 static Sound snd ( "alarm" );
1366 int fd; 1385 int fd;
1367 int vol; 1386 int vol;
1368 bool vol_reset = false; 1387 bool vol_reset = false;
1369 1388
1370 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1389 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1371 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1390 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1372 Config cfg ( "qpe" ); 1391 Config cfg ( "qpe" );
1373 cfg. setGroup ( "Volume" ); 1392 cfg. setGroup ( "Volume" );
1374 1393
1375 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1394 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1376 if ( volalarm < 0 ) 1395 if ( volalarm < 0 )
1377 volalarm = 0; 1396 volalarm = 0;
1378 else if ( volalarm > 100 ) 1397 else if ( volalarm > 100 )
1379 volalarm = 100; 1398 volalarm = 100;
1380 volalarm |= ( volalarm << 8 ); 1399 volalarm |= ( volalarm << 8 );
1381 1400
1382 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1401 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1383 vol_reset = true; 1402 vol_reset = true;
1384 } 1403 }
1385 } 1404 }
1386 1405
1387 snd. play ( ); 1406 snd. play ( );
1388 while ( !snd. isFinished ( )) 1407 while ( !snd. isFinished ( ))
1389 qApp-> processEvents ( ); 1408 qApp-> processEvents ( );
1390 1409
1391 if ( fd >= 0 ) { 1410 if ( fd >= 0 ) {
1392 if ( vol_reset ) 1411 if ( vol_reset )
1393 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1412 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1394 ::close ( fd ); 1413 ::close ( fd );
1395 } 1414 }
1396#endif 1415#endif
1397} 1416}
1398 1417
1399 1418
1400bool iPAQ::setSoftSuspend ( bool soft ) 1419bool iPAQ::setSoftSuspend ( bool soft )
1401{ 1420{
1402 bool res = false; 1421 bool res = false;
1403 int fd; 1422 int fd;
1404 1423
1405 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1424 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1406 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1425 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1407 res = true; 1426 res = true;
1408 else 1427 else
1409 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1428 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1410 1429
1411 ::close ( fd ); 1430 ::close ( fd );
1412 } 1431 }
1413 else 1432 else
1414 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1433 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1415 1434
1416 return res; 1435 return res;
1417} 1436}
1418 1437
1419 1438
1420bool iPAQ::setDisplayBrightness ( int bright ) 1439bool iPAQ::setDisplayBrightness ( int bright )
1421{ 1440{
1422 bool res = false; 1441 bool res = false;
1423 int fd; 1442 int fd;
1424 1443
1425 if ( bright > 255 ) 1444 if ( bright > 255 )
1426 bright = 255; 1445 bright = 255;
1427 if ( bright < 0 ) 1446 if ( bright < 0 )
1428 bright = 0; 1447 bright = 0;
1429 1448
1430 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1449 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1431 FLITE_IN bl; 1450 FLITE_IN bl;
1432 bl. mode = 1; 1451 bl. mode = 1;
1433 bl. pwr = bright ? 1 : 0; 1452 bl. pwr = bright ? 1 : 0;
1434 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1453 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1435 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1454 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1436 ::close ( fd ); 1455 ::close ( fd );
1437 } 1456 }
1438 return res; 1457 return res;
1439} 1458}
1440 1459
1441int iPAQ::displayBrightnessResolution ( ) const 1460int iPAQ::displayBrightnessResolution ( ) const
1442{ 1461{
1443 switch ( model ( )) { 1462 switch ( model ( )) {
1444 case Model_iPAQ_H31xx: 1463 case Model_iPAQ_H31xx:
1445 case Model_iPAQ_H36xx: 1464 case Model_iPAQ_H36xx:
1446 case Model_iPAQ_H37xx: 1465 case Model_iPAQ_H37xx:
1447 return 128; // really 256, but >128 could damage the LCD 1466 return 128; // really 256, but >128 could damage the LCD
1448 1467
1449 case Model_iPAQ_H38xx: 1468 case Model_iPAQ_H38xx:
1450 case Model_iPAQ_H39xx: 1469 case Model_iPAQ_H39xx:
1451 return 64; 1470 return 64;
1452 case Model_iPAQ_H5xxx: 1471 case Model_iPAQ_H5xxx:
1453 return 255; 1472 return 255;
1454 1473
1455 default: 1474 default:
1456 return 2; 1475 return 2;
1457 } 1476 }
1458} 1477}
1459 1478
1460 1479
1461bool iPAQ::hasLightSensor ( ) const 1480bool iPAQ::hasLightSensor ( ) const
1462{ 1481{
1463 return true; 1482 return true;
1464} 1483}
1465 1484
1466int iPAQ::readLightSensor ( ) 1485int iPAQ::readLightSensor ( )
1467{ 1486{
1468 int fd; 1487 int fd;
1469 int val = -1; 1488 int val = -1;
1470 1489
1471 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1490 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1472 char buffer [8]; 1491 char buffer [8];
1473 1492
1474 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1493 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1475 char *endptr; 1494 char *endptr;
1476 1495
1477 buffer [4] = 0; 1496 buffer [4] = 0;
1478 val = ::strtol ( buffer + 2, &endptr, 16 ); 1497 val = ::strtol ( buffer + 2, &endptr, 16 );
1479 1498
1480 if ( *endptr != 0 ) 1499 if ( *endptr != 0 )
1481 val = -1; 1500 val = -1;
1482 } 1501 }
1483 ::close ( fd ); 1502 ::close ( fd );
1484 } 1503 }
1485 1504
1486 return val; 1505 return val;
1487} 1506}
1488 1507
1489int iPAQ::lightSensorResolution ( ) const 1508int iPAQ::lightSensorResolution ( ) const
1490{ 1509{
1491 return 256; 1510 return 256;
1492} 1511}
1493 1512
1494/************************************************** 1513/**************************************************
1495 * 1514 *
1496 * Zaurus 1515 * Zaurus
1497 * 1516 *
1498 **************************************************/ 1517 **************************************************/
1499 1518
1500// Check whether this device is the sharp zaurus.. 1519// Check whether this device is the sharp zaurus..
1501// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 1520// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
1502// class up into individual classes. We need three classes 1521// class up into individual classes. We need three classes
1503// 1522//
1504// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 1523// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
1505// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 1524// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
1506// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 1525// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
1507// 1526//
1508// Only question right now is: Do we really need to do it? Because as soon 1527// Only question right now is: Do we really need to do it? Because as soon
1509// as the OpenZaurus kernel is ready, there will be a unified interface for all 1528// as the OpenZaurus kernel is ready, there will be a unified interface for all
1510// Zaurus models (concerning apm, backlight, buttons, etc.) 1529// Zaurus models (concerning apm, backlight, buttons, etc.)
1511// 1530//
1512// Comments? - mickeyl. 1531// Comments? - mickeyl.
1513 1532
1514bool Zaurus::isZaurus() 1533bool Zaurus::isZaurus()
1515{ 1534{
1516 1535
1517 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1536 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1518 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1537 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1519 return true; 1538 return true;
1520 } 1539 }
1521 1540
1522 // On non-embedix kernels, we have to look closer. 1541 // On non-embedix kernels, we have to look closer.
1523 bool is_zaurus = false; 1542 bool is_zaurus = false;
1524 QFile f ( "/proc/cpuinfo" ); 1543 QFile f ( "/proc/cpuinfo" );
1525 if ( f. open ( IO_ReadOnly ) ) { 1544 if ( f. open ( IO_ReadOnly ) ) {
1526 QString model; 1545 QString model;
1527 QFile f ( "/proc/cpuinfo" ); 1546 QFile f ( "/proc/cpuinfo" );
1528 1547
1529 QTextStream ts ( &f ); 1548 QTextStream ts ( &f );
1530 QString line; 1549 QString line;
1531 while( line = ts. readLine ( ) ) { 1550 while( line = ts. readLine ( ) ) {
1532 if ( line. left ( 8 ) == "Hardware" ) 1551 if ( line. left ( 8 ) == "Hardware" )
1533 break; 1552 break;
1534 } 1553 }
1535 int loc = line. find ( ":" ); 1554 int loc = line. find ( ":" );
1536 if ( loc != -1 ) 1555 if ( loc != -1 )
1537 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1556 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1538 1557
1539 if ( model == "Sharp-Collie" 1558 if ( model == "Sharp-Collie"
1540 || model == "Collie" 1559 || model == "Collie"
1541 || model == "SHARP Corgi" 1560 || model == "SHARP Corgi"
1542 || model == "SHARP Shepherd" 1561 || model == "SHARP Shepherd"
1543 || model == "SHARP Poodle" 1562 || model == "SHARP Poodle"
1544 || model == "SHARP Husky" 1563 || model == "SHARP Husky"
1545 ) 1564 )
1546 is_zaurus = true; 1565 is_zaurus = true;
1547 1566
1548 } 1567 }
1549 return is_zaurus; 1568 return is_zaurus;
1550} 1569}
1551 1570
1552 1571
1553void Zaurus::init ( ) 1572void Zaurus::init ( )
1554{ 1573{
1555 d-> m_vendorstr = "Sharp"; 1574 d-> m_vendorstr = "Sharp";
1556 d-> m_vendor = Vendor_Sharp; 1575 d-> m_vendor = Vendor_Sharp;
1557 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1576 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1558 1577
1559 // QFile f ( "/proc/filesystems" ); 1578 // QFile f ( "/proc/filesystems" );
1560 QString model; 1579 QString model;
1561 1580
1562 // It isn't a good idea to check the system configuration to 1581 // It isn't a good idea to check the system configuration to
1563 // detect the distribution ! 1582 // detect the distribution !
1564 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1583 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1565 // because it uses a jffs2 filesystem.. 1584 // because it uses a jffs2 filesystem..
1566 // (eilers) 1585 // (eilers)
1567 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1586 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1568 QFile f ("/etc/oz_version"); 1587 QFile f ("/etc/oz_version");
1569 if ( f.exists() ){ 1588 if ( f.exists() ){
1570 d-> m_vendorstr = "OpenZaurus Team"; 1589 d-> m_vendorstr = "OpenZaurus Team";
1571 d-> m_systemstr = "OpenZaurus"; 1590 d-> m_systemstr = "OpenZaurus";
1572 d-> m_system = System_OpenZaurus; 1591 d-> m_system = System_OpenZaurus;
1573 1592
1574 if ( f. open ( IO_ReadOnly )) { 1593 if ( f. open ( IO_ReadOnly )) {
1575 QTextStream ts ( &f ); 1594 QTextStream ts ( &f );
1576 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1595 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1577 f. close ( ); 1596 f. close ( );
1578 } 1597 }
1579 1598
1580 // Openzaurus sometimes uses the embedix kernel! 1599 // Openzaurus sometimes uses the embedix kernel!
1581 // => Check whether this is an embedix kernel 1600 // => Check whether this is an embedix kernel
1582 FILE *uname = popen("uname -r", "r"); 1601 FILE *uname = popen("uname -r", "r");
1583 QString line; 1602 QString line;
1584 if ( f.open(IO_ReadOnly, uname) ) { 1603 if ( f.open(IO_ReadOnly, uname) ) {
1585 QTextStream ts ( &f ); 1604 QTextStream ts ( &f );
1586 line = ts. readLine ( ); 1605 line = ts. readLine ( );
1587 int loc = line. find ( "embedix" ); 1606 int loc = line. find ( "embedix" );
1588 if ( loc != -1 ) 1607 if ( loc != -1 )
1589 m_embedix = true; 1608 m_embedix = true;
1590 else 1609 else
1591 m_embedix = false; 1610 m_embedix = false;
1592 f. close ( ); 1611 f. close ( );
1593 } 1612 }
1594 pclose(uname); 1613 pclose(uname);
1595 } 1614 }
1596 else { 1615 else {
1597 d-> m_systemstr = "Zaurus"; 1616 d-> m_systemstr = "Zaurus";
1598 d-> m_system = System_Zaurus; 1617 d-> m_system = System_Zaurus;
1599 } 1618 }
1600 1619
1601 f. setName ( "/proc/cpuinfo" ); 1620 f. setName ( "/proc/cpuinfo" );
1602 if ( f. open ( IO_ReadOnly ) ) { 1621 if ( f. open ( IO_ReadOnly ) ) {
1603 QTextStream ts ( &f ); 1622 QTextStream ts ( &f );
1604 QString line; 1623 QString line;
1605 while( line = ts. readLine ( ) ) { 1624 while( line = ts. readLine ( ) ) {
1606 if ( line. left ( 8 ) == "Hardware" ) 1625 if ( line. left ( 8 ) == "Hardware" )
1607 break; 1626 break;
1608 } 1627 }
1609 int loc = line. find ( ":" ); 1628 int loc = line. find ( ":" );
1610 if ( loc != -1 ) 1629 if ( loc != -1 )
1611 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1630 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1612 } 1631 }
1613 1632
1614 if ( model == "SHARP Corgi" ) { 1633 if ( model == "SHARP Corgi" ) {
1615 d-> m_model = Model_Zaurus_SLC7x0; 1634 d-> m_model = Model_Zaurus_SLC7x0;
1616 d-> m_modelstr = "Zaurus SL-C700"; 1635 d-> m_modelstr = "Zaurus SL-C700";
1617 } else if ( model == "SHARP Shepherd" ) { 1636 } else if ( model == "SHARP Shepherd" ) {
1618 d-> m_model = Model_Zaurus_SLC7x0; 1637 d-> m_model = Model_Zaurus_SLC7x0;
1619 d-> m_modelstr = "Zaurus SL-C750"; 1638 d-> m_modelstr = "Zaurus SL-C750";
1620 } else if ( model == "SHARP Husky" ) { 1639 } else if ( model == "SHARP Husky" ) {
1621 d-> m_model = Model_Zaurus_SLC7x0; 1640 d-> m_model = Model_Zaurus_SLC7x0;
1622 d-> m_modelstr = "Zaurus SL-C760"; 1641 d-> m_modelstr = "Zaurus SL-C760";
1623 } else if ( model == "SHARP Poodle" ) { 1642 } else if ( model == "SHARP Poodle" ) {
1624 d-> m_model = Model_Zaurus_SLB600; 1643 d-> m_model = Model_Zaurus_SLB600;
1625 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1644 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1626 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 1645 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
1627 d-> m_model = Model_Zaurus_SL5500; 1646 d-> m_model = Model_Zaurus_SL5500;
1628 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1647 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1629 } else { 1648 } else {
1630 d-> m_model = Model_Zaurus_SL5500; 1649 d-> m_model = Model_Zaurus_SL5500;
1631 d-> m_modelstr = "Zaurus (Model unknown)"; 1650 d-> m_modelstr = "Zaurus (Model unknown)";
1632 } 1651 }
1633 1652
1634 bool flipstate = false; 1653 bool flipstate = false;
1635 switch ( d-> m_model ) { 1654 switch ( d-> m_model ) {
1636 case Model_Zaurus_SLA300: 1655 case Model_Zaurus_SLA300:
1637 d-> m_rotation = Rot0; 1656 d-> m_rotation = Rot0;
1638 break; 1657 break;
1639 case Model_Zaurus_SLC7x0: 1658 case Model_Zaurus_SLC7x0:
1640 d-> m_rotation = rotation(); 1659 d-> m_rotation = rotation();
1641 d-> m_direction = direction(); 1660 d-> m_direction = direction();
1642 break; 1661 break;
1643 case Model_Zaurus_SLB600: 1662 case Model_Zaurus_SLB600:
1644 case Model_Zaurus_SL5500: 1663 case Model_Zaurus_SL5500:
1645 case Model_Zaurus_SL5000: 1664 case Model_Zaurus_SL5000:
1646 default: 1665 default:
1647 d-> m_rotation = Rot270; 1666 d-> m_rotation = Rot270;
1648 break; 1667 break;
1649 } 1668 }
1650 m_leds [0] = Led_Off; 1669 m_leds [0] = Led_Off;
1651} 1670}
1652 1671
1653void Zaurus::initButtons ( ) 1672void Zaurus::initButtons ( )
1654{ 1673{
1655 if ( d-> m_buttons ) 1674 if ( d-> m_buttons )
1656 return; 1675 return;
1657 1676
1658 d-> m_buttons = new QValueList <ODeviceButton>; 1677 d-> m_buttons = new QValueList <ODeviceButton>;
1659 1678
1660 struct z_button * pz_buttons; 1679 struct z_button * pz_buttons;
1661 int buttoncount; 1680 int buttoncount;
1662 switch ( d-> m_model ) { 1681 switch ( d-> m_model ) {
1663 case Model_Zaurus_SLC7x0: 1682 case Model_Zaurus_SLC7x0:
1664 pz_buttons = z_buttons_c700; 1683 pz_buttons = z_buttons_c700;
1665 buttoncount = ARRAY_SIZE(z_buttons_c700); 1684 buttoncount = ARRAY_SIZE(z_buttons_c700);
1666 break; 1685 break;
1667 default: 1686 default:
1668 pz_buttons = z_buttons; 1687 pz_buttons = z_buttons;
1669 buttoncount = ARRAY_SIZE(z_buttons); 1688 buttoncount = ARRAY_SIZE(z_buttons);
1670 break; 1689 break;
1671 } 1690 }
1672 1691
1673 for ( int i = 0; i < buttoncount; i++ ) { 1692 for ( int i = 0; i < buttoncount; i++ ) {
1674 struct z_button *zb = pz_buttons + i; 1693 struct z_button *zb = pz_buttons + i;
1675 ODeviceButton b; 1694 ODeviceButton b;
1676 1695
1677 b. setKeycode ( zb-> code ); 1696 b. setKeycode ( zb-> code );
1678 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1697 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1679 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1698 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1680 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), 1699 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
1681 zb-> fpressedaction )); 1700 zb-> fpressedaction ));
1682 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), 1701 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
1683 zb-> fheldaction )); 1702 zb-> fheldaction ));
1684 1703
1685 d-> m_buttons-> append ( b ); 1704 d-> m_buttons-> append ( b );
1686 } 1705 }
1687 1706
1688 reloadButtonMapping ( ); 1707 reloadButtonMapping ( );
1689 1708
1690 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1709 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1691 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 1710 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
1692 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1711 this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1693} 1712}
1694 1713
1695#include <unistd.h> 1714#include <unistd.h>
1696#include <fcntl.h> 1715#include <fcntl.h>
1697#include <sys/ioctl.h> 1716#include <sys/ioctl.h>
1698 1717
1699//#include <asm/sharp_char.h> // including kernel headers is evil ... 1718//#include <asm/sharp_char.h> // including kernel headers is evil ...
1700 1719
1701#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1720#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1702 1721
1703 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1722 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1704#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1723#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1705 1724
1706#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1725#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1707#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1726#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1708#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1727#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1709 1728
1710/* --- for SHARP_BUZZER device --- */ 1729/* --- for SHARP_BUZZER device --- */
1711 1730
1712 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1731 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1713//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1732//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1714 1733
1715#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1734#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1716#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1735#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1717#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1736#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1718#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1737#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1719#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1738#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1720 1739
1721//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1740//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1722//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1741//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1723 1742
1724//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1743//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1725//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1744//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1726//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1745//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1727//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1746//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1728//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1747//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1729//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1748//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1730//#define SHARP_PDA_APPSTART 9 /* application start */ 1749//#define SHARP_PDA_APPSTART 9 /* application start */
1731//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1750//#define SHARP_PDA_APPQUIT 10 /* application ends */
1732 1751
1733//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1752//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1734//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1753//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1735//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1754//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1736//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1755//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1737// 1756//
1738 1757
1739 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1758 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1740#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1759#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1741 1760
1742#define SHARP_IOCTL_GET_ROTATION 0x413c 1761#define SHARP_IOCTL_GET_ROTATION 0x413c
1743 1762
1744typedef struct sharp_led_status { 1763typedef struct sharp_led_status {
1745 int which; /* select which LED status is wanted. */ 1764 int which; /* select which LED status is wanted. */
1746 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1765 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1747} sharp_led_status; 1766} sharp_led_status;
1748 1767
1749#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1768#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1750 1769
1751#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1770#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1752#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1771#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1753#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1772#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1754 1773
1755// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1774// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1756 1775
1757#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1776#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1758#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1777#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1759#define APM_EVT_POWER_BUTTON (1 << 0) 1778#define APM_EVT_POWER_BUTTON (1 << 0)
1760 1779
1761#define FL_IOCTL_STEP_CONTRAST 100 1780#define FL_IOCTL_STEP_CONTRAST 100
1762 1781
1763 1782
1764void Zaurus::buzzer ( int sound ) 1783void Zaurus::buzzer ( int sound )
1765{ 1784{
1766#ifndef QT_NO_SOUND 1785#ifndef QT_NO_SOUND
1767 QString soundname; 1786 QString soundname;
1768 1787
1769 // Not all devices have real sound 1788 // Not all devices have real sound
1770 if ( d->m_model == Model_Zaurus_SLC7x0 1789 if ( d->m_model == Model_Zaurus_SLC7x0
1771 || d->m_model == Model_Zaurus_SLB600 ){ 1790 || d->m_model == Model_Zaurus_SLB600 ){
1772 1791
1773 switch ( sound ){ 1792 switch ( sound ){
1774 case SHARP_BUZ_SCHEDULE_ALARM: 1793 case SHARP_BUZ_SCHEDULE_ALARM:
1775 soundname = "alarm"; 1794 soundname = "alarm";
1776 break; 1795 break;
1777 case SHARP_BUZ_TOUCHSOUND: 1796 case SHARP_BUZ_TOUCHSOUND:
1778 soundname = "touchsound"; 1797 soundname = "touchsound";
1779 break; 1798 break;
1780 case SHARP_BUZ_KEYSOUND: 1799 case SHARP_BUZ_KEYSOUND:
1781 soundname = "keysound"; 1800 soundname = "keysound";
1782 break; 1801 break;
1783 default: 1802 default:
1784 soundname = "alarm"; 1803 soundname = "alarm";
1785 1804
1786 } 1805 }
1787 } 1806 }
1788 1807
1789 // If a soundname is defined, we expect that this device has 1808 // If a soundname is defined, we expect that this device has
1790 // sound capabilities.. Otherwise we expect to have the buzzer 1809 // sound capabilities.. Otherwise we expect to have the buzzer
1791 // device.. 1810 // device..
1792 if ( !soundname.isEmpty() ){ 1811 if ( !soundname.isEmpty() ){
1793 int fd; 1812 int fd;
1794 int vol; 1813 int vol;
1795 bool vol_reset = false; 1814 bool vol_reset = false;
1796 1815
1797 Sound snd ( soundname ); 1816 Sound snd ( soundname );
1798 1817
1799 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1818 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1800 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1819 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1801 Config cfg ( "qpe" ); 1820 Config cfg ( "qpe" );
1802 cfg. setGroup ( "Volume" ); 1821 cfg. setGroup ( "Volume" );
1803 1822
1804 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1823 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1805 if ( volalarm < 0 ) 1824 if ( volalarm < 0 )
1806 volalarm = 0; 1825 volalarm = 0;
1807 else if ( volalarm > 100 ) 1826 else if ( volalarm > 100 )
1808 volalarm = 100; 1827 volalarm = 100;
1809 volalarm |= ( volalarm << 8 ); 1828 volalarm |= ( volalarm << 8 );
1810 1829
1811 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1830 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1812 vol_reset = true; 1831 vol_reset = true;
1813 } 1832 }
1814 } 1833 }
1815 1834
1816 snd. play ( ); 1835 snd. play ( );
1817 while ( !snd. isFinished ( )) 1836 while ( !snd. isFinished ( ))
1818 qApp-> processEvents ( ); 1837 qApp-> processEvents ( );
1819 1838
1820 if ( fd >= 0 ) { 1839 if ( fd >= 0 ) {
1821 if ( vol_reset ) 1840 if ( vol_reset )
1822 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1841 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1823 ::close ( fd ); 1842 ::close ( fd );
1824 } 1843 }
1825 } else { 1844 } else {
1826 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1845 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1827 1846
1828 if ( fd >= 0 ) { 1847 if ( fd >= 0 ) {
1829 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1848 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1830 ::close ( fd ); 1849 ::close ( fd );
1831 } 1850 }
1832 1851
1833 } 1852 }
1834#endif 1853#endif
1835} 1854}
1836 1855
1837 1856
1838void Zaurus::alarmSound ( ) 1857void Zaurus::alarmSound ( )
1839{ 1858{
1840 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1859 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1841} 1860}
1842 1861
1843void Zaurus::touchSound ( ) 1862void Zaurus::touchSound ( )
1844{ 1863{
1845 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1864 buzzer ( SHARP_BUZ_TOUCHSOUND );
1846} 1865}
1847 1866
1848void Zaurus::keySound ( ) 1867void Zaurus::keySound ( )
1849{ 1868{
1850 buzzer ( SHARP_BUZ_KEYSOUND ); 1869 buzzer ( SHARP_BUZ_KEYSOUND );
1851} 1870}
1852 1871
1853 1872
1854QValueList <OLed> Zaurus::ledList ( ) const 1873QValueList <OLed> Zaurus::ledList ( ) const
1855{ 1874{
1856 QValueList <OLed> vl; 1875 QValueList <OLed> vl;
1857 vl << Led_Mail; 1876 vl << Led_Mail;
1858 return vl; 1877 return vl;
1859} 1878}
1860 1879
1861QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1880QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1862{ 1881{
1863 QValueList <OLedState> vl; 1882 QValueList <OLedState> vl;
1864 1883
1865 if ( l == Led_Mail ) 1884 if ( l == Led_Mail )
1866 vl << Led_Off << Led_On << Led_BlinkSlow; 1885 vl << Led_Off << Led_On << Led_BlinkSlow;
1867 return vl; 1886 return vl;
1868} 1887}
1869 1888
1870OLedState Zaurus::ledState ( OLed which ) const 1889OLedState Zaurus::ledState ( OLed which ) const
1871{ 1890{
1872 if ( which == Led_Mail ) 1891 if ( which == Led_Mail )
1873 return m_leds [0]; 1892 return m_leds [0];
1874 else 1893 else
1875 return Led_Off; 1894 return Led_Off;
1876} 1895}
1877 1896
1878bool Zaurus::setLedState ( OLed which, OLedState st ) 1897bool Zaurus::setLedState ( OLed which, OLedState st )
1879{ 1898{
1880 if (!m_embedix) // Currently not supported on non_embedix kernels 1899 if (!m_embedix) // Currently not supported on non_embedix kernels
1881 return false; 1900 return false;
1882 1901
1883 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1902 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1884 1903
1885 if ( which == Led_Mail ) { 1904 if ( which == Led_Mail ) {
1886 if ( fd >= 0 ) { 1905 if ( fd >= 0 ) {
1887 struct sharp_led_status leds; 1906 struct sharp_led_status leds;
1888 ::memset ( &leds, 0, sizeof( leds )); 1907 ::memset ( &leds, 0, sizeof( leds ));
1889 leds. which = SHARP_LED_MAIL_EXISTS; 1908 leds. which = SHARP_LED_MAIL_EXISTS;
1890 bool ok = true; 1909 bool ok = true;
1891 1910
1892 switch ( st ) { 1911 switch ( st ) {
1893 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1912 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1894 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1913 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1895 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1914 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1896 default : ok = false; 1915 default : ok = false;
1897 } 1916 }
1898 1917
1899 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1918 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1900 m_leds [0] = st; 1919 m_leds [0] = st;
1901 return true; 1920 return true;
1902 } 1921 }
1903 } 1922 }
1904 } 1923 }
1905 return false; 1924 return false;
1906} 1925}
1907 1926
1908bool Zaurus::setSoftSuspend ( bool soft ) 1927bool Zaurus::setSoftSuspend ( bool soft )
1909{ 1928{
1910 if (!m_embedix) { 1929 if (!m_embedix) {
1911 /* non-Embedix kernels dont have kernel autosuspend */ 1930 /* non-Embedix kernels dont have kernel autosuspend */
1912 return ODevice::setSoftSuspend( soft ); 1931 return ODevice::setSoftSuspend( soft );
1913 } 1932 }
1914 1933
1915 bool res = false; 1934 bool res = false;
1916 int fd; 1935 int fd;
1917 1936
1918 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1919 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1920 1939
1921 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1922 1941
1923 if ( sources >= 0 ) { 1942 if ( sources >= 0 ) {
1924 if ( soft ) 1943 if ( soft )
1925 sources &= ~APM_EVT_POWER_BUTTON; 1944 sources &= ~APM_EVT_POWER_BUTTON;
1926 else 1945 else
1927 sources |= APM_EVT_POWER_BUTTON; 1946 sources |= APM_EVT_POWER_BUTTON;
1928 1947
1929 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1930 res = true; 1949 res = true;
1931 else 1950 else
1932 perror ( "APM_IOCGEVTSRC" ); 1951 perror ( "APM_IOCGEVTSRC" );
1933 } 1952 }
1934 else 1953 else
1935 perror ( "APM_IOCGEVTSRC" ); 1954 perror ( "APM_IOCGEVTSRC" );
1936 1955
1937 ::close ( fd ); 1956 ::close ( fd );
1938 } 1957 }
1939 else 1958 else
1940 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1941 1960
1942 return res; 1961 return res;
1943} 1962}
1944 1963
1945 1964
1946bool Zaurus::setDisplayBrightness ( int bright ) 1965bool Zaurus::setDisplayBrightness ( int bright )
1947{ 1966{
1948// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which 1967 bool res = false;
1949// is nice to use. Currently it exposes 16+1 levels. Implement this! 1968 int fd;
1950// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) 1969
1951 bool res = false; 1970 if ( bright > 255 ) bright = 255;
1952 int fd; 1971 if ( bright < 0 ) bright = 0;
1953 1972
1954 if ( bright > 255 ) 1973 if ( m_embedix )
1955 bright = 255; 1974 {
1956 if ( bright < 0 ) 1975 if ( d->m_model == Model_Zaurus_SLC7x0 )
1957 bright = 0; 1976 {
1958 1977 // special treatment for devices with the corgi backlight interface
1959 if (m_embedix) { 1978 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
1960 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1979 {
1961 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1980 if ( bright > 0x11 ) bright = 0x11;
1962 if ( bright && !bl ) 1981 char writeCommand[100];
1963 bl = 1; 1982 const int count = sprintf( writeCommand, "0x%x\n", bright );
1964 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1983 res = ( ::write ( fd, writeCommand, count ) != -1 );
1965 ::close ( fd ); 1984 ::close ( fd );
1966 } 1985 }
1967 } else { 1986 return res;
1968#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 1987 }
1969 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 1988 else
1970 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 1989 {
1971 ::close ( fd ); 1990 // standard treatment for devices with the dumb embedix frontlight interface
1972 } 1991 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1973 } 1992 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1974 return res; 1993 if ( bright && !bl )
1994 bl = 1;
1995 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1996 ::close ( fd );
1997 }
1998 }
1999 }
2000 else
2001 {
2002 // special treatment for the OpenZaurus unified interface
2003 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
2004 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
2005 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
2006 ::close ( fd );
2007 }
2008 }
2009 return res;
1975} 2010}
1976 2011
1977bool Zaurus::suspend ( ) 2012bool Zaurus::suspend ( )
1978{ 2013{
1979 qDebug("ODevice::suspend"); 2014 qDebug("ODevice::suspend");
1980 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2015 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1981 return false; 2016 return false;
1982 2017
1983 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 2018 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
1984 return false; 2019 return false;
1985 2020
1986 bool res = false; 2021 bool res = false;
1987 2022
1988 struct timeval tvs, tvn; 2023 struct timeval tvs, tvn;
1989 ::gettimeofday ( &tvs, 0 ); 2024 ::gettimeofday ( &tvs, 0 );
1990 2025
1991 ::sync ( ); // flush fs caches 2026 ::sync ( ); // flush fs caches
1992 res = ( ::system ( "apm --suspend" ) == 0 ); 2027 res = ( ::system ( "apm --suspend" ) == 0 );
1993 2028
1994 // This is needed because the iPAQ apm implementation is asynchronous and we 2029 // This is needed because the iPAQ apm implementation is asynchronous and we
1995 // can not be sure when exactly the device is really suspended 2030 // can not be sure when exactly the device is really suspended
1996 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 2031 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
1997 2032
1998 if ( res ) { 2033 if ( res ) {
1999 do { // Yes, wait 15 seconds. This APM bug sucks big time. 2034 do { // Yes, wait 15 seconds. This APM bug sucks big time.
2000 ::usleep ( 200 * 1000 ); 2035 ::usleep ( 200 * 1000 );
2001 ::gettimeofday ( &tvn, 0 ); 2036 ::gettimeofday ( &tvn, 0 );
2002 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 2037 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
2003 } 2038 }
2004 2039
2005 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 2040 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
2006 return res; 2041 return res;
2007} 2042}
2008 2043
2009 2044
2010Transformation Zaurus::rotation ( ) const 2045Transformation Zaurus::rotation ( ) const
2011{ 2046{
2012 Transformation rot; 2047 Transformation rot;
2013 int handle = 0; 2048 int handle = 0;
2014 int retval = 0; 2049 int retval = 0;
2015 2050
2016 switch ( d-> m_model ) { 2051 switch ( d-> m_model ) {
2017 case Model_Zaurus_SLC7x0: 2052 case Model_Zaurus_SLC7x0:
2018 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2053 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2019 if (handle == -1) { 2054 if (handle == -1) {
2020 return Rot270; 2055 return Rot270;
2021 } else { 2056 } else {
2022 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2057 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2023 ::close (handle); 2058 ::close (handle);
2024 2059
2025 if (retval == 2 ) 2060 if (retval == 2 )
2026 rot = Rot0; 2061 rot = Rot0;
2027 else 2062 else
2028 rot = Rot270; 2063 rot = Rot270;
2029 } 2064 }
2030 break; 2065 break;
2031 case Model_Zaurus_SLA300: 2066 case Model_Zaurus_SLA300:
2032 case Model_Zaurus_SLB600: 2067 case Model_Zaurus_SLB600:
2033 case Model_Zaurus_SL5500: 2068 case Model_Zaurus_SL5500:
2034 case Model_Zaurus_SL5000: 2069 case Model_Zaurus_SL5000:
2035 default: 2070 default:
2036 rot = d-> m_rotation; 2071 rot = d-> m_rotation;
2037 break; 2072 break;
2038 } 2073 }
2039 2074
2040 return rot; 2075 return rot;
2041} 2076}
2042ODirection Zaurus::direction ( ) const 2077ODirection Zaurus::direction ( ) const
2043{ 2078{
2044 ODirection dir; 2079 ODirection dir;
2045 int handle = 0; 2080 int handle = 0;
2046 int retval = 0; 2081 int retval = 0;
2047 switch ( d-> m_model ) { 2082 switch ( d-> m_model ) {
2048 case Model_Zaurus_SLC7x0: 2083 case Model_Zaurus_SLC7x0:
2049 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2084 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2050 if (handle == -1) { 2085 if (handle == -1) {
2051 dir = CW; 2086 dir = CW;
2052 } else { 2087 } else {
2053 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2088 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2054 ::close (handle); 2089 ::close (handle);
2055 if (retval == 2 ) 2090 if (retval == 2 )
2056 dir = CCW; 2091 dir = CCW;
2057 else 2092 else
2058 dir = CW; 2093 dir = CW;
2059 } 2094 }
2060 break; 2095 break;
2061 case Model_Zaurus_SLA300: 2096 case Model_Zaurus_SLA300:
2062 case Model_Zaurus_SLB600: 2097 case Model_Zaurus_SLB600:
2063 case Model_Zaurus_SL5500: 2098 case Model_Zaurus_SL5500:
2064 case Model_Zaurus_SL5000: 2099 case Model_Zaurus_SL5000:
2065 default: 2100 default:
2066 dir = d-> m_direction; 2101 dir = d-> m_direction;
2067 break; 2102 break;
2068 } 2103 }
2069 return dir; 2104 return dir;
2070 2105
2071} 2106}
2072 2107
2073int Zaurus::displayBrightnessResolution ( ) const 2108int Zaurus::displayBrightnessResolution ( ) const
2074{ 2109{
2075 if (m_embedix) 2110 if (m_embedix)
2076 return 5; 2111 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
2077 else 2112 else
2078 return 256; 2113 return 256;
2079} 2114}
2080 2115
2116bool Zaurus::hasHingeSensor() const
2117{
2118 return d->m_model == Model_Zaurus_SLC7x0;
2119}
2120
2121OHingeStatus Zaurus::readHingeSensor()
2122{
2123 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2124 if (handle == -1)
2125 {
2126 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
2127 return CASE_UNKNOWN;
2128 }
2129 else
2130 {
2131 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2132 ::close (handle);
2133 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
2134 {
2135 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
2136 return static_cast<OHingeStatus>( retval );
2137 }
2138 else
2139 {
2140 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
2141 return CASE_UNKNOWN;
2142 }
2143 }
2144}
2145
2146
2081/************************************************** 2147/**************************************************
2082 * 2148 *
2083 * SIMpad 2149 * SIMpad
2084 * 2150 *
2085 **************************************************/ 2151 **************************************************/
2086 2152
2087void SIMpad::init ( ) 2153void SIMpad::init ( )
2088{ 2154{
2089 d-> m_vendorstr = "SIEMENS"; 2155 d-> m_vendorstr = "SIEMENS";
2090 d-> m_vendor = Vendor_SIEMENS; 2156 d-> m_vendor = Vendor_SIEMENS;
2091 2157
2092 QFile f ( "/proc/hal/model" ); 2158 QFile f ( "/proc/hal/model" );
2093 2159
2094 //TODO Implement model checking 2160 //TODO Implement model checking
2095 //FIXME For now we assume an SL4 2161 //FIXME For now we assume an SL4
2096 2162
2097 d-> m_modelstr = "SL4"; 2163 d-> m_modelstr = "SL4";
2098 d-> m_model = Model_SIMpad_SL4; 2164 d-> m_model = Model_SIMpad_SL4;
2099 2165
2100 switch ( d-> m_model ) { 2166 switch ( d-> m_model ) {
2101 default: 2167 default:
2102 d-> m_rotation = Rot0; 2168 d-> m_rotation = Rot0;
2103 d-> m_direction = CCW; 2169 d-> m_direction = CCW;
2104 d-> m_holdtime = 1000; // 1000ms 2170 d-> m_holdtime = 1000; // 1000ms
2105 2171
2106 break; 2172 break;
2107 } 2173 }
2108 2174
2109 f. setName ( "/etc/familiar-version" ); 2175 f. setName ( "/etc/familiar-version" );
2110 if ( f. open ( IO_ReadOnly )) { 2176 if ( f. open ( IO_ReadOnly )) {
2111 d-> m_systemstr = "Familiar"; 2177 d-> m_systemstr = "Familiar";
2112 d-> m_system = System_Familiar; 2178 d-> m_system = System_Familiar;
2113 2179
2114 QTextStream ts ( &f ); 2180 QTextStream ts ( &f );
2115 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2181 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2116 2182
2117 f. close ( ); 2183 f. close ( );
2118 } else { 2184 } else {
2119 f. setName ( "/etc/oz_version" ); 2185 f. setName ( "/etc/oz_version" );
2120 2186
2121 if ( f. open ( IO_ReadOnly )) { 2187 if ( f. open ( IO_ReadOnly )) {
2122 d-> m_systemstr = "OpenEmbedded/SIMpad"; 2188 d-> m_systemstr = "OpenEmbedded/SIMpad";
2123 d-> m_system = System_OpenZaurus; 2189 d-> m_system = System_OpenZaurus;
2124 2190
2125 QTextStream ts ( &f ); 2191 QTextStream ts ( &f );
2126 ts.setDevice ( &f ); 2192 ts.setDevice ( &f );
2127 d-> m_sysverstr = ts. readLine ( ); 2193 d-> m_sysverstr = ts. readLine ( );
2128 f. close ( ); 2194 f. close ( );
2129 } 2195 }
2130 } 2196 }
2131 2197
2132 m_leds [0] = m_leds [1] = Led_Off; 2198 m_leds [0] = m_leds [1] = Led_Off;
2133 2199
2134 m_power_timer = 0; 2200 m_power_timer = 0;
2135 2201
2136} 2202}
2137 2203
2138void SIMpad::initButtons ( ) 2204void SIMpad::initButtons ( )
2139{ 2205{
2140 if ( d-> m_buttons ) 2206 if ( d-> m_buttons )
2141 return; 2207 return;
2142 2208
2143 if ( isQWS( ) ) 2209 if ( isQWS( ) )
2144 QWSServer::setKeyboardFilter ( this ); 2210 QWSServer::setKeyboardFilter ( this );
2145 2211
2146 d-> m_buttons = new QValueList <ODeviceButton>; 2212 d-> m_buttons = new QValueList <ODeviceButton>;
2147 2213
2148 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 2214 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
2149 s_button *sb = simpad_buttons + i; 2215 s_button *sb = simpad_buttons + i;
2150 ODeviceButton b; 2216 ODeviceButton b;
2151 2217
2152 if (( sb-> model & d-> m_model ) == d-> m_model ) { 2218 if (( sb-> model & d-> m_model ) == d-> m_model ) {
2153 b. setKeycode ( sb-> code ); 2219 b. setKeycode ( sb-> code );
2154 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 2220 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
2155 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 2221 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
2156 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 2222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
2157 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 2223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
2158 2224
2159 d-> m_buttons-> append ( b ); 2225 d-> m_buttons-> append ( b );
2160 } 2226 }
2161 } 2227 }
2162 reloadButtonMapping ( ); 2228 reloadButtonMapping ( );
2163 2229
2164 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 2230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2165 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 2231 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
2166} 2232}
2167 2233
2168// SIMpad boardcontrol register CS3 2234// SIMpad boardcontrol register CS3
2169#define SIMPAD_BOARDCONTROL "/proc/cs3" 2235#define SIMPAD_BOARDCONTROL "/proc/cs3"
2170#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 2236#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
2171#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 2237#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
2172#define SIMPAD_EN1 0x0004 // This is only for EPROM's 2238#define SIMPAD_EN1 0x0004 // This is only for EPROM's
2173#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 2239#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
2174#define SIMPAD_DISPLAY_ON 0x0010 2240#define SIMPAD_DISPLAY_ON 0x0010
2175#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 2241#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
2176#define SIMPAD_MQ_RESET 0x0040 2242#define SIMPAD_MQ_RESET 0x0040
2177#define SIMPAD_PCMCIA_RESET 0x0080 2243#define SIMPAD_PCMCIA_RESET 0x0080
2178#define SIMPAD_DECT_POWER_ON 0x0100 2244#define SIMPAD_DECT_POWER_ON 0x0100
2179#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 2245#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
2180#define SIMPAD_RS232_ON 0x0400 2246#define SIMPAD_RS232_ON 0x0400
2181#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 2247#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
2182#define SIMPAD_LED2_ON 0x1000 2248#define SIMPAD_LED2_ON 0x1000
2183#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 2249#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
2184#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 2250#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
2185#define SIMPAD_RESET_SIMCARD 0x8000 2251#define SIMPAD_RESET_SIMCARD 0x8000
2186 2252
2187//SIMpad touchscreen backlight strength control 2253//SIMpad touchscreen backlight strength control
2188#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 2254#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
2189#define SIMPAD_BACKLIGHT_MASK 0x00a10044 2255#define SIMPAD_BACKLIGHT_MASK 0x00a10044
2190 2256
2191QValueList <OLed> SIMpad::ledList ( ) const 2257QValueList <OLed> SIMpad::ledList ( ) const
2192{ 2258{
2193 QValueList <OLed> vl; 2259 QValueList <OLed> vl;
2194 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 2260 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
2195 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 2261 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
2196 return vl; 2262 return vl;
2197} 2263}
2198 2264
2199QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 2265QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
2200{ 2266{
2201 QValueList <OLedState> vl; 2267 QValueList <OLedState> vl;
2202 2268
2203 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 2269 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
2204 vl << Led_Off << Led_On; 2270 vl << Led_Off << Led_On;
2205 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 2271 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
2206 //vl << Led_Off; 2272 //vl << Led_Off;
2207 return vl; 2273 return vl;
2208} 2274}
2209 2275
2210OLedState SIMpad::ledState ( OLed l ) const 2276OLedState SIMpad::ledState ( OLed l ) const
2211{ 2277{
2212 switch ( l ) { 2278 switch ( l ) {
2213 case Led_Power: 2279 case Led_Power:
2214 return m_leds [0]; 2280 return m_leds [0];
2215 //case Led_Mail: 2281 //case Led_Mail:
2216 //return m_leds [1]; 2282 //return m_leds [1];
2217 default: 2283 default:
2218 return Led_Off; 2284 return Led_Off;
2219 } 2285 }
2220} 2286}
2221 2287
2222bool SIMpad::setLedState ( OLed l, OLedState st ) 2288bool SIMpad::setLedState ( OLed l, OLedState st )
2223{ 2289{
2224 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 2290 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
2225 2291
2226 if ( l == Led_Power ) { 2292 if ( l == Led_Power ) {
2227 if ( fd >= 0 ) { 2293 if ( fd >= 0 ) {
2228 LED_IN leds; 2294 LED_IN leds;
2229 ::memset ( &leds, 0, sizeof( leds )); 2295 ::memset ( &leds, 0, sizeof( leds ));
2230 leds. TotalTime = 0; 2296 leds. TotalTime = 0;
2231 leds. OnTime = 0; 2297 leds. OnTime = 0;
2232 leds. OffTime = 1; 2298 leds. OffTime = 1;
2233 leds. OffOnBlink = 2; 2299 leds. OffOnBlink = 2;
2234 2300
2235 switch ( st ) { 2301 switch ( st ) {
2236 case Led_Off : leds. OffOnBlink = 0; break; 2302 case Led_Off : leds. OffOnBlink = 0; break;
2237 case Led_On : leds. OffOnBlink = 1; break; 2303 case Led_On : leds. OffOnBlink = 1; break;
2238 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 2304 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
2239 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 2305 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
2240 } 2306 }
2241 2307
2242 { 2308 {
2243 /*TODO Implement this like that: 2309 /*TODO Implement this like that:
2244 read from cs3 2310 read from cs3
2245 && with SIMPAD_LED2_ON 2311 && with SIMPAD_LED2_ON
2246 write to cs3 */ 2312 write to cs3 */
2247 m_leds [0] = st; 2313 m_leds [0] = st;
2248 return true; 2314 return true;
2249 } 2315 }
2250 } 2316 }
2251 } 2317 }
2252 return false; 2318 return false;
2253} 2319}
2254 2320
2255 2321
2256bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 2322bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
2257{ 2323{
2258 //TODO 2324 //TODO
2259 return false; 2325 return false;
2260} 2326}
2261 2327
2262void SIMpad::timerEvent ( QTimerEvent * ) 2328void SIMpad::timerEvent ( QTimerEvent * )
2263{ 2329{
2264 killTimer ( m_power_timer ); 2330 killTimer ( m_power_timer );
2265 m_power_timer = 0; 2331 m_power_timer = 0;
2266 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 2332 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
2267 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 2333 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
2268} 2334}
2269 2335
2270 2336
2271void SIMpad::alarmSound ( ) 2337void SIMpad::alarmSound ( )
2272{ 2338{
2273#ifndef QT_NO_SOUND 2339#ifndef QT_NO_SOUND
2274 static Sound snd ( "alarm" ); 2340 static Sound snd ( "alarm" );
2275 int fd; 2341 int fd;
2276 int vol; 2342 int vol;
2277 bool vol_reset = false; 2343 bool vol_reset = false;
2278 2344
2279 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 2345 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
2280 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 2346 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
2281 Config cfg ( "qpe" ); 2347 Config cfg ( "qpe" );
2282 cfg. setGroup ( "Volume" ); 2348 cfg. setGroup ( "Volume" );
2283 2349
2284 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 2350 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
2285 if ( volalarm < 0 ) 2351 if ( volalarm < 0 )
2286 volalarm = 0; 2352 volalarm = 0;
2287 else if ( volalarm > 100 ) 2353 else if ( volalarm > 100 )
2288 volalarm = 100; 2354 volalarm = 100;
2289 volalarm |= ( volalarm << 8 ); 2355 volalarm |= ( volalarm << 8 );
2290 2356
2291 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 2357 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
2292 vol_reset = true; 2358 vol_reset = true;
2293 } 2359 }
2294 } 2360 }
2295 2361
2296 snd. play ( ); 2362 snd. play ( );
2297 while ( !snd. isFinished ( )) 2363 while ( !snd. isFinished ( ))
2298 qApp-> processEvents ( ); 2364 qApp-> processEvents ( );
2299 2365
2300 if ( fd >= 0 ) { 2366 if ( fd >= 0 ) {
2301 if ( vol_reset ) 2367 if ( vol_reset )
2302 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 2368 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
2303 ::close ( fd ); 2369 ::close ( fd );
2304 } 2370 }
2305#endif 2371#endif
2306} 2372}
2307 2373
2308 2374
2309bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 2375bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
2310{ 2376{
2311 qDebug( "ODevice for SIMpad: suspend()" ); 2377 qDebug( "ODevice for SIMpad: suspend()" );
2312 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2378 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2313 return false; 2379 return false;
2314 2380
2315 bool res = false; 2381 bool res = false;
2316 2382
2317 struct timeval tvs, tvn; 2383 struct timeval tvs, tvn;
2318 ::gettimeofday ( &tvs, 0 ); 2384 ::gettimeofday ( &tvs, 0 );
2319 2385
2320 ::sync ( ); // flush fs caches 2386 ::sync ( ); // flush fs caches
2321 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 2387 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
2322 2388
2323 return res; 2389 return res;
2324} 2390}
2325 2391
2326 2392
2327bool SIMpad::setSoftSuspend ( bool soft ) 2393bool SIMpad::setSoftSuspend ( bool soft )
2328{ 2394{
2329 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 2395 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
2330 return false; 2396 return false;
2331} 2397}
2332 2398
2333 2399
2334bool SIMpad::setDisplayStatus ( bool on ) 2400bool SIMpad::setDisplayStatus ( bool on )
2335{ 2401{
2336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 2402 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
2337 2403
2338 bool res = false; 2404 bool res = false;
2339 int fd; 2405 int fd;
2340 2406
2341 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 2407 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
2342 2408
2343 res = ( ::system( (const char*) cmdline ) == 0 ); 2409 res = ( ::system( (const char*) cmdline ) == 0 );
2344 2410
2345 return res; 2411 return res;
2346} 2412}
2347 2413
2348 2414
2349bool SIMpad::setDisplayBrightness ( int bright ) 2415bool SIMpad::setDisplayBrightness ( int bright )
2350{ 2416{
2351 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 2417 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
2352 bool res = false; 2418 bool res = false;
2353 int fd; 2419 int fd;
2354 2420
2355 if ( bright > 255 ) 2421 if ( bright > 255 )
2356 bright = 255; 2422 bright = 255;
2357 if ( bright < 1 ) 2423 if ( bright < 1 )
2358 bright = 0; 2424 bright = 0;
2359 2425
2360 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 2426 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
2361 int value = 255 - bright; 2427 int value = 255 - bright;
2362 const int mask = SIMPAD_BACKLIGHT_MASK; 2428 const int mask = SIMPAD_BACKLIGHT_MASK;
2363 value = value << 8; 2429 value = value << 8;
2364 value += mask; 2430 value += mask;
2365 char writeCommand[100]; 2431 char writeCommand[100];
2366 const int count = sprintf( writeCommand, "0x%x\n", value ); 2432 const int count = sprintf( writeCommand, "0x%x\n", value );
2367 res = ( ::write ( fd, writeCommand, count ) != -1 ); 2433 res = ( ::write ( fd, writeCommand, count ) != -1 );
2368 ::close ( fd ); 2434 ::close ( fd );
2369 } 2435 }
2370 return res; 2436 return res;
2371} 2437}
2372 2438
2373 2439
2374int SIMpad::displayBrightnessResolution ( ) const 2440int SIMpad::displayBrightnessResolution ( ) const
2375{ 2441{
2376 return 255; // All SIMpad models share the same display 2442 return 255; // All SIMpad models share the same display
2377} 2443}
2378 2444
2379/************************************************** 2445/**************************************************
2380 * 2446 *
2381 * Ramses 2447 * Ramses
2382 * 2448 *
2383 **************************************************/ 2449 **************************************************/
2384 2450
2385void Ramses::init() 2451void Ramses::init()
2386{ 2452{
2387 d->m_vendorstr = "M und N"; 2453 d->m_vendorstr = "M und N";
2388 d->m_vendor = Vendor_MundN; 2454 d->m_vendor = Vendor_MundN;
2389 2455
2390 QFile f("/proc/sys/board/ramses"); 2456 QFile f("/proc/sys/board/ramses");
2391 2457
2392 d->m_modelstr = "Ramses"; 2458 d->m_modelstr = "Ramses";
2393 d->m_model = Model_Ramses_MNCI; 2459 d->m_model = Model_Ramses_MNCI;
2394 2460
2395 d->m_rotation = Rot0; 2461 d->m_rotation = Rot0;
2396 d->m_holdtime = 1000; 2462 d->m_holdtime = 1000;
2397 2463
2398 f.setName("/etc/oz_version"); 2464 f.setName("/etc/oz_version");
2399 2465
2400 if (f.open(IO_ReadOnly)) { 2466 if (f.open(IO_ReadOnly)) {
2401 d->m_systemstr = "OpenEmbedded/Ramses"; 2467 d->m_systemstr = "OpenEmbedded/Ramses";
2402 d->m_system = System_OpenZaurus; 2468 d->m_system = System_OpenZaurus;
2403 2469
2404 QTextStream ts(&f); 2470 QTextStream ts(&f);
2405 ts.setDevice(&f); 2471 ts.setDevice(&f);
2406 d->m_sysverstr = ts.readLine(); 2472 d->m_sysverstr = ts.readLine();
2407 f.close(); 2473 f.close();
2408 } 2474 }
2409 2475
2410 m_power_timer = 0; 2476 m_power_timer = 0;
2411 2477
2412#ifdef QT_QWS_ALLOW_OVERCLOCK 2478#ifdef QT_QWS_ALLOW_OVERCLOCK
2413#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 2479#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
2414#define OC(x...) x 2480#define OC(x...) x
2415#else 2481#else
2416#define OC(x...) 2482#define OC(x...)
2417#endif 2483#endif
2418 2484
2419 2485
2420 // This table is true for a Intel XScale PXA 255 2486 // This table is true for a Intel XScale PXA 255
2421 2487
2422 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 2488 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
2423 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 2489 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
2424 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 2490 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
2425 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 2491 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
2426 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 2492 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
2427 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 2493 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
2428 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 2494 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
2429 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 2495 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
2430 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 2496 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
2431 2497
2432} 2498}
2433 2499
2434bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 2500bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
2435{ 2501{
2436 Q_UNUSED( keycode ); 2502 Q_UNUSED( keycode );
2437 Q_UNUSED( modifiers ); 2503 Q_UNUSED( modifiers );
2438 Q_UNUSED( isPress ); 2504 Q_UNUSED( isPress );
2439 Q_UNUSED( autoRepeat ); 2505 Q_UNUSED( autoRepeat );
2440 return false; 2506 return false;
2441} 2507}
2442 2508
2443void Ramses::timerEvent(QTimerEvent *) 2509void Ramses::timerEvent(QTimerEvent *)
2444{ 2510{
2445 killTimer(m_power_timer); 2511 killTimer(m_power_timer);
2446 m_power_timer = 0; 2512 m_power_timer = 0;
2447 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 2513 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
2448 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 2514 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
2449} 2515}
2450 2516
2451 2517
2452bool Ramses::setSoftSuspend(bool soft) 2518bool Ramses::setSoftSuspend(bool soft)
2453{ 2519{
2454 qDebug("Ramses::setSoftSuspend(%d)", soft); 2520 qDebug("Ramses::setSoftSuspend(%d)", soft);
2455#if 0 2521#if 0
2456 bool res = false; 2522 bool res = false;
2457 int fd; 2523 int fd;
2458 2524
2459 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 2525 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
2460 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 2526 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
2461 2527
2462 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 2528 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
2463 2529
2464 if (sources >= 0) { 2530 if (sources >= 0) {
2465 if (soft) 2531 if (soft)
2466 sources &= ~APM_EVT_POWER_BUTTON; 2532 sources &= ~APM_EVT_POWER_BUTTON;
2467 else 2533 else
2468 sources |= APM_EVT_POWER_BUTTON; 2534 sources |= APM_EVT_POWER_BUTTON;
2469 2535
2470 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 2536 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
2471 res = true; 2537 res = true;
2472 else 2538 else
2473 perror("APM_IOCGEVTSRC"); 2539 perror("APM_IOCGEVTSRC");
2474 } 2540 }
2475 else 2541 else
2476 perror("APM_IOCGEVTSRC"); 2542 perror("APM_IOCGEVTSRC");
2477 2543
2478 ::close(fd); 2544 ::close(fd);
2479 } 2545 }
2480 else 2546 else
2481 perror("/dev/apm_bios or /dev/misc/apm_bios"); 2547 perror("/dev/apm_bios or /dev/misc/apm_bios");
2482 2548
2483 return res; 2549 return res;
2484#else 2550#else
2485 return true; 2551 return true;
2486#endif 2552#endif
2487} 2553}
2488 2554
2489bool Ramses::suspend ( ) 2555bool Ramses::suspend ( )
2490{ 2556{
2491 qDebug("Ramses::suspend"); 2557 qDebug("Ramses::suspend");
2492 return false; 2558 return false;
2493} 2559}
2494 2560
2495/** 2561/**
2496 * This sets the display on or off 2562 * This sets the display on or off
2497 */ 2563 */
2498bool Ramses::setDisplayStatus(bool on) 2564bool Ramses::setDisplayStatus(bool on)
2499{ 2565{
2500 qDebug("Ramses::setDisplayStatus(%d)", on); 2566 qDebug("Ramses::setDisplayStatus(%d)", on);
2501#if 0 2567#if 0
2502 bool res = false; 2568 bool res = false;
2503 int fd; 2569 int fd;
2504 2570
2505 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 2571 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2506 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2572 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2507 ::close(fd); 2573 ::close(fd);
2508 } 2574 }
2509 return res; 2575 return res;
2510#else 2576#else
2511 return true; 2577 return true;
2512#endif 2578#endif
2513} 2579}
2514 2580
2515 2581
2516/* 2582/*
2517 * We get something between 0..255 into us 2583 * We get something between 0..255 into us
2518*/ 2584*/
2519bool Ramses::setDisplayBrightness(int bright) 2585bool Ramses::setDisplayBrightness(int bright)
2520{ 2586{
2521 qDebug("Ramses::setDisplayBrightness(%d)", bright); 2587 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2522 bool res = false; 2588 bool res = false;
2523 int fd; 2589 int fd;
2524 2590
2525 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2591 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2526 2592
2527 if (bright > 255 ) 2593 if (bright > 255 )
2528 bright = 255; 2594 bright = 255;
2529 if (bright < 0) 2595 if (bright < 0)
2530 bright = 0; 2596 bright = 0;
2531 2597
2532 // Turn backlight completely off 2598 // Turn backlight completely off
2533 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2599 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2534 char writeCommand[10]; 2600 char writeCommand[10];
2535 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2601 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2536 res = (::write(fd, writeCommand, count) != -1); 2602 res = (::write(fd, writeCommand, count) != -1);
2537 ::close(fd); 2603 ::close(fd);
2538 } 2604 }
2539 2605
2540 // scale backlight brightness to hardware 2606 // scale backlight brightness to hardware
2541 bright = 500-(bright * 500 / 255); 2607 bright = 500-(bright * 500 / 255);
2542 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 2608 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2543 qDebug(" %d -> pwm1", bright); 2609 qDebug(" %d -> pwm1", bright);
2544 char writeCommand[100]; 2610 char writeCommand[100];
2545 const int count = sprintf(writeCommand, "%d\n", bright); 2611 const int count = sprintf(writeCommand, "%d\n", bright);
2546 res = (::write(fd, writeCommand, count) != -1); 2612 res = (::write(fd, writeCommand, count) != -1);
2547 ::close(fd); 2613 ::close(fd);
2548 } 2614 }
2549 return res; 2615 return res;
2550} 2616}
2551 2617
2552 2618
2553int Ramses::displayBrightnessResolution() const 2619int Ramses::displayBrightnessResolution() const
2554{ 2620{
2555 return 32; 2621 return 32;
2556} 2622}
2557 2623
2558bool Ramses::setDisplayContrast(int contr) 2624bool Ramses::setDisplayContrast(int contr)
2559{ 2625{
2560 qDebug("Ramses::setDisplayContrast(%d)", contr); 2626 qDebug("Ramses::setDisplayContrast(%d)", contr);
2561 bool res = false; 2627 bool res = false;
2562 int fd; 2628 int fd;
2563 2629
2564 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2630 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2565 2631
2566 if (contr > 255 ) 2632 if (contr > 255 )
2567 contr = 255; 2633 contr = 255;
2568 if (contr < 0) 2634 if (contr < 0)
2569 contr = 0; 2635 contr = 0;
2570 contr = 90 - (contr * 20 / 255); 2636 contr = 90 - (contr * 20 / 255);
2571 2637
2572 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 2638 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2573 qDebug(" %d -> pwm0", contr); 2639 qDebug(" %d -> pwm0", contr);
2574 char writeCommand[100]; 2640 char writeCommand[100];
2575 const int count = sprintf(writeCommand, "%d\n", contr); 2641 const int count = sprintf(writeCommand, "%d\n", contr);
2576 res = (::write(fd, writeCommand, count) != -1); 2642 res = (::write(fd, writeCommand, count) != -1);
2577 res = true; 2643 res = true;
2578 ::close(fd); 2644 ::close(fd);
2579 } 2645 }
2580 return res; 2646 return res;
2581} 2647}
2582 2648
2583 2649
2584int Ramses::displayContrastResolution() const 2650int Ramses::displayContrastResolution() const
2585{ 2651{
2586 return 20; 2652 return 20;
2587} 2653}
2588 2654
2589 2655
2590/************************************************** 2656/**************************************************
2591 * * 2657 * *
2592 * Jornada * 2658 * Jornada *
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 8273761..ee0b0ec 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,274 +1,284 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 Copyright (C) 2003 Holger 'zecke' Freyther (zecke@handhelds.org) 3 Copyright (C) 2003 Holger 'zecke' Freyther (zecke@handhelds.org)
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef _LIBOPIE_ODEVICE_H_ 21#ifndef _LIBOPIE_ODEVICE_H_
22#define _LIBOPIE_ODEVICE_H_ 22#define _LIBOPIE_ODEVICE_H_
23 23
24#include <qobject.h> 24#include <qobject.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qnamespace.h> 26#include <qnamespace.h>
27#include <qstrlist.h> 27#include <qstrlist.h>
28 28
29#include <opie/odevicebutton.h> 29#include <opie/odevicebutton.h>
30 30
31#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 31#include <qpe/qpeapplication.h> /* for Transformation enum.. */
32 32
33class ODeviceData; 33class ODeviceData;
34 34
35namespace Opie { 35namespace Opie {
36 36
37/** 37/**
38 * The available devices 38 * The available devices
39 */ 39 */
40enum OModel { 40enum OModel {
41 Model_Unknown, // = 0 41 Model_Unknown, // = 0
42 42
43 Model_Series_Mask = 0xff000000, 43 Model_Series_Mask = 0xff000000,
44 44
45 Model_iPAQ = ( 1 << 24 ), 45 Model_iPAQ = ( 1 << 24 ),
46 46
47 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 47 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
48 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 48 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
49 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 49 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
50 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 50 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
51 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 51 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
52 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 52 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
53 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 53 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
54 54
55 Model_Jornada = ( 6 << 24 ), 55 Model_Jornada = ( 6 << 24 ),
56 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 56 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
57 57
58 Model_Zaurus = ( 2 << 24 ), 58 Model_Zaurus = ( 2 << 24 ),
59 59
60 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 60 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
61 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 61 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
62 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 62 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
63 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 63 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
64 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 64 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
65 65
66 Model_SIMpad = ( 3 << 24 ), 66 Model_SIMpad = ( 3 << 24 ),
67 67
68 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 68 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
69 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 69 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
70 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 70 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
71 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 71 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
72 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 72 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
73 73
74 Model_Ramses = ( 4 << 24 ), 74 Model_Ramses = ( 4 << 24 ),
75 75
76 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 76 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
77 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 77 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
78 78
79 Model_Yopy = ( 5 << 24 ), 79 Model_Yopy = ( 5 << 24 ),
80 80
81 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 81 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
82 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 82 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
83 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 83 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
84 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 84 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
85 85
86}; 86};
87 87
88/** 88/**
89 * The vendor of the device 89 * The vendor of the device
90 */ 90 */
91enum OVendor { 91enum OVendor {
92 Vendor_Unknown, 92 Vendor_Unknown,
93 93
94 Vendor_HP, 94 Vendor_HP,
95 Vendor_Sharp, 95 Vendor_Sharp,
96 Vendor_SIEMENS, 96 Vendor_SIEMENS,
97 Vendor_MundN, 97 Vendor_MundN,
98 Vendor_GMate, 98 Vendor_GMate,
99}; 99};
100 100
101/** 101/**
102 * The System used 102 * The System used
103 */ 103 */
104enum OSystem { 104enum OSystem {
105 System_Unknown, 105 System_Unknown,
106 106
107 System_Familiar, 107 System_Familiar,
108 System_Zaurus, 108 System_Zaurus,
109 System_OpenZaurus, 109 System_OpenZaurus,
110 System_Linupy, 110 System_Linupy,
111}; 111};
112 112
113enum OLedState { 113enum OLedState {
114 Led_Off, 114 Led_Off,
115 Led_On, 115 Led_On,
116 Led_BlinkSlow, 116 Led_BlinkSlow,
117 Led_BlinkFast 117 Led_BlinkFast
118}; 118};
119 119
120enum OLed { 120enum OLed {
121 Led_Mail, 121 Led_Mail,
122 Led_Power, 122 Led_Power,
123 Led_BlueTooth 123 Led_BlueTooth
124}; 124};
125 125
126enum OHardKey { 126enum OHardKey {
127 HardKey_Datebook = Qt::Key_F9, 127 HardKey_Datebook = Qt::Key_F9,
128 HardKey_Contacts = Qt::Key_F10, 128 HardKey_Contacts = Qt::Key_F10,
129 HardKey_Menu = Qt::Key_F11, 129 HardKey_Menu = Qt::Key_F11,
130 HardKey_Home = Qt::Key_F12, 130 HardKey_Home = Qt::Key_F12,
131 HardKey_Mail = Qt::Key_F13, 131 HardKey_Mail = Qt::Key_F13,
132 HardKey_Record = Qt::Key_F24, 132 HardKey_Record = Qt::Key_F24,
133 HardKey_Suspend = Qt::Key_F34, 133 HardKey_Suspend = Qt::Key_F34,
134 HardKey_Backlight = Qt::Key_F35, 134 HardKey_Backlight = Qt::Key_F35,
135 HardKey_Action = Qt::Key_F10, 135 HardKey_Action = Qt::Key_F10,
136 HardKey_OK = Qt::Key_F11, 136 HardKey_OK = Qt::Key_F11,
137 HardKey_End = Qt::Key_F12, 137 HardKey_End = Qt::Key_F12,
138}; 138};
139 139
140enum ODirection { 140enum ODirection {
141 CW = 0, 141 CW = 0,
142 CCW = 1, 142 CCW = 1,
143 Flip = 2, 143 Flip = 2,
144}; 144};
145 145
146enum OHingeStatus {
147 CASE_CLOSED = 3,
148 CASE_PORTRAIT = 2,
149 CASE_LANDSCAPE = 0,
150 CASE_UNKNOWN = 1,
151};
152
146/** 153/**
147 * A singleton which gives informations about device specefic option 154 * A singleton which gives informations about device specefic option
148 * like the Hardware used, LEDs, the Base Distribution and 155 * like the Hardware used, LEDs, the Base Distribution and
149 * hardware key mappings. 156 * hardware key mappings.
150 * 157 *
151 * @short A small class for device specefic options 158 * @short A small class for device specefic options
152 * @see QObject 159 * @see QObject
153 * @author Robert Griebl 160 * @author Robert Griebl
154 * @version 1.0 161 * @version 1.0
155 */ 162 */
156class ODevice : public QObject { 163class ODevice : public QObject {
157 Q_OBJECT 164 Q_OBJECT
158 165
159private: 166private:
160 /* disable copy */ 167 /* disable copy */
161 ODevice ( const ODevice & ); 168 ODevice ( const ODevice & );
162 169
163protected: 170protected:
164 ODevice ( ); 171 ODevice ( );
165 virtual void init ( ); 172 virtual void init ( );
166 virtual void initButtons ( ); 173 virtual void initButtons ( );
167 174
168 ODeviceData *d; 175 ODeviceData *d;
169 176
170public: 177public:
171 // sandman do we want to allow destructions? -zecke? 178 // sandman do we want to allow destructions? -zecke?
172 virtual ~ODevice ( ); 179 virtual ~ODevice ( );
173 180
174 static ODevice *inst ( ); 181 static ODevice *inst ( );
175 182
176 // information 183 // information
177 184
178 QString modelString ( ) const; 185 QString modelString ( ) const;
179 OModel model ( ) const; 186 OModel model ( ) const;
180 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 187 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
181 188
182 QString vendorString ( ) const; 189 QString vendorString ( ) const;
183 OVendor vendor ( ) const; 190 OVendor vendor ( ) const;
184 191
185 QString systemString ( ) const; 192 QString systemString ( ) const;
186 OSystem system ( ) const; 193 OSystem system ( ) const;
187 194
188 QString systemVersionString ( ) const; 195 QString systemVersionString ( ) const;
189 196
190 virtual Transformation rotation ( ) const; 197 virtual Transformation rotation ( ) const;
191 virtual ODirection direction ( ) const; 198 virtual ODirection direction ( ) const;
192 199
193// system 200// system
194 201
195 virtual bool setSoftSuspend ( bool on ); 202 virtual bool setSoftSuspend ( bool on );
196 virtual bool suspend ( ); 203 virtual bool suspend ( );
197 204
198 virtual bool setDisplayStatus ( bool on ); 205 virtual bool setDisplayStatus ( bool on );
199 virtual bool setDisplayBrightness ( int brightness ); 206 virtual bool setDisplayBrightness ( int brightness );
200 virtual int displayBrightnessResolution ( ) const; 207 virtual int displayBrightnessResolution ( ) const;
201 virtual bool setDisplayContrast ( int contrast ); 208 virtual bool setDisplayContrast ( int contrast );
202 virtual int displayContrastResolution ( ) const; 209 virtual int displayContrastResolution ( ) const;
203 210
204 // don't add new virtual methods, use this: 211 // don't add new virtual methods, use this:
205 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 212 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
206 // and in your subclass do do overwrite 213 // and in your subclass do do overwrite
207 //protected virtual int virtual_hook(int, void *) 214 //protected virtual int virtual_hook(int, void *)
208 // which is defined below 215 // which is defined below
209 216
210// input / output 217 // input / output
211 //FIXME playAlarmSound and al might be better -zecke 218 //FIXME playAlarmSound and al might be better -zecke
212 virtual void alarmSound ( ); 219 virtual void alarmSound ( );
213 virtual void keySound ( ); 220 virtual void keySound ( );
214 virtual void touchSound ( ); 221 virtual void touchSound ( );
215 222
216 virtual QValueList <OLed> ledList ( ) const; 223 virtual QValueList <OLed> ledList ( ) const;
217 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 224 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
218 virtual OLedState ledState ( OLed led ) const; 225 virtual OLedState ledState ( OLed led ) const;
219 virtual bool setLedState ( OLed led, OLedState st ); 226 virtual bool setLedState ( OLed led, OLedState st );
220 227
221 virtual bool hasLightSensor ( ) const; 228 virtual bool hasLightSensor ( ) const;
222 virtual int readLightSensor ( ); 229 virtual int readLightSensor ( );
223 virtual int lightSensorResolution ( ) const; 230 virtual int lightSensorResolution ( ) const;
224 231
232 virtual bool hasHingeSensor ( ) const;
233 virtual OHingeStatus readHingeSensor ( );
234
225 const QStrList &allowedCpuFrequencies() const; 235 const QStrList &allowedCpuFrequencies() const;
226 bool setCurrentCpuFrequency(uint index); 236 bool setCurrentCpuFrequency(uint index);
227 237
228 /** 238 /**
229 * Returns the available buttons on this device. The number and location 239 * Returns the available buttons on this device. The number and location
230 * of buttons will vary depending on the device. Button numbers will be assigned 240 * of buttons will vary depending on the device. Button numbers will be assigned
231 * by the device manufacturer and will be from most preferred button to least preffered 241 * by the device manufacturer and will be from most preferred button to least preffered
232 * button. Note that this list only contains "user mappable" buttons. 242 * button. Note that this list only contains "user mappable" buttons.
233 */ 243 */
234 const QValueList<ODeviceButton> &buttons ( ) /* ### make const */; 244 const QValueList<ODeviceButton> &buttons ( ) /* ### make const */;
235 245
236 /** 246 /**
237 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 247 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
238 * returns 0L 248 * returns 0L
239 */ 249 */
240 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 250 const ODeviceButton *buttonForKeycode ( ushort keyCode );
241 251
242 /** 252 /**
243 * Reassigns the pressed action for \a button. To return to the factory 253 * Reassigns the pressed action for \a button. To return to the factory
244 * default pass an empty string as \a qcopMessage. 254 * default pass an empty string as \a qcopMessage.
245 */ 255 */
246 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 256 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
247 257
248 /** 258 /**
249 * Reassigns the held action for \a button. To return to the factory 259 * Reassigns the held action for \a button. To return to the factory
250 * default pass an empty string as \a qcopMessage. 260 * default pass an empty string as \a qcopMessage.
251 */ 261 */
252 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 262 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
253 263
254 /** 264 /**
255 * How long (in ms) you have to press a button for a "hold" action 265 * How long (in ms) you have to press a button for a "hold" action
256 */ 266 */
257 uint buttonHoldTime ( ) const; 267 uint buttonHoldTime ( ) const;
258 268
259signals: 269signals:
260 void buttonMappingChanged ( ); 270 void buttonMappingChanged ( );
261 271
262private slots: 272private slots:
263 void systemMessage ( const QCString &, const QByteArray & ); 273 void systemMessage ( const QCString &, const QByteArray & );
264 274
265protected: 275protected:
266 void reloadButtonMapping ( ); 276 void reloadButtonMapping ( );
267 /* ugly virtual hook */ 277 /* ugly virtual hook */
268 virtual void virtual_hook( int id, void* data ); 278 virtual void virtual_hook( int id, void* data );
269}; 279};
270 280
271} 281}
272 282
273#endif 283#endif
274 284