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