summaryrefslogtreecommitdiff
authorchicken <chicken>2003-10-22 19:22:35 (UTC)
committer chicken <chicken>2003-10-22 19:22:35 (UTC)
commita61c014e1fb43e36aa7454ce4b3cb9a7a706c6fa (patch) (unidiff)
treeea7707de2b221b08ca274ff69555323568118c04
parent3e9d8077999bd928b7103bd19f7b41f305c573d9 (diff)
downloadopie-a61c014e1fb43e36aa7454ce4b3cb9a7a706c6fa.zip
opie-a61c014e1fb43e36aa7454ce4b3cb9a7a706c6fa.tar.gz
opie-a61c014e1fb43e36aa7454ce4b3cb9a7a706c6fa.tar.bz2
improved Jornada 56X support
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp128
-rw-r--r--libopie/odevice.h3
2 files changed, 130 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index aadd0bf..8624016 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1370 +1,1384 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
41 41
42#ifndef ARRAY_SIZE 42#ifndef ARRAY_SIZE
43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44#endif 44#endif
45 45
46// _IO and friends are only defined in kernel headers ... 46// _IO and friends are only defined in kernel headers ...
47 47
48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
49 49
50#define OD_IO(type,number) OD_IOC(0,type,number,0) 50#define OD_IO(type,number) OD_IOC(0,type,number,0)
51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
54 54
55using namespace Opie; 55using namespace Opie;
56 56
57class ODeviceData { 57class ODeviceData {
58public: 58public:
59 QString m_vendorstr; 59 QString m_vendorstr;
60 OVendor m_vendor; 60 OVendor m_vendor;
61 61
62 QString m_modelstr; 62 QString m_modelstr;
63 OModel m_model; 63 OModel m_model;
64 64
65 QString m_systemstr; 65 QString m_systemstr;
66 OSystem m_system; 66 OSystem m_system;
67 67
68 QString m_sysverstr; 68 QString m_sysverstr;
69 69
70 Transformation m_rotation; 70 Transformation m_rotation;
71 ODirection m_direction; 71 ODirection m_direction;
72 72
73 QValueList <ODeviceButton> *m_buttons; 73 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 74 uint m_holdtime;
75 QStrList *m_cpu_frequencies; 75 QStrList *m_cpu_frequencies;
76}; 76};
77 77
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 79protected:
80 virtual void init ( ); 80 virtual void init ( );
81 virtual void initButtons ( ); 81 virtual void initButtons ( );
82 82
83public: 83public:
84 virtual bool setSoftSuspend ( bool soft ); 84 virtual bool setSoftSuspend ( bool soft );
85 85
86 virtual bool setDisplayBrightness ( int b ); 86 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 87 virtual int displayBrightnessResolution ( ) const;
88 88
89 virtual void alarmSound ( ); 89 virtual void alarmSound ( );
90 90
91 virtual QValueList <OLed> ledList ( ) const; 91 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 92 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 93 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
95 95
96 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
99 99
100protected: 100protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
103 103
104 int m_power_timer; 104 int m_power_timer;
105 105
106 OLedState m_leds [2]; 106 OLedState m_leds [2];
107}; 107};
108 108
109class Jornada : public ODevice {
110protected:
111 virtual void init ( );
112 virtual void initButtons ( );
113public:
114 virtual bool setSoftSuspend ( bool soft );
115 virtual bool setDisplayBrightness ( int b );
116 virtual int displayBrightnessResolution ( ) const;
117 static bool isJornada();
118
119};
120
109class Zaurus : public ODevice { 121class Zaurus : public ODevice {
110protected: 122protected:
111 virtual void init ( ); 123 virtual void init ( );
112 virtual void initButtons ( ); 124 virtual void initButtons ( );
113 125
114public: 126public:
115 virtual bool setSoftSuspend ( bool soft ); 127 virtual bool setSoftSuspend ( bool soft );
116 128
117 virtual bool setDisplayBrightness ( int b ); 129 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 130 virtual int displayBrightnessResolution ( ) const;
119 131
120 virtual void alarmSound ( ); 132 virtual void alarmSound ( );
121 virtual void keySound ( ); 133 virtual void keySound ( );
122 virtual void touchSound ( ); 134 virtual void touchSound ( );
123 135
124 virtual QValueList <OLed> ledList ( ) const; 136 virtual QValueList <OLed> ledList ( ) const;
125 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 137 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
126 virtual OLedState ledState ( OLed led ) const; 138 virtual OLedState ledState ( OLed led ) const;
127 virtual bool setLedState ( OLed led, OLedState st ); 139 virtual bool setLedState ( OLed led, OLedState st );
128 140
129 static bool isZaurus(); 141 static bool isZaurus();
130 142
131protected: 143protected:
132 virtual void buzzer ( int snd ); 144 virtual void buzzer ( int snd );
133 145
134 OLedState m_leds [1]; 146 OLedState m_leds [1];
135 bool m_embedix; 147 bool m_embedix;
136}; 148};
137 149
138class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 150class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
139protected: 151protected:
140 virtual void init ( ); 152 virtual void init ( );
141 virtual void initButtons ( ); 153 virtual void initButtons ( );
142 154
143public: 155public:
144 virtual bool setSoftSuspend ( bool soft ); 156 virtual bool setSoftSuspend ( bool soft );
145 virtual bool suspend(); 157 virtual bool suspend();
146 158
147 virtual bool setDisplayStatus( bool on ); 159 virtual bool setDisplayStatus( bool on );
148 virtual bool setDisplayBrightness ( int b ); 160 virtual bool setDisplayBrightness ( int b );
149 virtual int displayBrightnessResolution ( ) const; 161 virtual int displayBrightnessResolution ( ) const;
150 162
151 virtual void alarmSound ( ); 163 virtual void alarmSound ( );
152 164
153 virtual QValueList <OLed> ledList ( ) const; 165 virtual QValueList <OLed> ledList ( ) const;
154 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 166 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
155 virtual OLedState ledState ( OLed led ) const; 167 virtual OLedState ledState ( OLed led ) const;
156 virtual bool setLedState ( OLed led, OLedState st ); 168 virtual bool setLedState ( OLed led, OLedState st );
157 169
158protected: 170protected:
159 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 171 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
160 virtual void timerEvent ( QTimerEvent *te ); 172 virtual void timerEvent ( QTimerEvent *te );
161 173
162 int m_power_timer; 174 int m_power_timer;
163 175
164 OLedState m_leds [1]; //FIXME check if really only one 176 OLedState m_leds [1]; //FIXME check if really only one
165}; 177};
166 178
167class Ramses : public ODevice, public QWSServer::KeyboardFilter { 179class Ramses : public ODevice, public QWSServer::KeyboardFilter {
168protected: 180protected:
169 virtual void init ( ); 181 virtual void init ( );
170 182
171public: 183public:
172 virtual bool setSoftSuspend ( bool soft ); 184 virtual bool setSoftSuspend ( bool soft );
173 virtual bool suspend ( ); 185 virtual bool suspend ( );
174 186
175 virtual bool setDisplayStatus( bool on ); 187 virtual bool setDisplayStatus( bool on );
176 virtual bool setDisplayBrightness ( int b ); 188 virtual bool setDisplayBrightness ( int b );
177 virtual int displayBrightnessResolution ( ) const; 189 virtual int displayBrightnessResolution ( ) const;
178 virtual bool setDisplayContrast ( int b ); 190 virtual bool setDisplayContrast ( int b );
179 virtual int displayContrastResolution ( ) const; 191 virtual int displayContrastResolution ( ) const;
180 192
181protected: 193protected:
182 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 194 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
183 virtual void timerEvent ( QTimerEvent *te ); 195 virtual void timerEvent ( QTimerEvent *te );
184 196
185 int m_power_timer; 197 int m_power_timer;
186}; 198};
187 199
188struct i_button { 200struct i_button {
189 uint model; 201 uint model;
190 Qt::Key code; 202 Qt::Key code;
191 char *utext; 203 char *utext;
192 char *pix; 204 char *pix;
193 char *fpressedservice; 205 char *fpressedservice;
194 char *fpressedaction; 206 char *fpressedaction;
195 char *fheldservice; 207 char *fheldservice;
196 char *fheldaction; 208 char *fheldaction;
197} ipaq_buttons [] = { 209} ipaq_buttons [] = {
198 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 210 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
199 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 211 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
200 "devicebuttons/ipaq_calendar", 212 "devicebuttons/ipaq_calendar",
201 "datebook", "nextView()", 213 "datebook", "nextView()",
202 "today", "raise()" }, 214 "today", "raise()" },
203 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 215 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
204 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 216 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
205 "devicebuttons/ipaq_contact", 217 "devicebuttons/ipaq_contact",
206 "addressbook", "raise()", 218 "addressbook", "raise()",
207 "addressbook", "beamBusinessCard()" }, 219 "addressbook", "beamBusinessCard()" },
208 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
209 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 221 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
210 "devicebuttons/ipaq_menu", 222 "devicebuttons/ipaq_menu",
211 "QPE/TaskBar", "toggleMenu()", 223 "QPE/TaskBar", "toggleMenu()",
212 "QPE/TaskBar", "toggleStartMenu()" }, 224 "QPE/TaskBar", "toggleStartMenu()" },
213 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 225 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
214 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 226 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
215 "devicebuttons/ipaq_mail", 227 "devicebuttons/ipaq_mail",
216 "mail", "raise()", 228 "mail", "raise()",
217 "mail", "newMail()" }, 229 "mail", "newMail()" },
218 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 230 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
219 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 231 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
220 "devicebuttons/ipaq_home", 232 "devicebuttons/ipaq_home",
221 "QPE/Launcher", "home()", 233 "QPE/Launcher", "home()",
222 "buttonsettings", "raise()" }, 234 "buttonsettings", "raise()" },
223 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 235 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
224 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 236 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
225 "devicebuttons/ipaq_record", 237 "devicebuttons/ipaq_record",
226 "QPE/VMemo", "toggleRecord()", 238 "QPE/VMemo", "toggleRecord()",
227 "sound", "raise()" }, 239 "sound", "raise()" },
228}; 240};
229 241
230struct z_button { 242struct z_button {
231 Qt::Key code; 243 Qt::Key code;
232 char *utext; 244 char *utext;
233 char *pix; 245 char *pix;
234 char *fpressedservice; 246 char *fpressedservice;
235 char *fpressedaction; 247 char *fpressedaction;
236 char *fheldservice; 248 char *fheldservice;
237 char *fheldaction; 249 char *fheldaction;
238} z_buttons [] = { 250} z_buttons [] = {
239 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 251 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
240 "devicebuttons/z_calendar", 252 "devicebuttons/z_calendar",
241 "datebook", "nextView()", 253 "datebook", "nextView()",
242 "today", "raise()" }, 254 "today", "raise()" },
243 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 255 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
244 "devicebuttons/z_contact", 256 "devicebuttons/z_contact",
245 "addressbook", "raise()", 257 "addressbook", "raise()",
246 "addressbook", "beamBusinessCard()" }, 258 "addressbook", "beamBusinessCard()" },
247 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 259 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
248 "devicebuttons/z_home", 260 "devicebuttons/z_home",
249 "QPE/Launcher", "home()", 261 "QPE/Launcher", "home()",
250 "buttonsettings", "raise()" }, 262 "buttonsettings", "raise()" },
251 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 263 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
252 "devicebuttons/z_menu", 264 "devicebuttons/z_menu",
253 "QPE/TaskBar", "toggleMenu()", 265 "QPE/TaskBar", "toggleMenu()",
254 "QPE/TaskBar", "toggleStartMenu()" }, 266 "QPE/TaskBar", "toggleStartMenu()" },
255 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 267 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
256 "devicebuttons/z_mail", 268 "devicebuttons/z_mail",
257 "mail", "raise()", 269 "mail", "raise()",
258 "mail", "newMail()" }, 270 "mail", "newMail()" },
259}; 271};
260 272
261struct z_button z_buttons_c700 [] = { 273struct z_button z_buttons_c700 [] = {
262 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 274 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
263 "devicebuttons/z_calendar", 275 "devicebuttons/z_calendar",
264 "datebook", "nextView()", 276 "datebook", "nextView()",
265 "today", "raise()" }, 277 "today", "raise()" },
266 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 278 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
267 "devicebuttons/z_contact", 279 "devicebuttons/z_contact",
268 "addressbook", "raise()", 280 "addressbook", "raise()",
269 "addressbook", "beamBusinessCard()" }, 281 "addressbook", "beamBusinessCard()" },
270 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 282 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
271 "devicebuttons/z_home", 283 "devicebuttons/z_home",
272 "QPE/Launcher", "home()", 284 "QPE/Launcher", "home()",
273 "buttonsettings", "raise()" }, 285 "buttonsettings", "raise()" },
274 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 286 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
275 "devicebuttons/z_menu", 287 "devicebuttons/z_menu",
276 "QPE/TaskBar", "toggleMenu()", 288 "QPE/TaskBar", "toggleMenu()",
277 "QPE/TaskBar", "toggleStartMenu()" }, 289 "QPE/TaskBar", "toggleStartMenu()" },
278 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 290 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
279 "", 291 "",
280 "QPE/Rotation", "flip()", 292 "QPE/Rotation", "flip()",
281 "QPE/Rotation", "flip()" }, 293 "QPE/Rotation", "flip()" },
282}; 294};
283 295
284struct s_button { 296struct s_button {
285 uint model; 297 uint model;
286 Qt::Key code; 298 Qt::Key code;
287 char *utext; 299 char *utext;
288 char *pix; 300 char *pix;
289 char *fpressedservice; 301 char *fpressedservice;
290 char *fpressedaction; 302 char *fpressedaction;
291 char *fheldservice; 303 char *fheldservice;
292 char *fheldaction; 304 char *fheldaction;
293} simpad_buttons [] = { 305} simpad_buttons [] = {
294 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 306 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
295 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 307 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
296 "devicebuttons/simpad_lower_up", 308 "devicebuttons/simpad_lower_up",
297 "datebook", "nextView()", 309 "datebook", "nextView()",
298 "today", "raise()" }, 310 "today", "raise()" },
299 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 311 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
300 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 312 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
301 "devicebuttons/simpad_lower_down", 313 "devicebuttons/simpad_lower_down",
302 "addressbook", "raise()", 314 "addressbook", "raise()",
303 "addressbook", "beamBusinessCard()" }, 315 "addressbook", "beamBusinessCard()" },
304 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
305 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 317 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
306 "devicebuttons/simpad_lower_right", 318 "devicebuttons/simpad_lower_right",
307 "QPE/TaskBar", "toggleMenu()", 319 "QPE/TaskBar", "toggleMenu()",
308 "QPE/TaskBar", "toggleStartMenu()" }, 320 "QPE/TaskBar", "toggleStartMenu()" },
309 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 321 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
310 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 322 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
311 "devicebuttons/simpad_lower_left", 323 "devicebuttons/simpad_lower_left",
312 "mail", "raise()", 324 "mail", "raise()",
313 "mail", "newMail()" }, 325 "mail", "newMail()" },
314 326
315 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
316 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 328 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
317 "devicebuttons/simpad_upper_up", 329 "devicebuttons/simpad_upper_up",
318 "QPE/Launcher", "home()", 330 "QPE/Launcher", "home()",
319 "buttonsettings", "raise()" }, 331 "buttonsettings", "raise()" },
320 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 332 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
321 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 333 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
322 "devicebuttons/simpad_upper_down", 334 "devicebuttons/simpad_upper_down",
323 "addressbook", "raise()", 335 "addressbook", "raise()",
324 "addressbook", "beamBusinessCard()" }, 336 "addressbook", "beamBusinessCard()" },
325 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 337 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
326 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 338 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
327 "devicebuttons/simpad_upper_right", 339 "devicebuttons/simpad_upper_right",
328 "QPE/TaskBar", "toggleMenu()", 340 "QPE/TaskBar", "toggleMenu()",
329 "QPE/TaskBar", "toggleStartMenu()" }, 341 "QPE/TaskBar", "toggleStartMenu()" },
330 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 342 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
331 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 343 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
332 "devicebuttons/simpad_upper_left", 344 "devicebuttons/simpad_upper_left",
333 "QPE/Rotation", "flip()", 345 "QPE/Rotation", "flip()",
334 "QPE/Rotation", "flip()" }, 346 "QPE/Rotation", "flip()" },
335 /* 347 /*
336 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
337 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 349 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
338 "devicebuttons/simpad_lower_upper", 350 "devicebuttons/simpad_lower_upper",
339 "QPE/Launcher", "home()", 351 "QPE/Launcher", "home()",
340 "buttonsettings", "raise()" }, 352 "buttonsettings", "raise()" },
341 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
342 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 354 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
343 "devicebuttons/simpad_upper_lower", 355 "devicebuttons/simpad_upper_lower",
344 "QPE/Launcher", "home()", 356 "QPE/Launcher", "home()",
345 "buttonsettings", "raise()" }, 357 "buttonsettings", "raise()" },
346 */ 358 */
347}; 359};
348 360
349struct r_button { 361struct r_button {
350 uint model; 362 uint model;
351 Qt::Key code; 363 Qt::Key code;
352 char *utext; 364 char *utext;
353 char *pix; 365 char *pix;
354 char *fpressedservice; 366 char *fpressedservice;
355 char *fpressedaction; 367 char *fpressedaction;
356 char *fheldservice; 368 char *fheldservice;
357 char *fheldaction; 369 char *fheldaction;
358} ramses_buttons [] = { 370} ramses_buttons [] = {
359 { Model_Ramses_MNCI, 371 { Model_Ramses_MNCI,
360 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 372 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
361 "devicebuttons/z_menu", 373 "devicebuttons/z_menu",
362 "QPE/TaskBar", "toggleMenu()", 374 "QPE/TaskBar", "toggleMenu()",
363 "QPE/TaskBar", "toggleStartMenu()" }, 375 "QPE/TaskBar", "toggleStartMenu()" },
364 { Model_Ramses_MNCI, 376 { Model_Ramses_MNCI,
365 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 377 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
366 "devicebuttons/ipaq_home", 378 "devicebuttons/ipaq_home",
367 "QPE/Launcher", "home()", 379 "QPE/Launcher", "home()",
368 "buttonsettings", "raise()" }, 380 "buttonsettings", "raise()" },
369}; 381};
370 382
371class Yopy : public ODevice { 383class Yopy : public ODevice {
372protected: 384protected:
373 virtual void init ( ); 385 virtual void init ( );
374 virtual void initButtons ( ); 386 virtual void initButtons ( );
375 387
376public: 388public:
377 virtual bool suspend ( ); 389 virtual bool suspend ( );
378 390
379 virtual bool setDisplayBrightness ( int b ); 391 virtual bool setDisplayBrightness ( int b );
380 virtual int displayBrightnessResolution ( ) const; 392 virtual int displayBrightnessResolution ( ) const;
381 393
382 static bool isYopy ( ); 394 static bool isYopy ( );
383}; 395};
384 396
385struct yopy_button { 397struct yopy_button {
386 Qt::Key code; 398 Qt::Key code;
387 char *utext; 399 char *utext;
388 char *pix; 400 char *pix;
389 char *fpressedservice; 401 char *fpressedservice;
390 char *fpressedaction; 402 char *fpressedaction;
391 char *fheldservice; 403 char *fheldservice;
392 char *fheldaction; 404 char *fheldaction;
393} yopy_buttons [] = { 405} yopy_buttons [] = {
394 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 406 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
395 "devicebuttons/yopy_action", 407 "devicebuttons/yopy_action",
396 "datebook", "nextView()", 408 "datebook", "nextView()",
397 "today", "raise()" }, 409 "today", "raise()" },
398 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 410 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
399 "devicebuttons/yopy_ok", 411 "devicebuttons/yopy_ok",
400 "addressbook", "raise()", 412 "addressbook", "raise()",
401 "addressbook", "beamBusinessCard()" }, 413 "addressbook", "beamBusinessCard()" },
402 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 414 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
403 "devicebuttons/yopy_end", 415 "devicebuttons/yopy_end",
404 "QPE/Launcher", "home()", 416 "QPE/Launcher", "home()",
405 "buttonsettings", "raise()" }, 417 "buttonsettings", "raise()" },
406}; 418};
407 419
408static QCString makeChannel ( const char *str ) 420static QCString makeChannel ( const char *str )
409{ 421{
410 if ( str && !::strchr ( str, '/' )) 422 if ( str && !::strchr ( str, '/' ))
411 return QCString ( "QPE/Application/" ) + str; 423 return QCString ( "QPE/Application/" ) + str;
412 else 424 else
413 return str; 425 return str;
414} 426}
415 427
416static inline bool isQWS() 428static inline bool isQWS()
417{ 429{
418 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 430 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
419} 431}
420 432
421ODevice *ODevice::inst ( ) 433ODevice *ODevice::inst ( )
422{ 434{
423 static ODevice *dev = 0; 435 static ODevice *dev = 0;
424 436
425 if ( !dev ) { 437 if ( !dev ) {
426 if ( QFile::exists ( "/proc/hal/model" )) 438 if ( QFile::exists ( "/proc/hal/model" ))
427 dev = new iPAQ ( ); 439 dev = new iPAQ ( );
428 else if ( Zaurus::isZaurus() ) 440 else if ( Zaurus::isZaurus() )
429 dev = new Zaurus ( ); 441 dev = new Zaurus ( );
430 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 442 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
431 dev = new SIMpad ( ); 443 dev = new SIMpad ( );
432 else if ( QFile::exists ( "/proc/sys/board/name" )) 444 else if ( QFile::exists ( "/proc/sys/board/name" ))
433 dev = new Ramses ( ); 445 dev = new Ramses ( );
434 else if ( Yopy::isYopy() ) 446 else if ( Yopy::isYopy() )
435 dev = new Yopy ( ); 447 dev = new Yopy ( );
448 else if ( Jornada::isJornada() )
449 dev = new Jornada ( );
436 else 450 else
437 dev = new ODevice ( ); 451 dev = new ODevice ( );
438 dev-> init ( ); 452 dev-> init ( );
439 } 453 }
440 return dev; 454 return dev;
441} 455}
442 456
443 457
444/************************************************** 458/**************************************************
445 * 459 *
446 * common 460 * common
447 * 461 *
448 **************************************************/ 462 **************************************************/
449 463
450 464
451ODevice::ODevice ( ) 465ODevice::ODevice ( )
452{ 466{
453 d = new ODeviceData; 467 d = new ODeviceData;
454 468
455 d-> m_modelstr = "Unknown"; 469 d-> m_modelstr = "Unknown";
456 d-> m_model = Model_Unknown; 470 d-> m_model = Model_Unknown;
457 d-> m_vendorstr = "Unknown"; 471 d-> m_vendorstr = "Unknown";
458 d-> m_vendor = Vendor_Unknown; 472 d-> m_vendor = Vendor_Unknown;
459 d-> m_systemstr = "Unknown"; 473 d-> m_systemstr = "Unknown";
460 d-> m_system = System_Unknown; 474 d-> m_system = System_Unknown;
461 d-> m_sysverstr = "0.0"; 475 d-> m_sysverstr = "0.0";
462 d-> m_rotation = Rot0; 476 d-> m_rotation = Rot0;
463 d-> m_direction = CW; 477 d-> m_direction = CW;
464 478
465 d-> m_holdtime = 1000; // 1000ms 479 d-> m_holdtime = 1000; // 1000ms
466 d-> m_buttons = 0; 480 d-> m_buttons = 0;
467 d-> m_cpu_frequencies = new QStrList; 481 d-> m_cpu_frequencies = new QStrList;
468} 482}
469 483
470void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 484void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
471{ 485{
472 if ( msg == "deviceButtonMappingChanged()" ) { 486 if ( msg == "deviceButtonMappingChanged()" ) {
473 reloadButtonMapping ( ); 487 reloadButtonMapping ( );
474 } 488 }
475} 489}
476 490
477void ODevice::init ( ) 491void ODevice::init ( )
478{ 492{
479} 493}
480 494
481/** 495/**
482 * This method initialises the button mapping 496 * This method initialises the button mapping
483 */ 497 */
484void ODevice::initButtons ( ) 498void ODevice::initButtons ( )
485{ 499{
486 if ( d-> m_buttons ) 500 if ( d-> m_buttons )
487 return; 501 return;
488 502
489 // Simulation uses iPAQ 3660 device buttons 503 // Simulation uses iPAQ 3660 device buttons
490 504
491 qDebug ( "init Buttons" ); 505 qDebug ( "init Buttons" );
492 d-> m_buttons = new QValueList <ODeviceButton>; 506 d-> m_buttons = new QValueList <ODeviceButton>;
493 507
494 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 508 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
495 i_button *ib = ipaq_buttons + i; 509 i_button *ib = ipaq_buttons + i;
496 ODeviceButton b; 510 ODeviceButton b;
497 511
498 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 512 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
499 b. setKeycode ( ib-> code ); 513 b. setKeycode ( ib-> code );
500 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 514 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
501 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 515 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
502 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 516 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
503 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 517 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
504 d-> m_buttons-> append ( b ); 518 d-> m_buttons-> append ( b );
505 } 519 }
506 } 520 }
507 reloadButtonMapping ( ); 521 reloadButtonMapping ( );
508 522
509 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 523 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
510 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 524 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
511} 525}
512 526
513ODevice::~ODevice ( ) 527ODevice::~ODevice ( )
514{ 528{
515// we leak m_devicebuttons and m_cpu_frequency 529// we leak m_devicebuttons and m_cpu_frequency
516// but it's a singleton and it is not so importantant 530// but it's a singleton and it is not so importantant
517// -zecke 531// -zecke
518 delete d; 532 delete d;
519} 533}
520 534
521bool ODevice::setSoftSuspend ( bool /*soft*/ ) 535bool ODevice::setSoftSuspend ( bool /*soft*/ )
522{ 536{
523 return false; 537 return false;
524} 538}
525 539
526//#include <linux/apm_bios.h> 540//#include <linux/apm_bios.h>
527 541
528#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 542#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
529 543
530/** 544/**
531 * This method will try to suspend the device 545 * This method will try to suspend the device
532 * It only works if the user is the QWS Server and the apm application 546 * It only works if the user is the QWS Server and the apm application
533 * is installed. 547 * is installed.
534 * It tries to suspend and then waits some time cause some distributions 548 * It tries to suspend and then waits some time cause some distributions
535 * do have asynchronus apm implementations. 549 * do have asynchronus apm implementations.
536 * This method will either fail and return false or it'll suspend the 550 * This method will either fail and return false or it'll suspend the
537 * device and return once the device got woken up 551 * device and return once the device got woken up
538 * 552 *
539 * @return if the device got suspended 553 * @return if the device got suspended
540 */ 554 */
541bool ODevice::suspend ( ) 555bool ODevice::suspend ( )
542{ 556{
543 qDebug("ODevice::suspend"); 557 qDebug("ODevice::suspend");
544 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 558 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
545 return false; 559 return false;
546 560
547 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 561 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
548 return false; 562 return false;
549 563
550 bool res = false; 564 bool res = false;
551 565
552 struct timeval tvs, tvn; 566 struct timeval tvs, tvn;
553 ::gettimeofday ( &tvs, 0 ); 567 ::gettimeofday ( &tvs, 0 );
554 568
555 ::sync ( ); // flush fs caches 569 ::sync ( ); // flush fs caches
556 res = ( ::system ( "apm --suspend" ) == 0 ); 570 res = ( ::system ( "apm --suspend" ) == 0 );
557 571
558 // This is needed because the iPAQ apm implementation is asynchronous and we 572 // This is needed because the iPAQ apm implementation is asynchronous and we
559 // can not be sure when exactly the device is really suspended 573 // can not be sure when exactly the device is really suspended
560 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 574 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
561 575
562 if ( res ) { 576 if ( res ) {
563 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 577 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
564 ::usleep ( 200 * 1000 ); 578 ::usleep ( 200 * 1000 );
565 ::gettimeofday ( &tvn, 0 ); 579 ::gettimeofday ( &tvn, 0 );
566 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 580 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
567 } 581 }
568 582
569 return res; 583 return res;
570} 584}
571 585
572//#include <linux/fb.h> better not rely on kernel headers in userspace ... 586//#include <linux/fb.h> better not rely on kernel headers in userspace ...
573 587
574#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 588#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
575 589
576/* VESA Blanking Levels */ 590/* VESA Blanking Levels */
577#define VESA_NO_BLANKING 0 591#define VESA_NO_BLANKING 0
578#define VESA_VSYNC_SUSPEND 1 592#define VESA_VSYNC_SUSPEND 1
579#define VESA_HSYNC_SUSPEND 2 593#define VESA_HSYNC_SUSPEND 2
580#define VESA_POWERDOWN 3 594#define VESA_POWERDOWN 3
581 595
582/** 596/**
583 * This sets the display on or off 597 * This sets the display on or off
584 */ 598 */
585bool ODevice::setDisplayStatus ( bool on ) 599bool ODevice::setDisplayStatus ( bool on )
586{ 600{
587 qDebug("ODevice::setDisplayStatus(%d)", on); 601 qDebug("ODevice::setDisplayStatus(%d)", on);
588 602
589 if ( d-> m_model == Model_Unknown ) 603 if ( d-> m_model == Model_Unknown )
590 return false; 604 return false;
591 605
592 bool res = false; 606 bool res = false;
593 int fd; 607 int fd;
594 608
595 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 609 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
596 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 610 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
597 ::close ( fd ); 611 ::close ( fd );
598 } 612 }
599 return res; 613 return res;
600} 614}
601 615
602/** 616/**
603 * This sets the display brightness 617 * This sets the display brightness
604 * 618 *
605 * @param p The brightness to be set on a scale from 0 to 255 619 * @param p The brightness to be set on a scale from 0 to 255
606 * @return success or failure 620 * @return success or failure
607 */ 621 */
608bool ODevice::setDisplayBrightness ( int p) 622bool ODevice::setDisplayBrightness ( int p)
609{ 623{
610 Q_UNUSED( p ) 624 Q_UNUSED( p )
611 return false; 625 return false;
612} 626}
613 627
614/** 628/**
615 * @return returns the number of steppings on the brightness slider 629 * @return returns the number of steppings on the brightness slider
616 * in the Light-'n-Power settings. 630 * in the Light-'n-Power settings.
617 */ 631 */
618int ODevice::displayBrightnessResolution ( ) const 632int ODevice::displayBrightnessResolution ( ) const
619{ 633{
620 return 16; 634 return 16;
621} 635}
622 636
623/** 637/**
624 * This sets the display contrast 638 * This sets the display contrast
625 * @param p The contrast to be set on a scale from 0 to 255 639 * @param p The contrast to be set on a scale from 0 to 255
626 * @return success or failure 640 * @return success or failure
627 */ 641 */
628bool ODevice::setDisplayContrast ( int p) 642bool ODevice::setDisplayContrast ( int p)
629{ 643{
630 Q_UNUSED( p ) 644 Q_UNUSED( p )
631 return false; 645 return false;
632} 646}
633 647
634/** 648/**
635 * @return return the max value for the brightness settings slider 649 * @return return the max value for the brightness settings slider
636 * or 0 if the device doesn't support setting of a contrast 650 * or 0 if the device doesn't support setting of a contrast
637 */ 651 */
638int ODevice::displayContrastResolution ( ) const 652int ODevice::displayContrastResolution ( ) const
639{ 653{
640 return 0; 654 return 0;
641} 655}
642 656
643/** 657/**
644 * This returns the vendor as string 658 * This returns the vendor as string
645 * @return Vendor as QString 659 * @return Vendor as QString
646 */ 660 */
647QString ODevice::vendorString ( ) const 661QString ODevice::vendorString ( ) const
648{ 662{
649 return d-> m_vendorstr; 663 return d-> m_vendorstr;
650} 664}
651 665
652/** 666/**
653 * This returns the vendor as one of the values of OVendor 667 * This returns the vendor as one of the values of OVendor
654 * @return OVendor 668 * @return OVendor
655 */ 669 */
656OVendor ODevice::vendor ( ) const 670OVendor ODevice::vendor ( ) const
657{ 671{
658 return d-> m_vendor; 672 return d-> m_vendor;
659} 673}
660 674
661/** 675/**
662 * This returns the model as a string 676 * This returns the model as a string
663 * @return A string representing the model 677 * @return A string representing the model
664 */ 678 */
665QString ODevice::modelString ( ) const 679QString ODevice::modelString ( ) const
666{ 680{
667 return d-> m_modelstr; 681 return d-> m_modelstr;
668} 682}
669 683
670/** 684/**
671 * This does return the OModel used 685 * This does return the OModel used
672 */ 686 */
673OModel ODevice::model ( ) const 687OModel ODevice::model ( ) const
674{ 688{
675 return d-> m_model; 689 return d-> m_model;
676} 690}
677 691
678/** 692/**
679 * This does return the systen name 693 * This does return the systen name
680 */ 694 */
681QString ODevice::systemString ( ) const 695QString ODevice::systemString ( ) const
682{ 696{
683 return d-> m_systemstr; 697 return d-> m_systemstr;
684} 698}
685 699
686/** 700/**
687 * Return System as OSystem value 701 * Return System as OSystem value
688 */ 702 */
689OSystem ODevice::system ( ) const 703OSystem ODevice::system ( ) const
690{ 704{
691 return d-> m_system; 705 return d-> m_system;
692} 706}
693 707
694/** 708/**
695 * @return the version string of the base system 709 * @return the version string of the base system
696 */ 710 */
697QString ODevice::systemVersionString ( ) const 711QString ODevice::systemVersionString ( ) const
698{ 712{
699 return d-> m_sysverstr; 713 return d-> m_sysverstr;
700} 714}
701 715
702/** 716/**
703 * @return the current Transformation 717 * @return the current Transformation
704 */ 718 */
705Transformation ODevice::rotation ( ) const 719Transformation ODevice::rotation ( ) const
706{ 720{
707 return d-> m_rotation; 721 return d-> m_rotation;
708} 722}
709 723
710/** 724/**
711 * @return the current rotation direction 725 * @return the current rotation direction
712 */ 726 */
713ODirection ODevice::direction ( ) const 727ODirection ODevice::direction ( ) const
714{ 728{
715 return d-> m_direction; 729 return d-> m_direction;
716} 730}
717 731
718/** 732/**
719 * This plays an alarmSound 733 * This plays an alarmSound
720 */ 734 */
721void ODevice::alarmSound ( ) 735void ODevice::alarmSound ( )
722{ 736{
723#ifndef QT_NO_SOUND 737#ifndef QT_NO_SOUND
724 static Sound snd ( "alarm" ); 738 static Sound snd ( "alarm" );
725 739
726 if ( snd. isFinished ( )) 740 if ( snd. isFinished ( ))
727 snd. play ( ); 741 snd. play ( );
728#endif 742#endif
729} 743}
730 744
731/** 745/**
732 * This plays a key sound 746 * This plays a key sound
733 */ 747 */
734void ODevice::keySound ( ) 748void ODevice::keySound ( )
735{ 749{
736#ifndef QT_NO_SOUND 750#ifndef QT_NO_SOUND
737 static Sound snd ( "keysound" ); 751 static Sound snd ( "keysound" );
738 752
739 if ( snd. isFinished ( )) 753 if ( snd. isFinished ( ))
740 snd. play ( ); 754 snd. play ( );
741#endif 755#endif
742} 756}
743 757
744/** 758/**
745 * This plays a touch sound 759 * This plays a touch sound
746 */ 760 */
747void ODevice::touchSound ( ) 761void ODevice::touchSound ( )
748{ 762{
749#ifndef QT_NO_SOUND 763#ifndef QT_NO_SOUND
750 static Sound snd ( "touchsound" ); 764 static Sound snd ( "touchsound" );
751 765
752 if ( snd. isFinished ( )) 766 if ( snd. isFinished ( ))
753 snd. play ( ); 767 snd. play ( );
754#endif 768#endif
755} 769}
756 770
757/** 771/**
758 * This method will return a list of leds 772 * This method will return a list of leds
759 * available on this device 773 * available on this device
760 * @return a list of LEDs. 774 * @return a list of LEDs.
761 */ 775 */
762QValueList <OLed> ODevice::ledList ( ) const 776QValueList <OLed> ODevice::ledList ( ) const
763{ 777{
764 return QValueList <OLed> ( ); 778 return QValueList <OLed> ( );
765} 779}
766 780
767/** 781/**
768 * This does return the state of the LEDs 782 * This does return the state of the LEDs
769 */ 783 */
770QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 784QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
771{ 785{
772 return QValueList <OLedState> ( ); 786 return QValueList <OLedState> ( );
773} 787}
774 788
775/** 789/**
776 * @return the state for a given OLed 790 * @return the state for a given OLed
777 */ 791 */
778OLedState ODevice::ledState ( OLed /*which*/ ) const 792OLedState ODevice::ledState ( OLed /*which*/ ) const
779{ 793{
780 return Led_Off; 794 return Led_Off;
781} 795}
782 796
783/** 797/**
784 * Set the state for a LED 798 * Set the state for a LED
785 * @param which Which OLed to use 799 * @param which Which OLed to use
786 * @param st The state to set 800 * @param st The state to set
787 * @return success or failure 801 * @return success or failure
788 */ 802 */
789bool ODevice::setLedState ( OLed which, OLedState st ) 803bool ODevice::setLedState ( OLed which, OLedState st )
790{ 804{
791 Q_UNUSED( which ) 805 Q_UNUSED( which )
792 Q_UNUSED( st ) 806 Q_UNUSED( st )
793 return false; 807 return false;
794} 808}
795 809
796/** 810/**
797 * @return if the device has a light sensor 811 * @return if the device has a light sensor
798 */ 812 */
799bool ODevice::hasLightSensor ( ) const 813bool ODevice::hasLightSensor ( ) const
800{ 814{
801 return false; 815 return false;
802} 816}
803 817
804/** 818/**
805 * @return a value from the light senso 819 * @return a value from the light senso
806 */ 820 */
807int ODevice::readLightSensor ( ) 821int ODevice::readLightSensor ( )
808{ 822{
809 return -1; 823 return -1;
810} 824}
811 825
812/** 826/**
813 * @return the light sensor resolution whatever that is ;) 827 * @return the light sensor resolution whatever that is ;)
814 */ 828 */
815int ODevice::lightSensorResolution ( ) const 829int ODevice::lightSensorResolution ( ) const
816{ 830{
817 return 0; 831 return 0;
818} 832}
819 833
820/** 834/**
821 * @return a list with CPU frequencies supported by the hardware 835 * @return a list with CPU frequencies supported by the hardware
822 */ 836 */
823const QStrList &ODevice::allowedCpuFrequencies ( ) const 837const QStrList &ODevice::allowedCpuFrequencies ( ) const
824{ 838{
825 return *d->m_cpu_frequencies; 839 return *d->m_cpu_frequencies;
826} 840}
827 841
828 842
829/** 843/**
830 * Set desired CPU frequency 844 * Set desired CPU frequency
831 * 845 *
832 * @param index index into d->m_cpu_frequencies of the frequency to be set 846 * @param index index into d->m_cpu_frequencies of the frequency to be set
833 */ 847 */
834bool ODevice::setCurrentCpuFrequency(uint index) 848bool ODevice::setCurrentCpuFrequency(uint index)
835{ 849{
836 if (index >= d->m_cpu_frequencies->count()) 850 if (index >= d->m_cpu_frequencies->count())
837 return false; 851 return false;
838 852
839 char *freq = d->m_cpu_frequencies->at(index); 853 char *freq = d->m_cpu_frequencies->at(index);
840 qWarning("set freq to %s", freq); 854 qWarning("set freq to %s", freq);
841 855
842 int fd; 856 int fd;
843 857
844 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 858 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
845 char writeCommand[50]; 859 char writeCommand[50];
846 const int count = sprintf(writeCommand, "%s\n", freq); 860 const int count = sprintf(writeCommand, "%s\n", freq);
847 int res = (::write(fd, writeCommand, count) != -1); 861 int res = (::write(fd, writeCommand, count) != -1);
848 ::close(fd); 862 ::close(fd);
849 return res; 863 return res;
850 } 864 }
851 865
852 return false; 866 return false;
853} 867}
854 868
855 869
856/** 870/**
857 * @return a list of hardware buttons 871 * @return a list of hardware buttons
858 */ 872 */
859const QValueList <ODeviceButton> &ODevice::buttons ( ) 873const QValueList <ODeviceButton> &ODevice::buttons ( )
860{ 874{
861 initButtons ( ); 875 initButtons ( );
862 876
863 return *d-> m_buttons; 877 return *d-> m_buttons;
864} 878}
865 879
866/** 880/**
867 * @return The amount of time that would count as a hold 881 * @return The amount of time that would count as a hold
868 */ 882 */
869uint ODevice::buttonHoldTime ( ) const 883uint ODevice::buttonHoldTime ( ) const
870{ 884{
871 return d-> m_holdtime; 885 return d-> m_holdtime;
872} 886}
873 887
874/** 888/**
875 * This method return a ODeviceButton for a key code 889 * This method return a ODeviceButton for a key code
876 * or 0 if no special hardware button is available for the device 890 * or 0 if no special hardware button is available for the device
877 * 891 *
878 * @return The devicebutton or 0l 892 * @return The devicebutton or 0l
879 * @see ODeviceButton 893 * @see ODeviceButton
880 */ 894 */
881const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 895const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
882{ 896{
883 initButtons ( ); 897 initButtons ( );
884 898
885 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 899 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
886 if ( (*it). keycode ( ) == code ) 900 if ( (*it). keycode ( ) == code )
887 return &(*it); 901 return &(*it);
888 } 902 }
889 return 0; 903 return 0;
890} 904}
891 905
892void ODevice::reloadButtonMapping ( ) 906void ODevice::reloadButtonMapping ( )
893{ 907{
894 initButtons ( ); 908 initButtons ( );
895 909
896 Config cfg ( "ButtonSettings" ); 910 Config cfg ( "ButtonSettings" );
897 911
898 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 912 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
899 ODeviceButton &b = ( *d-> m_buttons ) [i]; 913 ODeviceButton &b = ( *d-> m_buttons ) [i];
900 QString group = "Button" + QString::number ( i ); 914 QString group = "Button" + QString::number ( i );
901 915
902 QCString pch, hch; 916 QCString pch, hch;
903 QCString pm, hm; 917 QCString pm, hm;
904 QByteArray pdata, hdata; 918 QByteArray pdata, hdata;
905 919
906 if ( cfg. hasGroup ( group )) { 920 if ( cfg. hasGroup ( group )) {
907 cfg. setGroup ( group ); 921 cfg. setGroup ( group );
908 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 922 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
909 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 923 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
910 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 924 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
911 925
912 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 926 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
913 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 927 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
914 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 928 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
915 } 929 }
916 930
917 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 931 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
918 932
919 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 933 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
920 } 934 }
921} 935}
922 936
923void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 937void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
924{ 938{
925 initButtons ( ); 939 initButtons ( );
926 940
927 QString mb_chan; 941 QString mb_chan;
928 942
929 if ( button >= (int) d-> m_buttons-> count ( )) 943 if ( button >= (int) d-> m_buttons-> count ( ))
930 return; 944 return;
931 945
932 ODeviceButton &b = ( *d-> m_buttons ) [button]; 946 ODeviceButton &b = ( *d-> m_buttons ) [button];
933 b. setPressedAction ( action ); 947 b. setPressedAction ( action );
934 948
935 mb_chan=b. pressedAction ( ). channel ( ); 949 mb_chan=b. pressedAction ( ). channel ( );
936 950
937 Config buttonFile ( "ButtonSettings" ); 951 Config buttonFile ( "ButtonSettings" );
938 buttonFile. setGroup ( "Button" + QString::number ( button )); 952 buttonFile. setGroup ( "Button" + QString::number ( button ));
939 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 953 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
940 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 954 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
941 955
942 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 956 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
943 957
944 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 958 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
945} 959}
946 960
947void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 961void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
948{ 962{
949 initButtons ( ); 963 initButtons ( );
950 964
951 if ( button >= (int) d-> m_buttons-> count ( )) 965 if ( button >= (int) d-> m_buttons-> count ( ))
952 return; 966 return;
953 967
954 ODeviceButton &b = ( *d-> m_buttons ) [button]; 968 ODeviceButton &b = ( *d-> m_buttons ) [button];
955 b. setHeldAction ( action ); 969 b. setHeldAction ( action );
956 970
957 Config buttonFile ( "ButtonSettings" ); 971 Config buttonFile ( "ButtonSettings" );
958 buttonFile. setGroup ( "Button" + QString::number ( button )); 972 buttonFile. setGroup ( "Button" + QString::number ( button ));
959 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 973 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
960 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 974 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
961 975
962 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 976 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
963 977
964 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 978 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
965} 979}
966void ODevice::virtual_hook(int, void* ){ 980void ODevice::virtual_hook(int, void* ){
967 981
968} 982}
969 983
970/************************************************** 984/**************************************************
971 * 985 *
972 * Yopy 3500/3700 986 * Yopy 3500/3700
973 * 987 *
974 **************************************************/ 988 **************************************************/
975 989
976bool Yopy::isYopy ( ) 990bool Yopy::isYopy ( )
977{ 991{
978 QFile f( "/proc/cpuinfo" ); 992 QFile f( "/proc/cpuinfo" );
979 if ( f. open ( IO_ReadOnly ) ) { 993 if ( f. open ( IO_ReadOnly ) ) {
980 QTextStream ts ( &f ); 994 QTextStream ts ( &f );
981 QString line; 995 QString line;
982 while( line = ts. readLine ( ) ) { 996 while( line = ts. readLine ( ) ) {
983 if ( line. left ( 8 ) == "Hardware" ) { 997 if ( line. left ( 8 ) == "Hardware" ) {
984 int loc = line. find ( ":" ); 998 int loc = line. find ( ":" );
985 if ( loc != -1 ) { 999 if ( loc != -1 ) {
986 QString model = 1000 QString model =
987 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1001 line. mid ( loc + 2 ). simplifyWhiteSpace( );
988 return ( model == "Yopy" ); 1002 return ( model == "Yopy" );
989 } 1003 }
990 } 1004 }
991 } 1005 }
992 } 1006 }
993 return false; 1007 return false;
994} 1008}
995 1009
996void Yopy::init ( ) 1010void Yopy::init ( )
997{ 1011{
998 d-> m_vendorstr = "G.Mate"; 1012 d-> m_vendorstr = "G.Mate";
999 d-> m_vendor = Vendor_GMate; 1013 d-> m_vendor = Vendor_GMate;
1000 d-> m_modelstr = "Yopy3700"; 1014 d-> m_modelstr = "Yopy3700";
1001 d-> m_model = Model_Yopy_3700; 1015 d-> m_model = Model_Yopy_3700;
1002 d-> m_rotation = Rot0; 1016 d-> m_rotation = Rot0;
1003 1017
1004 d-> m_systemstr = "Linupy"; 1018 d-> m_systemstr = "Linupy";
1005 d-> m_system = System_Linupy; 1019 d-> m_system = System_Linupy;
1006 1020
1007 QFile f ( "/etc/issue" ); 1021 QFile f ( "/etc/issue" );
1008 if ( f. open ( IO_ReadOnly )) { 1022 if ( f. open ( IO_ReadOnly )) {
1009 QTextStream ts ( &f ); 1023 QTextStream ts ( &f );
1010 ts.readLine(); 1024 ts.readLine();
1011 d-> m_sysverstr = ts. readLine ( ); 1025 d-> m_sysverstr = ts. readLine ( );
1012 f. close ( ); 1026 f. close ( );
1013 } 1027 }
1014} 1028}
1015 1029
1016void Yopy::initButtons ( ) 1030void Yopy::initButtons ( )
1017{ 1031{
1018 if ( d-> m_buttons ) 1032 if ( d-> m_buttons )
1019 return; 1033 return;
1020 1034
1021 d-> m_buttons = new QValueList <ODeviceButton>; 1035 d-> m_buttons = new QValueList <ODeviceButton>;
1022 1036
1023 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1037 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1024 1038
1025 yopy_button *ib = yopy_buttons + i; 1039 yopy_button *ib = yopy_buttons + i;
1026 1040
1027 ODeviceButton b; 1041 ODeviceButton b;
1028 1042
1029 b. setKeycode ( ib-> code ); 1043 b. setKeycode ( ib-> code );
1030 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1044 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1031 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1045 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1032 b. setFactoryPresetPressedAction 1046 b. setFactoryPresetPressedAction
1033 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1047 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1034 b. setFactoryPresetHeldAction 1048 b. setFactoryPresetHeldAction
1035 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1049 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1036 1050
1037 d-> m_buttons-> append ( b ); 1051 d-> m_buttons-> append ( b );
1038 } 1052 }
1039 reloadButtonMapping ( ); 1053 reloadButtonMapping ( );
1040 1054
1041 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1055 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1042 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1056 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1043 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1057 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1044} 1058}
1045 1059
1046bool Yopy::suspend() 1060bool Yopy::suspend()
1047{ 1061{
1048 /* Opie for Yopy does not implement its own power management at the 1062 /* Opie for Yopy does not implement its own power management at the
1049 moment. The public version runs parallel to X, and relies on the 1063 moment. The public version runs parallel to X, and relies on the
1050 existing power management features. */ 1064 existing power management features. */
1051 return false; 1065 return false;
1052} 1066}
1053 1067
1054bool Yopy::setDisplayBrightness(int bright) 1068bool Yopy::setDisplayBrightness(int bright)
1055{ 1069{
1056 /* The code here works, but is disabled as the current version runs 1070 /* The code here works, but is disabled as the current version runs
1057 parallel to X, and relies on the existing backlight demon. */ 1071 parallel to X, and relies on the existing backlight demon. */
1058#if 0 1072#if 0
1059 if ( QFile::exists("/proc/sys/pm/light") ) { 1073 if ( QFile::exists("/proc/sys/pm/light") ) {
1060 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1074 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1061 if (fd >= 0 ) { 1075 if (fd >= 0 ) {
1062 if (bright) 1076 if (bright)
1063 ::write(fd, "1\n", 2); 1077 ::write(fd, "1\n", 2);
1064 else 1078 else
1065 ::write(fd, "0\n", 2); 1079 ::write(fd, "0\n", 2);
1066 ::close(fd); 1080 ::close(fd);
1067 return true; 1081 return true;
1068 } 1082 }
1069 } 1083 }
1070#endif 1084#endif
1071 return false; 1085 return false;
1072} 1086}
1073 1087
1074int Yopy::displayBrightnessResolution() const 1088int Yopy::displayBrightnessResolution() const
1075{ 1089{
1076 return 2; 1090 return 2;
1077} 1091}
1078 1092
1079/************************************************** 1093/**************************************************
1080 * 1094 *
1081 * iPAQ 1095 * iPAQ
1082 * 1096 *
1083 **************************************************/ 1097 **************************************************/
1084 1098
1085void iPAQ::init ( ) 1099void iPAQ::init ( )
1086{ 1100{
1087 d-> m_vendorstr = "HP"; 1101 d-> m_vendorstr = "HP";
1088 d-> m_vendor = Vendor_HP; 1102 d-> m_vendor = Vendor_HP;
1089 1103
1090 QFile f ( "/proc/hal/model" ); 1104 QFile f ( "/proc/hal/model" );
1091 1105
1092 if ( f. open ( IO_ReadOnly )) { 1106 if ( f. open ( IO_ReadOnly )) {
1093 QTextStream ts ( &f ); 1107 QTextStream ts ( &f );
1094 1108
1095 d-> m_modelstr = "H" + ts. readLine ( ); 1109 d-> m_modelstr = "H" + ts. readLine ( );
1096 1110
1097 if ( d-> m_modelstr == "H3100" ) 1111 if ( d-> m_modelstr == "H3100" )
1098 d-> m_model = Model_iPAQ_H31xx; 1112 d-> m_model = Model_iPAQ_H31xx;
1099 else if ( d-> m_modelstr == "H3600" ) 1113 else if ( d-> m_modelstr == "H3600" )
1100 d-> m_model = Model_iPAQ_H36xx; 1114 d-> m_model = Model_iPAQ_H36xx;
1101 else if ( d-> m_modelstr == "H3700" ) 1115 else if ( d-> m_modelstr == "H3700" )
1102 d-> m_model = Model_iPAQ_H37xx; 1116 d-> m_model = Model_iPAQ_H37xx;
1103 else if ( d-> m_modelstr == "H3800" ) 1117 else if ( d-> m_modelstr == "H3800" )
1104 d-> m_model = Model_iPAQ_H38xx; 1118 d-> m_model = Model_iPAQ_H38xx;
1105 else if ( d-> m_modelstr == "H3900" ) 1119 else if ( d-> m_modelstr == "H3900" )
1106 d-> m_model = Model_iPAQ_H39xx; 1120 d-> m_model = Model_iPAQ_H39xx;
1107 else 1121 else
1108 d-> m_model = Model_Unknown; 1122 d-> m_model = Model_Unknown;
1109 1123
1110 f. close ( ); 1124 f. close ( );
1111 } 1125 }
1112 1126
1113 switch ( d-> m_model ) { 1127 switch ( d-> m_model ) {
1114 case Model_iPAQ_H31xx: 1128 case Model_iPAQ_H31xx:
1115 case Model_iPAQ_H38xx: 1129 case Model_iPAQ_H38xx:
1116 d-> m_rotation = Rot90; 1130 d-> m_rotation = Rot90;
1117 break; 1131 break;
1118 case Model_iPAQ_H36xx: 1132 case Model_iPAQ_H36xx:
1119 case Model_iPAQ_H37xx: 1133 case Model_iPAQ_H37xx:
1120 case Model_iPAQ_H39xx: 1134 case Model_iPAQ_H39xx:
1121 default: 1135 default:
1122 d-> m_rotation = Rot270; 1136 d-> m_rotation = Rot270;
1123 break; 1137 break;
1124 } 1138 }
1125 1139
1126 f. setName ( "/etc/familiar-version" ); 1140 f. setName ( "/etc/familiar-version" );
1127 if ( f. open ( IO_ReadOnly )) { 1141 if ( f. open ( IO_ReadOnly )) {
1128 d-> m_systemstr = "Familiar"; 1142 d-> m_systemstr = "Familiar";
1129 d-> m_system = System_Familiar; 1143 d-> m_system = System_Familiar;
1130 1144
1131 QTextStream ts ( &f ); 1145 QTextStream ts ( &f );
1132 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1146 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1133 1147
1134 f. close ( ); 1148 f. close ( );
1135 } else { 1149 } else {
1136 f. setName ( "/etc/oz_version" ); 1150 f. setName ( "/etc/oz_version" );
1137 1151
1138 if ( f. open ( IO_ReadOnly )) { 1152 if ( f. open ( IO_ReadOnly )) {
1139 d-> m_systemstr = "OpenEmbedded/iPaq"; 1153 d-> m_systemstr = "OpenEmbedded/iPaq";
1140 d-> m_system = System_Familiar; 1154 d-> m_system = System_Familiar;
1141 1155
1142 QTextStream ts ( &f ); 1156 QTextStream ts ( &f );
1143 ts.setDevice ( &f ); 1157 ts.setDevice ( &f );
1144 d-> m_sysverstr = ts. readLine ( ); 1158 d-> m_sysverstr = ts. readLine ( );
1145 f. close ( ); 1159 f. close ( );
1146 } 1160 }
1147 } 1161 }
1148 1162
1149 1163
1150 1164
1151 1165
1152 1166
1153 m_leds [0] = m_leds [1] = Led_Off; 1167 m_leds [0] = m_leds [1] = Led_Off;
1154 1168
1155 m_power_timer = 0; 1169 m_power_timer = 0;
1156 1170
1157} 1171}
1158 1172
1159void iPAQ::initButtons ( ) 1173void iPAQ::initButtons ( )
1160{ 1174{
1161 if ( d-> m_buttons ) 1175 if ( d-> m_buttons )
1162 return; 1176 return;
1163 1177
1164 if ( isQWS( ) ) 1178 if ( isQWS( ) )
1165 QWSServer::setKeyboardFilter ( this ); 1179 QWSServer::setKeyboardFilter ( this );
1166 1180
1167 d-> m_buttons = new QValueList <ODeviceButton>; 1181 d-> m_buttons = new QValueList <ODeviceButton>;
1168 1182
1169 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1183 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1170 i_button *ib = ipaq_buttons + i; 1184 i_button *ib = ipaq_buttons + i;
1171 ODeviceButton b; 1185 ODeviceButton b;
1172 1186
1173 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1187 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1174 b. setKeycode ( ib-> code ); 1188 b. setKeycode ( ib-> code );
1175 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1189 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1176 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1190 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1177 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1191 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1178 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1192 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1179 1193
1180 d-> m_buttons-> append ( b ); 1194 d-> m_buttons-> append ( b );
1181 } 1195 }
1182 } 1196 }
1183 reloadButtonMapping ( ); 1197 reloadButtonMapping ( );
1184 1198
1185 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1199 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1186 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1200 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1187} 1201}
1188 1202
1189 1203
1190//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1204//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1191 1205
1192typedef struct { 1206typedef struct {
1193 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1207 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1194 unsigned char TotalTime; /* Units of 5 seconds */ 1208 unsigned char TotalTime; /* Units of 5 seconds */
1195 unsigned char OnTime; /* units of 100m/s */ 1209 unsigned char OnTime; /* units of 100m/s */
1196 unsigned char OffTime; /* units of 100m/s */ 1210 unsigned char OffTime; /* units of 100m/s */
1197} LED_IN; 1211} LED_IN;
1198 1212
1199typedef struct { 1213typedef struct {
1200 unsigned char mode; 1214 unsigned char mode;
1201 unsigned char pwr; 1215 unsigned char pwr;
1202 unsigned char brightness; 1216 unsigned char brightness;
1203} FLITE_IN; 1217} FLITE_IN;
1204 1218
1205#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1219#define LED_ON OD_IOW( 'f', 5, LED_IN )
1206#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1220#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1207 1221
1208 1222
1209QValueList <OLed> iPAQ::ledList ( ) const 1223QValueList <OLed> iPAQ::ledList ( ) const
1210{ 1224{
1211 QValueList <OLed> vl; 1225 QValueList <OLed> vl;
1212 vl << Led_Power; 1226 vl << Led_Power;
1213 1227
1214 if ( d-> m_model == Model_iPAQ_H38xx ) 1228 if ( d-> m_model == Model_iPAQ_H38xx )
1215 vl << Led_BlueTooth; 1229 vl << Led_BlueTooth;
1216 return vl; 1230 return vl;
1217} 1231}
1218 1232
1219QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1233QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1220{ 1234{
1221 QValueList <OLedState> vl; 1235 QValueList <OLedState> vl;
1222 1236
1223 if ( l == Led_Power ) 1237 if ( l == Led_Power )
1224 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1238 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1225 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1239 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1226 vl << Led_Off; // << Led_On << ??? 1240 vl << Led_Off; // << Led_On << ???
1227 1241
1228 return vl; 1242 return vl;
1229} 1243}
1230 1244
1231OLedState iPAQ::ledState ( OLed l ) const 1245OLedState iPAQ::ledState ( OLed l ) const
1232{ 1246{
1233 switch ( l ) { 1247 switch ( l ) {
1234 case Led_Power: 1248 case Led_Power:
1235 return m_leds [0]; 1249 return m_leds [0];
1236 case Led_BlueTooth: 1250 case Led_BlueTooth:
1237 return m_leds [1]; 1251 return m_leds [1];
1238 default: 1252 default:
1239 return Led_Off; 1253 return Led_Off;
1240 } 1254 }
1241} 1255}
1242 1256
1243bool iPAQ::setLedState ( OLed l, OLedState st ) 1257bool iPAQ::setLedState ( OLed l, OLedState st )
1244{ 1258{
1245 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1259 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1246 1260
1247 if ( l == Led_Power ) { 1261 if ( l == Led_Power ) {
1248 if ( fd >= 0 ) { 1262 if ( fd >= 0 ) {
1249 LED_IN leds; 1263 LED_IN leds;
1250 ::memset ( &leds, 0, sizeof( leds )); 1264 ::memset ( &leds, 0, sizeof( leds ));
1251 leds. TotalTime = 0; 1265 leds. TotalTime = 0;
1252 leds. OnTime = 0; 1266 leds. OnTime = 0;
1253 leds. OffTime = 1; 1267 leds. OffTime = 1;
1254 leds. OffOnBlink = 2; 1268 leds. OffOnBlink = 2;
1255 1269
1256 switch ( st ) { 1270 switch ( st ) {
1257 case Led_Off : leds. OffOnBlink = 0; break; 1271 case Led_Off : leds. OffOnBlink = 0; break;
1258 case Led_On : leds. OffOnBlink = 1; break; 1272 case Led_On : leds. OffOnBlink = 1; break;
1259 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1273 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1260 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1274 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1261 } 1275 }
1262 1276
1263 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1277 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1264 m_leds [0] = st; 1278 m_leds [0] = st;
1265 return true; 1279 return true;
1266 } 1280 }
1267 } 1281 }
1268 } 1282 }
1269 return false; 1283 return false;
1270} 1284}
1271 1285
1272 1286
1273bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1287bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1274{ 1288{
1275 int newkeycode = keycode; 1289 int newkeycode = keycode;
1276 1290
1277 switch ( keycode ) { 1291 switch ( keycode ) {
1278 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1292 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1279 case HardKey_Menu: { 1293 case HardKey_Menu: {
1280 if (( d-> m_model == Model_iPAQ_H38xx ) || 1294 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1281 ( d-> m_model == Model_iPAQ_H39xx )) { 1295 ( d-> m_model == Model_iPAQ_H39xx )) {
1282 newkeycode = HardKey_Mail; 1296 newkeycode = HardKey_Mail;
1283 } 1297 }
1284 break; 1298 break;
1285 } 1299 }
1286 1300
1287 // Rotate cursor keys 180° 1301 // Rotate cursor keys 180°
1288 case Key_Left : 1302 case Key_Left :
1289 case Key_Right: 1303 case Key_Right:
1290 case Key_Up : 1304 case Key_Up :
1291 case Key_Down : { 1305 case Key_Down : {
1292 if (( d-> m_model == Model_iPAQ_H31xx ) || 1306 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1293 ( d-> m_model == Model_iPAQ_H38xx )) { 1307 ( d-> m_model == Model_iPAQ_H38xx )) {
1294 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1308 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1295 } 1309 }
1296 break; 1310 break;
1297 } 1311 }
1298 1312
1299 // map Power Button short/long press to F34/F35 1313 // map Power Button short/long press to F34/F35
1300 case Key_SysReq: { 1314 case Key_SysReq: {
1301 if ( isPress ) { 1315 if ( isPress ) {
1302 if ( m_power_timer ) 1316 if ( m_power_timer )
1303 killTimer ( m_power_timer ); 1317 killTimer ( m_power_timer );
1304 m_power_timer = startTimer ( 500 ); 1318 m_power_timer = startTimer ( 500 );
1305 } 1319 }
1306 else if ( m_power_timer ) { 1320 else if ( m_power_timer ) {
1307 killTimer ( m_power_timer ); 1321 killTimer ( m_power_timer );
1308 m_power_timer = 0; 1322 m_power_timer = 0;
1309 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1323 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1310 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1324 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1311 } 1325 }
1312 newkeycode = Key_unknown; 1326 newkeycode = Key_unknown;
1313 break; 1327 break;
1314 } 1328 }
1315 } 1329 }
1316 1330
1317 if ( newkeycode != keycode ) { 1331 if ( newkeycode != keycode ) {
1318 if ( newkeycode != Key_unknown ) 1332 if ( newkeycode != Key_unknown )
1319 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1333 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1320 return true; 1334 return true;
1321 } 1335 }
1322 else 1336 else
1323 return false; 1337 return false;
1324} 1338}
1325 1339
1326void iPAQ::timerEvent ( QTimerEvent * ) 1340void iPAQ::timerEvent ( QTimerEvent * )
1327{ 1341{
1328 killTimer ( m_power_timer ); 1342 killTimer ( m_power_timer );
1329 m_power_timer = 0; 1343 m_power_timer = 0;
1330 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1344 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1331 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1345 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1332} 1346}
1333 1347
1334 1348
1335void iPAQ::alarmSound ( ) 1349void iPAQ::alarmSound ( )
1336{ 1350{
1337#ifndef QT_NO_SOUND 1351#ifndef QT_NO_SOUND
1338 static Sound snd ( "alarm" ); 1352 static Sound snd ( "alarm" );
1339 int fd; 1353 int fd;
1340 int vol; 1354 int vol;
1341 bool vol_reset = false; 1355 bool vol_reset = false;
1342 1356
1343 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1357 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1344 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1358 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1345 Config cfg ( "qpe" ); 1359 Config cfg ( "qpe" );
1346 cfg. setGroup ( "Volume" ); 1360 cfg. setGroup ( "Volume" );
1347 1361
1348 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1362 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1349 if ( volalarm < 0 ) 1363 if ( volalarm < 0 )
1350 volalarm = 0; 1364 volalarm = 0;
1351 else if ( volalarm > 100 ) 1365 else if ( volalarm > 100 )
1352 volalarm = 100; 1366 volalarm = 100;
1353 volalarm |= ( volalarm << 8 ); 1367 volalarm |= ( volalarm << 8 );
1354 1368
1355 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1369 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1356 vol_reset = true; 1370 vol_reset = true;
1357 } 1371 }
1358 } 1372 }
1359 1373
1360 snd. play ( ); 1374 snd. play ( );
1361 while ( !snd. isFinished ( )) 1375 while ( !snd. isFinished ( ))
1362 qApp-> processEvents ( ); 1376 qApp-> processEvents ( );
1363 1377
1364 if ( fd >= 0 ) { 1378 if ( fd >= 0 ) {
1365 if ( vol_reset ) 1379 if ( vol_reset )
1366 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1380 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1367 ::close ( fd ); 1381 ::close ( fd );
1368 } 1382 }
1369#endif 1383#endif
1370} 1384}
@@ -2071,384 +2085,496 @@ QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
2071 vl << Led_Off << Led_On; 2085 vl << Led_Off << Led_On;
2072 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 2086 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
2073 //vl << Led_Off; 2087 //vl << Led_Off;
2074 return vl; 2088 return vl;
2075} 2089}
2076 2090
2077OLedState SIMpad::ledState ( OLed l ) const 2091OLedState SIMpad::ledState ( OLed l ) const
2078{ 2092{
2079 switch ( l ) { 2093 switch ( l ) {
2080 case Led_Power: 2094 case Led_Power:
2081 return m_leds [0]; 2095 return m_leds [0];
2082 //case Led_Mail: 2096 //case Led_Mail:
2083 //return m_leds [1]; 2097 //return m_leds [1];
2084 default: 2098 default:
2085 return Led_Off; 2099 return Led_Off;
2086 } 2100 }
2087} 2101}
2088 2102
2089bool SIMpad::setLedState ( OLed l, OLedState st ) 2103bool SIMpad::setLedState ( OLed l, OLedState st )
2090{ 2104{
2091 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 2105 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
2092 2106
2093 if ( l == Led_Power ) { 2107 if ( l == Led_Power ) {
2094 if ( fd >= 0 ) { 2108 if ( fd >= 0 ) {
2095 LED_IN leds; 2109 LED_IN leds;
2096 ::memset ( &leds, 0, sizeof( leds )); 2110 ::memset ( &leds, 0, sizeof( leds ));
2097 leds. TotalTime = 0; 2111 leds. TotalTime = 0;
2098 leds. OnTime = 0; 2112 leds. OnTime = 0;
2099 leds. OffTime = 1; 2113 leds. OffTime = 1;
2100 leds. OffOnBlink = 2; 2114 leds. OffOnBlink = 2;
2101 2115
2102 switch ( st ) { 2116 switch ( st ) {
2103 case Led_Off : leds. OffOnBlink = 0; break; 2117 case Led_Off : leds. OffOnBlink = 0; break;
2104 case Led_On : leds. OffOnBlink = 1; break; 2118 case Led_On : leds. OffOnBlink = 1; break;
2105 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 2119 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
2106 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 2120 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
2107 } 2121 }
2108 2122
2109 { 2123 {
2110 /*TODO Implement this like that: 2124 /*TODO Implement this like that:
2111 read from cs3 2125 read from cs3
2112 && with SIMPAD_LED2_ON 2126 && with SIMPAD_LED2_ON
2113 write to cs3 */ 2127 write to cs3 */
2114 m_leds [0] = st; 2128 m_leds [0] = st;
2115 return true; 2129 return true;
2116 } 2130 }
2117 } 2131 }
2118 } 2132 }
2119 return false; 2133 return false;
2120} 2134}
2121 2135
2122 2136
2123bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 2137bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
2124{ 2138{
2125 //TODO 2139 //TODO
2126 return false; 2140 return false;
2127} 2141}
2128 2142
2129void SIMpad::timerEvent ( QTimerEvent * ) 2143void SIMpad::timerEvent ( QTimerEvent * )
2130{ 2144{
2131 killTimer ( m_power_timer ); 2145 killTimer ( m_power_timer );
2132 m_power_timer = 0; 2146 m_power_timer = 0;
2133 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 2147 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
2134 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 2148 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
2135} 2149}
2136 2150
2137 2151
2138void SIMpad::alarmSound ( ) 2152void SIMpad::alarmSound ( )
2139{ 2153{
2140#ifndef QT_NO_SOUND 2154#ifndef QT_NO_SOUND
2141 static Sound snd ( "alarm" ); 2155 static Sound snd ( "alarm" );
2142 int fd; 2156 int fd;
2143 int vol; 2157 int vol;
2144 bool vol_reset = false; 2158 bool vol_reset = false;
2145 2159
2146 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 2160 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
2147 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 2161 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
2148 Config cfg ( "qpe" ); 2162 Config cfg ( "qpe" );
2149 cfg. setGroup ( "Volume" ); 2163 cfg. setGroup ( "Volume" );
2150 2164
2151 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 2165 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
2152 if ( volalarm < 0 ) 2166 if ( volalarm < 0 )
2153 volalarm = 0; 2167 volalarm = 0;
2154 else if ( volalarm > 100 ) 2168 else if ( volalarm > 100 )
2155 volalarm = 100; 2169 volalarm = 100;
2156 volalarm |= ( volalarm << 8 ); 2170 volalarm |= ( volalarm << 8 );
2157 2171
2158 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 2172 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
2159 vol_reset = true; 2173 vol_reset = true;
2160 } 2174 }
2161 } 2175 }
2162 2176
2163 snd. play ( ); 2177 snd. play ( );
2164 while ( !snd. isFinished ( )) 2178 while ( !snd. isFinished ( ))
2165 qApp-> processEvents ( ); 2179 qApp-> processEvents ( );
2166 2180
2167 if ( fd >= 0 ) { 2181 if ( fd >= 0 ) {
2168 if ( vol_reset ) 2182 if ( vol_reset )
2169 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 2183 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
2170 ::close ( fd ); 2184 ::close ( fd );
2171 } 2185 }
2172#endif 2186#endif
2173} 2187}
2174 2188
2175 2189
2176bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 2190bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
2177{ 2191{
2178 qDebug( "ODevice for SIMpad: suspend()" ); 2192 qDebug( "ODevice for SIMpad: suspend()" );
2179 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2193 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2180 return false; 2194 return false;
2181 2195
2182 bool res = false; 2196 bool res = false;
2183 2197
2184 struct timeval tvs, tvn; 2198 struct timeval tvs, tvn;
2185 ::gettimeofday ( &tvs, 0 ); 2199 ::gettimeofday ( &tvs, 0 );
2186 2200
2187 ::sync ( ); // flush fs caches 2201 ::sync ( ); // flush fs caches
2188 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 2202 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
2189 2203
2190 return res; 2204 return res;
2191} 2205}
2192 2206
2193 2207
2194bool SIMpad::setSoftSuspend ( bool soft ) 2208bool SIMpad::setSoftSuspend ( bool soft )
2195{ 2209{
2196 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 2210 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
2197 return false; 2211 return false;
2198} 2212}
2199 2213
2200 2214
2201bool SIMpad::setDisplayStatus ( bool on ) 2215bool SIMpad::setDisplayStatus ( bool on )
2202{ 2216{
2203 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 2217 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
2204 2218
2205 bool res = false; 2219 bool res = false;
2206 int fd; 2220 int fd;
2207 2221
2208 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 2222 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
2209 2223
2210 res = ( ::system( (const char*) cmdline ) == 0 ); 2224 res = ( ::system( (const char*) cmdline ) == 0 );
2211 2225
2212 return res; 2226 return res;
2213} 2227}
2214 2228
2215 2229
2216bool SIMpad::setDisplayBrightness ( int bright ) 2230bool SIMpad::setDisplayBrightness ( int bright )
2217{ 2231{
2218 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 2232 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
2219 bool res = false; 2233 bool res = false;
2220 int fd; 2234 int fd;
2221 2235
2222 if ( bright > 255 ) 2236 if ( bright > 255 )
2223 bright = 255; 2237 bright = 255;
2224 if ( bright < 1 ) 2238 if ( bright < 1 )
2225 bright = 0; 2239 bright = 0;
2226 2240
2227 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 2241 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
2228 int value = 255 - bright; 2242 int value = 255 - bright;
2229 const int mask = SIMPAD_BACKLIGHT_MASK; 2243 const int mask = SIMPAD_BACKLIGHT_MASK;
2230 value = value << 8; 2244 value = value << 8;
2231 value += mask; 2245 value += mask;
2232 char writeCommand[100]; 2246 char writeCommand[100];
2233 const int count = sprintf( writeCommand, "0x%x\n", value ); 2247 const int count = sprintf( writeCommand, "0x%x\n", value );
2234 res = ( ::write ( fd, writeCommand, count ) != -1 ); 2248 res = ( ::write ( fd, writeCommand, count ) != -1 );
2235 ::close ( fd ); 2249 ::close ( fd );
2236 } 2250 }
2237 return res; 2251 return res;
2238} 2252}
2239 2253
2240 2254
2241int SIMpad::displayBrightnessResolution ( ) const 2255int SIMpad::displayBrightnessResolution ( ) const
2242{ 2256{
2243 return 255; // All SIMpad models share the same display 2257 return 255; // All SIMpad models share the same display
2244} 2258}
2245 2259
2246/************************************************** 2260/**************************************************
2247 * 2261 *
2248 * Ramses 2262 * Ramses
2249 * 2263 *
2250 **************************************************/ 2264 **************************************************/
2251 2265
2252void Ramses::init() 2266void Ramses::init()
2253{ 2267{
2254 d->m_vendorstr = "M und N"; 2268 d->m_vendorstr = "M und N";
2255 d->m_vendor = Vendor_MundN; 2269 d->m_vendor = Vendor_MundN;
2256 2270
2257 QFile f("/proc/sys/board/ramses"); 2271 QFile f("/proc/sys/board/ramses");
2258 2272
2259 d->m_modelstr = "Ramses"; 2273 d->m_modelstr = "Ramses";
2260 d->m_model = Model_Ramses_MNCI; 2274 d->m_model = Model_Ramses_MNCI;
2261 2275
2262 d->m_rotation = Rot0; 2276 d->m_rotation = Rot0;
2263 d->m_holdtime = 1000; 2277 d->m_holdtime = 1000;
2264 2278
2265 f.setName("/etc/oz_version"); 2279 f.setName("/etc/oz_version");
2266 2280
2267 if (f.open(IO_ReadOnly)) { 2281 if (f.open(IO_ReadOnly)) {
2268 d->m_systemstr = "OpenEmbedded/Ramses"; 2282 d->m_systemstr = "OpenEmbedded/Ramses";
2269 d->m_system = System_OpenZaurus; 2283 d->m_system = System_OpenZaurus;
2270 2284
2271 QTextStream ts(&f); 2285 QTextStream ts(&f);
2272 ts.setDevice(&f); 2286 ts.setDevice(&f);
2273 d->m_sysverstr = ts.readLine(); 2287 d->m_sysverstr = ts.readLine();
2274 f.close(); 2288 f.close();
2275 } 2289 }
2276 2290
2277 m_power_timer = 0; 2291 m_power_timer = 0;
2278 2292
2279#ifdef QT_QWS_ALLOW_OVERCLOCK 2293#ifdef QT_QWS_ALLOW_OVERCLOCK
2280#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 2294#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
2281#define OC(x...) x 2295#define OC(x...) x
2282#else 2296#else
2283#define OC(x...) 2297#define OC(x...)
2284#endif 2298#endif
2285 2299
2286 2300
2287 // This table is true for a Intel XScale PXA 255 2301 // This table is true for a Intel XScale PXA 255
2288 2302
2289 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 2303 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
2290 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 2304 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
2291 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 2305 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
2292 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 2306 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
2293 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 2307 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
2294 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 2308 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
2295 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 2309 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
2296 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 2310 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
2297 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 2311 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
2298 2312
2299} 2313}
2300 2314
2301bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 2315bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
2302{ 2316{
2303 Q_UNUSED( keycode ); 2317 Q_UNUSED( keycode );
2304 Q_UNUSED( modifiers ); 2318 Q_UNUSED( modifiers );
2305 Q_UNUSED( isPress ); 2319 Q_UNUSED( isPress );
2306 Q_UNUSED( autoRepeat ); 2320 Q_UNUSED( autoRepeat );
2307 return false; 2321 return false;
2308} 2322}
2309 2323
2310void Ramses::timerEvent(QTimerEvent *) 2324void Ramses::timerEvent(QTimerEvent *)
2311{ 2325{
2312 killTimer(m_power_timer); 2326 killTimer(m_power_timer);
2313 m_power_timer = 0; 2327 m_power_timer = 0;
2314 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 2328 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
2315 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 2329 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
2316} 2330}
2317 2331
2318 2332
2319bool Ramses::setSoftSuspend(bool soft) 2333bool Ramses::setSoftSuspend(bool soft)
2320{ 2334{
2321 qDebug("Ramses::setSoftSuspend(%d)", soft); 2335 qDebug("Ramses::setSoftSuspend(%d)", soft);
2322#if 0 2336#if 0
2323 bool res = false; 2337 bool res = false;
2324 int fd; 2338 int fd;
2325 2339
2326 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 2340 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
2327 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 2341 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
2328 2342
2329 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 2343 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
2330 2344
2331 if (sources >= 0) { 2345 if (sources >= 0) {
2332 if (soft) 2346 if (soft)
2333 sources &= ~APM_EVT_POWER_BUTTON; 2347 sources &= ~APM_EVT_POWER_BUTTON;
2334 else 2348 else
2335 sources |= APM_EVT_POWER_BUTTON; 2349 sources |= APM_EVT_POWER_BUTTON;
2336 2350
2337 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 2351 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
2338 res = true; 2352 res = true;
2339 else 2353 else
2340 perror("APM_IOCGEVTSRC"); 2354 perror("APM_IOCGEVTSRC");
2341 } 2355 }
2342 else 2356 else
2343 perror("APM_IOCGEVTSRC"); 2357 perror("APM_IOCGEVTSRC");
2344 2358
2345 ::close(fd); 2359 ::close(fd);
2346 } 2360 }
2347 else 2361 else
2348 perror("/dev/apm_bios or /dev/misc/apm_bios"); 2362 perror("/dev/apm_bios or /dev/misc/apm_bios");
2349 2363
2350 return res; 2364 return res;
2351#else 2365#else
2352 return true; 2366 return true;
2353#endif 2367#endif
2354} 2368}
2355 2369
2356bool Ramses::suspend ( ) 2370bool Ramses::suspend ( )
2357{ 2371{
2358 qDebug("Ramses::suspend"); 2372 qDebug("Ramses::suspend");
2359 return false; 2373 return false;
2360} 2374}
2361 2375
2362/** 2376/**
2363 * This sets the display on or off 2377 * This sets the display on or off
2364 */ 2378 */
2365bool Ramses::setDisplayStatus(bool on) 2379bool Ramses::setDisplayStatus(bool on)
2366{ 2380{
2367 qDebug("Ramses::setDisplayStatus(%d)", on); 2381 qDebug("Ramses::setDisplayStatus(%d)", on);
2368#if 0 2382#if 0
2369 bool res = false; 2383 bool res = false;
2370 int fd; 2384 int fd;
2371 2385
2372 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 2386 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2373 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2387 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2374 ::close(fd); 2388 ::close(fd);
2375 } 2389 }
2376 return res; 2390 return res;
2377#else 2391#else
2378 return true; 2392 return true;
2379#endif 2393#endif
2380} 2394}
2381 2395
2382 2396
2383/* 2397/*
2384 * We get something between 0..255 into us 2398 * We get something between 0..255 into us
2385*/ 2399*/
2386bool Ramses::setDisplayBrightness(int bright) 2400bool Ramses::setDisplayBrightness(int bright)
2387{ 2401{
2388 qDebug("Ramses::setDisplayBrightness(%d)", bright); 2402 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2389 bool res = false; 2403 bool res = false;
2390 int fd; 2404 int fd;
2391 2405
2392 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2406 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2393 2407
2394 if (bright > 255 ) 2408 if (bright > 255 )
2395 bright = 255; 2409 bright = 255;
2396 if (bright < 0) 2410 if (bright < 0)
2397 bright = 0; 2411 bright = 0;
2398 2412
2399 // Turn backlight completely off 2413 // Turn backlight completely off
2400 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2414 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2401 char writeCommand[10]; 2415 char writeCommand[10];
2402 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2416 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2403 res = (::write(fd, writeCommand, count) != -1); 2417 res = (::write(fd, writeCommand, count) != -1);
2404 ::close(fd); 2418 ::close(fd);
2405 } 2419 }
2406 2420
2407 // scale backlight brightness to hardware 2421 // scale backlight brightness to hardware
2408 bright = 500-(bright * 500 / 255); 2422 bright = 500-(bright * 500 / 255);
2409 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 2423 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2410 qDebug(" %d -> pwm1", bright); 2424 qDebug(" %d -> pwm1", bright);
2411 char writeCommand[100]; 2425 char writeCommand[100];
2412 const int count = sprintf(writeCommand, "%d\n", bright); 2426 const int count = sprintf(writeCommand, "%d\n", bright);
2413 res = (::write(fd, writeCommand, count) != -1); 2427 res = (::write(fd, writeCommand, count) != -1);
2414 ::close(fd); 2428 ::close(fd);
2415 } 2429 }
2416 return res; 2430 return res;
2417} 2431}
2418 2432
2419 2433
2420int Ramses::displayBrightnessResolution() const 2434int Ramses::displayBrightnessResolution() const
2421{ 2435{
2422 return 32; 2436 return 32;
2423} 2437}
2424 2438
2425bool Ramses::setDisplayContrast(int contr) 2439bool Ramses::setDisplayContrast(int contr)
2426{ 2440{
2427 qDebug("Ramses::setDisplayContrast(%d)", contr); 2441 qDebug("Ramses::setDisplayContrast(%d)", contr);
2428 bool res = false; 2442 bool res = false;
2429 int fd; 2443 int fd;
2430 2444
2431 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2445 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2432 2446
2433 if (contr > 255 ) 2447 if (contr > 255 )
2434 contr = 255; 2448 contr = 255;
2435 if (contr < 0) 2449 if (contr < 0)
2436 contr = 0; 2450 contr = 0;
2437 contr = 90 - (contr * 20 / 255); 2451 contr = 90 - (contr * 20 / 255);
2438 2452
2439 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 2453 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2440 qDebug(" %d -> pwm0", contr); 2454 qDebug(" %d -> pwm0", contr);
2441 char writeCommand[100]; 2455 char writeCommand[100];
2442 const int count = sprintf(writeCommand, "%d\n", contr); 2456 const int count = sprintf(writeCommand, "%d\n", contr);
2443 res = (::write(fd, writeCommand, count) != -1); 2457 res = (::write(fd, writeCommand, count) != -1);
2444 res = true; 2458 res = true;
2445 ::close(fd); 2459 ::close(fd);
2446 } 2460 }
2447 return res; 2461 return res;
2448} 2462}
2449 2463
2450 2464
2451int Ramses::displayContrastResolution() const 2465int Ramses::displayContrastResolution() const
2452{ 2466{
2453 return 20; 2467 return 20;
2454} 2468}
2469
2470
2471/**************************************************
2472 * *
2473 * Jornada *
2474 * *
2475 **************************************************/
2476
2477
2478bool Jornada::isJornada ( )
2479{
2480 QFile f( "/proc/cpuinfo" );
2481 if ( f. open ( IO_ReadOnly ) ) {
2482 QTextStream ts ( &f );
2483 QString line;
2484 while( line = ts. readLine ( ) ) {
2485 if ( line. left ( 8 ) == "Hardware" ) {
2486 int loc = line. find ( ":" );
2487 if ( loc != -1 ) {
2488 QString model =
2489 line. mid ( loc + 2 ). simplifyWhiteSpace( );
2490 return ( model == "HP Jornada 56x" );
2491 }
2492 }
2493 }
2494 }
2495 return false;
2496}
2497
2498void Jornada::init ( )
2499{
2500 d-> m_vendorstr = "HP";
2501 d-> m_vendor = Vendor_HP;
2502 d-> m_modelstr = "Jornada 56x";
2503 d-> m_model = Model_Jornada_56x;
2504 d-> m_systemstr = "Familiar";
2505 d-> m_system = System_Familiar;
2506 d-> m_rotation = Rot0;
2507}
2508
2509void Jornada::initButtons ( )
2510{
2511 if ( d-> m_buttons )
2512 return;
2513
2514 // Simulation uses iPAQ 3660 device buttons
2515
2516 qDebug ( "init Buttons" );
2517 d-> m_buttons = new QValueList <ODeviceButton>;
2518
2519 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
2520 i_button *ib = ipaq_buttons + i;
2521 ODeviceButton b;
2522
2523 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
2524 b. setKeycode ( ib-> code );
2525 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
2526 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
2527 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
2528 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
2529 d-> m_buttons-> append ( b );
2530 }
2531 }
2532 reloadButtonMapping ( );
2533
2534 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2535 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
2536}
2537
2538int Jornada::displayBrightnessResolution ( ) const
2539{
2540}
2541
2542bool Jornada::setDisplayBrightness ( int bright )
2543{
2544 bool res = false;
2545 int fd;
2546
2547 if ( bright > 255 )
2548 bright = 255;
2549 if ( bright < 0 )
2550 bright = 0;
2551
2552 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
2553 FLITE_IN bl;
2554 bl. mode = 1;
2555 bl. pwr = bright ? 1 : 0;
2556 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
2557 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
2558 ::close ( fd );
2559 }
2560 return res;
2561}
2562
2563bool Jornada::setSoftSuspend ( bool soft )
2564{
2565 bool res = false;
2566 int fd;
2567
2568 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
2569 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
2570 res = true;
2571 else
2572 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
2573
2574 ::close ( fd );
2575 }
2576 else
2577 ::perror ( "/proc/sys/ts/suspend_button_mode" );
2578
2579 return res;
2580}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 2a5e494..35e3eff 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,270 +1,273 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 Copyright (C) 2003 Holger 'zecke' Freyther (zecke@handhelds.org) 3 Copyright (C) 2003 Holger 'zecke' Freyther (zecke@handhelds.org)
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef _LIBOPIE_ODEVICE_H_ 21#ifndef _LIBOPIE_ODEVICE_H_
22#define _LIBOPIE_ODEVICE_H_ 22#define _LIBOPIE_ODEVICE_H_
23 23
24#include <qobject.h> 24#include <qobject.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qnamespace.h> 26#include <qnamespace.h>
27#include <qstrlist.h> 27#include <qstrlist.h>
28 28
29#include <opie/odevicebutton.h> 29#include <opie/odevicebutton.h>
30 30
31#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 31#include <qpe/qpeapplication.h> /* for Transformation enum.. */
32 32
33class ODeviceData; 33class ODeviceData;
34 34
35namespace Opie { 35namespace Opie {
36 36
37/** 37/**
38 * The available devices 38 * The available devices
39 */ 39 */
40enum OModel { 40enum OModel {
41 Model_Unknown, // = 0 41 Model_Unknown, // = 0
42 42
43 Model_Series_Mask = 0xff000000, 43 Model_Series_Mask = 0xff000000,
44 44
45 Model_iPAQ = ( 1 << 24 ), 45 Model_iPAQ = ( 1 << 24 ),
46 46
47 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 47 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
48 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 48 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
49 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 49 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
50 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 50 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
51 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 51 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
52 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 52 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
53 53
54 Model_Jornada = ( 6 << 24 ),
55 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
56
54 Model_Zaurus = ( 2 << 24 ), 57 Model_Zaurus = ( 2 << 24 ),
55 58
56 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 59 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
57 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 60 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
58 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 61 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
59 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 62 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
60 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), 63 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ),
61 64
62 Model_SIMpad = ( 3 << 24 ), 65 Model_SIMpad = ( 3 << 24 ),
63 66
64 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 67 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
65 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 68 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
66 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 69 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
67 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 70 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
68 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 71 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
69 72
70 Model_Ramses = ( 4 << 24 ), 73 Model_Ramses = ( 4 << 24 ),
71 74
72 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 75 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
73 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 76 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
74 77
75 Model_Yopy = ( 5 << 24 ), 78 Model_Yopy = ( 5 << 24 ),
76 79
77 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 80 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
78 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 81 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
79 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 82 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
80 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 83 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
81 84
82}; 85};
83 86
84/** 87/**
85 * The vendor of the device 88 * The vendor of the device
86 */ 89 */
87enum OVendor { 90enum OVendor {
88 Vendor_Unknown, 91 Vendor_Unknown,
89 92
90 Vendor_HP, 93 Vendor_HP,
91 Vendor_Sharp, 94 Vendor_Sharp,
92 Vendor_SIEMENS, 95 Vendor_SIEMENS,
93 Vendor_MundN, 96 Vendor_MundN,
94 Vendor_GMate, 97 Vendor_GMate,
95}; 98};
96 99
97/** 100/**
98 * The System used 101 * The System used
99 */ 102 */
100enum OSystem { 103enum OSystem {
101 System_Unknown, 104 System_Unknown,
102 105
103 System_Familiar, 106 System_Familiar,
104 System_Zaurus, 107 System_Zaurus,
105 System_OpenZaurus, 108 System_OpenZaurus,
106 System_Linupy, 109 System_Linupy,
107}; 110};
108 111
109enum OLedState { 112enum OLedState {
110 Led_Off, 113 Led_Off,
111 Led_On, 114 Led_On,
112 Led_BlinkSlow, 115 Led_BlinkSlow,
113 Led_BlinkFast 116 Led_BlinkFast
114}; 117};
115 118
116enum OLed { 119enum OLed {
117 Led_Mail, 120 Led_Mail,
118 Led_Power, 121 Led_Power,
119 Led_BlueTooth 122 Led_BlueTooth
120}; 123};
121 124
122enum OHardKey { 125enum OHardKey {
123 HardKey_Datebook = Qt::Key_F9, 126 HardKey_Datebook = Qt::Key_F9,
124 HardKey_Contacts = Qt::Key_F10, 127 HardKey_Contacts = Qt::Key_F10,
125 HardKey_Menu = Qt::Key_F11, 128 HardKey_Menu = Qt::Key_F11,
126 HardKey_Home = Qt::Key_F12, 129 HardKey_Home = Qt::Key_F12,
127 HardKey_Mail = Qt::Key_F13, 130 HardKey_Mail = Qt::Key_F13,
128 HardKey_Record = Qt::Key_F24, 131 HardKey_Record = Qt::Key_F24,
129 HardKey_Suspend = Qt::Key_F34, 132 HardKey_Suspend = Qt::Key_F34,
130 HardKey_Backlight = Qt::Key_F35, 133 HardKey_Backlight = Qt::Key_F35,
131 HardKey_Action = Qt::Key_F10, 134 HardKey_Action = Qt::Key_F10,
132 HardKey_OK = Qt::Key_F11, 135 HardKey_OK = Qt::Key_F11,
133 HardKey_End = Qt::Key_F12, 136 HardKey_End = Qt::Key_F12,
134}; 137};
135 138
136enum ODirection { 139enum ODirection {
137 CW = 0, 140 CW = 0,
138 CCW = 1, 141 CCW = 1,
139 Flip = 2, 142 Flip = 2,
140}; 143};
141 144
142/** 145/**
143 * A singleton which gives informations about device specefic option 146 * A singleton which gives informations about device specefic option
144 * like the Hardware used, LEDs, the Base Distribution and 147 * like the Hardware used, LEDs, the Base Distribution and
145 * hardware key mappings. 148 * hardware key mappings.
146 * 149 *
147 * @short A small class for device specefic options 150 * @short A small class for device specefic options
148 * @see QObject 151 * @see QObject
149 * @author Robert Griebl 152 * @author Robert Griebl
150 * @version 1.0 153 * @version 1.0
151 */ 154 */
152class ODevice : public QObject { 155class ODevice : public QObject {
153 Q_OBJECT 156 Q_OBJECT
154 157
155private: 158private:
156 /* disable copy */ 159 /* disable copy */
157 ODevice ( const ODevice & ); 160 ODevice ( const ODevice & );
158 161
159protected: 162protected:
160 ODevice ( ); 163 ODevice ( );
161 virtual void init ( ); 164 virtual void init ( );
162 virtual void initButtons ( ); 165 virtual void initButtons ( );
163 166
164 ODeviceData *d; 167 ODeviceData *d;
165 168
166public: 169public:
167 // sandman do we want to allow destructions? -zecke? 170 // sandman do we want to allow destructions? -zecke?
168 virtual ~ODevice ( ); 171 virtual ~ODevice ( );
169 172
170 static ODevice *inst ( ); 173 static ODevice *inst ( );
171 174
172 // information 175 // information
173 176
174 QString modelString ( ) const; 177 QString modelString ( ) const;
175 OModel model ( ) const; 178 OModel model ( ) const;
176 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 179 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
177 180
178 QString vendorString ( ) const; 181 QString vendorString ( ) const;
179 OVendor vendor ( ) const; 182 OVendor vendor ( ) const;
180 183
181 QString systemString ( ) const; 184 QString systemString ( ) const;
182 OSystem system ( ) const; 185 OSystem system ( ) const;
183 186
184 QString systemVersionString ( ) const; 187 QString systemVersionString ( ) const;
185 188
186 Transformation rotation ( ) const; 189 Transformation rotation ( ) const;
187 ODirection direction ( ) const; 190 ODirection direction ( ) const;
188 191
189// system 192// system
190 193
191 virtual bool setSoftSuspend ( bool on ); 194 virtual bool setSoftSuspend ( bool on );
192 virtual bool suspend ( ); 195 virtual bool suspend ( );
193 196
194 virtual bool setDisplayStatus ( bool on ); 197 virtual bool setDisplayStatus ( bool on );
195 virtual bool setDisplayBrightness ( int brightness ); 198 virtual bool setDisplayBrightness ( int brightness );
196 virtual int displayBrightnessResolution ( ) const; 199 virtual int displayBrightnessResolution ( ) const;
197 virtual bool setDisplayContrast ( int contrast ); 200 virtual bool setDisplayContrast ( int contrast );
198 virtual int displayContrastResolution ( ) const; 201 virtual int displayContrastResolution ( ) const;
199 202
200 // don't add new virtual methods, use this: 203 // don't add new virtual methods, use this:
201 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 204 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
202 // and in your subclass do do overwrite 205 // and in your subclass do do overwrite
203 //protected virtual int virtual_hook(int, void *) 206 //protected virtual int virtual_hook(int, void *)
204 // which is defined below 207 // which is defined below
205 208
206// input / output 209// input / output
207 //FIXME playAlarmSound and al might be better -zecke 210 //FIXME playAlarmSound and al might be better -zecke
208 virtual void alarmSound ( ); 211 virtual void alarmSound ( );
209 virtual void keySound ( ); 212 virtual void keySound ( );
210 virtual void touchSound ( ); 213 virtual void touchSound ( );
211 214
212 virtual QValueList <OLed> ledList ( ) const; 215 virtual QValueList <OLed> ledList ( ) const;
213 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 216 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
214 virtual OLedState ledState ( OLed led ) const; 217 virtual OLedState ledState ( OLed led ) const;
215 virtual bool setLedState ( OLed led, OLedState st ); 218 virtual bool setLedState ( OLed led, OLedState st );
216 219
217 virtual bool hasLightSensor ( ) const; 220 virtual bool hasLightSensor ( ) const;
218 virtual int readLightSensor ( ); 221 virtual int readLightSensor ( );
219 virtual int lightSensorResolution ( ) const; 222 virtual int lightSensorResolution ( ) const;
220 223
221 const QStrList &allowedCpuFrequencies() const; 224 const QStrList &allowedCpuFrequencies() const;
222 bool setCurrentCpuFrequency(uint index); 225 bool setCurrentCpuFrequency(uint index);
223 226
224 /** 227 /**
225 * Returns the available buttons on this device. The number and location 228 * Returns the available buttons on this device. The number and location
226 * of buttons will vary depending on the device. Button numbers will be assigned 229 * of buttons will vary depending on the device. Button numbers will be assigned
227 * by the device manufacturer and will be from most preferred button to least preffered 230 * by the device manufacturer and will be from most preferred button to least preffered
228 * button. Note that this list only contains "user mappable" buttons. 231 * button. Note that this list only contains "user mappable" buttons.
229 */ 232 */
230 const QValueList<ODeviceButton> &buttons ( ) /* ### make const */; 233 const QValueList<ODeviceButton> &buttons ( ) /* ### make const */;
231 234
232 /** 235 /**
233 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 236 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
234 * returns 0L 237 * returns 0L
235 */ 238 */
236 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 239 const ODeviceButton *buttonForKeycode ( ushort keyCode );
237 240
238 /** 241 /**
239 * Reassigns the pressed action for \a button. To return to the factory 242 * Reassigns the pressed action for \a button. To return to the factory
240 * default pass an empty string as \a qcopMessage. 243 * default pass an empty string as \a qcopMessage.
241 */ 244 */
242 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 245 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
243 246
244 /** 247 /**
245 * Reassigns the held action for \a button. To return to the factory 248 * Reassigns the held action for \a button. To return to the factory
246 * default pass an empty string as \a qcopMessage. 249 * default pass an empty string as \a qcopMessage.
247 */ 250 */
248 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 251 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
249 252
250 /** 253 /**
251 * How long (in ms) you have to press a button for a "hold" action 254 * How long (in ms) you have to press a button for a "hold" action
252 */ 255 */
253 uint buttonHoldTime ( ) const; 256 uint buttonHoldTime ( ) const;
254 257
255signals: 258signals:
256 void buttonMappingChanged ( ); 259 void buttonMappingChanged ( );
257 260
258private slots: 261private slots:
259 void systemMessage ( const QCString &, const QByteArray & ); 262 void systemMessage ( const QCString &, const QByteArray & );
260 263
261protected: 264protected:
262 void reloadButtonMapping ( ); 265 void reloadButtonMapping ( );
263 /* ugly virtual hook */ 266 /* ugly virtual hook */
264 virtual void virtual_hook( int id, void* data ); 267 virtual void virtual_hook( int id, void* data );
265}; 268};
266 269
267} 270}
268 271
269#endif 272#endif
270 273