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