summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp225
-rw-r--r--libopie/odevice.h2
2 files changed, 142 insertions, 85 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index d86654e..160568b 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,929 +1,955 @@
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 { 164class Ramses : public ODevice, public QWSServer::KeyboardFilter {
165protected: 165protected:
166 virtual void init ( ); 166 virtual void init ( );
167 virtual void initButtons ( );
168 167
169public: 168public:
170 virtual bool setSoftSuspend ( bool soft ); 169 virtual bool setSoftSuspend ( bool soft );
170 virtual bool suspend ( );
171 171
172 virtual bool setDisplayStatus( bool on ); 172 virtual bool setDisplayStatus( bool on );
173 virtual bool setDisplayBrightness ( int b ); 173 virtual bool setDisplayBrightness ( int b );
174 virtual int displayBrightnessResolution ( ) const; 174 virtual int displayBrightnessResolution ( ) const;
175 virtual bool setDisplayContrast ( int b );
176 virtual int displayContrastResolution ( ) const;
175 177
176protected: 178protected:
177 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 179 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
178 virtual void timerEvent ( QTimerEvent *te ); 180 virtual void timerEvent ( QTimerEvent *te );
179 181
180 int m_power_timer; 182 int m_power_timer;
181}; 183};
182 184
183struct i_button { 185struct i_button {
184 uint model; 186 uint model;
185 Qt::Key code; 187 Qt::Key code;
186 char *utext; 188 char *utext;
187 char *pix; 189 char *pix;
188 char *fpressedservice; 190 char *fpressedservice;
189 char *fpressedaction; 191 char *fpressedaction;
190 char *fheldservice; 192 char *fheldservice;
191 char *fheldaction; 193 char *fheldaction;
192} ipaq_buttons [] = { 194} ipaq_buttons [] = {
193 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 195 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
194 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 196 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
195 "devicebuttons/ipaq_calendar", 197 "devicebuttons/ipaq_calendar",
196 "datebook", "nextView()", 198 "datebook", "nextView()",
197 "today", "raise()" }, 199 "today", "raise()" },
198 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 200 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
199 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 201 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
200 "devicebuttons/ipaq_contact", 202 "devicebuttons/ipaq_contact",
201 "addressbook", "raise()", 203 "addressbook", "raise()",
202 "addressbook", "beamBusinessCard()" }, 204 "addressbook", "beamBusinessCard()" },
203 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 205 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
204 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 206 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
205 "devicebuttons/ipaq_menu", 207 "devicebuttons/ipaq_menu",
206 "QPE/TaskBar", "toggleMenu()", 208 "QPE/TaskBar", "toggleMenu()",
207 "QPE/TaskBar", "toggleStartMenu()" }, 209 "QPE/TaskBar", "toggleStartMenu()" },
208 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 210 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
209 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 211 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
210 "devicebuttons/ipaq_mail", 212 "devicebuttons/ipaq_mail",
211 "mail", "raise()", 213 "mail", "raise()",
212 "mail", "newMail()" }, 214 "mail", "newMail()" },
213 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 215 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
214 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 216 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
215 "devicebuttons/ipaq_home", 217 "devicebuttons/ipaq_home",
216 "QPE/Launcher", "home()", 218 "QPE/Launcher", "home()",
217 "buttonsettings", "raise()" }, 219 "buttonsettings", "raise()" },
218 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
219 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 221 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
220 "devicebuttons/ipaq_record", 222 "devicebuttons/ipaq_record",
221 "QPE/VMemo", "toggleRecord()", 223 "QPE/VMemo", "toggleRecord()",
222 "sound", "raise()" }, 224 "sound", "raise()" },
223}; 225};
224 226
225struct z_button { 227struct z_button {
226 Qt::Key code; 228 Qt::Key code;
227 char *utext; 229 char *utext;
228 char *pix; 230 char *pix;
229 char *fpressedservice; 231 char *fpressedservice;
230 char *fpressedaction; 232 char *fpressedaction;
231 char *fheldservice; 233 char *fheldservice;
232 char *fheldaction; 234 char *fheldaction;
233} z_buttons [] = { 235} z_buttons [] = {
234 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 236 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
235 "devicebuttons/z_calendar", 237 "devicebuttons/z_calendar",
236 "datebook", "nextView()", 238 "datebook", "nextView()",
237 "today", "raise()" }, 239 "today", "raise()" },
238 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 240 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
239 "devicebuttons/z_contact", 241 "devicebuttons/z_contact",
240 "addressbook", "raise()", 242 "addressbook", "raise()",
241 "addressbook", "beamBusinessCard()" }, 243 "addressbook", "beamBusinessCard()" },
242 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 244 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
243 "devicebuttons/z_home", 245 "devicebuttons/z_home",
244 "QPE/Launcher", "home()", 246 "QPE/Launcher", "home()",
245 "buttonsettings", "raise()" }, 247 "buttonsettings", "raise()" },
246 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 248 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
247 "devicebuttons/z_menu", 249 "devicebuttons/z_menu",
248 "QPE/TaskBar", "toggleMenu()", 250 "QPE/TaskBar", "toggleMenu()",
249 "QPE/TaskBar", "toggleStartMenu()" }, 251 "QPE/TaskBar", "toggleStartMenu()" },
250 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 252 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
251 "devicebuttons/z_mail", 253 "devicebuttons/z_mail",
252 "mail", "raise()", 254 "mail", "raise()",
253 "mail", "newMail()" }, 255 "mail", "newMail()" },
254}; 256};
255 257
256struct z_button z_buttons_c700 [] = { 258struct z_button z_buttons_c700 [] = {
257 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 259 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
258 "devicebuttons/z_calendar", 260 "devicebuttons/z_calendar",
259 "datebook", "nextView()", 261 "datebook", "nextView()",
260 "today", "raise()" }, 262 "today", "raise()" },
261 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 263 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
262 "devicebuttons/z_contact", 264 "devicebuttons/z_contact",
263 "addressbook", "raise()", 265 "addressbook", "raise()",
264 "addressbook", "beamBusinessCard()" }, 266 "addressbook", "beamBusinessCard()" },
265 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 267 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
266 "devicebuttons/z_home", 268 "devicebuttons/z_home",
267 "QPE/Launcher", "home()", 269 "QPE/Launcher", "home()",
268 "buttonsettings", "raise()" }, 270 "buttonsettings", "raise()" },
269 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 271 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
270 "devicebuttons/z_menu", 272 "devicebuttons/z_menu",
271 "QPE/TaskBar", "toggleMenu()", 273 "QPE/TaskBar", "toggleMenu()",
272 "QPE/TaskBar", "toggleStartMenu()" }, 274 "QPE/TaskBar", "toggleStartMenu()" },
273 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 275 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
274 "", 276 "",
275 "QPE/Rotation", "flip()", 277 "QPE/Rotation", "flip()",
276 "QPE/Rotation", "flip()" }, 278 "QPE/Rotation", "flip()" },
277}; 279};
278 280
279struct s_button { 281struct s_button {
280 uint model; 282 uint model;
281 Qt::Key code; 283 Qt::Key code;
282 char *utext; 284 char *utext;
283 char *pix; 285 char *pix;
284 char *fpressedservice; 286 char *fpressedservice;
285 char *fpressedaction; 287 char *fpressedaction;
286 char *fheldservice; 288 char *fheldservice;
287 char *fheldaction; 289 char *fheldaction;
288} simpad_buttons [] = { 290} simpad_buttons [] = {
289 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 291 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
290 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 292 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
291 "devicebuttons/simpad_lower_up", 293 "devicebuttons/simpad_lower_up",
292 "datebook", "nextView()", 294 "datebook", "nextView()",
293 "today", "raise()" }, 295 "today", "raise()" },
294 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 296 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
295 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 297 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
296 "devicebuttons/simpad_lower_down", 298 "devicebuttons/simpad_lower_down",
297 "addressbook", "raise()", 299 "addressbook", "raise()",
298 "addressbook", "beamBusinessCard()" }, 300 "addressbook", "beamBusinessCard()" },
299 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 301 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
300 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 302 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
301 "devicebuttons/simpad_lower_right", 303 "devicebuttons/simpad_lower_right",
302 "QPE/TaskBar", "toggleMenu()", 304 "QPE/TaskBar", "toggleMenu()",
303 "QPE/TaskBar", "toggleStartMenu()" }, 305 "QPE/TaskBar", "toggleStartMenu()" },
304 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 306 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
305 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 307 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
306 "devicebuttons/simpad_lower_left", 308 "devicebuttons/simpad_lower_left",
307 "mail", "raise()", 309 "mail", "raise()",
308 "mail", "newMail()" }, 310 "mail", "newMail()" },
309 311
310 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 312 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
311 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 313 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
312 "devicebuttons/simpad_upper_up", 314 "devicebuttons/simpad_upper_up",
313 "QPE/Launcher", "home()", 315 "QPE/Launcher", "home()",
314 "buttonsettings", "raise()" }, 316 "buttonsettings", "raise()" },
315 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 317 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
316 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 318 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
317 "devicebuttons/simpad_upper_down", 319 "devicebuttons/simpad_upper_down",
318 "addressbook", "raise()", 320 "addressbook", "raise()",
319 "addressbook", "beamBusinessCard()" }, 321 "addressbook", "beamBusinessCard()" },
320 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 322 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
321 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 323 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
322 "devicebuttons/simpad_upper_right", 324 "devicebuttons/simpad_upper_right",
323 "QPE/TaskBar", "toggleMenu()", 325 "QPE/TaskBar", "toggleMenu()",
324 "QPE/TaskBar", "toggleStartMenu()" }, 326 "QPE/TaskBar", "toggleStartMenu()" },
325 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
326 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 328 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
327 "devicebuttons/simpad_upper_left", 329 "devicebuttons/simpad_upper_left",
328 "QPE/Rotation", "flip()", 330 "QPE/Rotation", "flip()",
329 "QPE/Rotation", "flip()" }, 331 "QPE/Rotation", "flip()" },
330 /* 332 /*
331 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 333 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
332 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 334 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
333 "devicebuttons/simpad_lower_upper", 335 "devicebuttons/simpad_lower_upper",
334 "QPE/Launcher", "home()", 336 "QPE/Launcher", "home()",
335 "buttonsettings", "raise()" }, 337 "buttonsettings", "raise()" },
336 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 338 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
337 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 339 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
338 "devicebuttons/simpad_upper_lower", 340 "devicebuttons/simpad_upper_lower",
339 "QPE/Launcher", "home()", 341 "QPE/Launcher", "home()",
340 "buttonsettings", "raise()" }, 342 "buttonsettings", "raise()" },
341 */ 343 */
342}; 344};
343 345
344struct r_button { 346struct r_button {
345 uint model; 347 uint model;
346 Qt::Key code; 348 Qt::Key code;
347 char *utext; 349 char *utext;
348 char *pix; 350 char *pix;
349 char *fpressedservice; 351 char *fpressedservice;
350 char *fpressedaction; 352 char *fpressedaction;
351 char *fheldservice; 353 char *fheldservice;
352 char *fheldaction; 354 char *fheldaction;
353} ramses_buttons [] = { 355} ramses_buttons [] = {
354 { Model_Ramses_MNCI, 356 { Model_Ramses_MNCI,
355 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 357 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
356 "devicebuttons/simpad_menu", 358 "devicebuttons/z_menu",
357 "QPE/TaskBar", "toggleMenu()", 359 "QPE/TaskBar", "toggleMenu()",
358 "QPE/TaskBar", "toggleStartMenu()" }, 360 "QPE/TaskBar", "toggleStartMenu()" },
359 { Model_Ramses_MNCI, 361 { Model_Ramses_MNCI,
360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 362 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
361 "devicebuttons/ipaq_home", 363 "devicebuttons/ipaq_home",
362 "QPE/Launcher", "home()", 364 "QPE/Launcher", "home()",
363 "buttonsettings", "raise()" }, 365 "buttonsettings", "raise()" },
364}; 366};
365 367
366static QCString makeChannel ( const char *str ) 368static QCString makeChannel ( const char *str )
367{ 369{
368 if ( str && !::strchr ( str, '/' )) 370 if ( str && !::strchr ( str, '/' ))
369 return QCString ( "QPE/Application/" ) + str; 371 return QCString ( "QPE/Application/" ) + str;
370 else 372 else
371 return str; 373 return str;
372} 374}
373 375
374static inline bool isQWS() 376static inline bool isQWS()
375{ 377{
376 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 378 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
377} 379}
378 380
379ODevice *ODevice::inst ( ) 381ODevice *ODevice::inst ( )
380{ 382{
381 static ODevice *dev = 0; 383 static ODevice *dev = 0;
382 384
383 if ( !dev ) { 385 if ( !dev ) {
384 if ( QFile::exists ( "/proc/hal/model" )) 386 if ( QFile::exists ( "/proc/hal/model" ))
385 dev = new iPAQ ( ); 387 dev = new iPAQ ( );
386 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 388 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
387 dev = new Zaurus ( ); 389 dev = new Zaurus ( );
388 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 390 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
389 dev = new SIMpad ( ); 391 dev = new SIMpad ( );
390 else if ( QFile::exists ( "/proc/sys/board/name" )) 392 else if ( QFile::exists ( "/proc/sys/board/name" ))
391 dev = new Ramses ( ); 393 dev = new Ramses ( );
392 else 394 else
393 dev = new ODevice ( ); 395 dev = new ODevice ( );
394 396
395 dev-> init ( ); 397 dev-> init ( );
396 } 398 }
397 return dev; 399 return dev;
398} 400}
399 401
400 402
401/************************************************** 403/**************************************************
402 * 404 *
403 * common 405 * common
404 * 406 *
405 **************************************************/ 407 **************************************************/
406 408
407 409
408ODevice::ODevice ( ) 410ODevice::ODevice ( )
409{ 411{
410 d = new ODeviceData; 412 d = new ODeviceData;
411 413
412 d-> m_modelstr = "Unknown"; 414 d-> m_modelstr = "Unknown";
413 d-> m_model = Model_Unknown; 415 d-> m_model = Model_Unknown;
414 d-> m_vendorstr = "Unknown"; 416 d-> m_vendorstr = "Unknown";
415 d-> m_vendor = Vendor_Unknown; 417 d-> m_vendor = Vendor_Unknown;
416 d-> m_systemstr = "Unknown"; 418 d-> m_systemstr = "Unknown";
417 d-> m_system = System_Unknown; 419 d-> m_system = System_Unknown;
418 d-> m_sysverstr = "0.0"; 420 d-> m_sysverstr = "0.0";
419 d-> m_rotation = Rot0; 421 d-> m_rotation = Rot0;
420 d-> m_direction = CW; 422 d-> m_direction = CW;
421 423
422 d-> m_holdtime = 1000; // 1000ms 424 d-> m_holdtime = 1000; // 1000ms
423 d-> m_buttons = 0; 425 d-> m_buttons = 0;
424} 426}
425 427
426void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 428void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
427{ 429{
428 if ( msg == "deviceButtonMappingChanged()" ) { 430 if ( msg == "deviceButtonMappingChanged()" ) {
429 reloadButtonMapping ( ); 431 reloadButtonMapping ( );
430 } 432 }
431} 433}
432 434
433void ODevice::init ( ) 435void ODevice::init ( )
434{ 436{
435} 437}
436 438
437/** 439/**
438 * This method initialises the button mapping 440 * This method initialises the button mapping
439 */ 441 */
440void ODevice::initButtons ( ) 442void ODevice::initButtons ( )
441{ 443{
442 if ( d-> m_buttons ) 444 if ( d-> m_buttons )
443 return; 445 return;
444 446
445 // Simulation uses iPAQ 3660 device buttons 447 // Simulation uses iPAQ 3660 device buttons
446 448
447 qDebug ( "init Buttons" ); 449 qDebug ( "init Buttons" );
448 d-> m_buttons = new QValueList <ODeviceButton>; 450 d-> m_buttons = new QValueList <ODeviceButton>;
449 451
450 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 452 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
451 i_button *ib = ipaq_buttons + i; 453 i_button *ib = ipaq_buttons + i;
452 ODeviceButton b; 454 ODeviceButton b;
453 455
454 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 456 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
455 b. setKeycode ( ib-> code ); 457 b. setKeycode ( ib-> code );
456 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 458 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
457 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 459 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
458 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 460 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
459 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 461 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
460 d-> m_buttons-> append ( b ); 462 d-> m_buttons-> append ( b );
461 } 463 }
462 } 464 }
463 reloadButtonMapping ( ); 465 reloadButtonMapping ( );
464 466
465 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 467 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
466 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 468 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
467} 469}
468 470
469ODevice::~ODevice ( ) 471ODevice::~ODevice ( )
470{ 472{
471 delete d; 473 delete d;
472} 474}
473 475
474bool ODevice::setSoftSuspend ( bool /*soft*/ ) 476bool ODevice::setSoftSuspend ( bool /*soft*/ )
475{ 477{
476 return false; 478 return false;
477} 479}
478 480
479//#include <linux/apm_bios.h> 481//#include <linux/apm_bios.h>
480 482
481#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 483#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
482 484
483/** 485/**
484 * This method will try to suspend the device 486 * This method will try to suspend the device
485 * It only works if the user is the QWS Server and the apm application 487 * It only works if the user is the QWS Server and the apm application
486 * is installed. 488 * is installed.
487 * It tries to suspend and then waits some time cause some distributions 489 * It tries to suspend and then waits some time cause some distributions
488 * do have asynchronus apm implementations. 490 * do have asynchronus apm implementations.
489 * This method will either fail and return false or it'll suspend the 491 * This method will either fail and return false or it'll suspend the
490 * device and return once the device got woken up 492 * device and return once the device got woken up
491 * 493 *
492 * @return if the device got suspended 494 * @return if the device got suspended
493 */ 495 */
494bool ODevice::suspend ( ) 496bool ODevice::suspend ( )
495{ 497{
498 qDebug("ODevice::suspend");
496 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 499 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
497 return false; 500 return false;
498 501
499 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 502 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
500 return false; 503 return false;
501 504
502 bool res = false; 505 bool res = false;
503 506
504 struct timeval tvs, tvn; 507 struct timeval tvs, tvn;
505 ::gettimeofday ( &tvs, 0 ); 508 ::gettimeofday ( &tvs, 0 );
506 509
507 ::sync ( ); // flush fs caches 510 ::sync ( ); // flush fs caches
508 res = ( ::system ( "apm --suspend" ) == 0 ); 511 res = ( ::system ( "apm --suspend" ) == 0 );
509 512
510 // This is needed because the iPAQ apm implementation is asynchronous and we 513 // This is needed because the iPAQ apm implementation is asynchronous and we
511 // can not be sure when exactly the device is really suspended 514 // can not be sure when exactly the device is really suspended
512 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 515 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
513 516
514 if ( res ) { 517 if ( res ) {
515 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 518 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
516 ::usleep ( 200 * 1000 ); 519 ::usleep ( 200 * 1000 );
517 ::gettimeofday ( &tvn, 0 ); 520 ::gettimeofday ( &tvn, 0 );
518 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 521 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
519 } 522 }
520 523
521 return res; 524 return res;
522} 525}
523 526
524//#include <linux/fb.h> better not rely on kernel headers in userspace ... 527//#include <linux/fb.h> better not rely on kernel headers in userspace ...
525 528
526#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 529#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
527 530
528/* VESA Blanking Levels */ 531/* VESA Blanking Levels */
529#define VESA_NO_BLANKING 0 532#define VESA_NO_BLANKING 0
530#define VESA_VSYNC_SUSPEND 1 533#define VESA_VSYNC_SUSPEND 1
531#define VESA_HSYNC_SUSPEND 2 534#define VESA_HSYNC_SUSPEND 2
532#define VESA_POWERDOWN 3 535#define VESA_POWERDOWN 3
533 536
534/** 537/**
535 * This sets the display on or off 538 * This sets the display on or off
536 */ 539 */
537bool ODevice::setDisplayStatus ( bool on ) 540bool ODevice::setDisplayStatus ( bool on )
538{ 541{
542 qDebug("ODevice::setDisplayStatus(%d)", on);
543
539 if ( d-> m_model == Model_Unknown ) 544 if ( d-> m_model == Model_Unknown )
540 return false; 545 return false;
541 546
542 bool res = false; 547 bool res = false;
543 int fd; 548 int fd;
544 549
545 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 550 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
546 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 551 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
547 ::close ( fd ); 552 ::close ( fd );
548 } 553 }
549 return res; 554 return res;
550} 555}
551 556
552/** 557/**
553 * This sets the display brightness 558 * This sets the display brightness
554 * @return success or failure 559 * @return success or failure
555 */ 560 */
556bool ODevice::setDisplayBrightness ( int p) 561bool ODevice::setDisplayBrightness ( int p)
557{ 562{
558 Q_UNUSED( p ) 563 Q_UNUSED( p )
559 return false; 564 return false;
560} 565}
561 566
567/**
568 * @return return the max value for the brightness settings slider
569 */
562int ODevice::displayBrightnessResolution ( ) const 570int ODevice::displayBrightnessResolution ( ) const
563{ 571{
564 return 16; 572 return 16;
565} 573}
566 574
567/** 575/**
576 * This sets the display contrast
577 * @return success or failure
578 */
579bool ODevice::setDisplayContrast ( int p)
580{
581 Q_UNUSED( p )
582 return false;
583}
584
585/**
586 * @return return the max value for the brightness settings slider
587 * or 0 if the device doesn't support setting of a contrast
588 */
589int ODevice::displayContrastResolution ( ) const
590{
591 return 0;
592}
593
594/**
568 * This returns the vendor as string 595 * This returns the vendor as string
569 * @return Vendor as QString 596 * @return Vendor as QString
570 */ 597 */
571QString ODevice::vendorString ( ) const 598QString ODevice::vendorString ( ) const
572{ 599{
573 return d-> m_vendorstr; 600 return d-> m_vendorstr;
574} 601}
575 602
576/** 603/**
577 * This returns the vendor as one of the values of OVendor 604 * This returns the vendor as one of the values of OVendor
578 * @return OVendor 605 * @return OVendor
579 */ 606 */
580OVendor ODevice::vendor ( ) const 607OVendor ODevice::vendor ( ) const
581{ 608{
582 return d-> m_vendor; 609 return d-> m_vendor;
583} 610}
584 611
585/** 612/**
586 * This returns the model as a string 613 * This returns the model as a string
587 * @return A string representing the model 614 * @return A string representing the model
588 */ 615 */
589QString ODevice::modelString ( ) const 616QString ODevice::modelString ( ) const
590{ 617{
591 return d-> m_modelstr; 618 return d-> m_modelstr;
592} 619}
593 620
594/** 621/**
595 * This does return the OModel used 622 * This does return the OModel used
596 */ 623 */
597OModel ODevice::model ( ) const 624OModel ODevice::model ( ) const
598{ 625{
599 return d-> m_model; 626 return d-> m_model;
600} 627}
601 628
602/** 629/**
603 * This does return the systen name 630 * This does return the systen name
604 */ 631 */
605QString ODevice::systemString ( ) const 632QString ODevice::systemString ( ) const
606{ 633{
607 return d-> m_systemstr; 634 return d-> m_systemstr;
608} 635}
609 636
610/** 637/**
611 * Return System as OSystem value 638 * Return System as OSystem value
612 */ 639 */
613OSystem ODevice::system ( ) const 640OSystem ODevice::system ( ) const
614{ 641{
615 return d-> m_system; 642 return d-> m_system;
616} 643}
617 644
618/** 645/**
619 * @return the version string of the base system 646 * @return the version string of the base system
620 */ 647 */
621QString ODevice::systemVersionString ( ) const 648QString ODevice::systemVersionString ( ) const
622{ 649{
623 return d-> m_sysverstr; 650 return d-> m_sysverstr;
624} 651}
625 652
626/** 653/**
627 * @return the current Transformation 654 * @return the current Transformation
628 */ 655 */
629Transformation ODevice::rotation ( ) const 656Transformation ODevice::rotation ( ) const
630{ 657{
631 return d-> m_rotation; 658 return d-> m_rotation;
632} 659}
633 660
634/** 661/**
635 * @return the current rotation direction 662 * @return the current rotation direction
636 */ 663 */
637ODirection ODevice::direction ( ) const 664ODirection ODevice::direction ( ) const
638{ 665{
639 return d-> m_direction; 666 return d-> m_direction;
640} 667}
641 668
642/** 669/**
643 * This plays an alarmSound 670 * This plays an alarmSound
644 */ 671 */
645void ODevice::alarmSound ( ) 672void ODevice::alarmSound ( )
646{ 673{
647#ifndef QT_NO_SOUND 674#ifndef QT_NO_SOUND
648 static Sound snd ( "alarm" ); 675 static Sound snd ( "alarm" );
649 676
650 if ( snd. isFinished ( )) 677 if ( snd. isFinished ( ))
651 snd. play ( ); 678 snd. play ( );
652#endif 679#endif
653} 680}
654 681
655/** 682/**
656 * This plays a key sound 683 * This plays a key sound
657 */ 684 */
658void ODevice::keySound ( ) 685void ODevice::keySound ( )
659{ 686{
660#ifndef QT_NO_SOUND 687#ifndef QT_NO_SOUND
661 static Sound snd ( "keysound" ); 688 static Sound snd ( "keysound" );
662 689
663 if ( snd. isFinished ( )) 690 if ( snd. isFinished ( ))
664 snd. play ( ); 691 snd. play ( );
665#endif 692#endif
666} 693}
667 694
668/** 695/**
669 * This plays a touch sound 696 * This plays a touch sound
670 */ 697 */
671void ODevice::touchSound ( ) 698void ODevice::touchSound ( )
672{ 699{
673
674#ifndef QT_NO_SOUND 700#ifndef QT_NO_SOUND
675 static Sound snd ( "touchsound" ); 701 static Sound snd ( "touchsound" );
676 702
677 if ( snd. isFinished ( )) 703 if ( snd. isFinished ( ))
678 snd. play ( ); 704 snd. play ( );
679#endif 705#endif
680} 706}
681 707
682/** 708/**
683 * This method will return a list of leds 709 * This method will return a list of leds
684 * available on this device 710 * available on this device
685 * @return a list of LEDs. 711 * @return a list of LEDs.
686 */ 712 */
687QValueList <OLed> ODevice::ledList ( ) const 713QValueList <OLed> ODevice::ledList ( ) const
688{ 714{
689 return QValueList <OLed> ( ); 715 return QValueList <OLed> ( );
690} 716}
691 717
692/** 718/**
693 * This does return the state of the LEDs 719 * This does return the state of the LEDs
694 */ 720 */
695QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 721QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
696{ 722{
697 return QValueList <OLedState> ( ); 723 return QValueList <OLedState> ( );
698} 724}
699 725
700/** 726/**
701 * @return the state for a given OLed 727 * @return the state for a given OLed
702 */ 728 */
703OLedState ODevice::ledState ( OLed /*which*/ ) const 729OLedState ODevice::ledState ( OLed /*which*/ ) const
704{ 730{
705 return Led_Off; 731 return Led_Off;
706} 732}
707 733
708/** 734/**
709 * Set the state for a LED 735 * Set the state for a LED
710 * @param which Which OLed to use 736 * @param which Which OLed to use
711 * @param st The state to set 737 * @param st The state to set
712 * @return success or failure 738 * @return success or failure
713 */ 739 */
714bool ODevice::setLedState ( OLed which, OLedState st ) 740bool ODevice::setLedState ( OLed which, OLedState st )
715{ 741{
716 Q_UNUSED( which ) 742 Q_UNUSED( which )
717 Q_UNUSED( st ) 743 Q_UNUSED( st )
718 return false; 744 return false;
719} 745}
720 746
721/** 747/**
722 * @return if the device has a light sensor 748 * @return if the device has a light sensor
723 */ 749 */
724bool ODevice::hasLightSensor ( ) const 750bool ODevice::hasLightSensor ( ) const
725{ 751{
726 return false; 752 return false;
727} 753}
728 754
729/** 755/**
730 * @return a value from the light senso 756 * @return a value from the light senso
731 */ 757 */
732int ODevice::readLightSensor ( ) 758int ODevice::readLightSensor ( )
733{ 759{
734 return -1; 760 return -1;
735} 761}
736 762
737/** 763/**
738 * @return the light sensor resolution whatever that is ;) 764 * @return the light sensor resolution whatever that is ;)
739 */ 765 */
740int ODevice::lightSensorResolution ( ) const 766int ODevice::lightSensorResolution ( ) const
741{ 767{
742 return 0; 768 return 0;
743} 769}
744 770
745/** 771/**
746 * @return a list of hardware buttons 772 * @return a list of hardware buttons
747 */ 773 */
748const QValueList <ODeviceButton> &ODevice::buttons ( ) 774const QValueList <ODeviceButton> &ODevice::buttons ( )
749{ 775{
750 initButtons ( ); 776 initButtons ( );
751 777
752 return *d-> m_buttons; 778 return *d-> m_buttons;
753} 779}
754 780
755/** 781/**
756 * @return The amount of time that would count as a hold 782 * @return The amount of time that would count as a hold
757 */ 783 */
758uint ODevice::buttonHoldTime ( ) const 784uint ODevice::buttonHoldTime ( ) const
759{ 785{
760 return d-> m_holdtime; 786 return d-> m_holdtime;
761} 787}
762 788
763/** 789/**
764 * This method return a ODeviceButton for a key code 790 * This method return a ODeviceButton for a key code
765 * or 0 if no special hardware button is available for the device 791 * or 0 if no special hardware button is available for the device
766 * 792 *
767 * @return The devicebutton or 0l 793 * @return The devicebutton or 0l
768 * @see ODeviceButton 794 * @see ODeviceButton
769 */ 795 */
770const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 796const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
771{ 797{
772 initButtons ( ); 798 initButtons ( );
773 799
774 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 800 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
775 if ( (*it). keycode ( ) == code ) 801 if ( (*it). keycode ( ) == code )
776 return &(*it); 802 return &(*it);
777 } 803 }
778 return 0; 804 return 0;
779} 805}
780 806
781void ODevice::reloadButtonMapping ( ) 807void ODevice::reloadButtonMapping ( )
782{ 808{
783 initButtons ( ); 809 initButtons ( );
784 810
785 Config cfg ( "ButtonSettings" ); 811 Config cfg ( "ButtonSettings" );
786 812
787 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 813 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
788 ODeviceButton &b = ( *d-> m_buttons ) [i]; 814 ODeviceButton &b = ( *d-> m_buttons ) [i];
789 QString group = "Button" + QString::number ( i ); 815 QString group = "Button" + QString::number ( i );
790 816
791 QCString pch, hch; 817 QCString pch, hch;
792 QCString pm, hm; 818 QCString pm, hm;
793 QByteArray pdata, hdata; 819 QByteArray pdata, hdata;
794 820
795 if ( cfg. hasGroup ( group )) { 821 if ( cfg. hasGroup ( group )) {
796 cfg. setGroup ( group ); 822 cfg. setGroup ( group );
797 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 823 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
798 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 824 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
799 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 825 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
800 826
801 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 827 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
802 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 828 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
803 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 829 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
804 } 830 }
805 831
806 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 832 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
807 833
808 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 834 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
809 } 835 }
810} 836}
811 837
812void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 838void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
813{ 839{
814 initButtons ( ); 840 initButtons ( );
815 841
816 QString mb_chan; 842 QString mb_chan;
817 843
818 if ( button >= (int) d-> m_buttons-> count ( )) 844 if ( button >= (int) d-> m_buttons-> count ( ))
819 return; 845 return;
820 846
821 ODeviceButton &b = ( *d-> m_buttons ) [button]; 847 ODeviceButton &b = ( *d-> m_buttons ) [button];
822 b. setPressedAction ( action ); 848 b. setPressedAction ( action );
823 849
824 mb_chan=b. pressedAction ( ). channel ( ); 850 mb_chan=b. pressedAction ( ). channel ( );
825 851
826 Config buttonFile ( "ButtonSettings" ); 852 Config buttonFile ( "ButtonSettings" );
827 buttonFile. setGroup ( "Button" + QString::number ( button )); 853 buttonFile. setGroup ( "Button" + QString::number ( button ));
828 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 854 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
829 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 855 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
830 856
831 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 857 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
832 858
833 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 859 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
834} 860}
835 861
836void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 862void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
837{ 863{
838 initButtons ( ); 864 initButtons ( );
839 865
840 if ( button >= (int) d-> m_buttons-> count ( )) 866 if ( button >= (int) d-> m_buttons-> count ( ))
841 return; 867 return;
842 868
843 ODeviceButton &b = ( *d-> m_buttons ) [button]; 869 ODeviceButton &b = ( *d-> m_buttons ) [button];
844 b. setHeldAction ( action ); 870 b. setHeldAction ( action );
845 871
846 Config buttonFile ( "ButtonSettings" ); 872 Config buttonFile ( "ButtonSettings" );
847 buttonFile. setGroup ( "Button" + QString::number ( button )); 873 buttonFile. setGroup ( "Button" + QString::number ( button ));
848 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 874 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
849 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 875 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
850 876
851 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 877 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
852 878
853 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 879 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
854} 880}
855 881
856 882
857 883
858 884
859/************************************************** 885/**************************************************
860 * 886 *
861 * iPAQ 887 * iPAQ
862 * 888 *
863 **************************************************/ 889 **************************************************/
864 890
865void iPAQ::init ( ) 891void iPAQ::init ( )
866{ 892{
867 d-> m_vendorstr = "HP"; 893 d-> m_vendorstr = "HP";
868 d-> m_vendor = Vendor_HP; 894 d-> m_vendor = Vendor_HP;
869 895
870 QFile f ( "/proc/hal/model" ); 896 QFile f ( "/proc/hal/model" );
871 897
872 if ( f. open ( IO_ReadOnly )) { 898 if ( f. open ( IO_ReadOnly )) {
873 QTextStream ts ( &f ); 899 QTextStream ts ( &f );
874 900
875 d-> m_modelstr = "H" + ts. readLine ( ); 901 d-> m_modelstr = "H" + ts. readLine ( );
876 902
877 if ( d-> m_modelstr == "H3100" ) 903 if ( d-> m_modelstr == "H3100" )
878 d-> m_model = Model_iPAQ_H31xx; 904 d-> m_model = Model_iPAQ_H31xx;
879 else if ( d-> m_modelstr == "H3600" ) 905 else if ( d-> m_modelstr == "H3600" )
880 d-> m_model = Model_iPAQ_H36xx; 906 d-> m_model = Model_iPAQ_H36xx;
881 else if ( d-> m_modelstr == "H3700" ) 907 else if ( d-> m_modelstr == "H3700" )
882 d-> m_model = Model_iPAQ_H37xx; 908 d-> m_model = Model_iPAQ_H37xx;
883 else if ( d-> m_modelstr == "H3800" ) 909 else if ( d-> m_modelstr == "H3800" )
884 d-> m_model = Model_iPAQ_H38xx; 910 d-> m_model = Model_iPAQ_H38xx;
885 else if ( d-> m_modelstr == "H3900" ) 911 else if ( d-> m_modelstr == "H3900" )
886 d-> m_model = Model_iPAQ_H39xx; 912 d-> m_model = Model_iPAQ_H39xx;
887 else 913 else
888 d-> m_model = Model_Unknown; 914 d-> m_model = Model_Unknown;
889 915
890 f. close ( ); 916 f. close ( );
891 } 917 }
892 918
893 switch ( d-> m_model ) { 919 switch ( d-> m_model ) {
894 case Model_iPAQ_H31xx: 920 case Model_iPAQ_H31xx:
895 case Model_iPAQ_H38xx: 921 case Model_iPAQ_H38xx:
896 d-> m_rotation = Rot90; 922 d-> m_rotation = Rot90;
897 break; 923 break;
898 case Model_iPAQ_H36xx: 924 case Model_iPAQ_H36xx:
899 case Model_iPAQ_H37xx: 925 case Model_iPAQ_H37xx:
900 case Model_iPAQ_H39xx: 926 case Model_iPAQ_H39xx:
901 default: 927 default:
902 d-> m_rotation = Rot270; 928 d-> m_rotation = Rot270;
903 break; 929 break;
904 } 930 }
905 931
906 f. setName ( "/etc/familiar-version" ); 932 f. setName ( "/etc/familiar-version" );
907 if ( f. open ( IO_ReadOnly )) { 933 if ( f. open ( IO_ReadOnly )) {
908 d-> m_systemstr = "Familiar"; 934 d-> m_systemstr = "Familiar";
909 d-> m_system = System_Familiar; 935 d-> m_system = System_Familiar;
910 936
911 QTextStream ts ( &f ); 937 QTextStream ts ( &f );
912 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 938 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
913 939
914 f. close ( ); 940 f. close ( );
915 } else { 941 } else {
916 f. setName ( "/etc/oz_version" ); 942 f. setName ( "/etc/oz_version" );
917 943
918 if ( f. open ( IO_ReadOnly )) { 944 if ( f. open ( IO_ReadOnly )) {
919 d-> m_systemstr = "OpenEmbedded/iPaq"; 945 d-> m_systemstr = "OpenEmbedded/iPaq";
920 d-> m_system = System_Familiar; 946 d-> m_system = System_Familiar;
921 947
922 QTextStream ts ( &f ); 948 QTextStream ts ( &f );
923 ts.setDevice ( &f ); 949 ts.setDevice ( &f );
924 d-> m_sysverstr = ts. readLine ( ); 950 d-> m_sysverstr = ts. readLine ( );
925 f. close ( ); 951 f. close ( );
926 } 952 }
927 } 953 }
928 954
929 955
@@ -1640,404 +1666,433 @@ void SIMpad::initButtons ( )
1640 if ( d-> m_buttons ) 1666 if ( d-> m_buttons )
1641 return; 1667 return;
1642 1668
1643 if ( isQWS( ) ) 1669 if ( isQWS( ) )
1644 QWSServer::setKeyboardFilter ( this ); 1670 QWSServer::setKeyboardFilter ( this );
1645 1671
1646 d-> m_buttons = new QValueList <ODeviceButton>; 1672 d-> m_buttons = new QValueList <ODeviceButton>;
1647 1673
1648 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 1674 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
1649 s_button *sb = simpad_buttons + i; 1675 s_button *sb = simpad_buttons + i;
1650 ODeviceButton b; 1676 ODeviceButton b;
1651 1677
1652 if (( sb-> model & d-> m_model ) == d-> m_model ) { 1678 if (( sb-> model & d-> m_model ) == d-> m_model ) {
1653 b. setKeycode ( sb-> code ); 1679 b. setKeycode ( sb-> code );
1654 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 1680 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
1655 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 1681 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
1656 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 1682 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
1657 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 1683 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
1658 1684
1659 d-> m_buttons-> append ( b ); 1685 d-> m_buttons-> append ( b );
1660 } 1686 }
1661 } 1687 }
1662 reloadButtonMapping ( ); 1688 reloadButtonMapping ( );
1663 1689
1664 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1690 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1665 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1691 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1666} 1692}
1667 1693
1668// SIMpad boardcontrol register CS3 1694// SIMpad boardcontrol register CS3
1669#define SIMPAD_BOARDCONTROL "/proc/cs3" 1695#define SIMPAD_BOARDCONTROL "/proc/cs3"
1670#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 1696#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
1671#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 1697#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
1672#define SIMPAD_EN1 0x0004 // This is only for EPROM's 1698#define SIMPAD_EN1 0x0004 // This is only for EPROM's
1673#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 1699#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
1674#define SIMPAD_DISPLAY_ON 0x0010 1700#define SIMPAD_DISPLAY_ON 0x0010
1675#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 1701#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
1676#define SIMPAD_MQ_RESET 0x0040 1702#define SIMPAD_MQ_RESET 0x0040
1677#define SIMPAD_PCMCIA_RESET 0x0080 1703#define SIMPAD_PCMCIA_RESET 0x0080
1678#define SIMPAD_DECT_POWER_ON 0x0100 1704#define SIMPAD_DECT_POWER_ON 0x0100
1679#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 1705#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
1680#define SIMPAD_RS232_ON 0x0400 1706#define SIMPAD_RS232_ON 0x0400
1681#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 1707#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
1682#define SIMPAD_LED2_ON 0x1000 1708#define SIMPAD_LED2_ON 0x1000
1683#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 1709#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
1684#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 1710#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
1685#define SIMPAD_RESET_SIMCARD 0x8000 1711#define SIMPAD_RESET_SIMCARD 0x8000
1686 1712
1687//SIMpad touchscreen backlight strength control 1713//SIMpad touchscreen backlight strength control
1688#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 1714#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
1689#define SIMPAD_BACKLIGHT_MASK 0x00a10044 1715#define SIMPAD_BACKLIGHT_MASK 0x00a10044
1690 1716
1691QValueList <OLed> SIMpad::ledList ( ) const 1717QValueList <OLed> SIMpad::ledList ( ) const
1692{ 1718{
1693 QValueList <OLed> vl; 1719 QValueList <OLed> vl;
1694 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 1720 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
1695 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 1721 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
1696 return vl; 1722 return vl;
1697} 1723}
1698 1724
1699QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 1725QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
1700{ 1726{
1701 QValueList <OLedState> vl; 1727 QValueList <OLedState> vl;
1702 1728
1703 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 1729 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
1704 vl << Led_Off << Led_On; 1730 vl << Led_Off << Led_On;
1705 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 1731 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
1706 //vl << Led_Off; 1732 //vl << Led_Off;
1707 return vl; 1733 return vl;
1708} 1734}
1709 1735
1710OLedState SIMpad::ledState ( OLed l ) const 1736OLedState SIMpad::ledState ( OLed l ) const
1711{ 1737{
1712 switch ( l ) { 1738 switch ( l ) {
1713 case Led_Power: 1739 case Led_Power:
1714 return m_leds [0]; 1740 return m_leds [0];
1715 //case Led_Mail: 1741 //case Led_Mail:
1716 //return m_leds [1]; 1742 //return m_leds [1];
1717 default: 1743 default:
1718 return Led_Off; 1744 return Led_Off;
1719 } 1745 }
1720} 1746}
1721 1747
1722bool SIMpad::setLedState ( OLed l, OLedState st ) 1748bool SIMpad::setLedState ( OLed l, OLedState st )
1723{ 1749{
1724 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 1750 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
1725 1751
1726 if ( l == Led_Power ) { 1752 if ( l == Led_Power ) {
1727 if ( fd >= 0 ) { 1753 if ( fd >= 0 ) {
1728 LED_IN leds; 1754 LED_IN leds;
1729 ::memset ( &leds, 0, sizeof( leds )); 1755 ::memset ( &leds, 0, sizeof( leds ));
1730 leds. TotalTime = 0; 1756 leds. TotalTime = 0;
1731 leds. OnTime = 0; 1757 leds. OnTime = 0;
1732 leds. OffTime = 1; 1758 leds. OffTime = 1;
1733 leds. OffOnBlink = 2; 1759 leds. OffOnBlink = 2;
1734 1760
1735 switch ( st ) { 1761 switch ( st ) {
1736 case Led_Off : leds. OffOnBlink = 0; break; 1762 case Led_Off : leds. OffOnBlink = 0; break;
1737 case Led_On : leds. OffOnBlink = 1; break; 1763 case Led_On : leds. OffOnBlink = 1; break;
1738 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1764 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1739 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1765 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1740 } 1766 }
1741 1767
1742 { 1768 {
1743 /*TODO Implement this like that: 1769 /*TODO Implement this like that:
1744 read from cs3 1770 read from cs3
1745 && with SIMPAD_LED2_ON 1771 && with SIMPAD_LED2_ON
1746 write to cs3 */ 1772 write to cs3 */
1747 m_leds [0] = st; 1773 m_leds [0] = st;
1748 return true; 1774 return true;
1749 } 1775 }
1750 } 1776 }
1751 } 1777 }
1752 return false; 1778 return false;
1753} 1779}
1754 1780
1755 1781
1756bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1782bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1757{ 1783{
1758 //TODO 1784 //TODO
1759 return false; 1785 return false;
1760} 1786}
1761 1787
1762void SIMpad::timerEvent ( QTimerEvent * ) 1788void SIMpad::timerEvent ( QTimerEvent * )
1763{ 1789{
1764 killTimer ( m_power_timer ); 1790 killTimer ( m_power_timer );
1765 m_power_timer = 0; 1791 m_power_timer = 0;
1766 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1792 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1767 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1793 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1768} 1794}
1769 1795
1770 1796
1771void SIMpad::alarmSound ( ) 1797void SIMpad::alarmSound ( )
1772{ 1798{
1773#ifndef QT_NO_SOUND 1799#ifndef QT_NO_SOUND
1774 static Sound snd ( "alarm" ); 1800 static Sound snd ( "alarm" );
1775 int fd; 1801 int fd;
1776 int vol; 1802 int vol;
1777 bool vol_reset = false; 1803 bool vol_reset = false;
1778 1804
1779 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1805 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1780 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1806 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1781 Config cfg ( "qpe" ); 1807 Config cfg ( "qpe" );
1782 cfg. setGroup ( "Volume" ); 1808 cfg. setGroup ( "Volume" );
1783 1809
1784 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1810 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1785 if ( volalarm < 0 ) 1811 if ( volalarm < 0 )
1786 volalarm = 0; 1812 volalarm = 0;
1787 else if ( volalarm > 100 ) 1813 else if ( volalarm > 100 )
1788 volalarm = 100; 1814 volalarm = 100;
1789 volalarm |= ( volalarm << 8 ); 1815 volalarm |= ( volalarm << 8 );
1790 1816
1791 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1817 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1792 vol_reset = true; 1818 vol_reset = true;
1793 } 1819 }
1794 } 1820 }
1795 1821
1796 snd. play ( ); 1822 snd. play ( );
1797 while ( !snd. isFinished ( )) 1823 while ( !snd. isFinished ( ))
1798 qApp-> processEvents ( ); 1824 qApp-> processEvents ( );
1799 1825
1800 if ( fd >= 0 ) { 1826 if ( fd >= 0 ) {
1801 if ( vol_reset ) 1827 if ( vol_reset )
1802 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1828 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1803 ::close ( fd ); 1829 ::close ( fd );
1804 } 1830 }
1805#endif 1831#endif
1806} 1832}
1807 1833
1808 1834
1809bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 1835bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1810{ 1836{
1811 qDebug( "ODevice for SIMpad: suspend()" ); 1837 qDebug( "ODevice for SIMpad: suspend()" );
1812 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 1838 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1813 return false; 1839 return false;
1814 1840
1815 bool res = false; 1841 bool res = false;
1816 1842
1817 struct timeval tvs, tvn; 1843 struct timeval tvs, tvn;
1818 ::gettimeofday ( &tvs, 0 ); 1844 ::gettimeofday ( &tvs, 0 );
1819 1845
1820 ::sync ( ); // flush fs caches 1846 ::sync ( ); // flush fs caches
1821 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) 1847 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
1822 1848
1823 return res; 1849 return res;
1824} 1850}
1825 1851
1826 1852
1827bool SIMpad::setSoftSuspend ( bool soft ) 1853bool SIMpad::setSoftSuspend ( bool soft )
1828{ 1854{
1829 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 1855 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1830 return false; 1856 return false;
1831} 1857}
1832 1858
1833 1859
1834bool SIMpad::setDisplayStatus ( bool on ) 1860bool SIMpad::setDisplayStatus ( bool on )
1835{ 1861{
1836 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 1862 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1837 1863
1838 bool res = false; 1864 bool res = false;
1839 int fd; 1865 int fd;
1840 1866
1841 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 1867 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1842 1868
1843 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 1869 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
1844 res = ( ::system( (const char*) cmdline ) == 0 ); 1870 res = ( ::system( (const char*) cmdline ) == 0 );
1845 ::close ( fd ); 1871 ::close ( fd );
1846 } 1872 }
1847 return res; 1873 return res;
1848} 1874}
1849 1875
1850 1876
1851bool SIMpad::setDisplayBrightness ( int bright ) 1877bool SIMpad::setDisplayBrightness ( int bright )
1852{ 1878{
1853 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 1879 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1854 bool res = false; 1880 bool res = false;
1855 int fd; 1881 int fd;
1856 1882
1857 if ( bright > 255 ) 1883 if ( bright > 255 )
1858 bright = 255; 1884 bright = 255;
1859 if ( bright < 0 ) 1885 if ( bright < 0 )
1860 bright = 0; 1886 bright = 0;
1861 1887
1862 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1888 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1863 int value = 255 - bright; 1889 int value = 255 - bright;
1864 const int mask = SIMPAD_BACKLIGHT_MASK; 1890 const int mask = SIMPAD_BACKLIGHT_MASK;
1865 value = value << 8; 1891 value = value << 8;
1866 value += mask; 1892 value += mask;
1867 char writeCommand[100]; 1893 char writeCommand[100];
1868 const int count = sprintf( writeCommand, "0x%x\n", value ); 1894 const int count = sprintf( writeCommand, "0x%x\n", value );
1869 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1895 res = ( ::write ( fd, writeCommand, count ) != -1 );
1870 ::close ( fd ); 1896 ::close ( fd );
1871 } 1897 }
1872 return res; 1898 return res;
1873} 1899}
1874 1900
1875 1901
1876int SIMpad::displayBrightnessResolution ( ) const 1902int SIMpad::displayBrightnessResolution ( ) const
1877{ 1903{
1878 switch ( model ( )) { 1904 switch ( model ( )) {
1879 case Model_SIMpad_CL4: 1905 case Model_SIMpad_CL4:
1880 case Model_SIMpad_SL4: 1906 case Model_SIMpad_SL4:
1881 case Model_SIMpad_SLC: 1907 case Model_SIMpad_SLC:
1882 case Model_SIMpad_TSinus: 1908 case Model_SIMpad_TSinus:
1883 return 255; //TODO find out if this is save 1909 return 255; //TODO find out if this is save
1884 1910
1885 default: 1911 default:
1886 return 2; 1912 return 2;
1887 } 1913 }
1888} 1914}
1889 1915
1890/************************************************** 1916/**************************************************
1891 * 1917 *
1892 * Ramses 1918 * Ramses
1893 * 1919 *
1894 **************************************************/ 1920 **************************************************/
1895 1921
1896void Ramses::init ( ) 1922void Ramses::init()
1897{ 1923{
1898 d->m_vendorstr = "M und N"; 1924 d->m_vendorstr = "M und N";
1899 d->m_vendor = Vendor_MundN; 1925 d->m_vendor = Vendor_MundN;
1900 1926
1901 QFile f( "/proc/sys/board/ramses" ); 1927 QFile f("/proc/sys/board/ramses");
1902 1928
1903 d->m_modelstr = "Ramses"; 1929 d->m_modelstr = "Ramses";
1904 d->m_model = Model_Ramses_MNCI; 1930 d->m_model = Model_Ramses_MNCI;
1905 1931
1906 d->m_rotation = Rot180; 1932 d->m_rotation = Rot0;
1907 d->m_direction = CCW;
1908 d->m_holdtime = 1000; 1933 d->m_holdtime = 1000;
1909 1934
1910 f.setName( "/etc/oz_version" ); 1935 f.setName("/etc/oz_version");
1911 1936
1912 if ( f.open( IO_ReadOnly )) { 1937 if (f.open(IO_ReadOnly)) {
1913 d->m_systemstr = "OpenEmbedded/Ramses"; 1938 d->m_systemstr = "OpenEmbedded/Ramses";
1914 d->m_system = System_OpenZaurus; 1939 d->m_system = System_OpenZaurus;
1915 1940
1916 QTextStream ts ( &f ); 1941 QTextStream ts(&f);
1917 ts.setDevice ( &f ); 1942 ts.setDevice(&f);
1918 d->m_sysverstr = ts.readLine ( ); 1943 d->m_sysverstr = ts.readLine();
1919 f.close ( ); 1944 f.close();
1920 } 1945 }
1921 1946
1922 m_power_timer = 0; 1947 m_power_timer = 0;
1923 1948
1924} 1949}
1925 1950
1926void Ramses::initButtons ( ) 1951bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
1927{ 1952{
1928 if ( d->m_buttons ) 1953 Q_UNUSED( keycode );
1929 return; 1954 Q_UNUSED( modifiers );
1930 1955 Q_UNUSED( isPress );
1931 if ( isQWS( ) ) 1956 Q_UNUSED( autoRepeat );
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; 1957 return false;
1960} 1958}
1961 1959
1962void Ramses::timerEvent ( QTimerEvent * ) 1960void Ramses::timerEvent(QTimerEvent *)
1963{ 1961{
1964 killTimer ( m_power_timer ); 1962 killTimer(m_power_timer);
1965 m_power_timer = 0; 1963 m_power_timer = 0;
1966 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1964 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
1967 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1965 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
1968} 1966}
1969 1967
1970 1968
1971bool Ramses::setSoftSuspend ( bool soft ) 1969bool Ramses::setSoftSuspend(bool soft)
1972{ 1970{
1971 qDebug("Ramses::setSoftSuspend(%d)", soft);
1972#if 0
1973 bool res = false; 1973 bool res = false;
1974 int fd; 1974 int fd;
1975 1975
1976 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1976 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
1977 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1977 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
1978 1978
1979 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1979 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
1980 1980
1981 if ( sources >= 0 ) { 1981 if (sources >= 0) {
1982 if ( soft ) 1982 if (soft)
1983 sources &= ~APM_EVT_POWER_BUTTON; 1983 sources &= ~APM_EVT_POWER_BUTTON;
1984 else 1984 else
1985 sources |= APM_EVT_POWER_BUTTON; 1985 sources |= APM_EVT_POWER_BUTTON;
1986 1986
1987 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1987 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
1988 res = true; 1988 res = true;
1989 else 1989 else
1990 perror ( "APM_IOCGEVTSRC" ); 1990 perror("APM_IOCGEVTSRC");
1991 } 1991 }
1992 else 1992 else
1993 perror ( "APM_IOCGEVTSRC" ); 1993 perror("APM_IOCGEVTSRC");
1994 1994
1995 ::close ( fd ); 1995 ::close(fd);
1996 } 1996 }
1997 else 1997 else
1998 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1998 perror("/dev/apm_bios or /dev/misc/apm_bios");
1999 1999
2000 return res; 2000 return res;
2001#else
2002 return true;
2003#endif
2004}
2005
2006bool Ramses::suspend ( )
2007{
2008 qDebug("Ramses::suspend");
2001} 2009}
2002 2010
2003/** 2011/**
2004 * This sets the display on or off 2012 * This sets the display on or off
2005 */ 2013 */
2006bool Ramses::setDisplayStatus ( bool on ) 2014bool Ramses::setDisplayStatus(bool on)
2007{ 2015{
2016 qDebug("Ramses::setDisplayStatus(%d)", on);
2017#if 0
2008 bool res = false; 2018 bool res = false;
2009 int fd; 2019 int fd;
2010 2020
2011 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 2021 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2012 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 2022 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2013 ::close ( fd ); 2023 ::close(fd);
2014 } 2024 }
2015 return res; 2025 return res;
2026#else
2027 return true;
2028#endif
2016} 2029}
2017 2030
2018 2031
2019bool Ramses::setDisplayBrightness ( int bright ) 2032/*
2033 * We get something between 0..255 into us
2034*/
2035bool Ramses::setDisplayBrightness(int bright)
2020{ 2036{
2021 qDebug( "ODevice for Ramses: setDisplayBrightness( %d )", bright ); 2037 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2022 bool res = false; 2038 bool res = false;
2023 int fd; 2039 int fd;
2024 2040
2025 if ( bright > 255 ) 2041 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2026 bright = 100; 2042
2027 if ( bright < 0 ) 2043 if (bright > 255 )
2044 bright = 255;
2045 if (bright < 0)
2028 bright = 0; 2046 bright = 0;
2047 bright = 500-(bright * 500 / 255);
2029 2048
2030 if (( fd = ::open ( "/proc/sys/board/pwm0", O_WRONLY )) >= 0 ) { 2049 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2050 qDebug(" %d -> pwm1", bright);
2031 char writeCommand[100]; 2051 char writeCommand[100];
2032 const int count = sprintf( writeCommand, "%d\n", bright); 2052 const int count = sprintf(writeCommand, "%d\n", bright);
2033 res = ( ::write ( fd, writeCommand, count ) != -1 ); 2053 res = (::write(fd, writeCommand, count) != -1);
2034 ::close ( fd ); 2054 ::close(fd);
2055 } else {
2056 qWarning("no write");
2057 }
2058 return res;
2059}
2060
2061
2062int Ramses::displayBrightnessResolution() const
2063{
2064 return 32;
2065}
2066
2067bool Ramses::setDisplayContrast(int contr)
2068{
2069 qDebug("Ramses::setDisplayContrast(%d)", contr);
2070 bool res = false;
2071 int fd;
2072
2073 // pwm0 contrast: 35 steps 65..100 (dunkel->hell)
2074
2075 if (contr > 255 )
2076 contr = 255;
2077 if (contr < 0)
2078 contr = 0;
2079 contr = 65 + (contr * 350 / 255);
2080
2081 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2082 qDebug(" %d -> pwm0", contr);
2083 char writeCommand[100];
2084 const int count = sprintf(writeCommand, "%d\n", contr);
2085 res = (::write(fd, writeCommand, count) != -1);
2086 res = true;
2087 ::close(fd);
2088 } else {
2089 qWarning("no write");
2035 } 2090 }
2036 return res; 2091 return res;
2037} 2092}
2038 2093
2039 2094
2040int Ramses::displayBrightnessResolution ( ) const 2095int Ramses::displayContrastResolution() const
2041{ 2096{
2042 return 100; 2097 return 32;
2043} 2098}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 5829440..6c4830e 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,244 +1,246 @@
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 67
68 Model_Ramses = ( 4 << 24 ), 68 Model_Ramses = ( 4 << 24 ),
69 69
70 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 70 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
71 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 71 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
72}; 72};
73 73
74/** 74/**
75 * The vendor of the device 75 * The vendor of the device
76 */ 76 */
77enum OVendor { 77enum OVendor {
78 Vendor_Unknown, 78 Vendor_Unknown,
79 79
80 Vendor_HP, 80 Vendor_HP,
81 Vendor_Sharp, 81 Vendor_Sharp,
82 Vendor_SIEMENS, 82 Vendor_SIEMENS,
83 Vendor_MundN, 83 Vendor_MundN,
84}; 84};
85 85
86/** 86/**
87 * The System used 87 * The System used
88 */ 88 */
89enum OSystem { 89enum OSystem {
90 System_Unknown, 90 System_Unknown,
91 91
92 System_Familiar, 92 System_Familiar,
93 System_Zaurus, 93 System_Zaurus,
94 System_OpenZaurus 94 System_OpenZaurus
95}; 95};
96 96
97enum OLedState { 97enum OLedState {
98 Led_Off, 98 Led_Off,
99 Led_On, 99 Led_On,
100 Led_BlinkSlow, 100 Led_BlinkSlow,
101 Led_BlinkFast 101 Led_BlinkFast
102}; 102};
103 103
104enum OLed { 104enum OLed {
105 Led_Mail, 105 Led_Mail,
106 Led_Power, 106 Led_Power,
107 Led_BlueTooth 107 Led_BlueTooth
108}; 108};
109 109
110enum OHardKey { 110enum OHardKey {
111 HardKey_Datebook = Qt::Key_F9, 111 HardKey_Datebook = Qt::Key_F9,
112 HardKey_Contacts = Qt::Key_F10, 112 HardKey_Contacts = Qt::Key_F10,
113 HardKey_Menu = Qt::Key_F11, 113 HardKey_Menu = Qt::Key_F11,
114 HardKey_Home = Qt::Key_F12, 114 HardKey_Home = Qt::Key_F12,
115 HardKey_Mail = Qt::Key_F13, 115 HardKey_Mail = Qt::Key_F13,
116 HardKey_Record = Qt::Key_F24, 116 HardKey_Record = Qt::Key_F24,
117 HardKey_Suspend = Qt::Key_F34, 117 HardKey_Suspend = Qt::Key_F34,
118 HardKey_Backlight = Qt::Key_F35, 118 HardKey_Backlight = Qt::Key_F35,
119}; 119};
120 120
121enum ODirection { 121enum ODirection {
122 CW = 0, 122 CW = 0,
123 CCW = 1, 123 CCW = 1,
124 Flip = 2, 124 Flip = 2,
125}; 125};
126 126
127/** 127/**
128 * A singleton which gives informations about device specefic option 128 * A singleton which gives informations about device specefic option
129 * like the Hardware used, LEDs, the Base Distribution and 129 * like the Hardware used, LEDs, the Base Distribution and
130 * hardware key mappings. 130 * hardware key mappings.
131 * 131 *
132 * 132 *
133 * @short A small class for device specefic options 133 * @short A small class for device specefic options
134 * @see QObject 134 * @see QObject
135 * @author Robert Griebl 135 * @author Robert Griebl
136 * @version 1.0 136 * @version 1.0
137 */ 137 */
138class ODevice : public QObject { 138class ODevice : public QObject {
139 Q_OBJECT 139 Q_OBJECT
140 140
141private: 141private:
142 /* disable copy */ 142 /* disable copy */
143 ODevice ( const ODevice & ); 143 ODevice ( const ODevice & );
144 144
145protected: 145protected:
146 ODevice ( ); 146 ODevice ( );
147 virtual void init ( ); 147 virtual void init ( );
148 virtual void initButtons ( ); 148 virtual void initButtons ( );
149 149
150 ODeviceData *d; 150 ODeviceData *d;
151 151
152public: 152public:
153 // sandman do we want to allow destructions? -zecke? 153 // sandman do we want to allow destructions? -zecke?
154 virtual ~ODevice ( ); 154 virtual ~ODevice ( );
155 155
156 156
157 static ODevice *inst ( ); 157 static ODevice *inst ( );
158 158
159// information 159// information
160 160
161 QString modelString ( ) const; 161 QString modelString ( ) const;
162 OModel model ( ) const; 162 OModel model ( ) const;
163 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 163 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
164 164
165 QString vendorString ( ) const; 165 QString vendorString ( ) const;
166 OVendor vendor ( ) const; 166 OVendor vendor ( ) const;
167 167
168 QString systemString ( ) const; 168 QString systemString ( ) const;
169 OSystem system ( ) const; 169 OSystem system ( ) const;
170 170
171 QString systemVersionString ( ) const; 171 QString systemVersionString ( ) const;
172 172
173 Transformation rotation ( ) const; 173 Transformation rotation ( ) const;
174 ODirection direction ( ) const; 174 ODirection direction ( ) const;
175 175
176// system 176// system
177 177
178 virtual bool setSoftSuspend ( bool on ); 178 virtual bool setSoftSuspend ( bool on );
179 virtual bool suspend ( ); 179 virtual bool suspend ( );
180 180
181 virtual bool setDisplayStatus ( bool on ); 181 virtual bool setDisplayStatus ( bool on );
182 virtual bool setDisplayBrightness ( int brightness ); 182 virtual bool setDisplayBrightness ( int brightness );
183 virtual int displayBrightnessResolution ( ) const; 183 virtual int displayBrightnessResolution ( ) const;
184 virtual bool setDisplayContrast ( int contrast );
185 virtual int displayContrastResolution ( ) const;
184 186
185// input / output 187// input / output
186 //FIXME playAlarmSound and al might be better -zecke 188 //FIXME playAlarmSound and al might be better -zecke
187 virtual void alarmSound ( ); 189 virtual void alarmSound ( );
188 virtual void keySound ( ); 190 virtual void keySound ( );
189 virtual void touchSound ( ); 191 virtual void touchSound ( );
190 192
191 virtual QValueList <OLed> ledList ( ) const; 193 virtual QValueList <OLed> ledList ( ) const;
192 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 194 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
193 virtual OLedState ledState ( OLed led ) const; 195 virtual OLedState ledState ( OLed led ) const;
194 virtual bool setLedState ( OLed led, OLedState st ); 196 virtual bool setLedState ( OLed led, OLedState st );
195 197
196 virtual bool hasLightSensor ( ) const; 198 virtual bool hasLightSensor ( ) const;
197 virtual int readLightSensor ( ); 199 virtual int readLightSensor ( );
198 virtual int lightSensorResolution ( ) const; 200 virtual int lightSensorResolution ( ) const;
199 201
200 /** 202 /**
201 * Returns the available buttons on this device. The number and location 203 * Returns the available buttons on this device. The number and location
202 * of buttons will vary depending on the device. Button numbers will be assigned 204 * of buttons will vary depending on the device. Button numbers will be assigned
203 * by the device manufacturer and will be from most preferred button to least preffered 205 * by the device manufacturer and will be from most preferred button to least preffered
204 * button. Note that this list only contains "user mappable" buttons. 206 * button. Note that this list only contains "user mappable" buttons.
205 */ 207 */
206 const QValueList<ODeviceButton> &buttons ( ); 208 const QValueList<ODeviceButton> &buttons ( );
207 209
208 /** 210 /**
209 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 211 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
210 * returns 0L 212 * returns 0L
211 */ 213 */
212 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 214 const ODeviceButton *buttonForKeycode ( ushort keyCode );
213 215
214 /** 216 /**
215 * Reassigns the pressed action for \a button. To return to the factory 217 * Reassigns the pressed action for \a button. To return to the factory
216 * default pass an empty string as \a qcopMessage. 218 * default pass an empty string as \a qcopMessage.
217 */ 219 */
218 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 220 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
219 221
220 /** 222 /**
221 * Reassigns the held action for \a button. To return to the factory 223 * Reassigns the held action for \a button. To return to the factory
222 * default pass an empty string as \a qcopMessage. 224 * default pass an empty string as \a qcopMessage.
223 */ 225 */
224 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 226 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
225 227
226 /** 228 /**
227 * How long (in ms) you have to press a button for a "hold" action 229 * How long (in ms) you have to press a button for a "hold" action
228 */ 230 */
229 uint buttonHoldTime ( ) const; 231 uint buttonHoldTime ( ) const;
230 232
231signals: 233signals:
232 void buttonMappingChanged ( ); 234 void buttonMappingChanged ( );
233 235
234private slots: 236private slots:
235 void systemMessage ( const QCString &, const QByteArray & ); 237 void systemMessage ( const QCString &, const QByteArray & );
236 238
237protected: 239protected:
238 void reloadButtonMapping ( ); 240 void reloadButtonMapping ( );
239}; 241};
240 242
241} 243}
242 244
243#endif 245#endif
244 246