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