summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 3edf8e7..fef623a 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1562 +1,1564 @@
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#ifndef QT_NO_SOUND
26#include <linux/soundcard.h> 27#include <linux/soundcard.h>
28#endif
27#include <math.h> 29#include <math.h>
28 30
29#include <qapplication.h> 31#include <qapplication.h>
30 32
31#include <qfile.h> 33#include <qfile.h>
32#include <qtextstream.h> 34#include <qtextstream.h>
33#include <qpe/sound.h> 35#include <qpe/sound.h>
34#include <qpe/resource.h> 36#include <qpe/resource.h>
35#include <qpe/config.h> 37#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
37 39
38#include "odevice.h" 40#include "odevice.h"
39 41
40#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
41 43
42#ifndef ARRAY_SIZE 44#ifndef ARRAY_SIZE
43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 45#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44#endif 46#endif
45 47
46// _IO and friends are only defined in kernel headers ... 48// _IO and friends are only defined in kernel headers ...
47 49
48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 50#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
49 51
50#define OD_IO(type,number) OD_IOC(0,type,number,0) 52#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)) 53#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)) 54#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)) 55#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
54 56
55using namespace Opie; 57using namespace Opie;
56 58
57class ODeviceData { 59class ODeviceData {
58public: 60public:
59 QString m_vendorstr; 61 QString m_vendorstr;
60 OVendor m_vendor; 62 OVendor m_vendor;
61 63
62 QString m_modelstr; 64 QString m_modelstr;
63 OModel m_model; 65 OModel m_model;
64 66
65 QString m_systemstr; 67 QString m_systemstr;
66 OSystem m_system; 68 OSystem m_system;
67 69
68 QString m_sysverstr; 70 QString m_sysverstr;
69 71
70 Transformation m_rotation; 72 Transformation m_rotation;
71 ODirection m_direction; 73 ODirection m_direction;
72 74
73 QValueList <ODeviceButton> *m_buttons; 75 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 76 uint m_holdtime;
75 QStrList *m_cpu_frequencies; 77 QStrList *m_cpu_frequencies;
76}; 78};
77 79
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 80class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 81protected:
80 virtual void init ( ); 82 virtual void init ( );
81 virtual void initButtons ( ); 83 virtual void initButtons ( );
82 84
83public: 85public:
84 virtual bool setSoftSuspend ( bool soft ); 86 virtual bool setSoftSuspend ( bool soft );
85 87
86 virtual bool setDisplayBrightness ( int b ); 88 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 89 virtual int displayBrightnessResolution ( ) const;
88 90
89 virtual void alarmSound ( ); 91 virtual void alarmSound ( );
90 92
91 virtual QValueList <OLed> ledList ( ) const; 93 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 94 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 95 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 96 virtual bool setLedState ( OLed led, OLedState st );
95 97
96 virtual bool hasLightSensor ( ) const; 98 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 99 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 100 virtual int lightSensorResolution ( ) const;
99 101
100protected: 102protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 104 virtual void timerEvent ( QTimerEvent *te );
103 105
104 int m_power_timer; 106 int m_power_timer;
105 107
106 OLedState m_leds [2]; 108 OLedState m_leds [2];
107}; 109};
108 110
109class Jornada : public ODevice { 111class Jornada : public ODevice {
110protected: 112protected:
111 virtual void init ( ); 113 virtual void init ( );
112 //virtual void initButtons ( ); 114 //virtual void initButtons ( );
113public: 115public:
114 virtual bool setSoftSuspend ( bool soft ); 116 virtual bool setSoftSuspend ( bool soft );
115 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
116 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
117 static bool isJornada(); 119 static bool isJornada();
118 120
119}; 121};
120 122
121class Zaurus : public ODevice { 123class Zaurus : public ODevice {
122protected: 124protected:
123 virtual void init ( ); 125 virtual void init ( );
124 virtual void initButtons ( ); 126 virtual void initButtons ( );
125 127
126public: 128public:
127 virtual bool setSoftSuspend ( bool soft ); 129 virtual bool setSoftSuspend ( bool soft );
128 130
129 virtual bool setDisplayBrightness ( int b ); 131 virtual bool setDisplayBrightness ( int b );
130 virtual int displayBrightnessResolution ( ) const; 132 virtual int displayBrightnessResolution ( ) const;
131 133
132 virtual void alarmSound ( ); 134 virtual void alarmSound ( );
133 virtual void keySound ( ); 135 virtual void keySound ( );
134 virtual void touchSound ( ); 136 virtual void touchSound ( );
135 137
136 virtual QValueList <OLed> ledList ( ) const; 138 virtual QValueList <OLed> ledList ( ) const;
137 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 139 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
138 virtual OLedState ledState ( OLed led ) const; 140 virtual OLedState ledState ( OLed led ) const;
139 virtual bool setLedState ( OLed led, OLedState st ); 141 virtual bool setLedState ( OLed led, OLedState st );
140 142
141 static bool isZaurus(); 143 static bool isZaurus();
142 144
143protected: 145protected:
144 virtual void buzzer ( int snd ); 146 virtual void buzzer ( int snd );
145 147
146 OLedState m_leds [1]; 148 OLedState m_leds [1];
147 bool m_embedix; 149 bool m_embedix;
148}; 150};
149 151
150class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 152class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
151protected: 153protected:
152 virtual void init ( ); 154 virtual void init ( );
153 virtual void initButtons ( ); 155 virtual void initButtons ( );
154 156
155public: 157public:
156 virtual bool setSoftSuspend ( bool soft ); 158 virtual bool setSoftSuspend ( bool soft );
157 virtual bool suspend(); 159 virtual bool suspend();
158 160
159 virtual bool setDisplayStatus( bool on ); 161 virtual bool setDisplayStatus( bool on );
160 virtual bool setDisplayBrightness ( int b ); 162 virtual bool setDisplayBrightness ( int b );
161 virtual int displayBrightnessResolution ( ) const; 163 virtual int displayBrightnessResolution ( ) const;
162 164
163 virtual void alarmSound ( ); 165 virtual void alarmSound ( );
164 166
165 virtual QValueList <OLed> ledList ( ) const; 167 virtual QValueList <OLed> ledList ( ) const;
166 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 168 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
167 virtual OLedState ledState ( OLed led ) const; 169 virtual OLedState ledState ( OLed led ) const;
168 virtual bool setLedState ( OLed led, OLedState st ); 170 virtual bool setLedState ( OLed led, OLedState st );
169 171
170protected: 172protected:
171 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 173 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
172 virtual void timerEvent ( QTimerEvent *te ); 174 virtual void timerEvent ( QTimerEvent *te );
173 175
174 int m_power_timer; 176 int m_power_timer;
175 177
176 OLedState m_leds [1]; //FIXME check if really only one 178 OLedState m_leds [1]; //FIXME check if really only one
177}; 179};
178 180
179class Ramses : public ODevice, public QWSServer::KeyboardFilter { 181class Ramses : public ODevice, public QWSServer::KeyboardFilter {
180protected: 182protected:
181 virtual void init ( ); 183 virtual void init ( );
182 184
183public: 185public:
184 virtual bool setSoftSuspend ( bool soft ); 186 virtual bool setSoftSuspend ( bool soft );
185 virtual bool suspend ( ); 187 virtual bool suspend ( );
186 188
187 virtual bool setDisplayStatus( bool on ); 189 virtual bool setDisplayStatus( bool on );
188 virtual bool setDisplayBrightness ( int b ); 190 virtual bool setDisplayBrightness ( int b );
189 virtual int displayBrightnessResolution ( ) const; 191 virtual int displayBrightnessResolution ( ) const;
190 virtual bool setDisplayContrast ( int b ); 192 virtual bool setDisplayContrast ( int b );
191 virtual int displayContrastResolution ( ) const; 193 virtual int displayContrastResolution ( ) const;
192 194
193protected: 195protected:
194 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 196 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
195 virtual void timerEvent ( QTimerEvent *te ); 197 virtual void timerEvent ( QTimerEvent *te );
196 198
197 int m_power_timer; 199 int m_power_timer;
198}; 200};
199 201
200struct i_button { 202struct i_button {
201 uint model; 203 uint model;
202 Qt::Key code; 204 Qt::Key code;
203 char *utext; 205 char *utext;
204 char *pix; 206 char *pix;
205 char *fpressedservice; 207 char *fpressedservice;
206 char *fpressedaction; 208 char *fpressedaction;
207 char *fheldservice; 209 char *fheldservice;
208 char *fheldaction; 210 char *fheldaction;
209} ipaq_buttons [] = { 211} ipaq_buttons [] = {
210 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 212 { 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"), 213 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
212 "devicebuttons/ipaq_calendar", 214 "devicebuttons/ipaq_calendar",
213 "datebook", "nextView()", 215 "datebook", "nextView()",
214 "today", "raise()" }, 216 "today", "raise()" },
215 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 217 { 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"), 218 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
217 "devicebuttons/ipaq_contact", 219 "devicebuttons/ipaq_contact",
218 "addressbook", "raise()", 220 "addressbook", "raise()",
219 "addressbook", "beamBusinessCard()" }, 221 "addressbook", "beamBusinessCard()" },
220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 222 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
221 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 223 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
222 "devicebuttons/ipaq_menu", 224 "devicebuttons/ipaq_menu",
223 "QPE/TaskBar", "toggleMenu()", 225 "QPE/TaskBar", "toggleMenu()",
224 "QPE/TaskBar", "toggleStartMenu()" }, 226 "QPE/TaskBar", "toggleStartMenu()" },
225 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 227 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
226 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 228 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
227 "devicebuttons/ipaq_mail", 229 "devicebuttons/ipaq_mail",
228 "mail", "raise()", 230 "mail", "raise()",
229 "mail", "newMail()" }, 231 "mail", "newMail()" },
230 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 232 { 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"), 233 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
232 "devicebuttons/ipaq_home", 234 "devicebuttons/ipaq_home",
233 "QPE/Launcher", "home()", 235 "QPE/Launcher", "home()",
234 "buttonsettings", "raise()" }, 236 "buttonsettings", "raise()" },
235 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 237 { 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"), 238 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
237 "devicebuttons/ipaq_record", 239 "devicebuttons/ipaq_record",
238 "QPE/VMemo", "toggleRecord()", 240 "QPE/VMemo", "toggleRecord()",
239 "sound", "raise()" }, 241 "sound", "raise()" },
240}; 242};
241 243
242struct z_button { 244struct z_button {
243 Qt::Key code; 245 Qt::Key code;
244 char *utext; 246 char *utext;
245 char *pix; 247 char *pix;
246 char *fpressedservice; 248 char *fpressedservice;
247 char *fpressedaction; 249 char *fpressedaction;
248 char *fheldservice; 250 char *fheldservice;
249 char *fheldaction; 251 char *fheldaction;
250} z_buttons [] = { 252} z_buttons [] = {
251 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 253 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
252 "devicebuttons/z_calendar", 254 "devicebuttons/z_calendar",
253 "datebook", "nextView()", 255 "datebook", "nextView()",
254 "today", "raise()" }, 256 "today", "raise()" },
255 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 257 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
256 "devicebuttons/z_contact", 258 "devicebuttons/z_contact",
257 "addressbook", "raise()", 259 "addressbook", "raise()",
258 "addressbook", "beamBusinessCard()" }, 260 "addressbook", "beamBusinessCard()" },
259 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 261 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
260 "devicebuttons/z_home", 262 "devicebuttons/z_home",
261 "QPE/Launcher", "home()", 263 "QPE/Launcher", "home()",
262 "buttonsettings", "raise()" }, 264 "buttonsettings", "raise()" },
263 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 265 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
264 "devicebuttons/z_menu", 266 "devicebuttons/z_menu",
265 "QPE/TaskBar", "toggleMenu()", 267 "QPE/TaskBar", "toggleMenu()",
266 "QPE/TaskBar", "toggleStartMenu()" }, 268 "QPE/TaskBar", "toggleStartMenu()" },
267 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 269 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
268 "devicebuttons/z_mail", 270 "devicebuttons/z_mail",
269 "mail", "raise()", 271 "mail", "raise()",
270 "mail", "newMail()" }, 272 "mail", "newMail()" },
271}; 273};
272 274
273struct z_button z_buttons_c700 [] = { 275struct z_button z_buttons_c700 [] = {
274 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 276 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
275 "devicebuttons/z_calendar", 277 "devicebuttons/z_calendar",
276 "datebook", "nextView()", 278 "datebook", "nextView()",
277 "today", "raise()" }, 279 "today", "raise()" },
278 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 280 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
279 "devicebuttons/z_contact", 281 "devicebuttons/z_contact",
280 "addressbook", "raise()", 282 "addressbook", "raise()",
281 "addressbook", "beamBusinessCard()" }, 283 "addressbook", "beamBusinessCard()" },
282 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 284 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
283 "devicebuttons/z_home", 285 "devicebuttons/z_home",
284 "QPE/Launcher", "home()", 286 "QPE/Launcher", "home()",
285 "buttonsettings", "raise()" }, 287 "buttonsettings", "raise()" },
286 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 288 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
287 "devicebuttons/z_menu", 289 "devicebuttons/z_menu",
288 "QPE/TaskBar", "toggleMenu()", 290 "QPE/TaskBar", "toggleMenu()",
289 "QPE/TaskBar", "toggleStartMenu()" }, 291 "QPE/TaskBar", "toggleStartMenu()" },
290 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 292 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
291 "", 293 "",
292 "QPE/Rotation", "flip()", 294 "QPE/Rotation", "flip()",
293 "QPE/Rotation", "flip()" }, 295 "QPE/Rotation", "flip()" },
294}; 296};
295 297
296struct s_button { 298struct s_button {
297 uint model; 299 uint model;
298 Qt::Key code; 300 Qt::Key code;
299 char *utext; 301 char *utext;
300 char *pix; 302 char *pix;
301 char *fpressedservice; 303 char *fpressedservice;
302 char *fpressedaction; 304 char *fpressedaction;
303 char *fheldservice; 305 char *fheldservice;
304 char *fheldaction; 306 char *fheldaction;
305} simpad_buttons [] = { 307} simpad_buttons [] = {
306 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 308 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
307 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 309 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
308 "devicebuttons/simpad_lower_up", 310 "devicebuttons/simpad_lower_up",
309 "datebook", "nextView()", 311 "datebook", "nextView()",
310 "today", "raise()" }, 312 "today", "raise()" },
311 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 313 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
312 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 314 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
313 "devicebuttons/simpad_lower_down", 315 "devicebuttons/simpad_lower_down",
314 "addressbook", "raise()", 316 "addressbook", "raise()",
315 "addressbook", "beamBusinessCard()" }, 317 "addressbook", "beamBusinessCard()" },
316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 318 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
317 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 319 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
318 "devicebuttons/simpad_lower_right", 320 "devicebuttons/simpad_lower_right",
319 "QPE/TaskBar", "toggleMenu()", 321 "QPE/TaskBar", "toggleMenu()",
320 "QPE/TaskBar", "toggleStartMenu()" }, 322 "QPE/TaskBar", "toggleStartMenu()" },
321 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 323 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
322 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 324 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
323 "devicebuttons/simpad_lower_left", 325 "devicebuttons/simpad_lower_left",
324 "mail", "raise()", 326 "mail", "raise()",
325 "mail", "newMail()" }, 327 "mail", "newMail()" },
326 328
327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 329 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
328 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 330 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
329 "devicebuttons/simpad_upper_up", 331 "devicebuttons/simpad_upper_up",
330 "QPE/Launcher", "home()", 332 "QPE/Launcher", "home()",
331 "buttonsettings", "raise()" }, 333 "buttonsettings", "raise()" },
332 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 334 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
333 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 335 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
334 "devicebuttons/simpad_upper_down", 336 "devicebuttons/simpad_upper_down",
335 "addressbook", "raise()", 337 "addressbook", "raise()",
336 "addressbook", "beamBusinessCard()" }, 338 "addressbook", "beamBusinessCard()" },
337 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 339 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
338 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 340 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
339 "devicebuttons/simpad_upper_right", 341 "devicebuttons/simpad_upper_right",
340 "QPE/TaskBar", "toggleMenu()", 342 "QPE/TaskBar", "toggleMenu()",
341 "QPE/TaskBar", "toggleStartMenu()" }, 343 "QPE/TaskBar", "toggleStartMenu()" },
342 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 344 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
343 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 345 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
344 "devicebuttons/simpad_upper_left", 346 "devicebuttons/simpad_upper_left",
345 "QPE/Rotation", "flip()", 347 "QPE/Rotation", "flip()",
346 "QPE/Rotation", "flip()" }, 348 "QPE/Rotation", "flip()" },
347 /* 349 /*
348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 350 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
349 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 351 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
350 "devicebuttons/simpad_lower_upper", 352 "devicebuttons/simpad_lower_upper",
351 "QPE/Launcher", "home()", 353 "QPE/Launcher", "home()",
352 "buttonsettings", "raise()" }, 354 "buttonsettings", "raise()" },
353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 355 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
354 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 356 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
355 "devicebuttons/simpad_upper_lower", 357 "devicebuttons/simpad_upper_lower",
356 "QPE/Launcher", "home()", 358 "QPE/Launcher", "home()",
357 "buttonsettings", "raise()" }, 359 "buttonsettings", "raise()" },
358 */ 360 */
359}; 361};
360 362
361struct r_button { 363struct r_button {
362 uint model; 364 uint model;
363 Qt::Key code; 365 Qt::Key code;
364 char *utext; 366 char *utext;
365 char *pix; 367 char *pix;
366 char *fpressedservice; 368 char *fpressedservice;
367 char *fpressedaction; 369 char *fpressedaction;
368 char *fheldservice; 370 char *fheldservice;
369 char *fheldaction; 371 char *fheldaction;
370} ramses_buttons [] = { 372} ramses_buttons [] = {
371 { Model_Ramses_MNCI, 373 { Model_Ramses_MNCI,
372 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 374 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
373 "devicebuttons/z_menu", 375 "devicebuttons/z_menu",
374 "QPE/TaskBar", "toggleMenu()", 376 "QPE/TaskBar", "toggleMenu()",
375 "QPE/TaskBar", "toggleStartMenu()" }, 377 "QPE/TaskBar", "toggleStartMenu()" },
376 { Model_Ramses_MNCI, 378 { Model_Ramses_MNCI,
377 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 379 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
378 "devicebuttons/ipaq_home", 380 "devicebuttons/ipaq_home",
379 "QPE/Launcher", "home()", 381 "QPE/Launcher", "home()",
380 "buttonsettings", "raise()" }, 382 "buttonsettings", "raise()" },
381}; 383};
382 384
383class Yopy : public ODevice { 385class Yopy : public ODevice {
384protected: 386protected:
385 virtual void init ( ); 387 virtual void init ( );
386 virtual void initButtons ( ); 388 virtual void initButtons ( );
387 389
388public: 390public:
389 virtual bool suspend ( ); 391 virtual bool suspend ( );
390 392
391 virtual bool setDisplayBrightness ( int b ); 393 virtual bool setDisplayBrightness ( int b );
392 virtual int displayBrightnessResolution ( ) const; 394 virtual int displayBrightnessResolution ( ) const;
393 395
394 static bool isYopy ( ); 396 static bool isYopy ( );
395}; 397};
396 398
397struct yopy_button { 399struct yopy_button {
398 Qt::Key code; 400 Qt::Key code;
399 char *utext; 401 char *utext;
400 char *pix; 402 char *pix;
401 char *fpressedservice; 403 char *fpressedservice;
402 char *fpressedaction; 404 char *fpressedaction;
403 char *fheldservice; 405 char *fheldservice;
404 char *fheldaction; 406 char *fheldaction;
405} yopy_buttons [] = { 407} yopy_buttons [] = {
406 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 408 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
407 "devicebuttons/yopy_action", 409 "devicebuttons/yopy_action",
408 "datebook", "nextView()", 410 "datebook", "nextView()",
409 "today", "raise()" }, 411 "today", "raise()" },
410 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 412 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
411 "devicebuttons/yopy_ok", 413 "devicebuttons/yopy_ok",
412 "addressbook", "raise()", 414 "addressbook", "raise()",
413 "addressbook", "beamBusinessCard()" }, 415 "addressbook", "beamBusinessCard()" },
414 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 416 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
415 "devicebuttons/yopy_end", 417 "devicebuttons/yopy_end",
416 "QPE/Launcher", "home()", 418 "QPE/Launcher", "home()",
417 "buttonsettings", "raise()" }, 419 "buttonsettings", "raise()" },
418}; 420};
419 421
420static QCString makeChannel ( const char *str ) 422static QCString makeChannel ( const char *str )
421{ 423{
422 if ( str && !::strchr ( str, '/' )) 424 if ( str && !::strchr ( str, '/' ))
423 return QCString ( "QPE/Application/" ) + str; 425 return QCString ( "QPE/Application/" ) + str;
424 else 426 else
425 return str; 427 return str;
426} 428}
427 429
428static inline bool isQWS() 430static inline bool isQWS()
429{ 431{
430 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 432 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
431} 433}
432 434
433ODevice *ODevice::inst ( ) 435ODevice *ODevice::inst ( )
434{ 436{
435 static ODevice *dev = 0; 437 static ODevice *dev = 0;
436 438
437 if ( !dev ) { 439 if ( !dev ) {
438 if ( QFile::exists ( "/proc/hal/model" )) 440 if ( QFile::exists ( "/proc/hal/model" ))
439 dev = new iPAQ ( ); 441 dev = new iPAQ ( );
440 else if ( Zaurus::isZaurus() ) 442 else if ( Zaurus::isZaurus() )
441 dev = new Zaurus ( ); 443 dev = new Zaurus ( );
442 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 444 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
443 dev = new SIMpad ( ); 445 dev = new SIMpad ( );
444 else if ( QFile::exists ( "/proc/sys/board/name" )) 446 else if ( QFile::exists ( "/proc/sys/board/name" ))
445 dev = new Ramses ( ); 447 dev = new Ramses ( );
446 else if ( Yopy::isYopy() ) 448 else if ( Yopy::isYopy() )
447 dev = new Yopy ( ); 449 dev = new Yopy ( );
448 else if ( Jornada::isJornada() ) 450 else if ( Jornada::isJornada() )
449 dev = new Jornada ( ); 451 dev = new Jornada ( );
450 else 452 else
451 dev = new ODevice ( ); 453 dev = new ODevice ( );
452 dev-> init ( ); 454 dev-> init ( );
453 } 455 }
454 return dev; 456 return dev;
455} 457}
456 458
457 459
458/************************************************** 460/**************************************************
459 * 461 *
460 * common 462 * common
461 * 463 *
462 **************************************************/ 464 **************************************************/
463 465
464 466
465ODevice::ODevice ( ) 467ODevice::ODevice ( )
466{ 468{
467 d = new ODeviceData; 469 d = new ODeviceData;
468 470
469 d-> m_modelstr = "Unknown"; 471 d-> m_modelstr = "Unknown";
470 d-> m_model = Model_Unknown; 472 d-> m_model = Model_Unknown;
471 d-> m_vendorstr = "Unknown"; 473 d-> m_vendorstr = "Unknown";
472 d-> m_vendor = Vendor_Unknown; 474 d-> m_vendor = Vendor_Unknown;
473 d-> m_systemstr = "Unknown"; 475 d-> m_systemstr = "Unknown";
474 d-> m_system = System_Unknown; 476 d-> m_system = System_Unknown;
475 d-> m_sysverstr = "0.0"; 477 d-> m_sysverstr = "0.0";
476 d-> m_rotation = Rot0; 478 d-> m_rotation = Rot0;
477 d-> m_direction = CW; 479 d-> m_direction = CW;
478 480
479 d-> m_holdtime = 1000; // 1000ms 481 d-> m_holdtime = 1000; // 1000ms
480 d-> m_buttons = 0; 482 d-> m_buttons = 0;
481 d-> m_cpu_frequencies = new QStrList; 483 d-> m_cpu_frequencies = new QStrList;
482} 484}
483 485
484void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 486void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
485{ 487{
486 if ( msg == "deviceButtonMappingChanged()" ) { 488 if ( msg == "deviceButtonMappingChanged()" ) {
487 reloadButtonMapping ( ); 489 reloadButtonMapping ( );
488 } 490 }
489} 491}
490 492
491void ODevice::init ( ) 493void ODevice::init ( )
492{ 494{
493} 495}
494 496
495/** 497/**
496 * This method initialises the button mapping 498 * This method initialises the button mapping
497 */ 499 */
498void ODevice::initButtons ( ) 500void ODevice::initButtons ( )
499{ 501{
500 if ( d-> m_buttons ) 502 if ( d-> m_buttons )
501 return; 503 return;
502 504
503 // Simulation uses iPAQ 3660 device buttons 505 // Simulation uses iPAQ 3660 device buttons
504 506
505 qDebug ( "init Buttons" ); 507 qDebug ( "init Buttons" );
506 d-> m_buttons = new QValueList <ODeviceButton>; 508 d-> m_buttons = new QValueList <ODeviceButton>;
507 509
508 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 510 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
509 i_button *ib = ipaq_buttons + i; 511 i_button *ib = ipaq_buttons + i;
510 ODeviceButton b; 512 ODeviceButton b;
511 513
512 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 514 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
513 b. setKeycode ( ib-> code ); 515 b. setKeycode ( ib-> code );
514 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 516 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
515 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 517 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
516 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 518 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
517 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 519 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
518 d-> m_buttons-> append ( b ); 520 d-> m_buttons-> append ( b );
519 } 521 }
520 } 522 }
521 reloadButtonMapping ( ); 523 reloadButtonMapping ( );
522 524
523 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 525 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
524 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 526 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
525} 527}
526 528
527ODevice::~ODevice ( ) 529ODevice::~ODevice ( )
528{ 530{
529// we leak m_devicebuttons and m_cpu_frequency 531// we leak m_devicebuttons and m_cpu_frequency
530// but it's a singleton and it is not so importantant 532// but it's a singleton and it is not so importantant
531// -zecke 533// -zecke
532 delete d; 534 delete d;
533} 535}
534 536
535bool ODevice::setSoftSuspend ( bool /*soft*/ ) 537bool ODevice::setSoftSuspend ( bool /*soft*/ )
536{ 538{
537 return false; 539 return false;
538} 540}
539 541
540//#include <linux/apm_bios.h> 542//#include <linux/apm_bios.h>
541 543
542#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 544#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
543 545
544/** 546/**
545 * This method will try to suspend the device 547 * This method will try to suspend the device
546 * It only works if the user is the QWS Server and the apm application 548 * It only works if the user is the QWS Server and the apm application
547 * is installed. 549 * is installed.
548 * It tries to suspend and then waits some time cause some distributions 550 * It tries to suspend and then waits some time cause some distributions
549 * do have asynchronus apm implementations. 551 * do have asynchronus apm implementations.
550 * This method will either fail and return false or it'll suspend the 552 * This method will either fail and return false or it'll suspend the
551 * device and return once the device got woken up 553 * device and return once the device got woken up
552 * 554 *
553 * @return if the device got suspended 555 * @return if the device got suspended
554 */ 556 */
555bool ODevice::suspend ( ) 557bool ODevice::suspend ( )
556{ 558{
557 qDebug("ODevice::suspend"); 559 qDebug("ODevice::suspend");
558 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 560 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
559 return false; 561 return false;
560 562
561 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 563 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
562 return false; 564 return false;
563 565
564 bool res = false; 566 bool res = false;
565 567
566 struct timeval tvs, tvn; 568 struct timeval tvs, tvn;
567 ::gettimeofday ( &tvs, 0 ); 569 ::gettimeofday ( &tvs, 0 );
568 570
569 ::sync ( ); // flush fs caches 571 ::sync ( ); // flush fs caches
570 res = ( ::system ( "apm --suspend" ) == 0 ); 572 res = ( ::system ( "apm --suspend" ) == 0 );
571 573
572 // This is needed because the iPAQ apm implementation is asynchronous and we 574 // This is needed because the iPAQ apm implementation is asynchronous and we
573 // can not be sure when exactly the device is really suspended 575 // 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. 576 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
575 577
576 if ( res ) { 578 if ( res ) {
577 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 579 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
578 ::usleep ( 200 * 1000 ); 580 ::usleep ( 200 * 1000 );
579 ::gettimeofday ( &tvn, 0 ); 581 ::gettimeofday ( &tvn, 0 );
580 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 582 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
581 } 583 }
582 584
583 return res; 585 return res;
584} 586}
585 587
586//#include <linux/fb.h> better not rely on kernel headers in userspace ... 588//#include <linux/fb.h> better not rely on kernel headers in userspace ...
587 589
588#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 590#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
589 591
590/* VESA Blanking Levels */ 592/* VESA Blanking Levels */
591#define VESA_NO_BLANKING 0 593#define VESA_NO_BLANKING 0
592#define VESA_VSYNC_SUSPEND 1 594#define VESA_VSYNC_SUSPEND 1
593#define VESA_HSYNC_SUSPEND 2 595#define VESA_HSYNC_SUSPEND 2
594#define VESA_POWERDOWN 3 596#define VESA_POWERDOWN 3
595 597
596/** 598/**
597 * This sets the display on or off 599 * This sets the display on or off
598 */ 600 */
599bool ODevice::setDisplayStatus ( bool on ) 601bool ODevice::setDisplayStatus ( bool on )
600{ 602{
601 qDebug("ODevice::setDisplayStatus(%d)", on); 603 qDebug("ODevice::setDisplayStatus(%d)", on);
602 604
603 if ( d-> m_model == Model_Unknown ) 605 if ( d-> m_model == Model_Unknown )
604 return false; 606 return false;
605 607
606 bool res = false; 608 bool res = false;
607 int fd; 609 int fd;
608 610
609 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 611 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
610 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 612 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
611 ::close ( fd ); 613 ::close ( fd );
612 } 614 }
613 return res; 615 return res;
614} 616}
615 617
616/** 618/**
617 * This sets the display brightness 619 * This sets the display brightness
618 * 620 *
619 * @param p The brightness to be set on a scale from 0 to 255 621 * @param p The brightness to be set on a scale from 0 to 255
620 * @return success or failure 622 * @return success or failure
621 */ 623 */
622bool ODevice::setDisplayBrightness ( int p) 624bool ODevice::setDisplayBrightness ( int p)
623{ 625{
624 Q_UNUSED( p ) 626 Q_UNUSED( p )
625 return false; 627 return false;
626} 628}
627 629
628/** 630/**
629 * @return returns the number of steppings on the brightness slider 631 * @return returns the number of steppings on the brightness slider
630 * in the Light-'n-Power settings. 632 * in the Light-'n-Power settings.
631 */ 633 */
632int ODevice::displayBrightnessResolution ( ) const 634int ODevice::displayBrightnessResolution ( ) const
633{ 635{
634 return 16; 636 return 16;
635} 637}
636 638
637/** 639/**
638 * This sets the display contrast 640 * This sets the display contrast
639 * @param p The contrast to be set on a scale from 0 to 255 641 * @param p The contrast to be set on a scale from 0 to 255
640 * @return success or failure 642 * @return success or failure
641 */ 643 */
642bool ODevice::setDisplayContrast ( int p) 644bool ODevice::setDisplayContrast ( int p)
643{ 645{
644 Q_UNUSED( p ) 646 Q_UNUSED( p )
645 return false; 647 return false;
646} 648}
647 649
648/** 650/**
649 * @return return the max value for the brightness settings slider 651 * @return return the max value for the brightness settings slider
650 * or 0 if the device doesn't support setting of a contrast 652 * or 0 if the device doesn't support setting of a contrast
651 */ 653 */
652int ODevice::displayContrastResolution ( ) const 654int ODevice::displayContrastResolution ( ) const
653{ 655{
654 return 0; 656 return 0;
655} 657}
656 658
657/** 659/**
658 * This returns the vendor as string 660 * This returns the vendor as string
659 * @return Vendor as QString 661 * @return Vendor as QString
660 */ 662 */
661QString ODevice::vendorString ( ) const 663QString ODevice::vendorString ( ) const
662{ 664{
663 return d-> m_vendorstr; 665 return d-> m_vendorstr;
664} 666}
665 667
666/** 668/**
667 * This returns the vendor as one of the values of OVendor 669 * This returns the vendor as one of the values of OVendor
668 * @return OVendor 670 * @return OVendor
669 */ 671 */
670OVendor ODevice::vendor ( ) const 672OVendor ODevice::vendor ( ) const
671{ 673{
672 return d-> m_vendor; 674 return d-> m_vendor;
673} 675}
674 676
675/** 677/**
676 * This returns the model as a string 678 * This returns the model as a string
677 * @return A string representing the model 679 * @return A string representing the model
678 */ 680 */
679QString ODevice::modelString ( ) const 681QString ODevice::modelString ( ) const
680{ 682{
681 return d-> m_modelstr; 683 return d-> m_modelstr;
682} 684}
683 685
684/** 686/**
685 * This does return the OModel used 687 * This does return the OModel used
686 */ 688 */
687OModel ODevice::model ( ) const 689OModel ODevice::model ( ) const
688{ 690{
689 return d-> m_model; 691 return d-> m_model;
690} 692}
691 693
692/** 694/**
693 * This does return the systen name 695 * This does return the systen name
694 */ 696 */
695QString ODevice::systemString ( ) const 697QString ODevice::systemString ( ) const
696{ 698{
697 return d-> m_systemstr; 699 return d-> m_systemstr;
698} 700}
699 701
700/** 702/**
701 * Return System as OSystem value 703 * Return System as OSystem value
702 */ 704 */
703OSystem ODevice::system ( ) const 705OSystem ODevice::system ( ) const
704{ 706{
705 return d-> m_system; 707 return d-> m_system;
706} 708}
707 709
708/** 710/**
709 * @return the version string of the base system 711 * @return the version string of the base system
710 */ 712 */
711QString ODevice::systemVersionString ( ) const 713QString ODevice::systemVersionString ( ) const
712{ 714{
713 return d-> m_sysverstr; 715 return d-> m_sysverstr;
714} 716}
715 717
716/** 718/**
717 * @return the current Transformation 719 * @return the current Transformation
718 */ 720 */
719Transformation ODevice::rotation ( ) const 721Transformation ODevice::rotation ( ) const
720{ 722{
721 return d-> m_rotation; 723 return d-> m_rotation;
722} 724}
723 725
724/** 726/**
725 * @return the current rotation direction 727 * @return the current rotation direction
726 */ 728 */
727ODirection ODevice::direction ( ) const 729ODirection ODevice::direction ( ) const
728{ 730{
729 return d-> m_direction; 731 return d-> m_direction;
730} 732}
731 733
732/** 734/**
733 * This plays an alarmSound 735 * This plays an alarmSound
734 */ 736 */
735void ODevice::alarmSound ( ) 737void ODevice::alarmSound ( )
736{ 738{
737#ifndef QT_NO_SOUND 739#ifndef QT_NO_SOUND
738 static Sound snd ( "alarm" ); 740 static Sound snd ( "alarm" );
739 741
740 if ( snd. isFinished ( )) 742 if ( snd. isFinished ( ))
741 snd. play ( ); 743 snd. play ( );
742#endif 744#endif
743} 745}
744 746
745/** 747/**
746 * This plays a key sound 748 * This plays a key sound
747 */ 749 */
748void ODevice::keySound ( ) 750void ODevice::keySound ( )
749{ 751{
750#ifndef QT_NO_SOUND 752#ifndef QT_NO_SOUND
751 static Sound snd ( "keysound" ); 753 static Sound snd ( "keysound" );
752 754
753 if ( snd. isFinished ( )) 755 if ( snd. isFinished ( ))
754 snd. play ( ); 756 snd. play ( );
755#endif 757#endif
756} 758}
757 759
758/** 760/**
759 * This plays a touch sound 761 * This plays a touch sound
760 */ 762 */
761void ODevice::touchSound ( ) 763void ODevice::touchSound ( )
762{ 764{
763#ifndef QT_NO_SOUND 765#ifndef QT_NO_SOUND
764 static Sound snd ( "touchsound" ); 766 static Sound snd ( "touchsound" );
765 767
766 if ( snd. isFinished ( )) 768 if ( snd. isFinished ( ))
767 snd. play ( ); 769 snd. play ( );
768#endif 770#endif
769} 771}
770 772
771/** 773/**
772 * This method will return a list of leds 774 * This method will return a list of leds
773 * available on this device 775 * available on this device
774 * @return a list of LEDs. 776 * @return a list of LEDs.
775 */ 777 */
776QValueList <OLed> ODevice::ledList ( ) const 778QValueList <OLed> ODevice::ledList ( ) const
777{ 779{
778 return QValueList <OLed> ( ); 780 return QValueList <OLed> ( );
779} 781}
780 782
781/** 783/**
782 * This does return the state of the LEDs 784 * This does return the state of the LEDs
783 */ 785 */
784QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 786QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
785{ 787{
786 return QValueList <OLedState> ( ); 788 return QValueList <OLedState> ( );
787} 789}
788 790
789/** 791/**
790 * @return the state for a given OLed 792 * @return the state for a given OLed
791 */ 793 */
792OLedState ODevice::ledState ( OLed /*which*/ ) const 794OLedState ODevice::ledState ( OLed /*which*/ ) const
793{ 795{
794 return Led_Off; 796 return Led_Off;
795} 797}
796 798
797/** 799/**
798 * Set the state for a LED 800 * Set the state for a LED
799 * @param which Which OLed to use 801 * @param which Which OLed to use
800 * @param st The state to set 802 * @param st The state to set
801 * @return success or failure 803 * @return success or failure
802 */ 804 */
803bool ODevice::setLedState ( OLed which, OLedState st ) 805bool ODevice::setLedState ( OLed which, OLedState st )
804{ 806{
805 Q_UNUSED( which ) 807 Q_UNUSED( which )
806 Q_UNUSED( st ) 808 Q_UNUSED( st )
807 return false; 809 return false;
808} 810}
809 811
810/** 812/**
811 * @return if the device has a light sensor 813 * @return if the device has a light sensor
812 */ 814 */
813bool ODevice::hasLightSensor ( ) const 815bool ODevice::hasLightSensor ( ) const
814{ 816{
815 return false; 817 return false;
816} 818}
817 819
818/** 820/**
819 * @return a value from the light senso 821 * @return a value from the light senso
820 */ 822 */
821int ODevice::readLightSensor ( ) 823int ODevice::readLightSensor ( )
822{ 824{
823 return -1; 825 return -1;
824} 826}
825 827
826/** 828/**
827 * @return the light sensor resolution whatever that is ;) 829 * @return the light sensor resolution whatever that is ;)
828 */ 830 */
829int ODevice::lightSensorResolution ( ) const 831int ODevice::lightSensorResolution ( ) const
830{ 832{
831 return 0; 833 return 0;
832} 834}
833 835
834/** 836/**
835 * @return a list with CPU frequencies supported by the hardware 837 * @return a list with CPU frequencies supported by the hardware
836 */ 838 */
837const QStrList &ODevice::allowedCpuFrequencies ( ) const 839const QStrList &ODevice::allowedCpuFrequencies ( ) const
838{ 840{
839 return *d->m_cpu_frequencies; 841 return *d->m_cpu_frequencies;
840} 842}
841 843
842 844
843/** 845/**
844 * Set desired CPU frequency 846 * Set desired CPU frequency
845 * 847 *
846 * @param index index into d->m_cpu_frequencies of the frequency to be set 848 * @param index index into d->m_cpu_frequencies of the frequency to be set
847 */ 849 */
848bool ODevice::setCurrentCpuFrequency(uint index) 850bool ODevice::setCurrentCpuFrequency(uint index)
849{ 851{
850 if (index >= d->m_cpu_frequencies->count()) 852 if (index >= d->m_cpu_frequencies->count())
851 return false; 853 return false;
852 854
853 char *freq = d->m_cpu_frequencies->at(index); 855 char *freq = d->m_cpu_frequencies->at(index);
854 qWarning("set freq to %s", freq); 856 qWarning("set freq to %s", freq);
855 857
856 int fd; 858 int fd;
857 859
858 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 860 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
859 char writeCommand[50]; 861 char writeCommand[50];
860 const int count = sprintf(writeCommand, "%s\n", freq); 862 const int count = sprintf(writeCommand, "%s\n", freq);
861 int res = (::write(fd, writeCommand, count) != -1); 863 int res = (::write(fd, writeCommand, count) != -1);
862 ::close(fd); 864 ::close(fd);
863 return res; 865 return res;
864 } 866 }
865 867
866 return false; 868 return false;
867} 869}
868 870
869 871
870/** 872/**
871 * @return a list of hardware buttons 873 * @return a list of hardware buttons
872 */ 874 */
873const QValueList <ODeviceButton> &ODevice::buttons ( ) 875const QValueList <ODeviceButton> &ODevice::buttons ( )
874{ 876{
875 initButtons ( ); 877 initButtons ( );
876 878
877 return *d-> m_buttons; 879 return *d-> m_buttons;
878} 880}
879 881
880/** 882/**
881 * @return The amount of time that would count as a hold 883 * @return The amount of time that would count as a hold
882 */ 884 */
883uint ODevice::buttonHoldTime ( ) const 885uint ODevice::buttonHoldTime ( ) const
884{ 886{
885 return d-> m_holdtime; 887 return d-> m_holdtime;
886} 888}
887 889
888/** 890/**
889 * This method return a ODeviceButton for a key code 891 * This method return a ODeviceButton for a key code
890 * or 0 if no special hardware button is available for the device 892 * or 0 if no special hardware button is available for the device
891 * 893 *
892 * @return The devicebutton or 0l 894 * @return The devicebutton or 0l
893 * @see ODeviceButton 895 * @see ODeviceButton
894 */ 896 */
895const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 897const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
896{ 898{
897 initButtons ( ); 899 initButtons ( );
898 900
899 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 901 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
900 if ( (*it). keycode ( ) == code ) 902 if ( (*it). keycode ( ) == code )
901 return &(*it); 903 return &(*it);
902 } 904 }
903 return 0; 905 return 0;
904} 906}
905 907
906void ODevice::reloadButtonMapping ( ) 908void ODevice::reloadButtonMapping ( )
907{ 909{
908 initButtons ( ); 910 initButtons ( );
909 911
910 Config cfg ( "ButtonSettings" ); 912 Config cfg ( "ButtonSettings" );
911 913
912 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 914 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
913 ODeviceButton &b = ( *d-> m_buttons ) [i]; 915 ODeviceButton &b = ( *d-> m_buttons ) [i];
914 QString group = "Button" + QString::number ( i ); 916 QString group = "Button" + QString::number ( i );
915 917
916 QCString pch, hch; 918 QCString pch, hch;
917 QCString pm, hm; 919 QCString pm, hm;
918 QByteArray pdata, hdata; 920 QByteArray pdata, hdata;
919 921
920 if ( cfg. hasGroup ( group )) { 922 if ( cfg. hasGroup ( group )) {
921 cfg. setGroup ( group ); 923 cfg. setGroup ( group );
922 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 924 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
923 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 925 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
924 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 926 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
925 927
926 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 928 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
927 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 929 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
928 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 930 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
929 } 931 }
930 932
931 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 933 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
932 934
933 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 935 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
934 } 936 }
935} 937}
936 938
937void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 939void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
938{ 940{
939 initButtons ( ); 941 initButtons ( );
940 942
941 QString mb_chan; 943 QString mb_chan;
942 944
943 if ( button >= (int) d-> m_buttons-> count ( )) 945 if ( button >= (int) d-> m_buttons-> count ( ))
944 return; 946 return;
945 947
946 ODeviceButton &b = ( *d-> m_buttons ) [button]; 948 ODeviceButton &b = ( *d-> m_buttons ) [button];
947 b. setPressedAction ( action ); 949 b. setPressedAction ( action );
948 950
949 mb_chan=b. pressedAction ( ). channel ( ); 951 mb_chan=b. pressedAction ( ). channel ( );
950 952
951 Config buttonFile ( "ButtonSettings" ); 953 Config buttonFile ( "ButtonSettings" );
952 buttonFile. setGroup ( "Button" + QString::number ( button )); 954 buttonFile. setGroup ( "Button" + QString::number ( button ));
953 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 955 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
954 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 956 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
955 957
956 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 958 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
957 959
958 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 960 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
959} 961}
960 962
961void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 963void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
962{ 964{
963 initButtons ( ); 965 initButtons ( );
964 966
965 if ( button >= (int) d-> m_buttons-> count ( )) 967 if ( button >= (int) d-> m_buttons-> count ( ))
966 return; 968 return;
967 969
968 ODeviceButton &b = ( *d-> m_buttons ) [button]; 970 ODeviceButton &b = ( *d-> m_buttons ) [button];
969 b. setHeldAction ( action ); 971 b. setHeldAction ( action );
970 972
971 Config buttonFile ( "ButtonSettings" ); 973 Config buttonFile ( "ButtonSettings" );
972 buttonFile. setGroup ( "Button" + QString::number ( button )); 974 buttonFile. setGroup ( "Button" + QString::number ( button ));
973 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 975 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
974 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 976 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
975 977
976 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 978 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
977 979
978 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 980 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
979} 981}
980void ODevice::virtual_hook(int, void* ){ 982void ODevice::virtual_hook(int, void* ){
981 983
982} 984}
983 985
984/************************************************** 986/**************************************************
985 * 987 *
986 * Yopy 3500/3700 988 * Yopy 3500/3700
987 * 989 *
988 **************************************************/ 990 **************************************************/
989 991
990bool Yopy::isYopy ( ) 992bool Yopy::isYopy ( )
991{ 993{
992 QFile f( "/proc/cpuinfo" ); 994 QFile f( "/proc/cpuinfo" );
993 if ( f. open ( IO_ReadOnly ) ) { 995 if ( f. open ( IO_ReadOnly ) ) {
994 QTextStream ts ( &f ); 996 QTextStream ts ( &f );
995 QString line; 997 QString line;
996 while( line = ts. readLine ( ) ) { 998 while( line = ts. readLine ( ) ) {
997 if ( line. left ( 8 ) == "Hardware" ) { 999 if ( line. left ( 8 ) == "Hardware" ) {
998 int loc = line. find ( ":" ); 1000 int loc = line. find ( ":" );
999 if ( loc != -1 ) { 1001 if ( loc != -1 ) {
1000 QString model = 1002 QString model =
1001 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1003 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1002 return ( model == "Yopy" ); 1004 return ( model == "Yopy" );
1003 } 1005 }
1004 } 1006 }
1005 } 1007 }
1006 } 1008 }
1007 return false; 1009 return false;
1008} 1010}
1009 1011
1010void Yopy::init ( ) 1012void Yopy::init ( )
1011{ 1013{
1012 d-> m_vendorstr = "G.Mate"; 1014 d-> m_vendorstr = "G.Mate";
1013 d-> m_vendor = Vendor_GMate; 1015 d-> m_vendor = Vendor_GMate;
1014 d-> m_modelstr = "Yopy3700"; 1016 d-> m_modelstr = "Yopy3700";
1015 d-> m_model = Model_Yopy_3700; 1017 d-> m_model = Model_Yopy_3700;
1016 d-> m_rotation = Rot0; 1018 d-> m_rotation = Rot0;
1017 1019
1018 d-> m_systemstr = "Linupy"; 1020 d-> m_systemstr = "Linupy";
1019 d-> m_system = System_Linupy; 1021 d-> m_system = System_Linupy;
1020 1022
1021 QFile f ( "/etc/issue" ); 1023 QFile f ( "/etc/issue" );
1022 if ( f. open ( IO_ReadOnly )) { 1024 if ( f. open ( IO_ReadOnly )) {
1023 QTextStream ts ( &f ); 1025 QTextStream ts ( &f );
1024 ts.readLine(); 1026 ts.readLine();
1025 d-> m_sysverstr = ts. readLine ( ); 1027 d-> m_sysverstr = ts. readLine ( );
1026 f. close ( ); 1028 f. close ( );
1027 } 1029 }
1028} 1030}
1029 1031
1030void Yopy::initButtons ( ) 1032void Yopy::initButtons ( )
1031{ 1033{
1032 if ( d-> m_buttons ) 1034 if ( d-> m_buttons )
1033 return; 1035 return;
1034 1036
1035 d-> m_buttons = new QValueList <ODeviceButton>; 1037 d-> m_buttons = new QValueList <ODeviceButton>;
1036 1038
1037 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1039 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1038 1040
1039 yopy_button *ib = yopy_buttons + i; 1041 yopy_button *ib = yopy_buttons + i;
1040 1042
1041 ODeviceButton b; 1043 ODeviceButton b;
1042 1044
1043 b. setKeycode ( ib-> code ); 1045 b. setKeycode ( ib-> code );
1044 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1046 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1045 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1047 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1046 b. setFactoryPresetPressedAction 1048 b. setFactoryPresetPressedAction
1047 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1049 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1048 b. setFactoryPresetHeldAction 1050 b. setFactoryPresetHeldAction
1049 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1051 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1050 1052
1051 d-> m_buttons-> append ( b ); 1053 d-> m_buttons-> append ( b );
1052 } 1054 }
1053 reloadButtonMapping ( ); 1055 reloadButtonMapping ( );
1054 1056
1055 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1057 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1056 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1058 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1057 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1059 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1058} 1060}
1059 1061
1060bool Yopy::suspend() 1062bool Yopy::suspend()
1061{ 1063{
1062 /* Opie for Yopy does not implement its own power management at the 1064 /* 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 1065 moment. The public version runs parallel to X, and relies on the
1064 existing power management features. */ 1066 existing power management features. */
1065 return false; 1067 return false;
1066} 1068}
1067 1069
1068bool Yopy::setDisplayBrightness(int bright) 1070bool Yopy::setDisplayBrightness(int bright)
1069{ 1071{
1070 /* The code here works, but is disabled as the current version runs 1072 /* The code here works, but is disabled as the current version runs
1071 parallel to X, and relies on the existing backlight demon. */ 1073 parallel to X, and relies on the existing backlight demon. */
1072#if 0 1074#if 0
1073 if ( QFile::exists("/proc/sys/pm/light") ) { 1075 if ( QFile::exists("/proc/sys/pm/light") ) {
1074 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1076 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1075 if (fd >= 0 ) { 1077 if (fd >= 0 ) {
1076 if (bright) 1078 if (bright)
1077 ::write(fd, "1\n", 2); 1079 ::write(fd, "1\n", 2);
1078 else 1080 else
1079 ::write(fd, "0\n", 2); 1081 ::write(fd, "0\n", 2);
1080 ::close(fd); 1082 ::close(fd);
1081 return true; 1083 return true;
1082 } 1084 }
1083 } 1085 }
1084#endif 1086#endif
1085 return false; 1087 return false;
1086} 1088}
1087 1089
1088int Yopy::displayBrightnessResolution() const 1090int Yopy::displayBrightnessResolution() const
1089{ 1091{
1090 return 2; 1092 return 2;
1091} 1093}
1092 1094
1093/************************************************** 1095/**************************************************
1094 * 1096 *
1095 * iPAQ 1097 * iPAQ
1096 * 1098 *
1097 **************************************************/ 1099 **************************************************/
1098 1100
1099void iPAQ::init ( ) 1101void iPAQ::init ( )
1100{ 1102{
1101 d-> m_vendorstr = "HP"; 1103 d-> m_vendorstr = "HP";
1102 d-> m_vendor = Vendor_HP; 1104 d-> m_vendor = Vendor_HP;
1103 1105
1104 QFile f ( "/proc/hal/model" ); 1106 QFile f ( "/proc/hal/model" );
1105 1107
1106 if ( f. open ( IO_ReadOnly )) { 1108 if ( f. open ( IO_ReadOnly )) {
1107 QTextStream ts ( &f ); 1109 QTextStream ts ( &f );
1108 1110
1109 d-> m_modelstr = "H" + ts. readLine ( ); 1111 d-> m_modelstr = "H" + ts. readLine ( );
1110 1112
1111 if ( d-> m_modelstr == "H3100" ) 1113 if ( d-> m_modelstr == "H3100" )
1112 d-> m_model = Model_iPAQ_H31xx; 1114 d-> m_model = Model_iPAQ_H31xx;
1113 else if ( d-> m_modelstr == "H3600" ) 1115 else if ( d-> m_modelstr == "H3600" )
1114 d-> m_model = Model_iPAQ_H36xx; 1116 d-> m_model = Model_iPAQ_H36xx;
1115 else if ( d-> m_modelstr == "H3700" ) 1117 else if ( d-> m_modelstr == "H3700" )
1116 d-> m_model = Model_iPAQ_H37xx; 1118 d-> m_model = Model_iPAQ_H37xx;
1117 else if ( d-> m_modelstr == "H3800" ) 1119 else if ( d-> m_modelstr == "H3800" )
1118 d-> m_model = Model_iPAQ_H38xx; 1120 d-> m_model = Model_iPAQ_H38xx;
1119 else if ( d-> m_modelstr == "H3900" ) 1121 else if ( d-> m_modelstr == "H3900" )
1120 d-> m_model = Model_iPAQ_H39xx; 1122 d-> m_model = Model_iPAQ_H39xx;
1121 else if ( d-> m_modelstr == "H5400" ) 1123 else if ( d-> m_modelstr == "H5400" )
1122 d-> m_model = Model_iPAQ_H5xxx; 1124 d-> m_model = Model_iPAQ_H5xxx;
1123 else 1125 else
1124 d-> m_model = Model_Unknown; 1126 d-> m_model = Model_Unknown;
1125 1127
1126 f. close ( ); 1128 f. close ( );
1127 } 1129 }
1128 1130
1129 switch ( d-> m_model ) { 1131 switch ( d-> m_model ) {
1130 case Model_iPAQ_H31xx: 1132 case Model_iPAQ_H31xx:
1131 case Model_iPAQ_H38xx: 1133 case Model_iPAQ_H38xx:
1132 d-> m_rotation = Rot90; 1134 d-> m_rotation = Rot90;
1133 break; 1135 break;
1134 case Model_iPAQ_H36xx: 1136 case Model_iPAQ_H36xx:
1135 case Model_iPAQ_H37xx: 1137 case Model_iPAQ_H37xx:
1136 case Model_iPAQ_H39xx: 1138 case Model_iPAQ_H39xx:
1137 default: 1139 default:
1138 d-> m_rotation = Rot270; 1140 d-> m_rotation = Rot270;
1139 break; 1141 break;
1140 case Model_iPAQ_H5xxx: 1142 case Model_iPAQ_H5xxx:
1141 d-> m_rotation = Rot0; 1143 d-> m_rotation = Rot0;
1142 } 1144 }
1143 1145
1144 f. setName ( "/etc/familiar-version" ); 1146 f. setName ( "/etc/familiar-version" );
1145 if ( f. open ( IO_ReadOnly )) { 1147 if ( f. open ( IO_ReadOnly )) {
1146 d-> m_systemstr = "Familiar"; 1148 d-> m_systemstr = "Familiar";
1147 d-> m_system = System_Familiar; 1149 d-> m_system = System_Familiar;
1148 1150
1149 QTextStream ts ( &f ); 1151 QTextStream ts ( &f );
1150 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1152 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1151 1153
1152 f. close ( ); 1154 f. close ( );
1153 } else { 1155 } else {
1154 f. setName ( "/etc/oz_version" ); 1156 f. setName ( "/etc/oz_version" );
1155 1157
1156 if ( f. open ( IO_ReadOnly )) { 1158 if ( f. open ( IO_ReadOnly )) {
1157 d-> m_systemstr = "OpenEmbedded/iPaq"; 1159 d-> m_systemstr = "OpenEmbedded/iPaq";
1158 d-> m_system = System_Familiar; 1160 d-> m_system = System_Familiar;
1159 1161
1160 QTextStream ts ( &f ); 1162 QTextStream ts ( &f );
1161 ts.setDevice ( &f ); 1163 ts.setDevice ( &f );
1162 d-> m_sysverstr = ts. readLine ( ); 1164 d-> m_sysverstr = ts. readLine ( );
1163 f. close ( ); 1165 f. close ( );
1164 } 1166 }
1165 } 1167 }
1166 1168
1167 1169
1168 1170
1169 1171
1170 1172
1171 m_leds [0] = m_leds [1] = Led_Off; 1173 m_leds [0] = m_leds [1] = Led_Off;
1172 1174
1173 m_power_timer = 0; 1175 m_power_timer = 0;
1174 1176
1175} 1177}
1176 1178
1177void iPAQ::initButtons ( ) 1179void iPAQ::initButtons ( )
1178{ 1180{
1179 if ( d-> m_buttons ) 1181 if ( d-> m_buttons )
1180 return; 1182 return;
1181 1183
1182 if ( isQWS( ) ) 1184 if ( isQWS( ) )
1183 QWSServer::setKeyboardFilter ( this ); 1185 QWSServer::setKeyboardFilter ( this );
1184 1186
1185 d-> m_buttons = new QValueList <ODeviceButton>; 1187 d-> m_buttons = new QValueList <ODeviceButton>;
1186 1188
1187 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1189 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1188 i_button *ib = ipaq_buttons + i; 1190 i_button *ib = ipaq_buttons + i;
1189 ODeviceButton b; 1191 ODeviceButton b;
1190 1192
1191 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1193 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1192 b. setKeycode ( ib-> code ); 1194 b. setKeycode ( ib-> code );
1193 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1195 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1194 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1196 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1195 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1197 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1196 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1198 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1197 1199
1198 d-> m_buttons-> append ( b ); 1200 d-> m_buttons-> append ( b );
1199 } 1201 }
1200 } 1202 }
1201 reloadButtonMapping ( ); 1203 reloadButtonMapping ( );
1202 1204
1203 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1205 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1204 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1206 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1205} 1207}
1206 1208
1207 1209
1208//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1210//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1209 1211
1210typedef struct { 1212typedef struct {
1211 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1213 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1212 unsigned char TotalTime; /* Units of 5 seconds */ 1214 unsigned char TotalTime; /* Units of 5 seconds */
1213 unsigned char OnTime; /* units of 100m/s */ 1215 unsigned char OnTime; /* units of 100m/s */
1214 unsigned char OffTime; /* units of 100m/s */ 1216 unsigned char OffTime; /* units of 100m/s */
1215} LED_IN; 1217} LED_IN;
1216 1218
1217typedef struct { 1219typedef struct {
1218 unsigned char mode; 1220 unsigned char mode;
1219 unsigned char pwr; 1221 unsigned char pwr;
1220 unsigned char brightness; 1222 unsigned char brightness;
1221} FLITE_IN; 1223} FLITE_IN;
1222 1224
1223#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1225#define LED_ON OD_IOW( 'f', 5, LED_IN )
1224#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1226#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1225 1227
1226 1228
1227QValueList <OLed> iPAQ::ledList ( ) const 1229QValueList <OLed> iPAQ::ledList ( ) const
1228{ 1230{
1229 QValueList <OLed> vl; 1231 QValueList <OLed> vl;
1230 vl << Led_Power; 1232 vl << Led_Power;
1231 1233
1232 if ( d-> m_model == Model_iPAQ_H38xx ) 1234 if ( d-> m_model == Model_iPAQ_H38xx )
1233 vl << Led_BlueTooth; 1235 vl << Led_BlueTooth;
1234 return vl; 1236 return vl;
1235} 1237}
1236 1238
1237QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1239QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1238{ 1240{
1239 QValueList <OLedState> vl; 1241 QValueList <OLedState> vl;
1240 1242
1241 if ( l == Led_Power ) 1243 if ( l == Led_Power )
1242 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1244 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1243 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1245 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1244 vl << Led_Off; // << Led_On << ??? 1246 vl << Led_Off; // << Led_On << ???
1245 1247
1246 return vl; 1248 return vl;
1247} 1249}
1248 1250
1249OLedState iPAQ::ledState ( OLed l ) const 1251OLedState iPAQ::ledState ( OLed l ) const
1250{ 1252{
1251 switch ( l ) { 1253 switch ( l ) {
1252 case Led_Power: 1254 case Led_Power:
1253 return m_leds [0]; 1255 return m_leds [0];
1254 case Led_BlueTooth: 1256 case Led_BlueTooth:
1255 return m_leds [1]; 1257 return m_leds [1];
1256 default: 1258 default:
1257 return Led_Off; 1259 return Led_Off;
1258 } 1260 }
1259} 1261}
1260 1262
1261bool iPAQ::setLedState ( OLed l, OLedState st ) 1263bool iPAQ::setLedState ( OLed l, OLedState st )
1262{ 1264{
1263 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1265 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1264 1266
1265 if ( l == Led_Power ) { 1267 if ( l == Led_Power ) {
1266 if ( fd >= 0 ) { 1268 if ( fd >= 0 ) {
1267 LED_IN leds; 1269 LED_IN leds;
1268 ::memset ( &leds, 0, sizeof( leds )); 1270 ::memset ( &leds, 0, sizeof( leds ));
1269 leds. TotalTime = 0; 1271 leds. TotalTime = 0;
1270 leds. OnTime = 0; 1272 leds. OnTime = 0;
1271 leds. OffTime = 1; 1273 leds. OffTime = 1;
1272 leds. OffOnBlink = 2; 1274 leds. OffOnBlink = 2;
1273 1275
1274 switch ( st ) { 1276 switch ( st ) {
1275 case Led_Off : leds. OffOnBlink = 0; break; 1277 case Led_Off : leds. OffOnBlink = 0; break;
1276 case Led_On : leds. OffOnBlink = 1; break; 1278 case Led_On : leds. OffOnBlink = 1; break;
1277 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1279 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1278 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1280 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1279 } 1281 }
1280 1282
1281 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1283 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1282 m_leds [0] = st; 1284 m_leds [0] = st;
1283 return true; 1285 return true;
1284 } 1286 }
1285 } 1287 }
1286 } 1288 }
1287 return false; 1289 return false;
1288} 1290}
1289 1291
1290 1292
1291bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1293bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1292{ 1294{
1293 int newkeycode = keycode; 1295 int newkeycode = keycode;
1294 1296
1295 switch ( keycode ) { 1297 switch ( keycode ) {
1296 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1298 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1297 case HardKey_Menu: { 1299 case HardKey_Menu: {
1298 if (( d-> m_model == Model_iPAQ_H38xx ) || 1300 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1299 ( d-> m_model == Model_iPAQ_H39xx ) || 1301 ( d-> m_model == Model_iPAQ_H39xx ) ||
1300 ( d-> m_model == Model_iPAQ_H5xxx)) { 1302 ( d-> m_model == Model_iPAQ_H5xxx)) {
1301 newkeycode = HardKey_Mail; 1303 newkeycode = HardKey_Mail;
1302 } 1304 }
1303 break; 1305 break;
1304 } 1306 }
1305 1307
1306 // Rotate cursor keys 180° 1308 // Rotate cursor keys 180°
1307 case Key_Left : 1309 case Key_Left :
1308 case Key_Right: 1310 case Key_Right:
1309 case Key_Up : 1311 case Key_Up :
1310 case Key_Down : { 1312 case Key_Down : {
1311 if (( d-> m_model == Model_iPAQ_H31xx ) || 1313 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1312 ( d-> m_model == Model_iPAQ_H38xx )) { 1314 ( d-> m_model == Model_iPAQ_H38xx )) {
1313 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1315 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1314 } 1316 }
1315 break; 1317 break;
1316 } 1318 }
1317 1319
1318 // map Power Button short/long press to F34/F35 1320 // map Power Button short/long press to F34/F35
1319 case Key_SysReq: { 1321 case Key_SysReq: {
1320 if ( isPress ) { 1322 if ( isPress ) {
1321 if ( m_power_timer ) 1323 if ( m_power_timer )
1322 killTimer ( m_power_timer ); 1324 killTimer ( m_power_timer );
1323 m_power_timer = startTimer ( 500 ); 1325 m_power_timer = startTimer ( 500 );
1324 } 1326 }
1325 else if ( m_power_timer ) { 1327 else if ( m_power_timer ) {
1326 killTimer ( m_power_timer ); 1328 killTimer ( m_power_timer );
1327 m_power_timer = 0; 1329 m_power_timer = 0;
1328 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1329 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1331 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1330 } 1332 }
1331 newkeycode = Key_unknown; 1333 newkeycode = Key_unknown;
1332 break; 1334 break;
1333 } 1335 }
1334 } 1336 }
1335 1337
1336 if ( newkeycode != keycode ) { 1338 if ( newkeycode != keycode ) {
1337 if ( newkeycode != Key_unknown ) 1339 if ( newkeycode != Key_unknown )
1338 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1340 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1339 return true; 1341 return true;
1340 } 1342 }
1341 else 1343 else
1342 return false; 1344 return false;
1343} 1345}
1344 1346
1345void iPAQ::timerEvent ( QTimerEvent * ) 1347void iPAQ::timerEvent ( QTimerEvent * )
1346{ 1348{
1347 killTimer ( m_power_timer ); 1349 killTimer ( m_power_timer );
1348 m_power_timer = 0; 1350 m_power_timer = 0;
1349 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1350 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1352 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1351} 1353}
1352 1354
1353 1355
1354void iPAQ::alarmSound ( ) 1356void iPAQ::alarmSound ( )
1355{ 1357{
1356#ifndef QT_NO_SOUND 1358#ifndef QT_NO_SOUND
1357 static Sound snd ( "alarm" ); 1359 static Sound snd ( "alarm" );
1358 int fd; 1360 int fd;
1359 int vol; 1361 int vol;
1360 bool vol_reset = false; 1362 bool vol_reset = false;
1361 1363
1362 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1363 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1364 Config cfg ( "qpe" ); 1366 Config cfg ( "qpe" );
1365 cfg. setGroup ( "Volume" ); 1367 cfg. setGroup ( "Volume" );
1366 1368
1367 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1368 if ( volalarm < 0 ) 1370 if ( volalarm < 0 )
1369 volalarm = 0; 1371 volalarm = 0;
1370 else if ( volalarm > 100 ) 1372 else if ( volalarm > 100 )
1371 volalarm = 100; 1373 volalarm = 100;
1372 volalarm |= ( volalarm << 8 ); 1374 volalarm |= ( volalarm << 8 );
1373 1375
1374 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1375 vol_reset = true; 1377 vol_reset = true;
1376 } 1378 }
1377 } 1379 }
1378 1380
1379 snd. play ( ); 1381 snd. play ( );
1380 while ( !snd. isFinished ( )) 1382 while ( !snd. isFinished ( ))
1381 qApp-> processEvents ( ); 1383 qApp-> processEvents ( );
1382 1384
1383 if ( fd >= 0 ) { 1385 if ( fd >= 0 ) {
1384 if ( vol_reset ) 1386 if ( vol_reset )
1385 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1386 ::close ( fd ); 1388 ::close ( fd );
1387 } 1389 }
1388#endif 1390#endif
1389} 1391}
1390 1392
1391 1393
1392bool iPAQ::setSoftSuspend ( bool soft ) 1394bool iPAQ::setSoftSuspend ( bool soft )
1393{ 1395{
1394 bool res = false; 1396 bool res = false;
1395 int fd; 1397 int fd;
1396 1398
1397 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1399 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1398 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1400 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1399 res = true; 1401 res = true;
1400 else 1402 else
1401 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1403 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1402 1404
1403 ::close ( fd ); 1405 ::close ( fd );
1404 } 1406 }
1405 else 1407 else
1406 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1408 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1407 1409
1408 return res; 1410 return res;
1409} 1411}
1410 1412
1411 1413
1412bool iPAQ::setDisplayBrightness ( int bright ) 1414bool iPAQ::setDisplayBrightness ( int bright )
1413{ 1415{
1414 bool res = false; 1416 bool res = false;
1415 int fd; 1417 int fd;
1416 1418
1417 if ( bright > 255 ) 1419 if ( bright > 255 )
1418 bright = 255; 1420 bright = 255;
1419 if ( bright < 0 ) 1421 if ( bright < 0 )
1420 bright = 0; 1422 bright = 0;
1421 1423
1422 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1424 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1423 FLITE_IN bl; 1425 FLITE_IN bl;
1424 bl. mode = 1; 1426 bl. mode = 1;
1425 bl. pwr = bright ? 1 : 0; 1427 bl. pwr = bright ? 1 : 0;
1426 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1428 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1427 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1429 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1428 ::close ( fd ); 1430 ::close ( fd );
1429 } 1431 }
1430 return res; 1432 return res;
1431} 1433}
1432 1434
1433int iPAQ::displayBrightnessResolution ( ) const 1435int iPAQ::displayBrightnessResolution ( ) const
1434{ 1436{
1435 switch ( model ( )) { 1437 switch ( model ( )) {
1436 case Model_iPAQ_H31xx: 1438 case Model_iPAQ_H31xx:
1437 case Model_iPAQ_H36xx: 1439 case Model_iPAQ_H36xx:
1438 case Model_iPAQ_H37xx: 1440 case Model_iPAQ_H37xx:
1439 return 128; // really 256, but >128 could damage the LCD 1441 return 128; // really 256, but >128 could damage the LCD
1440 1442
1441 case Model_iPAQ_H38xx: 1443 case Model_iPAQ_H38xx:
1442 case Model_iPAQ_H39xx: 1444 case Model_iPAQ_H39xx:
1443 return 64; 1445 return 64;
1444 case Model_iPAQ_H5xxx: 1446 case Model_iPAQ_H5xxx:
1445 return 255; 1447 return 255;
1446 1448
1447 default: 1449 default:
1448 return 2; 1450 return 2;
1449 } 1451 }
1450} 1452}
1451 1453
1452 1454
1453bool iPAQ::hasLightSensor ( ) const 1455bool iPAQ::hasLightSensor ( ) const
1454{ 1456{
1455 return true; 1457 return true;
1456} 1458}
1457 1459
1458int iPAQ::readLightSensor ( ) 1460int iPAQ::readLightSensor ( )
1459{ 1461{
1460 int fd; 1462 int fd;
1461 int val = -1; 1463 int val = -1;
1462 1464
1463 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1465 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1464 char buffer [8]; 1466 char buffer [8];
1465 1467
1466 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1468 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1467 char *endptr; 1469 char *endptr;
1468 1470
1469 buffer [4] = 0; 1471 buffer [4] = 0;
1470 val = ::strtol ( buffer + 2, &endptr, 16 ); 1472 val = ::strtol ( buffer + 2, &endptr, 16 );
1471 1473
1472 if ( *endptr != 0 ) 1474 if ( *endptr != 0 )
1473 val = -1; 1475 val = -1;
1474 } 1476 }
1475 ::close ( fd ); 1477 ::close ( fd );
1476 } 1478 }
1477 1479
1478 return val; 1480 return val;
1479} 1481}
1480 1482
1481int iPAQ::lightSensorResolution ( ) const 1483int iPAQ::lightSensorResolution ( ) const
1482{ 1484{
1483 return 256; 1485 return 256;
1484} 1486}
1485 1487
1486/************************************************** 1488/**************************************************
1487 * 1489 *
1488 * Zaurus 1490 * Zaurus
1489 * 1491 *
1490 **************************************************/ 1492 **************************************************/
1491 1493
1492// Check whether this device is the sharp zaurus.. 1494// Check whether this device is the sharp zaurus..
1493bool Zaurus::isZaurus() 1495bool Zaurus::isZaurus()
1494{ 1496{
1495 1497
1496 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1498 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1497 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1499 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1498 return true; 1500 return true;
1499 } 1501 }
1500 1502
1501 // On non-embedix kenrnels, we have too look closer. 1503 // On non-embedix kenrnels, we have too look closer.
1502 bool is_zaurus = false; 1504 bool is_zaurus = false;
1503 QFile f ( "/proc/cpuinfo" ); 1505 QFile f ( "/proc/cpuinfo" );
1504 if ( f. open ( IO_ReadOnly ) ) { 1506 if ( f. open ( IO_ReadOnly ) ) {
1505 QString model; 1507 QString model;
1506 QFile f ( "/proc/cpuinfo" ); 1508 QFile f ( "/proc/cpuinfo" );
1507 1509
1508 QTextStream ts ( &f ); 1510 QTextStream ts ( &f );
1509 QString line; 1511 QString line;
1510 while( line = ts. readLine ( ) ) { 1512 while( line = ts. readLine ( ) ) {
1511 if ( line. left ( 8 ) == "Hardware" ) 1513 if ( line. left ( 8 ) == "Hardware" )
1512 break; 1514 break;
1513 } 1515 }
1514 int loc = line. find ( ":" ); 1516 int loc = line. find ( ":" );
1515 if ( loc != -1 ) 1517 if ( loc != -1 )
1516 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1518 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1517 1519
1518 if ( model == "Sharp-Collie" 1520 if ( model == "Sharp-Collie"
1519 || model == "Collie" 1521 || model == "Collie"
1520 || model == "SHARP Corgi" 1522 || model == "SHARP Corgi"
1521 || model == "SHARP Shepherd" 1523 || model == "SHARP Shepherd"
1522 || model == "SHARP Poodle" 1524 || model == "SHARP Poodle"
1523 ) 1525 )
1524 is_zaurus = true; 1526 is_zaurus = true;
1525 1527
1526 } 1528 }
1527 return is_zaurus; 1529 return is_zaurus;
1528} 1530}
1529 1531
1530 1532
1531void Zaurus::init ( ) 1533void Zaurus::init ( )
1532{ 1534{
1533 d-> m_vendorstr = "Sharp"; 1535 d-> m_vendorstr = "Sharp";
1534 d-> m_vendor = Vendor_Sharp; 1536 d-> m_vendor = Vendor_Sharp;
1535 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1537 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1536 1538
1537 // QFile f ( "/proc/filesystems" ); 1539 // QFile f ( "/proc/filesystems" );
1538 QString model; 1540 QString model;
1539 1541
1540 // It isn't a good idea to check the system configuration to 1542 // It isn't a good idea to check the system configuration to
1541 // detect the distribution ! 1543 // detect the distribution !
1542 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1544 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1543 // because it uses a jffs2 filesystem.. 1545 // because it uses a jffs2 filesystem..
1544 // (eilers) 1546 // (eilers)
1545 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1547 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1546 QFile f ("/etc/oz_version"); 1548 QFile f ("/etc/oz_version");
1547 if ( f.exists() ){ 1549 if ( f.exists() ){
1548 d-> m_vendorstr = "OpenZaurus Team"; 1550 d-> m_vendorstr = "OpenZaurus Team";
1549 d-> m_systemstr = "OpenZaurus"; 1551 d-> m_systemstr = "OpenZaurus";
1550 d-> m_system = System_OpenZaurus; 1552 d-> m_system = System_OpenZaurus;
1551 1553
1552 if ( f. open ( IO_ReadOnly )) { 1554 if ( f. open ( IO_ReadOnly )) {
1553 QTextStream ts ( &f ); 1555 QTextStream ts ( &f );
1554 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1556 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1555 f. close ( ); 1557 f. close ( );
1556 } 1558 }
1557 1559
1558 // Openzaurus sometimes uses the embedix kernel! 1560 // Openzaurus sometimes uses the embedix kernel!
1559 // => Check whether this is an embedix kernel 1561 // => Check whether this is an embedix kernel
1560 FILE *uname = popen("uname -r", "r"); 1562 FILE *uname = popen("uname -r", "r");
1561 QString line; 1563 QString line;
1562 if ( f.open(IO_ReadOnly, uname) ) { 1564 if ( f.open(IO_ReadOnly, uname) ) {