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