author | sandman <sandman> | 2002-10-29 18:43:23 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-29 18:43:23 (UTC) |
commit | 5ac67b8aece5aca20419f8953f88a36fd729adfc (patch) (unidiff) | |
tree | 3ce57c7a938d36ce40ff0dfe4b114233febf7b08 /libopie | |
parent | 45d9a30ec17b5146ffdac8e776003752fe2deeea (diff) | |
download | opie-5ac67b8aece5aca20419f8953f88a36fd729adfc.zip opie-5ac67b8aece5aca20419f8953f88a36fd729adfc.tar.gz opie-5ac67b8aece5aca20419f8953f88a36fd729adfc.tar.bz2 |
- redone the Model enum to make it easy to check for series (like: is this an
iPAQ - and not is this a 31xx or 36xx or ...)
- fixed the disply brightness resolution bug on H38xx
-rw-r--r-- | libopie/odevice.cpp | 34 | ||||
-rw-r--r-- | libopie/odevice.h | 21 |
2 files changed, 31 insertions, 24 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 4c49c4f..8f4e296 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,966 +1,970 @@ | |||
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 | 36 | ||
37 | #include "odevice.h" | 37 | #include "odevice.h" |
38 | 38 | ||
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | 40 | ||
41 | 41 | ||
42 | // _IO and friends are only defined in kernel headers ... | 42 | // _IO and friends are only defined in kernel headers ... |
43 | 43 | ||
44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
45 | 45 | ||
46 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 46 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
47 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 47 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
48 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 48 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
49 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 49 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
50 | 50 | ||
51 | using namespace Opie; | 51 | using namespace Opie; |
52 | 52 | ||
53 | class ODeviceData { | 53 | class ODeviceData { |
54 | public: | 54 | public: |
55 | bool m_qwsserver; | 55 | bool m_qwsserver; |
56 | 56 | ||
57 | QString m_vendorstr; | 57 | QString m_vendorstr; |
58 | OVendor m_vendor; | 58 | OVendor m_vendor; |
59 | 59 | ||
60 | QString m_modelstr; | 60 | QString m_modelstr; |
61 | OModel m_model; | 61 | OModel m_model; |
62 | 62 | ||
63 | QString m_systemstr; | 63 | QString m_systemstr; |
64 | OSystem m_system; | 64 | OSystem m_system; |
65 | 65 | ||
66 | QString m_sysverstr; | 66 | QString m_sysverstr; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | 69 | ||
70 | class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { | 70 | class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { |
71 | protected: | 71 | protected: |
72 | virtual void init ( ); | 72 | virtual void init ( ); |
73 | 73 | ||
74 | public: | 74 | public: |
75 | virtual bool setSoftSuspend ( bool soft ); | 75 | virtual bool setSoftSuspend ( bool soft ); |
76 | 76 | ||
77 | virtual bool setDisplayBrightness ( int b ); | 77 | virtual bool setDisplayBrightness ( int b ); |
78 | virtual int displayBrightnessResolution ( ) const; | 78 | virtual int displayBrightnessResolution ( ) const; |
79 | 79 | ||
80 | virtual void alarmSound ( ); | 80 | virtual void alarmSound ( ); |
81 | 81 | ||
82 | virtual QValueList <OLed> ledList ( ) const; | 82 | virtual QValueList <OLed> ledList ( ) const; |
83 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 83 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
84 | virtual OLedState ledState ( OLed led ) const; | 84 | virtual OLedState ledState ( OLed led ) const; |
85 | virtual bool setLedState ( OLed led, OLedState st ); | 85 | virtual bool setLedState ( OLed led, OLedState st ); |
86 | 86 | ||
87 | virtual bool hasLightSensor ( ) const; | 87 | virtual bool hasLightSensor ( ) const; |
88 | virtual int readLightSensor ( ); | 88 | virtual int readLightSensor ( ); |
89 | virtual int lightSensorResolution ( ) const; | 89 | virtual int lightSensorResolution ( ) const; |
90 | 90 | ||
91 | //virtual QValueList <int> keyList ( ) const; | 91 | //virtual QValueList <int> keyList ( ) const; |
92 | 92 | ||
93 | protected: | 93 | protected: |
94 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 94 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
95 | virtual void timerEvent ( QTimerEvent *te ); | 95 | virtual void timerEvent ( QTimerEvent *te ); |
96 | 96 | ||
97 | int m_power_timer; | 97 | int m_power_timer; |
98 | 98 | ||
99 | OLedState m_leds [2]; | 99 | OLedState m_leds [2]; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | class Zaurus : public ODevice { | 102 | class Zaurus : public ODevice { |
103 | protected: | 103 | protected: |
104 | virtual void init ( ); | 104 | virtual void init ( ); |
105 | 105 | ||
106 | public: | 106 | public: |
107 | virtual bool setSoftSuspend ( bool soft ); | 107 | virtual bool setSoftSuspend ( bool soft ); |
108 | 108 | ||
109 | virtual bool setDisplayBrightness ( int b ); | 109 | virtual bool setDisplayBrightness ( int b ); |
110 | virtual int displayBrightnessResolution ( ) const; | 110 | virtual int displayBrightnessResolution ( ) const; |
111 | 111 | ||
112 | virtual void alarmSound ( ); | 112 | virtual void alarmSound ( ); |
113 | virtual void keySound ( ); | 113 | virtual void keySound ( ); |
114 | virtual void touchSound ( ); | 114 | virtual void touchSound ( ); |
115 | 115 | ||
116 | virtual QValueList <OLed> ledList ( ) const; | 116 | virtual QValueList <OLed> ledList ( ) const; |
117 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 117 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
118 | virtual OLedState ledState ( OLed led ) const; | 118 | virtual OLedState ledState ( OLed led ) const; |
119 | virtual bool setLedState ( OLed led, OLedState st ); | 119 | virtual bool setLedState ( OLed led, OLedState st ); |
120 | 120 | ||
121 | //virtual QValueList <int> keyList ( ) const; | 121 | //virtual QValueList <int> keyList ( ) const; |
122 | 122 | ||
123 | protected: | 123 | protected: |
124 | virtual void buzzer ( int snd ); | 124 | virtual void buzzer ( int snd ); |
125 | 125 | ||
126 | OLedState m_leds [1]; | 126 | OLedState m_leds [1]; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | 129 | ||
130 | 130 | ||
131 | 131 | ||
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | ODevice *ODevice::inst ( ) | 135 | ODevice *ODevice::inst ( ) |
136 | { | 136 | { |
137 | static ODevice *dev = 0; | 137 | static ODevice *dev = 0; |
138 | 138 | ||
139 | if ( !dev ) { | 139 | if ( !dev ) { |
140 | if ( QFile::exists ( "/proc/hal/model" )) | 140 | if ( QFile::exists ( "/proc/hal/model" )) |
141 | dev = new iPAQ ( ); | 141 | dev = new iPAQ ( ); |
142 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 142 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
143 | dev = new Zaurus ( ); | 143 | dev = new Zaurus ( ); |
144 | else | 144 | else |
145 | dev = new ODevice ( ); | 145 | dev = new ODevice ( ); |
146 | 146 | ||
147 | dev-> init ( ); | 147 | dev-> init ( ); |
148 | } | 148 | } |
149 | return dev; | 149 | return dev; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | /************************************************** | 153 | /************************************************** |
154 | * | 154 | * |
155 | * common | 155 | * common |
156 | * | 156 | * |
157 | **************************************************/ | 157 | **************************************************/ |
158 | 158 | ||
159 | 159 | ||
160 | ODevice::ODevice ( ) | 160 | ODevice::ODevice ( ) |
161 | { | 161 | { |
162 | d = new ODeviceData; | 162 | d = new ODeviceData; |
163 | 163 | ||
164 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 164 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
165 | 165 | ||
166 | d-> m_modelstr = "Unknown"; | 166 | d-> m_modelstr = "Unknown"; |
167 | d-> m_model = Model_Unknown; | 167 | d-> m_model = Model_Unknown; |
168 | d-> m_vendorstr = "Unkown"; | 168 | d-> m_vendorstr = "Unkown"; |
169 | d-> m_vendor = Vendor_Unknown; | 169 | d-> m_vendor = Vendor_Unknown; |
170 | d-> m_systemstr = "Unkown"; | 170 | d-> m_systemstr = "Unkown"; |
171 | d-> m_system = System_Unknown; | 171 | d-> m_system = System_Unknown; |
172 | d-> m_sysverstr = "0.0"; | 172 | d-> m_sysverstr = "0.0"; |
173 | } | 173 | } |
174 | 174 | ||
175 | void ODevice::init ( ) | 175 | void ODevice::init ( ) |
176 | { | 176 | { |
177 | } | 177 | } |
178 | 178 | ||
179 | ODevice::~ODevice ( ) | 179 | ODevice::~ODevice ( ) |
180 | { | 180 | { |
181 | delete d; | 181 | delete d; |
182 | } | 182 | } |
183 | 183 | ||
184 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 184 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
185 | { | 185 | { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | 188 | ||
189 | //#include <linux/apm_bios.h> | 189 | //#include <linux/apm_bios.h> |
190 | 190 | ||
191 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 191 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
192 | 192 | ||
193 | 193 | ||
194 | bool ODevice::suspend ( ) | 194 | bool ODevice::suspend ( ) |
195 | { | 195 | { |
196 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 196 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
197 | return false; | 197 | return false; |
198 | 198 | ||
199 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 199 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
200 | return false; | 200 | return false; |
201 | 201 | ||
202 | int fd; | 202 | int fd; |
203 | bool res = false; | 203 | bool res = false; |
204 | 204 | ||
205 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 205 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
206 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 206 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
207 | struct timeval tvs, tvn; | 207 | struct timeval tvs, tvn; |
208 | 208 | ||
209 | // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped | 209 | // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped |
210 | ::gettimeofday ( &tvs, 0 ); | 210 | ::gettimeofday ( &tvs, 0 ); |
211 | 211 | ||
212 | ::sync ( ); // flush fs caches | 212 | ::sync ( ); // flush fs caches |
213 | 213 | ||
214 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending | 214 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending |
215 | ::close ( fd ); | 215 | ::close ( fd ); |
216 | 216 | ||
217 | if ( res ) { | 217 | if ( res ) { |
218 | // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group | 218 | // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group |
219 | 219 | ||
220 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 220 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
221 | ::usleep ( 200 * 1000 ); | 221 | ::usleep ( 200 * 1000 ); |
222 | ::gettimeofday ( &tvn, 0 ); | 222 | ::gettimeofday ( &tvn, 0 ); |
223 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 223 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
224 | 224 | ||
225 | // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group | 225 | // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group |
226 | } | 226 | } |
227 | 227 | ||
228 | // ::signal ( SIGTSTP, SIG_DFL ); | 228 | // ::signal ( SIGTSTP, SIG_DFL ); |
229 | } | 229 | } |
230 | 230 | ||
231 | return res; | 231 | return res; |
232 | } | 232 | } |
233 | 233 | ||
234 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 234 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
235 | 235 | ||
236 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 236 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
237 | 237 | ||
238 | /* VESA Blanking Levels */ | 238 | /* VESA Blanking Levels */ |
239 | #define VESA_NO_BLANKING 0 | 239 | #define VESA_NO_BLANKING 0 |
240 | #define VESA_VSYNC_SUSPEND 1 | 240 | #define VESA_VSYNC_SUSPEND 1 |
241 | #define VESA_HSYNC_SUSPEND 2 | 241 | #define VESA_HSYNC_SUSPEND 2 |
242 | #define VESA_POWERDOWN 3 | 242 | #define VESA_POWERDOWN 3 |
243 | 243 | ||
244 | 244 | ||
245 | bool ODevice::setDisplayStatus ( bool on ) | 245 | bool ODevice::setDisplayStatus ( bool on ) |
246 | { | 246 | { |
247 | if ( d-> m_model == Model_Unknown ) | 247 | if ( d-> m_model == Model_Unknown ) |
248 | return false; | 248 | return false; |
249 | 249 | ||
250 | bool res = false; | 250 | bool res = false; |
251 | int fd; | 251 | int fd; |
252 | 252 | ||
253 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 253 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
254 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 254 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
255 | ::close ( fd ); | 255 | ::close ( fd ); |
256 | } | 256 | } |
257 | return res; | 257 | return res; |
258 | } | 258 | } |
259 | 259 | ||
260 | bool ODevice::setDisplayBrightness ( int ) | 260 | bool ODevice::setDisplayBrightness ( int ) |
261 | { | 261 | { |
262 | return false; | 262 | return false; |
263 | } | 263 | } |
264 | 264 | ||
265 | int ODevice::displayBrightnessResolution ( ) const | 265 | int ODevice::displayBrightnessResolution ( ) const |
266 | { | 266 | { |
267 | return 16; | 267 | return 16; |
268 | } | 268 | } |
269 | 269 | ||
270 | QString ODevice::vendorString ( ) const | 270 | QString ODevice::vendorString ( ) const |
271 | { | 271 | { |
272 | return d-> m_vendorstr; | 272 | return d-> m_vendorstr; |
273 | } | 273 | } |
274 | 274 | ||
275 | OVendor ODevice::vendor ( ) const | 275 | OVendor ODevice::vendor ( ) const |
276 | { | 276 | { |
277 | return d-> m_vendor; | 277 | return d-> m_vendor; |
278 | } | 278 | } |
279 | 279 | ||
280 | QString ODevice::modelString ( ) const | 280 | QString ODevice::modelString ( ) const |
281 | { | 281 | { |
282 | return d-> m_modelstr; | 282 | return d-> m_modelstr; |
283 | } | 283 | } |
284 | 284 | ||
285 | OModel ODevice::model ( ) const | 285 | OModel ODevice::model ( ) const |
286 | { | 286 | { |
287 | return d-> m_model; | 287 | return d-> m_model; |
288 | } | 288 | } |
289 | 289 | ||
290 | QString ODevice::systemString ( ) const | 290 | QString ODevice::systemString ( ) const |
291 | { | 291 | { |
292 | return d-> m_systemstr; | 292 | return d-> m_systemstr; |
293 | } | 293 | } |
294 | 294 | ||
295 | OSystem ODevice::system ( ) const | 295 | OSystem ODevice::system ( ) const |
296 | { | 296 | { |
297 | return d-> m_system; | 297 | return d-> m_system; |
298 | } | 298 | } |
299 | 299 | ||
300 | QString ODevice::systemVersionString ( ) const | 300 | QString ODevice::systemVersionString ( ) const |
301 | { | 301 | { |
302 | return d-> m_sysverstr; | 302 | return d-> m_sysverstr; |
303 | } | 303 | } |
304 | 304 | ||
305 | void ODevice::alarmSound ( ) | 305 | void ODevice::alarmSound ( ) |
306 | { | 306 | { |
307 | #ifndef QT_QWS_EBX | 307 | #ifndef QT_QWS_EBX |
308 | #ifndef QT_NO_SOUND | 308 | #ifndef QT_NO_SOUND |
309 | static Sound snd ( "alarm" ); | 309 | static Sound snd ( "alarm" ); |
310 | 310 | ||
311 | if ( snd. isFinished ( )) | 311 | if ( snd. isFinished ( )) |
312 | snd. play ( ); | 312 | snd. play ( ); |
313 | #endif | 313 | #endif |
314 | #endif | 314 | #endif |
315 | } | 315 | } |
316 | 316 | ||
317 | void ODevice::keySound ( ) | 317 | void ODevice::keySound ( ) |
318 | { | 318 | { |
319 | #ifndef QT_QWS_EBX | 319 | #ifndef QT_QWS_EBX |
320 | #ifndef QT_NO_SOUND | 320 | #ifndef QT_NO_SOUND |
321 | static Sound snd ( "keysound" ); | 321 | static Sound snd ( "keysound" ); |
322 | 322 | ||
323 | if ( snd. isFinished ( )) | 323 | if ( snd. isFinished ( )) |
324 | snd. play ( ); | 324 | snd. play ( ); |
325 | #endif | 325 | #endif |
326 | #endif | 326 | #endif |
327 | } | 327 | } |
328 | 328 | ||
329 | void ODevice::touchSound ( ) | 329 | void ODevice::touchSound ( ) |
330 | { | 330 | { |
331 | 331 | ||
332 | #ifndef QT_QWS_EBX | 332 | #ifndef QT_QWS_EBX |
333 | #ifndef QT_NO_SOUND | 333 | #ifndef QT_NO_SOUND |
334 | static Sound snd ( "touchsound" ); | 334 | static Sound snd ( "touchsound" ); |
335 | 335 | ||
336 | if ( snd. isFinished ( )) | 336 | if ( snd. isFinished ( )) |
337 | snd. play ( ); | 337 | snd. play ( ); |
338 | #endif | 338 | #endif |
339 | #endif | 339 | #endif |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | QValueList <OLed> ODevice::ledList ( ) const | 343 | QValueList <OLed> ODevice::ledList ( ) const |
344 | { | 344 | { |
345 | return QValueList <OLed> ( ); | 345 | return QValueList <OLed> ( ); |
346 | } | 346 | } |
347 | 347 | ||
348 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 348 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
349 | { | 349 | { |
350 | return QValueList <OLedState> ( ); | 350 | return QValueList <OLedState> ( ); |
351 | } | 351 | } |
352 | 352 | ||
353 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 353 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
354 | { | 354 | { |
355 | return Led_Off; | 355 | return Led_Off; |
356 | } | 356 | } |
357 | 357 | ||
358 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 358 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
359 | { | 359 | { |
360 | return false; | 360 | return false; |
361 | } | 361 | } |
362 | 362 | ||
363 | bool ODevice::hasLightSensor ( ) const | 363 | bool ODevice::hasLightSensor ( ) const |
364 | { | 364 | { |
365 | return false; | 365 | return false; |
366 | } | 366 | } |
367 | 367 | ||
368 | int ODevice::readLightSensor ( ) | 368 | int ODevice::readLightSensor ( ) |
369 | { | 369 | { |
370 | return -1; | 370 | return -1; |
371 | } | 371 | } |
372 | 372 | ||
373 | int ODevice::lightSensorResolution ( ) const | 373 | int ODevice::lightSensorResolution ( ) const |
374 | { | 374 | { |
375 | return 0; | 375 | return 0; |
376 | } | 376 | } |
377 | 377 | ||
378 | //QValueList <int> ODevice::keyList ( ) const | 378 | //QValueList <int> ODevice::keyList ( ) const |
379 | //{ | 379 | //{ |
380 | //return QValueList <int> ( ); | 380 | //return QValueList <int> ( ); |
381 | //} | 381 | //} |
382 | 382 | ||
383 | 383 | ||
384 | 384 | ||
385 | /************************************************** | 385 | /************************************************** |
386 | * | 386 | * |
387 | * iPAQ | 387 | * iPAQ |
388 | * | 388 | * |
389 | **************************************************/ | 389 | **************************************************/ |
390 | 390 | ||
391 | void iPAQ::init ( ) | 391 | void iPAQ::init ( ) |
392 | { | 392 | { |
393 | d-> m_vendorstr = "HP"; | 393 | d-> m_vendorstr = "HP"; |
394 | d-> m_vendor = Vendor_HP; | 394 | d-> m_vendor = Vendor_HP; |
395 | 395 | ||
396 | QFile f ( "/proc/hal/model" ); | 396 | QFile f ( "/proc/hal/model" ); |
397 | 397 | ||
398 | if ( f. open ( IO_ReadOnly )) { | 398 | if ( f. open ( IO_ReadOnly )) { |
399 | QTextStream ts ( &f ); | 399 | QTextStream ts ( &f ); |
400 | 400 | ||
401 | d-> m_modelstr = "H" + ts. readLine ( ); | 401 | d-> m_modelstr = "H" + ts. readLine ( ); |
402 | 402 | ||
403 | if ( d-> m_modelstr == "H3100" ) | 403 | if ( d-> m_modelstr == "H3100" ) |
404 | d-> m_model = Model_iPAQ_H31xx; | 404 | d-> m_model = Model_iPAQ_H31xx; |
405 | else if ( d-> m_modelstr == "H3600" ) | 405 | else if ( d-> m_modelstr == "H3600" ) |
406 | d-> m_model = Model_iPAQ_H36xx; | 406 | d-> m_model = Model_iPAQ_H36xx; |
407 | else if ( d-> m_modelstr == "H3700" ) | 407 | else if ( d-> m_modelstr == "H3700" ) |
408 | d-> m_model = Model_iPAQ_H37xx; | 408 | d-> m_model = Model_iPAQ_H37xx; |
409 | else if ( d-> m_modelstr == "H3800" ) | 409 | else if ( d-> m_modelstr == "H3800" ) |
410 | d-> m_model = Model_iPAQ_H38xx; | 410 | d-> m_model = Model_iPAQ_H38xx; |
411 | else if ( d-> m_modelstr == "H3900" ) | ||
412 | d-> m_model = Model_iPAQ_H39xx; | ||
411 | else | 413 | else |
412 | d-> m_model = Model_Unknown; | 414 | d-> m_model = Model_Unknown; |
413 | 415 | ||
414 | f. close ( ); | 416 | f. close ( ); |
415 | } | 417 | } |
416 | 418 | ||
417 | f. setName ( "/etc/familiar-version" ); | 419 | f. setName ( "/etc/familiar-version" ); |
418 | if ( f. open ( IO_ReadOnly )) { | 420 | if ( f. open ( IO_ReadOnly )) { |
419 | d-> m_systemstr = "Familiar"; | 421 | d-> m_systemstr = "Familiar"; |
420 | d-> m_system = System_Familiar; | 422 | d-> m_system = System_Familiar; |
421 | 423 | ||
422 | QTextStream ts ( &f ); | 424 | QTextStream ts ( &f ); |
423 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 425 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
424 | 426 | ||
425 | f. close ( ); | 427 | f. close ( ); |
426 | } | 428 | } |
427 | 429 | ||
428 | m_leds [0] = m_leds [1] = Led_Off; | 430 | m_leds [0] = m_leds [1] = Led_Off; |
429 | 431 | ||
430 | m_power_timer = 0; | 432 | m_power_timer = 0; |
431 | 433 | ||
432 | if ( d-> m_qwsserver ) | 434 | if ( d-> m_qwsserver ) |
433 | QWSServer::setKeyboardFilter ( this ); | 435 | QWSServer::setKeyboardFilter ( this ); |
434 | } | 436 | } |
435 | 437 | ||
436 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 438 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
437 | 439 | ||
438 | typedef struct { | 440 | typedef struct { |
439 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 441 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
440 | unsigned char TotalTime; /* Units of 5 seconds */ | 442 | unsigned char TotalTime; /* Units of 5 seconds */ |
441 | unsigned char OnTime; /* units of 100m/s */ | 443 | unsigned char OnTime; /* units of 100m/s */ |
442 | unsigned char OffTime; /* units of 100m/s */ | 444 | unsigned char OffTime; /* units of 100m/s */ |
443 | } LED_IN; | 445 | } LED_IN; |
444 | 446 | ||
445 | typedef struct { | 447 | typedef struct { |
446 | unsigned char mode; | 448 | unsigned char mode; |
447 | unsigned char pwr; | 449 | unsigned char pwr; |
448 | unsigned char brightness; | 450 | unsigned char brightness; |
449 | } FLITE_IN; | 451 | } FLITE_IN; |
450 | 452 | ||
451 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 453 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
452 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 454 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
453 | 455 | ||
454 | 456 | ||
455 | 457 | ||
456 | QValueList <OLed> iPAQ::ledList ( ) const | 458 | QValueList <OLed> iPAQ::ledList ( ) const |
457 | { | 459 | { |
458 | QValueList <OLed> vl; | 460 | QValueList <OLed> vl; |
459 | vl << Led_Power; | 461 | vl << Led_Power; |
460 | 462 | ||
461 | if ( d-> m_model == Model_iPAQ_H38xx ) | 463 | if ( d-> m_model == Model_iPAQ_H38xx ) |
462 | vl << Led_BlueTooth; | 464 | vl << Led_BlueTooth; |
463 | return vl; | 465 | return vl; |
464 | } | 466 | } |
465 | 467 | ||
466 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 468 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
467 | { | 469 | { |
468 | QValueList <OLedState> vl; | 470 | QValueList <OLedState> vl; |
469 | 471 | ||
470 | if ( l == Led_Power ) | 472 | if ( l == Led_Power ) |
471 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 473 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
472 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 474 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
473 | vl << Led_Off; // << Led_On << ??? | 475 | vl << Led_Off; // << Led_On << ??? |
474 | 476 | ||
475 | return vl; | 477 | return vl; |
476 | } | 478 | } |
477 | 479 | ||
478 | OLedState iPAQ::ledState ( OLed l ) const | 480 | OLedState iPAQ::ledState ( OLed l ) const |
479 | { | 481 | { |
480 | switch ( l ) { | 482 | switch ( l ) { |
481 | case Led_Power: | 483 | case Led_Power: |
482 | return m_leds [0]; | 484 | return m_leds [0]; |
483 | case Led_BlueTooth: | 485 | case Led_BlueTooth: |
484 | return m_leds [1]; | 486 | return m_leds [1]; |
485 | default: | 487 | default: |
486 | return Led_Off; | 488 | return Led_Off; |
487 | } | 489 | } |
488 | } | 490 | } |
489 | 491 | ||
490 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 492 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
491 | { | 493 | { |
492 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 494 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
493 | 495 | ||
494 | if ( l == Led_Power ) { | 496 | if ( l == Led_Power ) { |
495 | if ( fd >= 0 ) { | 497 | if ( fd >= 0 ) { |
496 | LED_IN leds; | 498 | LED_IN leds; |
497 | ::memset ( &leds, 0, sizeof( leds )); | 499 | ::memset ( &leds, 0, sizeof( leds )); |
498 | leds. TotalTime = 0; | 500 | leds. TotalTime = 0; |
499 | leds. OnTime = 0; | 501 | leds. OnTime = 0; |
500 | leds. OffTime = 1; | 502 | leds. OffTime = 1; |
501 | leds. OffOnBlink = 2; | 503 | leds. OffOnBlink = 2; |
502 | 504 | ||
503 | switch ( st ) { | 505 | switch ( st ) { |
504 | case Led_Off : leds. OffOnBlink = 0; break; | 506 | case Led_Off : leds. OffOnBlink = 0; break; |
505 | case Led_On : leds. OffOnBlink = 1; break; | 507 | case Led_On : leds. OffOnBlink = 1; break; |
506 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 508 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
507 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 509 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
508 | } | 510 | } |
509 | 511 | ||
510 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 512 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
511 | m_leds [0] = st; | 513 | m_leds [0] = st; |
512 | return true; | 514 | return true; |
513 | } | 515 | } |
514 | } | 516 | } |
515 | } | 517 | } |
516 | return false; | 518 | return false; |
517 | } | 519 | } |
518 | 520 | ||
519 | 521 | ||
520 | //QValueList <int> iPAQ::keyList ( ) const | 522 | //QValueList <int> iPAQ::keyList ( ) const |
521 | //{ | 523 | //{ |
522 | //QValueList <int> vl; | 524 | //QValueList <int> vl; |
523 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; | 525 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; |
524 | //return vl; | 526 | //return vl; |
525 | //} | 527 | //} |
526 | 528 | ||
527 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 529 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
528 | { | 530 | { |
529 | int newkeycode = keycode; | 531 | int newkeycode = keycode; |
530 | 532 | ||
531 | 533 | ||
532 | // simple susbstitutions | 534 | // simple susbstitutions |
533 | switch ( d-> m_model ) { | 535 | switch ( d-> m_model ) { |
534 | case Model_iPAQ_H38xx: | 536 | case Model_iPAQ_H38xx: |
535 | // H38xx has no "Q" key anymore - this is now the Mail key | 537 | // H38xx has no "Q" key anymore - this is now the Mail key |
536 | if ( keycode == HardKey_Menu ) | 538 | if ( keycode == HardKey_Menu ) |
537 | newkeycode = HardKey_Mail; | 539 | newkeycode = HardKey_Mail; |
538 | //nobreak | 540 | //nobreak |
539 | 541 | ||
540 | case Model_iPAQ_H31xx: | 542 | case Model_iPAQ_H31xx: |
541 | // Rotate cursor keys 180° | 543 | // Rotate cursor keys 180° |
542 | switch ( keycode ) { | 544 | switch ( keycode ) { |
543 | case Key_Left : newkeycode = Key_Right; break; | 545 | case Key_Left : newkeycode = Key_Right; break; |
544 | case Key_Right: newkeycode = Key_Left; break; | 546 | case Key_Right: newkeycode = Key_Left; break; |
545 | case Key_Up : newkeycode = Key_Down; break; | 547 | case Key_Up : newkeycode = Key_Down; break; |
546 | case Key_Down : newkeycode = Key_Up; break; | 548 | case Key_Down : newkeycode = Key_Up; break; |
547 | } | 549 | } |
548 | //nobreak; | 550 | //nobreak; |
549 | 551 | ||
550 | case Model_iPAQ_H36xx: | 552 | case Model_iPAQ_H36xx: |
551 | case Model_iPAQ_H37xx: | 553 | case Model_iPAQ_H37xx: |
552 | // map Power Button short/long press to F34/F35 | 554 | // map Power Button short/long press to F34/F35 |
553 | if ( keycode == Key_SysReq ) { | 555 | if ( keycode == Key_SysReq ) { |
554 | if ( isPress ) { | 556 | if ( isPress ) { |
555 | if ( m_power_timer ) | 557 | if ( m_power_timer ) |
556 | killTimer ( m_power_timer ); | 558 | killTimer ( m_power_timer ); |
557 | m_power_timer = startTimer ( 500 ); | 559 | m_power_timer = startTimer ( 500 ); |
558 | } | 560 | } |
559 | else if ( m_power_timer ) { | 561 | else if ( m_power_timer ) { |
560 | killTimer ( m_power_timer ); | 562 | killTimer ( m_power_timer ); |
561 | m_power_timer = 0; | 563 | m_power_timer = 0; |
562 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 564 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
563 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 565 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
564 | } | 566 | } |
565 | newkeycode = Key_unknown; | 567 | newkeycode = Key_unknown; |
566 | } | 568 | } |
567 | //nobreak; | 569 | //nobreak; |
568 | 570 | ||
569 | default: | 571 | default: |
570 | break; | 572 | break; |
571 | } | 573 | } |
572 | 574 | ||
573 | if ( newkeycode != keycode ) { | 575 | if ( newkeycode != keycode ) { |
574 | if ( newkeycode != Key_unknown ) | 576 | if ( newkeycode != Key_unknown ) |
575 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 577 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
576 | return true; | 578 | return true; |
577 | } | 579 | } |
578 | else | 580 | else |
579 | return false; | 581 | return false; |
580 | } | 582 | } |
581 | 583 | ||
582 | void iPAQ::timerEvent ( QTimerEvent * ) | 584 | void iPAQ::timerEvent ( QTimerEvent * ) |
583 | { | 585 | { |
584 | killTimer ( m_power_timer ); | 586 | killTimer ( m_power_timer ); |
585 | m_power_timer = 0; | 587 | m_power_timer = 0; |
586 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 588 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
587 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 589 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
588 | } | 590 | } |
589 | 591 | ||
590 | 592 | ||
591 | void iPAQ::alarmSound ( ) | 593 | void iPAQ::alarmSound ( ) |
592 | { | 594 | { |
593 | #if defined( QT_QWS_IPAQ ) // IPAQ | 595 | #if defined( QT_QWS_IPAQ ) // IPAQ |
594 | #ifndef QT_NO_SOUND | 596 | #ifndef QT_NO_SOUND |
595 | static Sound snd ( "alarm" ); | 597 | static Sound snd ( "alarm" ); |
596 | int fd; | 598 | int fd; |
597 | int vol; | 599 | int vol; |
598 | bool vol_reset = false; | 600 | bool vol_reset = false; |
599 | 601 | ||
600 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 602 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
601 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 603 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
602 | Config cfg ( "qpe" ); | 604 | Config cfg ( "qpe" ); |
603 | cfg. setGroup ( "Volume" ); | 605 | cfg. setGroup ( "Volume" ); |
604 | 606 | ||
605 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 607 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
606 | if ( volalarm < 0 ) | 608 | if ( volalarm < 0 ) |
607 | volalarm = 0; | 609 | volalarm = 0; |
608 | else if ( volalarm > 100 ) | 610 | else if ( volalarm > 100 ) |
609 | volalarm = 100; | 611 | volalarm = 100; |
610 | volalarm |= ( volalarm << 8 ); | 612 | volalarm |= ( volalarm << 8 ); |
611 | 613 | ||
612 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 614 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
613 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 615 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
614 | vol_reset = true; | 616 | vol_reset = true; |
615 | } | 617 | } |
616 | } | 618 | } |
617 | } | 619 | } |
618 | 620 | ||
619 | snd. play ( ); | 621 | snd. play ( ); |
620 | while ( !snd. isFinished ( )) | 622 | while ( !snd. isFinished ( )) |
621 | qApp-> processEvents ( ); | 623 | qApp-> processEvents ( ); |
622 | 624 | ||
623 | if ( fd >= 0 ) { | 625 | if ( fd >= 0 ) { |
624 | if ( vol_reset ) | 626 | if ( vol_reset ) |
625 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 627 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
626 | ::close ( fd ); | 628 | ::close ( fd ); |
627 | } | 629 | } |
628 | #endif | 630 | #endif |
629 | #endif | 631 | #endif |
630 | } | 632 | } |
631 | 633 | ||
632 | 634 | ||
633 | bool iPAQ::setSoftSuspend ( bool soft ) | 635 | bool iPAQ::setSoftSuspend ( bool soft ) |
634 | { | 636 | { |
635 | bool res = false; | 637 | bool res = false; |
636 | int fd; | 638 | int fd; |
637 | 639 | ||
638 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 640 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
639 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 641 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
640 | res = true; | 642 | res = true; |
641 | else | 643 | else |
642 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 644 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
643 | 645 | ||
644 | ::close ( fd ); | 646 | ::close ( fd ); |
645 | } | 647 | } |
646 | else | 648 | else |
647 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 649 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
648 | 650 | ||
649 | return res; | 651 | return res; |
650 | } | 652 | } |
651 | 653 | ||
652 | 654 | ||
653 | bool iPAQ::setDisplayBrightness ( int bright ) | 655 | bool iPAQ::setDisplayBrightness ( int bright ) |
654 | { | 656 | { |
655 | bool res = false; | 657 | bool res = false; |
656 | int fd; | 658 | int fd; |
657 | 659 | ||
658 | if ( bright > 255 ) | 660 | int maxbright = displayBrightnessResolution ( ); |
659 | bright = 255; | 661 | |
662 | if ( bright > maxbright ) | ||
663 | bright = maxbright; | ||
660 | if ( bright < 0 ) | 664 | if ( bright < 0 ) |
661 | bright = 0; | 665 | bright = 0; |
662 | 666 | ||
663 | // 128 is the maximum if you want a decent lifetime for the LCD | ||
664 | |||
665 | if ( bright > 1 ) | ||
666 | bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic | ||
667 | //bright = ( bright + 1 ) / 2; | ||
668 | |||
669 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 667 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
670 | FLITE_IN bl; | 668 | FLITE_IN bl; |
671 | bl. mode = 1; | 669 | bl. mode = 1; |
672 | bl. pwr = bright ? 1 : 0; | 670 | bl. pwr = bright ? 1 : 0; |
673 | bl. brightness = bright; | 671 | bl. brightness = bright; |
674 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 672 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
675 | ::close ( fd ); | 673 | ::close ( fd ); |
676 | } | 674 | } |
677 | return res; | 675 | return res; |
678 | } | 676 | } |
679 | 677 | ||
680 | int iPAQ::displayBrightnessResolution ( ) const | 678 | int iPAQ::displayBrightnessResolution ( ) const |
681 | { | 679 | { |
682 | return 256; // really 128, but logarithmic control is smoother this way | 680 | switch ( model ( )) { |
681 | case Model_iPAQ_H31xx: | ||
682 | case Model_iPAQ_H36xx: | ||
683 | case Model_iPAQ_H37xx: | ||
684 | return 128; // really 256, but >128 could damage the LCD | ||
685 | |||
686 | case Model_iPAQ_H38xx: | ||
687 | case Model_iPAQ_H39xx: | ||
688 | return 64; | ||
689 | |||
690 | default: | ||
691 | return 2; | ||
692 | } | ||
683 | } | 693 | } |
684 | 694 | ||
685 | 695 | ||
686 | bool iPAQ::hasLightSensor ( ) const | 696 | bool iPAQ::hasLightSensor ( ) const |
687 | { | 697 | { |
688 | return true; | 698 | return true; |
689 | } | 699 | } |
690 | 700 | ||
691 | int iPAQ::readLightSensor ( ) | 701 | int iPAQ::readLightSensor ( ) |
692 | { | 702 | { |
693 | int fd; | 703 | int fd; |
694 | int val = -1; | 704 | int val = -1; |
695 | 705 | ||
696 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 706 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
697 | char buffer [8]; | 707 | char buffer [8]; |
698 | 708 | ||
699 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 709 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
700 | char *endptr; | 710 | char *endptr; |
701 | 711 | ||
702 | buffer [4] = 0; | 712 | buffer [4] = 0; |
703 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 713 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
704 | 714 | ||
705 | if ( *endptr != 0 ) | 715 | if ( *endptr != 0 ) |
706 | val = -1; | 716 | val = -1; |
707 | } | 717 | } |
708 | ::close ( fd ); | 718 | ::close ( fd ); |
709 | } | 719 | } |
710 | 720 | ||
711 | return val; | 721 | return val; |
712 | } | 722 | } |
713 | 723 | ||
714 | int iPAQ::lightSensorResolution ( ) const | 724 | int iPAQ::lightSensorResolution ( ) const |
715 | { | 725 | { |
716 | return 256; | 726 | return 256; |
717 | } | 727 | } |
718 | 728 | ||
719 | /************************************************** | 729 | /************************************************** |
720 | * | 730 | * |
721 | * Zaurus | 731 | * Zaurus |
722 | * | 732 | * |
723 | **************************************************/ | 733 | **************************************************/ |
724 | 734 | ||
725 | 735 | ||
726 | 736 | ||
727 | void Zaurus::init ( ) | 737 | void Zaurus::init ( ) |
728 | { | 738 | { |
729 | d-> m_modelstr = "Zaurus SL5000"; | 739 | d-> m_modelstr = "Zaurus SL5000"; |
730 | d-> m_model = Model_Zaurus_SL5000; | 740 | d-> m_model = Model_Zaurus_SL5000; |
731 | d-> m_vendorstr = "Sharp"; | 741 | d-> m_vendorstr = "Sharp"; |
732 | d-> m_vendor = Vendor_Sharp; | 742 | d-> m_vendor = Vendor_Sharp; |
733 | 743 | ||
734 | QFile f ( "/proc/filesystems" ); | 744 | QFile f ( "/proc/filesystems" ); |
735 | 745 | ||
736 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 746 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
737 | d-> m_systemstr = "OpenZaurus"; | 747 | d-> m_systemstr = "OpenZaurus"; |
738 | d-> m_system = System_OpenZaurus; | 748 | d-> m_system = System_OpenZaurus; |
739 | 749 | ||
740 | f. close ( ); | 750 | f. close ( ); |
741 | 751 | ||
742 | f. setName ( "/etc/oz_version" ); | 752 | f. setName ( "/etc/oz_version" ); |
743 | if ( f. open ( IO_ReadOnly )) { | 753 | if ( f. open ( IO_ReadOnly )) { |
744 | QTextStream ts ( &f ); | 754 | QTextStream ts ( &f ); |
745 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 755 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
746 | f. close ( ); | 756 | f. close ( ); |
747 | } | 757 | } |
748 | } | 758 | } |
749 | else { | 759 | else { |
750 | d-> m_systemstr = "Zaurus"; | 760 | d-> m_systemstr = "Zaurus"; |
751 | d-> m_system = System_Zaurus; | 761 | d-> m_system = System_Zaurus; |
752 | } | 762 | } |
753 | 763 | ||
754 | 764 | ||
755 | m_leds [0] = Led_Off; | 765 | m_leds [0] = Led_Off; |
756 | } | 766 | } |
757 | 767 | ||
758 | #include <unistd.h> | 768 | #include <unistd.h> |
759 | #include <fcntl.h> | 769 | #include <fcntl.h> |
760 | #include <sys/ioctl.h> | 770 | #include <sys/ioctl.h> |
761 | 771 | ||
762 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 772 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
763 | 773 | ||
764 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 774 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
765 | 775 | ||
766 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 776 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
767 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 777 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
768 | 778 | ||
769 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 779 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
770 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 780 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
771 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 781 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
772 | 782 | ||
773 | /* --- for SHARP_BUZZER device --- */ | 783 | /* --- for SHARP_BUZZER device --- */ |
774 | 784 | ||
775 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 785 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
776 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 786 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
777 | 787 | ||
778 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 788 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
779 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 789 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
780 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 790 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
781 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 791 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
782 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 792 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
783 | 793 | ||
784 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 794 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
785 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 795 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
786 | 796 | ||
787 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 797 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
788 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 798 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
789 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 799 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
790 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 800 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
791 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 801 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
792 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 802 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
793 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 803 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
794 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 804 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
795 | 805 | ||
796 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 806 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
797 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 807 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
798 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 808 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
799 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 809 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
800 | // | 810 | // |
801 | 811 | ||
802 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 812 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
803 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 813 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
804 | 814 | ||
805 | typedef struct sharp_led_status { | 815 | typedef struct sharp_led_status { |
806 | int which; /* select which LED status is wanted. */ | 816 | int which; /* select which LED status is wanted. */ |
807 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 817 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
808 | } sharp_led_status; | 818 | } sharp_led_status; |
809 | 819 | ||
810 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 820 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
811 | 821 | ||
812 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 822 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
813 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 823 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
814 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 824 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
815 | 825 | ||
816 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 826 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
817 | 827 | ||
818 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 828 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
819 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 829 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
820 | #define APM_EVT_POWER_BUTTON (1 << 0) | 830 | #define APM_EVT_POWER_BUTTON (1 << 0) |
821 | 831 | ||
822 | #define FL_IOCTL_STEP_CONTRAST 100 | 832 | #define FL_IOCTL_STEP_CONTRAST 100 |
823 | 833 | ||
824 | 834 | ||
825 | void Zaurus::buzzer ( int sound ) | 835 | void Zaurus::buzzer ( int sound ) |
826 | { | 836 | { |
827 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 837 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
828 | 838 | ||
829 | if ( fd >= 0 ) | 839 | if ( fd >= 0 ) |
830 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 840 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
831 | } | 841 | } |
832 | 842 | ||
833 | 843 | ||
834 | void Zaurus::alarmSound ( ) | 844 | void Zaurus::alarmSound ( ) |
835 | { | 845 | { |
836 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 846 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
837 | } | 847 | } |
838 | 848 | ||
839 | void Zaurus::touchSound ( ) | 849 | void Zaurus::touchSound ( ) |
840 | { | 850 | { |
841 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 851 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
842 | } | 852 | } |
843 | 853 | ||
844 | void Zaurus::keySound ( ) | 854 | void Zaurus::keySound ( ) |
845 | { | 855 | { |
846 | buzzer ( SHARP_BUZ_KEYSOUND ); | 856 | buzzer ( SHARP_BUZ_KEYSOUND ); |
847 | } | 857 | } |
848 | 858 | ||
849 | 859 | ||
850 | QValueList <OLed> Zaurus::ledList ( ) const | 860 | QValueList <OLed> Zaurus::ledList ( ) const |
851 | { | 861 | { |
852 | QValueList <OLed> vl; | 862 | QValueList <OLed> vl; |
853 | vl << Led_Mail; | 863 | vl << Led_Mail; |
854 | return vl; | 864 | return vl; |
855 | } | 865 | } |
856 | 866 | ||
857 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 867 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
858 | { | 868 | { |
859 | QValueList <OLedState> vl; | 869 | QValueList <OLedState> vl; |
860 | 870 | ||
861 | if ( l == Led_Mail ) | 871 | if ( l == Led_Mail ) |
862 | vl << Led_Off << Led_On << Led_BlinkSlow; | 872 | vl << Led_Off << Led_On << Led_BlinkSlow; |
863 | return vl; | 873 | return vl; |
864 | } | 874 | } |
865 | 875 | ||
866 | OLedState Zaurus::ledState ( OLed which ) const | 876 | OLedState Zaurus::ledState ( OLed which ) const |
867 | { | 877 | { |
868 | if ( which == Led_Mail ) | 878 | if ( which == Led_Mail ) |
869 | return m_leds [0]; | 879 | return m_leds [0]; |
870 | else | 880 | else |
871 | return Led_Off; | 881 | return Led_Off; |
872 | } | 882 | } |
873 | 883 | ||
874 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 884 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
875 | { | 885 | { |
876 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 886 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
877 | 887 | ||
878 | if ( which == Led_Mail ) { | 888 | if ( which == Led_Mail ) { |
879 | if ( fd >= 0 ) { | 889 | if ( fd >= 0 ) { |
880 | struct sharp_led_status leds; | 890 | struct sharp_led_status leds; |
881 | ::memset ( &leds, 0, sizeof( leds )); | 891 | ::memset ( &leds, 0, sizeof( leds )); |
882 | leds. which = SHARP_LED_MAIL_EXISTS; | 892 | leds. which = SHARP_LED_MAIL_EXISTS; |
883 | bool ok = true; | 893 | bool ok = true; |
884 | 894 | ||
885 | switch ( st ) { | 895 | switch ( st ) { |
886 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 896 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
887 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 897 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
888 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 898 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
889 | default : ok = false; | 899 | default : ok = false; |
890 | } | 900 | } |
891 | 901 | ||
892 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 902 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
893 | m_leds [0] = st; | 903 | m_leds [0] = st; |
894 | return true; | 904 | return true; |
895 | } | 905 | } |
896 | } | 906 | } |
897 | } | 907 | } |
898 | return false; | 908 | return false; |
899 | } | 909 | } |
900 | 910 | ||
901 | bool Zaurus::setSoftSuspend ( bool soft ) | 911 | bool Zaurus::setSoftSuspend ( bool soft ) |
902 | { | 912 | { |
903 | bool res = false; | 913 | bool res = false; |
904 | int fd; | 914 | int fd; |
905 | 915 | ||
906 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 916 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
907 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 917 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
908 | 918 | ||
909 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 919 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
910 | 920 | ||
911 | if ( sources >= 0 ) { | 921 | if ( sources >= 0 ) { |
912 | if ( soft ) | 922 | if ( soft ) |
913 | sources &= ~APM_EVT_POWER_BUTTON; | 923 | sources &= ~APM_EVT_POWER_BUTTON; |
914 | else | 924 | else |
915 | sources |= APM_EVT_POWER_BUTTON; | 925 | sources |= APM_EVT_POWER_BUTTON; |
916 | 926 | ||
917 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 927 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
918 | res = true; | 928 | res = true; |
919 | else | 929 | else |
920 | perror ( "APM_IOCGEVTSRC" ); | 930 | perror ( "APM_IOCGEVTSRC" ); |
921 | } | 931 | } |
922 | else | 932 | else |
923 | perror ( "APM_IOCGEVTSRC" ); | 933 | perror ( "APM_IOCGEVTSRC" ); |
924 | 934 | ||
925 | ::close ( fd ); | 935 | ::close ( fd ); |
926 | } | 936 | } |
927 | else | 937 | else |
928 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 938 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
929 | 939 | ||
930 | return res; | 940 | return res; |
931 | } | 941 | } |
932 | 942 | ||
933 | 943 | ||
934 | bool Zaurus::setDisplayBrightness ( int bright ) | 944 | bool Zaurus::setDisplayBrightness ( int bright ) |
935 | { | 945 | { |
936 | bool res = false; | 946 | bool res = false; |
937 | int fd; | 947 | int fd; |
938 | 948 | ||
939 | if ( bright > 255 ) | 949 | if ( bright > 255 ) |
940 | bright = 255; | 950 | bright = 255; |
941 | if ( bright < 0 ) | 951 | if ( bright < 0 ) |
942 | bright = 0; | 952 | bright = 0; |
943 | 953 | ||
944 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 954 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
945 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 955 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
946 | if ( bright && !bl ) | 956 | if ( bright && !bl ) |
947 | bl = 1; | 957 | bl = 1; |
948 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 958 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
949 | ::close ( fd ); | 959 | ::close ( fd ); |
950 | } | 960 | } |
951 | return res; | 961 | return res; |
952 | } | 962 | } |
953 | 963 | ||
954 | 964 | ||
955 | int Zaurus::displayBrightnessResolution ( ) const | 965 | int Zaurus::displayBrightnessResolution ( ) const |
956 | { | 966 | { |
957 | return 5; | 967 | return 5; |
958 | } | 968 | } |
959 | 969 | ||
960 | //QValueList <int> Zaurus::keyList ( ) const | ||
961 | //{ | ||
962 | //QValueList <int> vl; | ||
963 | //vl << HardKey_Datebook << HardKey_Contacts << HardKey_Mail << HardKey_Menu << HardKey_Home << HardKey_Suspend << HardKey_Backlight; | ||
964 | //return vl; | ||
965 | //} | ||
966 | 970 | ||
diff --git a/libopie/odevice.h b/libopie/odevice.h index e07b91c..e50009c 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,146 +1,149 @@ | |||
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 <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qnamespace.h> | 24 | #include <qnamespace.h> |
25 | 25 | ||
26 | class ODeviceData; | 26 | class ODeviceData; |
27 | 27 | ||
28 | namespace Opie { | 28 | namespace Opie { |
29 | 29 | ||
30 | enum OModel { | 30 | enum OModel { |
31 | Model_Unknown, | 31 | Model_Unknown, |
32 | |||
33 | Model_Series_Mask = 0xff000000, | ||
32 | 34 | ||
33 | Model_iPAQ = ( 1 << 16 ), | 35 | Model_iPAQ = ( 1 << 24 ), |
34 | 36 | ||
35 | Model_iPAQ_H31xx = ( Model_iPAQ | 1 ), | 37 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
36 | Model_iPAQ_H36xx = ( Model_iPAQ | 2 ), | 38 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
37 | Model_iPAQ_H37xx = ( Model_iPAQ | 3 ), | 39 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
38 | Model_iPAQ_H38xx = ( Model_iPAQ | 4 ), | 40 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
41 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | ||
42 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | ||
39 | 43 | ||
40 | Model_Zaurus = ( 2 << 16 ), | 44 | Model_Zaurus = ( 2 << 24 ), |
41 | 45 | ||
42 | Model_Zaurus_SL5000 = ( Model_Zaurus | 1 ), | 46 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
43 | }; | 47 | }; |
44 | 48 | ||
45 | enum OVendor { | 49 | enum OVendor { |
46 | Vendor_Unknown, | 50 | Vendor_Unknown, |
47 | 51 | ||
48 | Vendor_HP, | 52 | Vendor_HP, |
49 | Vendor_Sharp | 53 | Vendor_Sharp |
50 | }; | 54 | }; |
51 | 55 | ||
52 | enum OSystem { | 56 | enum OSystem { |
53 | System_Unknown, | 57 | System_Unknown, |
54 | 58 | ||
55 | System_Familiar, | 59 | System_Familiar, |
56 | System_Zaurus, | 60 | System_Zaurus, |
57 | System_OpenZaurus | 61 | System_OpenZaurus |
58 | }; | 62 | }; |
59 | 63 | ||
60 | enum OLedState { | 64 | enum OLedState { |
61 | Led_Off, | 65 | Led_Off, |
62 | Led_On, | 66 | Led_On, |
63 | Led_BlinkSlow, | 67 | Led_BlinkSlow, |
64 | Led_BlinkFast | 68 | Led_BlinkFast |
65 | }; | 69 | }; |
66 | 70 | ||
67 | enum OLed { | 71 | enum OLed { |
68 | Led_Mail, | 72 | Led_Mail, |
69 | Led_Power, | 73 | Led_Power, |
70 | Led_BlueTooth | 74 | Led_BlueTooth |
71 | }; | 75 | }; |
72 | 76 | ||
73 | enum OHardKey { | 77 | enum OHardKey { |
74 | HardKey_Datebook = Qt::Key_F9, | 78 | HardKey_Datebook = Qt::Key_F9, |
75 | HardKey_Contacts = Qt::Key_F10, | 79 | HardKey_Contacts = Qt::Key_F10, |
76 | HardKey_Menu = Qt::Key_F11, | 80 | HardKey_Menu = Qt::Key_F11, |
77 | HardKey_Home = Qt::Key_F12, | 81 | HardKey_Home = Qt::Key_F12, |
78 | HardKey_Mail = Qt::Key_F14, | 82 | HardKey_Mail = Qt::Key_F14, |
79 | HardKey_Record = Qt::Key_F24, | 83 | HardKey_Record = Qt::Key_F24, |
80 | HardKey_Suspend = Qt::Key_F34, | 84 | HardKey_Suspend = Qt::Key_F34, |
81 | HardKey_Backlight = Qt::Key_F35, | 85 | HardKey_Backlight = Qt::Key_F35, |
82 | }; | 86 | }; |
83 | 87 | ||
84 | 88 | ||
85 | class ODevice | 89 | class ODevice |
86 | { | 90 | { |
87 | private: | 91 | private: |
88 | ODevice ( const ODevice & ); | 92 | ODevice ( const ODevice & ); |
89 | 93 | ||
90 | protected: | 94 | protected: |
91 | ODevice ( ); | 95 | ODevice ( ); |
92 | virtual void init ( ); | 96 | virtual void init ( ); |
93 | 97 | ||
94 | ODeviceData *d; | 98 | ODeviceData *d; |
95 | 99 | ||
96 | public: | 100 | public: |
97 | virtual ~ODevice ( ); | 101 | virtual ~ODevice ( ); |
98 | 102 | ||
99 | static ODevice *inst ( ); | 103 | static ODevice *inst ( ); |
100 | 104 | ||
101 | 105 | ||
102 | 106 | ||
103 | // information | 107 | // information |
104 | 108 | ||
105 | QString modelString ( ) const; | 109 | QString modelString ( ) const; |
106 | OModel model ( ) const; | 110 | OModel model ( ) const; |
111 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | ||
107 | 112 | ||
108 | QString vendorString ( ) const; | 113 | QString vendorString ( ) const; |
109 | OVendor vendor ( ) const; | 114 | OVendor vendor ( ) const; |
110 | 115 | ||
111 | QString systemString ( ) const; | 116 | QString systemString ( ) const; |
112 | OSystem system ( ) const; | 117 | OSystem system ( ) const; |
113 | 118 | ||
114 | QString systemVersionString ( ) const; | 119 | QString systemVersionString ( ) const; |
115 | 120 | ||
116 | // system | 121 | // system |
117 | 122 | ||
118 | virtual bool setSoftSuspend ( bool on ); | 123 | virtual bool setSoftSuspend ( bool on ); |
119 | virtual bool suspend ( ); | 124 | virtual bool suspend ( ); |
120 | 125 | ||
121 | virtual bool setDisplayStatus ( bool on ); | 126 | virtual bool setDisplayStatus ( bool on ); |
122 | virtual bool setDisplayBrightness ( int brightness ); | 127 | virtual bool setDisplayBrightness ( int brightness ); |
123 | virtual int displayBrightnessResolution ( ) const; | 128 | virtual int displayBrightnessResolution ( ) const; |
124 | 129 | ||
125 | // input / output | 130 | // input / output |
126 | 131 | ||
127 | virtual void alarmSound ( ); | 132 | virtual void alarmSound ( ); |
128 | virtual void keySound ( ); | 133 | virtual void keySound ( ); |
129 | virtual void touchSound ( ); | 134 | virtual void touchSound ( ); |
130 | 135 | ||
131 | virtual QValueList <OLed> ledList ( ) const; | 136 | virtual QValueList <OLed> ledList ( ) const; |
132 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 137 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
133 | virtual OLedState ledState ( OLed led ) const; | 138 | virtual OLedState ledState ( OLed led ) const; |
134 | virtual bool setLedState ( OLed led, OLedState st ); | 139 | virtual bool setLedState ( OLed led, OLedState st ); |
135 | 140 | ||
136 | virtual bool hasLightSensor ( ) const; | 141 | virtual bool hasLightSensor ( ) const; |
137 | virtual int readLightSensor ( ); | 142 | virtual int readLightSensor ( ); |
138 | virtual int lightSensorResolution ( ) const; | 143 | virtual int lightSensorResolution ( ) const; |
139 | |||
140 | //virtual QValueList <int> keyList ( ) const; | ||
141 | }; | 144 | }; |
142 | 145 | ||
143 | } | 146 | } |
144 | 147 | ||
145 | #endif | 148 | #endif |
146 | 149 | ||