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