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