author | erik <erik> | 2007-02-21 16:59:03 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-21 16:59:03 (UTC) |
commit | 6b0fa616c4aac654c549621eb0009ab3eb32fe34 (patch) (unidiff) | |
tree | b5a592194a9cbf3b02b38b0d2e412201beb5b49c | |
parent | 45f2e4cdc6e185439ef4bde6e2b8181a4decd032 (diff) | |
download | opie-6b0fa616c4aac654c549621eb0009ab3eb32fe34.zip opie-6b0fa616c4aac654c549621eb0009ab3eb32fe34.tar.gz opie-6b0fa616c4aac654c549621eb0009ab3eb32fe34.tar.bz2 |
This commit fixes Opie bug 1839:
http://opie-bugs.oszine.de/view.php?id=1839
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 02b685a..6dc1295 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -224,210 +224,206 @@ void iPAQ::initButtons() | |||
224 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 224 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
225 | i_button *ib = ipaq_buttons + i; | 225 | i_button *ib = ipaq_buttons + i; |
226 | ODeviceButton b; | 226 | ODeviceButton b; |
227 | 227 | ||
228 | if (( ib->model & d->m_model ) == d->m_model ) { | 228 | if (( ib->model & d->m_model ) == d->m_model ) { |
229 | b. setKeycode ( ib->code ); | 229 | b. setKeycode ( ib->code ); |
230 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 230 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
231 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); | 231 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
232 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 232 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
233 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 233 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
234 | 234 | ||
235 | d->m_buttons->append ( b ); | 235 | d->m_buttons->append ( b ); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | reloadButtonMapping(); | 238 | reloadButtonMapping(); |
239 | } | 239 | } |
240 | 240 | ||
241 | QValueList <OLed> iPAQ::ledList() const | 241 | QValueList <OLed> iPAQ::ledList() const |
242 | { | 242 | { |
243 | QValueList <OLed> vl; | 243 | QValueList <OLed> vl; |
244 | vl << Led_Power; | 244 | vl << Led_Power; |
245 | 245 | ||
246 | if ( d->m_model == Model_iPAQ_H38xx ) | 246 | if ( d->m_model == Model_iPAQ_H38xx ) |
247 | vl << Led_BlueTooth; | 247 | vl << Led_BlueTooth; |
248 | return vl; | 248 | return vl; |
249 | } | 249 | } |
250 | 250 | ||
251 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 251 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
252 | { | 252 | { |
253 | QValueList <OLedState> vl; | 253 | QValueList <OLedState> vl; |
254 | 254 | ||
255 | if ( l == Led_Power ) | 255 | if ( l == Led_Power ) |
256 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 256 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
257 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) | 257 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) |
258 | vl << Led_Off; // << Led_On << ??? | 258 | vl << Led_Off; // << Led_On << ??? |
259 | 259 | ||
260 | return vl; | 260 | return vl; |
261 | } | 261 | } |
262 | 262 | ||
263 | OLedState iPAQ::ledState ( OLed l ) const | 263 | OLedState iPAQ::ledState ( OLed l ) const |
264 | { | 264 | { |
265 | switch ( l ) { | 265 | switch ( l ) { |
266 | case Led_Power: | 266 | case Led_Power: |
267 | return m_leds [0]; | 267 | return m_leds [0]; |
268 | case Led_BlueTooth: | 268 | case Led_BlueTooth: |
269 | return m_leds [1]; | 269 | return m_leds [1]; |
270 | default: | 270 | default: |
271 | return Led_Off; | 271 | return Led_Off; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 275 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
276 | { | 276 | { |
277 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 277 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
278 | 278 | ||
279 | if ( l == Led_Power ) { | 279 | if ( l == Led_Power ) { |
280 | if ( fd >= 0 ) { | 280 | if ( fd >= 0 ) { |
281 | LED_IN leds; | 281 | LED_IN leds; |
282 | ::memset ( &leds, 0, sizeof( leds )); | 282 | ::memset ( &leds, 0, sizeof( leds )); |
283 | leds. TotalTime = 0; | 283 | leds. TotalTime = 0; |
284 | leds. OnTime = 0; | 284 | leds. OnTime = 0; |
285 | leds. OffTime = 1; | 285 | leds. OffTime = 1; |
286 | leds. OffOnBlink = 2; | 286 | leds. OffOnBlink = 2; |
287 | 287 | ||
288 | switch ( st ) { | 288 | switch ( st ) { |
289 | case Led_Off : leds. OffOnBlink = 0; break; | 289 | case Led_Off : leds. OffOnBlink = 0; break; |
290 | case Led_On : leds. OffOnBlink = 1; break; | 290 | case Led_On : leds. OffOnBlink = 1; break; |
291 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 291 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
292 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 292 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
293 | } | 293 | } |
294 | 294 | ||
295 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 295 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
296 | m_leds [0] = st; | 296 | m_leds [0] = st; |
297 | return true; | 297 | return true; |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | return false; | 301 | return false; |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 305 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
306 | { | 306 | { |
307 | int newkeycode = keycode; | 307 | int newkeycode = keycode; |
308 | 308 | ||
309 | switch ( keycode ) { | 309 | switch ( keycode ) { |
310 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 310 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
311 | case HardKey_Menu: { | 311 | case HardKey_Menu: { |
312 | if (( d->m_model == Model_iPAQ_H38xx ) || | 312 | if (( d->m_model == Model_iPAQ_H38xx ) || |
313 | ( d->m_model == Model_iPAQ_H39xx ) || | 313 | ( d->m_model == Model_iPAQ_H39xx ) || |
314 | ( d->m_model == Model_iPAQ_H5xxx)) { | 314 | ( d->m_model == Model_iPAQ_H5xxx)) { |
315 | newkeycode = HardKey_Mail; | 315 | newkeycode = HardKey_Mail; |
316 | } | 316 | } |
317 | break; | 317 | break; |
318 | } | 318 | } |
319 | 319 | ||
320 | // Rotate cursor keys 180 or 270 | 320 | // QT has strange screen coordinate system, so depending |
321 | // on native device screen orientation, we need to rotate cursor keys | ||
321 | case Key_Left : | 322 | case Key_Left : |
322 | case Key_Right: | 323 | case Key_Right: |
323 | case Key_Up : | 324 | case Key_Up : |
324 | case Key_Down : { | 325 | case Key_Down : { |
325 | if (( d->m_model == Model_iPAQ_H31xx ) || | 326 | int quarters; |
326 | ( d->m_model == Model_iPAQ_H38xx )) { | 327 | switch (d->m_rotation) { |
327 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 328 | case Rot0: quarters = 3/*270deg*/; break; |
329 | case Rot90: quarters = 2/*270deg*/; break; | ||
330 | case Rot180: quarters = 1/*270deg*/; break; | ||
331 | case Rot270: quarters = 0/*270deg*/; break; | ||
328 | } | 332 | } |
329 | // Rotate the cursor keys by 270 | 333 | newkeycode = Key_Left + ( keycode - Key_Left + quarters ) % 4; |
330 | // keycode - Key_Left = position of the button starting from left clockwise | ||
331 | // add the rotation to it and modolo. No we've the original offset | ||
332 | // add the offset to the Key_Left key | ||
333 | if (( d->m_model == Model_iPAQ_H5xxx ) || | ||
334 | ( d->m_model == Model_iPAQ_H191x ) || | ||
335 | ( d->m_model == Model_iPAQ_H4xxx ) || | ||
336 | ( d->m_model == Model_iPAQ_H1940 )) | ||
337 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | ||
338 | break; | 334 | break; |
339 | } | 335 | } |
340 | 336 | ||
341 | // map Power Button short/long press to F34/F35 | 337 | // map Power Button short/long press to F34/F35 |
342 | case HardKey_Suspend: // Hope we don't have infinite recursion here | 338 | case HardKey_Suspend: // Hope we don't have infinite recursion here |
343 | case Key_SysReq: { | 339 | case Key_SysReq: { |
344 | if ( isPress ) { | 340 | if ( isPress ) { |
345 | if ( m_power_timer ) | 341 | if ( m_power_timer ) |
346 | killTimer ( m_power_timer ); | 342 | killTimer ( m_power_timer ); |
347 | m_power_timer = startTimer ( 500 ); | 343 | m_power_timer = startTimer ( 500 ); |
348 | } | 344 | } |
349 | else if ( m_power_timer ) { | 345 | else if ( m_power_timer ) { |
350 | killTimer ( m_power_timer ); | 346 | killTimer ( m_power_timer ); |
351 | m_power_timer = 0; | 347 | m_power_timer = 0; |
352 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 348 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
353 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 349 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
354 | } | 350 | } |
355 | newkeycode = Key_unknown; | 351 | newkeycode = Key_unknown; |
356 | break; | 352 | break; |
357 | } | 353 | } |
358 | } | 354 | } |
359 | 355 | ||
360 | if ( newkeycode != keycode ) { | 356 | if ( newkeycode != keycode ) { |
361 | if ( newkeycode != Key_unknown ) | 357 | if ( newkeycode != Key_unknown ) |
362 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 358 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
363 | return true; | 359 | return true; |
364 | } | 360 | } |
365 | else | 361 | else |
366 | return false; | 362 | return false; |
367 | } | 363 | } |
368 | 364 | ||
369 | void iPAQ::timerEvent ( QTimerEvent * ) | 365 | void iPAQ::timerEvent ( QTimerEvent * ) |
370 | { | 366 | { |
371 | killTimer ( m_power_timer ); | 367 | killTimer ( m_power_timer ); |
372 | m_power_timer = 0; | 368 | m_power_timer = 0; |
373 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 369 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
374 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 370 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
375 | } | 371 | } |
376 | 372 | ||
377 | 373 | ||
378 | void iPAQ::playAlarmSound() | 374 | void iPAQ::playAlarmSound() |
379 | { | 375 | { |
380 | #ifndef QT_NO_SOUND | 376 | #ifndef QT_NO_SOUND |
381 | static Sound snd ( "alarm" ); | 377 | static Sound snd ( "alarm" ); |
382 | if(!snd.isFinished()) | 378 | if(!snd.isFinished()) |
383 | return; | 379 | return; |
384 | 380 | ||
385 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 381 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
386 | snd. play(); | 382 | snd. play(); |
387 | #endif | 383 | #endif |
388 | } | 384 | } |
389 | 385 | ||
390 | bool iPAQ::setDisplayBrightness ( int bright ) | 386 | bool iPAQ::setDisplayBrightness ( int bright ) |
391 | { | 387 | { |
392 | bool res = false; | 388 | bool res = false; |
393 | int fd; | 389 | int fd; |
394 | 390 | ||
395 | if ( bright > 255 ) | 391 | if ( bright > 255 ) |
396 | bright = 255; | 392 | bright = 255; |
397 | if ( bright < 0 ) | 393 | if ( bright < 0 ) |
398 | bright = 0; | 394 | bright = 0; |
399 | 395 | ||
400 | QDir sysClass( "/sys/class/backlight/" ); | 396 | QDir sysClass( "/sys/class/backlight/" ); |
401 | sysClass.setFilter(QDir::Dirs); | 397 | sysClass.setFilter(QDir::Dirs); |
402 | if ( sysClass.exists() && sysClass.count() > 2 ) { | 398 | if ( sysClass.exists() && sysClass.count() > 2 ) { |
403 | QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" ); | 399 | QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" ); |
404 | int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK ); | 400 | int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK ); |
405 | if ( fd ) { | 401 | if ( fd ) { |
406 | char buf[100]; | 402 | char buf[100]; |
407 | int val = bright * displayBrightnessResolution() / 255; | 403 | int val = bright * displayBrightnessResolution() / 255; |
408 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 404 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
409 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 405 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
410 | ::close( fd ); | 406 | ::close( fd ); |
411 | } | 407 | } |
412 | } else { | 408 | } else { |
413 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 409 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
414 | FLITE_IN bl; | 410 | FLITE_IN bl; |
415 | bl. mode = 1; | 411 | bl. mode = 1; |
416 | bl. pwr = bright ? 1 : 0; | 412 | bl. pwr = bright ? 1 : 0; |
417 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 413 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
418 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 414 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
419 | ::close ( fd ); | 415 | ::close ( fd ); |
420 | } | 416 | } |
421 | } | 417 | } |
422 | 418 | ||
423 | return res; | 419 | return res; |
424 | } | 420 | } |
425 | 421 | ||
426 | int iPAQ::displayBrightnessResolution() const | 422 | int iPAQ::displayBrightnessResolution() const |
427 | { | 423 | { |
428 | int res = 16; | 424 | int res = 16; |
429 | 425 | ||
430 | QDir sysClass( "/sys/class/backlight/" ); | 426 | QDir sysClass( "/sys/class/backlight/" ); |
431 | sysClass.setFilter(QDir::Dirs); | 427 | sysClass.setFilter(QDir::Dirs); |
432 | if ( sysClass.exists() && sysClass.count() > 2 ) { | 428 | if ( sysClass.exists() && sysClass.count() > 2 ) { |
433 | QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" ); | 429 | QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" ); |