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