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