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