author | mickeyl <mickeyl> | 2003-05-07 13:44:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-07 13:44:23 (UTC) |
commit | 4619398b4712062e65d1919156edea38785c590e (patch) (unidiff) | |
tree | 4d00604960974ca16f9d40468bce4c096e2a76b0 /libopie/odevice.cpp | |
parent | 83f53eede83728c131b1134ae0a674a7d8f6f00a (diff) | |
download | opie-4619398b4712062e65d1919156edea38785c590e.zip opie-4619398b4712062e65d1919156edea38785c590e.tar.gz opie-4619398b4712062e65d1919156edea38785c590e.tar.bz2 |
fix bug kergoth introduced in rev 1.43
fd was an integer static to the function which means that the assignment only
happens once. This is ok, when we don't close the device, but not if we close
it after usage. Thanks to eilers for confirming! I wonder why noone else spotted this...
-rw-r--r-- | libopie/odevice.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 62e3569..7d862cd 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -283,1160 +283,1160 @@ ODevice::ODevice ( ) | |||
283 | 283 | ||
284 | d-> m_holdtime = 1000; // 1000ms | 284 | d-> m_holdtime = 1000; // 1000ms |
285 | d-> m_buttons = 0; | 285 | d-> m_buttons = 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 288 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
289 | { | 289 | { |
290 | if ( msg == "deviceButtonMappingChanged()" ) { | 290 | if ( msg == "deviceButtonMappingChanged()" ) { |
291 | reloadButtonMapping ( ); | 291 | reloadButtonMapping ( ); |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | void ODevice::init ( ) | 295 | void ODevice::init ( ) |
296 | { | 296 | { |
297 | } | 297 | } |
298 | 298 | ||
299 | /** | 299 | /** |
300 | * This method initialises the button mapping | 300 | * This method initialises the button mapping |
301 | */ | 301 | */ |
302 | void ODevice::initButtons ( ) | 302 | void ODevice::initButtons ( ) |
303 | { | 303 | { |
304 | if ( d-> m_buttons ) | 304 | if ( d-> m_buttons ) |
305 | return; | 305 | return; |
306 | 306 | ||
307 | // Simulation uses iPAQ 3660 device buttons | 307 | // Simulation uses iPAQ 3660 device buttons |
308 | 308 | ||
309 | qDebug ( "init Buttons" ); | 309 | qDebug ( "init Buttons" ); |
310 | d-> m_buttons = new QValueList <ODeviceButton>; | 310 | d-> m_buttons = new QValueList <ODeviceButton>; |
311 | 311 | ||
312 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 312 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
313 | i_button *ib = ipaq_buttons + i; | 313 | i_button *ib = ipaq_buttons + i; |
314 | ODeviceButton b; | 314 | ODeviceButton b; |
315 | 315 | ||
316 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 316 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
317 | b. setKeycode ( ib-> code ); | 317 | b. setKeycode ( ib-> code ); |
318 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 318 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
319 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 319 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
320 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 320 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
321 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 321 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
322 | d-> m_buttons-> append ( b ); | 322 | d-> m_buttons-> append ( b ); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | reloadButtonMapping ( ); | 325 | reloadButtonMapping ( ); |
326 | 326 | ||
327 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 327 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
328 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 328 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
329 | } | 329 | } |
330 | 330 | ||
331 | ODevice::~ODevice ( ) | 331 | ODevice::~ODevice ( ) |
332 | { | 332 | { |
333 | delete d; | 333 | delete d; |
334 | } | 334 | } |
335 | 335 | ||
336 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 336 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
337 | { | 337 | { |
338 | return false; | 338 | return false; |
339 | } | 339 | } |
340 | 340 | ||
341 | //#include <linux/apm_bios.h> | 341 | //#include <linux/apm_bios.h> |
342 | 342 | ||
343 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 343 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
344 | 344 | ||
345 | /** | 345 | /** |
346 | * This method will try to suspend the device | 346 | * This method will try to suspend the device |
347 | * It only works if the user is the QWS Server and the apm application | 347 | * It only works if the user is the QWS Server and the apm application |
348 | * is installed. | 348 | * is installed. |
349 | * It tries to suspend and then waits some time cause some distributions | 349 | * It tries to suspend and then waits some time cause some distributions |
350 | * do have asynchronus apm implementations. | 350 | * do have asynchronus apm implementations. |
351 | * This method will either fail and return false or it'll suspend the | 351 | * This method will either fail and return false or it'll suspend the |
352 | * device and return once the device got woken up | 352 | * device and return once the device got woken up |
353 | * | 353 | * |
354 | * @return if the device got suspended | 354 | * @return if the device got suspended |
355 | */ | 355 | */ |
356 | bool ODevice::suspend ( ) | 356 | bool ODevice::suspend ( ) |
357 | { | 357 | { |
358 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 358 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
359 | return false; | 359 | return false; |
360 | 360 | ||
361 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 361 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
362 | return false; | 362 | return false; |
363 | 363 | ||
364 | bool res = false; | 364 | bool res = false; |
365 | 365 | ||
366 | struct timeval tvs, tvn; | 366 | struct timeval tvs, tvn; |
367 | ::gettimeofday ( &tvs, 0 ); | 367 | ::gettimeofday ( &tvs, 0 ); |
368 | 368 | ||
369 | ::sync ( ); // flush fs caches | 369 | ::sync ( ); // flush fs caches |
370 | res = ( ::system ( "apm --suspend" ) == 0 ); | 370 | res = ( ::system ( "apm --suspend" ) == 0 ); |
371 | 371 | ||
372 | // This is needed because the iPAQ apm implementation is asynchronous and we | 372 | // This is needed because the iPAQ apm implementation is asynchronous and we |
373 | // can not be sure when exactly the device is really suspended | 373 | // can not be sure when exactly the device is really suspended |
374 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 374 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
375 | 375 | ||
376 | if ( res ) { | 376 | if ( res ) { |
377 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 377 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
378 | ::usleep ( 200 * 1000 ); | 378 | ::usleep ( 200 * 1000 ); |
379 | ::gettimeofday ( &tvn, 0 ); | 379 | ::gettimeofday ( &tvn, 0 ); |
380 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 380 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
381 | } | 381 | } |
382 | 382 | ||
383 | return res; | 383 | return res; |
384 | } | 384 | } |
385 | 385 | ||
386 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 386 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
387 | 387 | ||
388 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 388 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
389 | 389 | ||
390 | /* VESA Blanking Levels */ | 390 | /* VESA Blanking Levels */ |
391 | #define VESA_NO_BLANKING 0 | 391 | #define VESA_NO_BLANKING 0 |
392 | #define VESA_VSYNC_SUSPEND 1 | 392 | #define VESA_VSYNC_SUSPEND 1 |
393 | #define VESA_HSYNC_SUSPEND 2 | 393 | #define VESA_HSYNC_SUSPEND 2 |
394 | #define VESA_POWERDOWN 3 | 394 | #define VESA_POWERDOWN 3 |
395 | 395 | ||
396 | /** | 396 | /** |
397 | * This sets the display on or off | 397 | * This sets the display on or off |
398 | */ | 398 | */ |
399 | bool ODevice::setDisplayStatus ( bool on ) | 399 | bool ODevice::setDisplayStatus ( bool on ) |
400 | { | 400 | { |
401 | if ( d-> m_model == Model_Unknown ) | 401 | if ( d-> m_model == Model_Unknown ) |
402 | return false; | 402 | return false; |
403 | 403 | ||
404 | bool res = false; | 404 | bool res = false; |
405 | int fd; | 405 | int fd; |
406 | 406 | ||
407 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 407 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
408 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 408 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
409 | ::close ( fd ); | 409 | ::close ( fd ); |
410 | } | 410 | } |
411 | return res; | 411 | return res; |
412 | } | 412 | } |
413 | 413 | ||
414 | /** | 414 | /** |
415 | * This sets the display brightness | 415 | * This sets the display brightness |
416 | * @return success or failure | 416 | * @return success or failure |
417 | */ | 417 | */ |
418 | bool ODevice::setDisplayBrightness ( int p) | 418 | bool ODevice::setDisplayBrightness ( int p) |
419 | { | 419 | { |
420 | Q_UNUSED( p ) | 420 | Q_UNUSED( p ) |
421 | return false; | 421 | return false; |
422 | } | 422 | } |
423 | 423 | ||
424 | int ODevice::displayBrightnessResolution ( ) const | 424 | int ODevice::displayBrightnessResolution ( ) const |
425 | { | 425 | { |
426 | return 16; | 426 | return 16; |
427 | } | 427 | } |
428 | 428 | ||
429 | /** | 429 | /** |
430 | * This returns the vendor as string | 430 | * This returns the vendor as string |
431 | * @return Vendor as QString | 431 | * @return Vendor as QString |
432 | */ | 432 | */ |
433 | QString ODevice::vendorString ( ) const | 433 | QString ODevice::vendorString ( ) const |
434 | { | 434 | { |
435 | return d-> m_vendorstr; | 435 | return d-> m_vendorstr; |
436 | } | 436 | } |
437 | 437 | ||
438 | /** | 438 | /** |
439 | * This returns the vendor as one of the values of OVendor | 439 | * This returns the vendor as one of the values of OVendor |
440 | * @return OVendor | 440 | * @return OVendor |
441 | */ | 441 | */ |
442 | OVendor ODevice::vendor ( ) const | 442 | OVendor ODevice::vendor ( ) const |
443 | { | 443 | { |
444 | return d-> m_vendor; | 444 | return d-> m_vendor; |
445 | } | 445 | } |
446 | 446 | ||
447 | /** | 447 | /** |
448 | * This returns the model as a string | 448 | * This returns the model as a string |
449 | * @return A string representing the model | 449 | * @return A string representing the model |
450 | */ | 450 | */ |
451 | QString ODevice::modelString ( ) const | 451 | QString ODevice::modelString ( ) const |
452 | { | 452 | { |
453 | return d-> m_modelstr; | 453 | return d-> m_modelstr; |
454 | } | 454 | } |
455 | 455 | ||
456 | /** | 456 | /** |
457 | * This does return the OModel used | 457 | * This does return the OModel used |
458 | */ | 458 | */ |
459 | OModel ODevice::model ( ) const | 459 | OModel ODevice::model ( ) const |
460 | { | 460 | { |
461 | return d-> m_model; | 461 | return d-> m_model; |
462 | } | 462 | } |
463 | 463 | ||
464 | /** | 464 | /** |
465 | * This does return the systen name | 465 | * This does return the systen name |
466 | */ | 466 | */ |
467 | QString ODevice::systemString ( ) const | 467 | QString ODevice::systemString ( ) const |
468 | { | 468 | { |
469 | return d-> m_systemstr; | 469 | return d-> m_systemstr; |
470 | } | 470 | } |
471 | 471 | ||
472 | /** | 472 | /** |
473 | * Return System as OSystem value | 473 | * Return System as OSystem value |
474 | */ | 474 | */ |
475 | OSystem ODevice::system ( ) const | 475 | OSystem ODevice::system ( ) const |
476 | { | 476 | { |
477 | return d-> m_system; | 477 | return d-> m_system; |
478 | } | 478 | } |
479 | 479 | ||
480 | /** | 480 | /** |
481 | * @return the version string of the base system | 481 | * @return the version string of the base system |
482 | */ | 482 | */ |
483 | QString ODevice::systemVersionString ( ) const | 483 | QString ODevice::systemVersionString ( ) const |
484 | { | 484 | { |
485 | return d-> m_sysverstr; | 485 | return d-> m_sysverstr; |
486 | } | 486 | } |
487 | 487 | ||
488 | /** | 488 | /** |
489 | * @return the current Transformation | 489 | * @return the current Transformation |
490 | */ | 490 | */ |
491 | Transformation ODevice::rotation ( ) const | 491 | Transformation ODevice::rotation ( ) const |
492 | { | 492 | { |
493 | return d-> m_rotation; | 493 | return d-> m_rotation; |
494 | } | 494 | } |
495 | 495 | ||
496 | /** | 496 | /** |
497 | * @return the current rotation direction | 497 | * @return the current rotation direction |
498 | */ | 498 | */ |
499 | ODirection ODevice::direction ( ) const | 499 | ODirection ODevice::direction ( ) const |
500 | { | 500 | { |
501 | return d-> m_direction; | 501 | return d-> m_direction; |
502 | } | 502 | } |
503 | 503 | ||
504 | /** | 504 | /** |
505 | * This plays an alarmSound | 505 | * This plays an alarmSound |
506 | */ | 506 | */ |
507 | void ODevice::alarmSound ( ) | 507 | void ODevice::alarmSound ( ) |
508 | { | 508 | { |
509 | #ifndef QT_NO_SOUND | 509 | #ifndef QT_NO_SOUND |
510 | static Sound snd ( "alarm" ); | 510 | static Sound snd ( "alarm" ); |
511 | 511 | ||
512 | if ( snd. isFinished ( )) | 512 | if ( snd. isFinished ( )) |
513 | snd. play ( ); | 513 | snd. play ( ); |
514 | #endif | 514 | #endif |
515 | } | 515 | } |
516 | 516 | ||
517 | /** | 517 | /** |
518 | * This plays a key sound | 518 | * This plays a key sound |
519 | */ | 519 | */ |
520 | void ODevice::keySound ( ) | 520 | void ODevice::keySound ( ) |
521 | { | 521 | { |
522 | #ifndef QT_NO_SOUND | 522 | #ifndef QT_NO_SOUND |
523 | static Sound snd ( "keysound" ); | 523 | static Sound snd ( "keysound" ); |
524 | 524 | ||
525 | if ( snd. isFinished ( )) | 525 | if ( snd. isFinished ( )) |
526 | snd. play ( ); | 526 | snd. play ( ); |
527 | #endif | 527 | #endif |
528 | } | 528 | } |
529 | 529 | ||
530 | /** | 530 | /** |
531 | * This plays a touch sound | 531 | * This plays a touch sound |
532 | */ | 532 | */ |
533 | void ODevice::touchSound ( ) | 533 | void ODevice::touchSound ( ) |
534 | { | 534 | { |
535 | 535 | ||
536 | #ifndef QT_NO_SOUND | 536 | #ifndef QT_NO_SOUND |
537 | static Sound snd ( "touchsound" ); | 537 | static Sound snd ( "touchsound" ); |
538 | 538 | ||
539 | if ( snd. isFinished ( )) | 539 | if ( snd. isFinished ( )) |
540 | snd. play ( ); | 540 | snd. play ( ); |
541 | #endif | 541 | #endif |
542 | } | 542 | } |
543 | 543 | ||
544 | /** | 544 | /** |
545 | * This method will return a list of leds | 545 | * This method will return a list of leds |
546 | * available on this device | 546 | * available on this device |
547 | * @return a list of LEDs. | 547 | * @return a list of LEDs. |
548 | */ | 548 | */ |
549 | QValueList <OLed> ODevice::ledList ( ) const | 549 | QValueList <OLed> ODevice::ledList ( ) const |
550 | { | 550 | { |
551 | return QValueList <OLed> ( ); | 551 | return QValueList <OLed> ( ); |
552 | } | 552 | } |
553 | 553 | ||
554 | /** | 554 | /** |
555 | * This does return the state of the LEDs | 555 | * This does return the state of the LEDs |
556 | */ | 556 | */ |
557 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 557 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
558 | { | 558 | { |
559 | return QValueList <OLedState> ( ); | 559 | return QValueList <OLedState> ( ); |
560 | } | 560 | } |
561 | 561 | ||
562 | /** | 562 | /** |
563 | * @return the state for a given OLed | 563 | * @return the state for a given OLed |
564 | */ | 564 | */ |
565 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 565 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
566 | { | 566 | { |
567 | return Led_Off; | 567 | return Led_Off; |
568 | } | 568 | } |
569 | 569 | ||
570 | /** | 570 | /** |
571 | * Set the state for a LED | 571 | * Set the state for a LED |
572 | * @param which Which OLed to use | 572 | * @param which Which OLed to use |
573 | * @param st The state to set | 573 | * @param st The state to set |
574 | * @return success or failure | 574 | * @return success or failure |
575 | */ | 575 | */ |
576 | bool ODevice::setLedState ( OLed which, OLedState st ) | 576 | bool ODevice::setLedState ( OLed which, OLedState st ) |
577 | { | 577 | { |
578 | Q_UNUSED( which ) | 578 | Q_UNUSED( which ) |
579 | Q_UNUSED( st ) | 579 | Q_UNUSED( st ) |
580 | return false; | 580 | return false; |
581 | } | 581 | } |
582 | 582 | ||
583 | /** | 583 | /** |
584 | * @return if the device has a light sensor | 584 | * @return if the device has a light sensor |
585 | */ | 585 | */ |
586 | bool ODevice::hasLightSensor ( ) const | 586 | bool ODevice::hasLightSensor ( ) const |
587 | { | 587 | { |
588 | return false; | 588 | return false; |
589 | } | 589 | } |
590 | 590 | ||
591 | /** | 591 | /** |
592 | * @return a value from the light senso | 592 | * @return a value from the light senso |
593 | */ | 593 | */ |
594 | int ODevice::readLightSensor ( ) | 594 | int ODevice::readLightSensor ( ) |
595 | { | 595 | { |
596 | return -1; | 596 | return -1; |
597 | } | 597 | } |
598 | 598 | ||
599 | /** | 599 | /** |
600 | * @return the light sensor resolution whatever that is ;) | 600 | * @return the light sensor resolution whatever that is ;) |
601 | */ | 601 | */ |
602 | int ODevice::lightSensorResolution ( ) const | 602 | int ODevice::lightSensorResolution ( ) const |
603 | { | 603 | { |
604 | return 0; | 604 | return 0; |
605 | } | 605 | } |
606 | 606 | ||
607 | /** | 607 | /** |
608 | * @return a list of hardware buttons | 608 | * @return a list of hardware buttons |
609 | */ | 609 | */ |
610 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 610 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
611 | { | 611 | { |
612 | initButtons ( ); | 612 | initButtons ( ); |
613 | 613 | ||
614 | return *d-> m_buttons; | 614 | return *d-> m_buttons; |
615 | } | 615 | } |
616 | 616 | ||
617 | /** | 617 | /** |
618 | * @return The amount of time that would count as a hold | 618 | * @return The amount of time that would count as a hold |
619 | */ | 619 | */ |
620 | uint ODevice::buttonHoldTime ( ) const | 620 | uint ODevice::buttonHoldTime ( ) const |
621 | { | 621 | { |
622 | return d-> m_holdtime; | 622 | return d-> m_holdtime; |
623 | } | 623 | } |
624 | 624 | ||
625 | /** | 625 | /** |
626 | * This method return a ODeviceButton for a key code | 626 | * This method return a ODeviceButton for a key code |
627 | * or 0 if no special hardware button is available for the device | 627 | * or 0 if no special hardware button is available for the device |
628 | * | 628 | * |
629 | * @return The devicebutton or 0l | 629 | * @return The devicebutton or 0l |
630 | * @see ODeviceButton | 630 | * @see ODeviceButton |
631 | */ | 631 | */ |
632 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 632 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
633 | { | 633 | { |
634 | initButtons ( ); | 634 | initButtons ( ); |
635 | 635 | ||
636 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 636 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
637 | if ( (*it). keycode ( ) == code ) | 637 | if ( (*it). keycode ( ) == code ) |
638 | return &(*it); | 638 | return &(*it); |
639 | } | 639 | } |
640 | return 0; | 640 | return 0; |
641 | } | 641 | } |
642 | 642 | ||
643 | void ODevice::reloadButtonMapping ( ) | 643 | void ODevice::reloadButtonMapping ( ) |
644 | { | 644 | { |
645 | initButtons ( ); | 645 | initButtons ( ); |
646 | 646 | ||
647 | Config cfg ( "ButtonSettings" ); | 647 | Config cfg ( "ButtonSettings" ); |
648 | 648 | ||
649 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 649 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
650 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 650 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
651 | QString group = "Button" + QString::number ( i ); | 651 | QString group = "Button" + QString::number ( i ); |
652 | 652 | ||
653 | QCString pch, hch; | 653 | QCString pch, hch; |
654 | QCString pm, hm; | 654 | QCString pm, hm; |
655 | QByteArray pdata, hdata; | 655 | QByteArray pdata, hdata; |
656 | 656 | ||
657 | if ( cfg. hasGroup ( group )) { | 657 | if ( cfg. hasGroup ( group )) { |
658 | cfg. setGroup ( group ); | 658 | cfg. setGroup ( group ); |
659 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 659 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
660 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 660 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
661 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 661 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
662 | 662 | ||
663 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 663 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
664 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 664 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
665 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 665 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
666 | } | 666 | } |
667 | 667 | ||
668 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 668 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
669 | 669 | ||
670 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 670 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
671 | } | 671 | } |
672 | } | 672 | } |
673 | 673 | ||
674 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 674 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
675 | { | 675 | { |
676 | initButtons ( ); | 676 | initButtons ( ); |
677 | 677 | ||
678 | QString mb_chan; | 678 | QString mb_chan; |
679 | 679 | ||
680 | if ( button >= (int) d-> m_buttons-> count ( )) | 680 | if ( button >= (int) d-> m_buttons-> count ( )) |
681 | return; | 681 | return; |
682 | 682 | ||
683 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 683 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
684 | b. setPressedAction ( action ); | 684 | b. setPressedAction ( action ); |
685 | 685 | ||
686 | mb_chan=b. pressedAction ( ). channel ( ); | 686 | mb_chan=b. pressedAction ( ). channel ( ); |
687 | 687 | ||
688 | Config buttonFile ( "ButtonSettings" ); | 688 | Config buttonFile ( "ButtonSettings" ); |
689 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 689 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
690 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 690 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
691 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 691 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
692 | 692 | ||
693 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 693 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
694 | 694 | ||
695 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 695 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
696 | } | 696 | } |
697 | 697 | ||
698 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 698 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
699 | { | 699 | { |
700 | initButtons ( ); | 700 | initButtons ( ); |
701 | 701 | ||
702 | if ( button >= (int) d-> m_buttons-> count ( )) | 702 | if ( button >= (int) d-> m_buttons-> count ( )) |
703 | return; | 703 | return; |
704 | 704 | ||
705 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 705 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
706 | b. setHeldAction ( action ); | 706 | b. setHeldAction ( action ); |
707 | 707 | ||
708 | Config buttonFile ( "ButtonSettings" ); | 708 | Config buttonFile ( "ButtonSettings" ); |
709 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 709 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
710 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 710 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
711 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 711 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
712 | 712 | ||
713 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 713 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
714 | 714 | ||
715 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 715 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
716 | } | 716 | } |
717 | 717 | ||
718 | 718 | ||
719 | 719 | ||
720 | 720 | ||
721 | /************************************************** | 721 | /************************************************** |
722 | * | 722 | * |
723 | * iPAQ | 723 | * iPAQ |
724 | * | 724 | * |
725 | **************************************************/ | 725 | **************************************************/ |
726 | 726 | ||
727 | void iPAQ::init ( ) | 727 | void iPAQ::init ( ) |
728 | { | 728 | { |
729 | d-> m_vendorstr = "HP"; | 729 | d-> m_vendorstr = "HP"; |
730 | d-> m_vendor = Vendor_HP; | 730 | d-> m_vendor = Vendor_HP; |
731 | 731 | ||
732 | QFile f ( "/proc/hal/model" ); | 732 | QFile f ( "/proc/hal/model" ); |
733 | 733 | ||
734 | if ( f. open ( IO_ReadOnly )) { | 734 | if ( f. open ( IO_ReadOnly )) { |
735 | QTextStream ts ( &f ); | 735 | QTextStream ts ( &f ); |
736 | 736 | ||
737 | d-> m_modelstr = "H" + ts. readLine ( ); | 737 | d-> m_modelstr = "H" + ts. readLine ( ); |
738 | 738 | ||
739 | if ( d-> m_modelstr == "H3100" ) | 739 | if ( d-> m_modelstr == "H3100" ) |
740 | d-> m_model = Model_iPAQ_H31xx; | 740 | d-> m_model = Model_iPAQ_H31xx; |
741 | else if ( d-> m_modelstr == "H3600" ) | 741 | else if ( d-> m_modelstr == "H3600" ) |
742 | d-> m_model = Model_iPAQ_H36xx; | 742 | d-> m_model = Model_iPAQ_H36xx; |
743 | else if ( d-> m_modelstr == "H3700" ) | 743 | else if ( d-> m_modelstr == "H3700" ) |
744 | d-> m_model = Model_iPAQ_H37xx; | 744 | d-> m_model = Model_iPAQ_H37xx; |
745 | else if ( d-> m_modelstr == "H3800" ) | 745 | else if ( d-> m_modelstr == "H3800" ) |
746 | d-> m_model = Model_iPAQ_H38xx; | 746 | d-> m_model = Model_iPAQ_H38xx; |
747 | else if ( d-> m_modelstr == "H3900" ) | 747 | else if ( d-> m_modelstr == "H3900" ) |
748 | d-> m_model = Model_iPAQ_H39xx; | 748 | d-> m_model = Model_iPAQ_H39xx; |
749 | else | 749 | else |
750 | d-> m_model = Model_Unknown; | 750 | d-> m_model = Model_Unknown; |
751 | 751 | ||
752 | f. close ( ); | 752 | f. close ( ); |
753 | } | 753 | } |
754 | 754 | ||
755 | switch ( d-> m_model ) { | 755 | switch ( d-> m_model ) { |
756 | case Model_iPAQ_H31xx: | 756 | case Model_iPAQ_H31xx: |
757 | case Model_iPAQ_H38xx: | 757 | case Model_iPAQ_H38xx: |
758 | d-> m_rotation = Rot90; | 758 | d-> m_rotation = Rot90; |
759 | break; | 759 | break; |
760 | case Model_iPAQ_H36xx: | 760 | case Model_iPAQ_H36xx: |
761 | case Model_iPAQ_H37xx: | 761 | case Model_iPAQ_H37xx: |
762 | case Model_iPAQ_H39xx: | 762 | case Model_iPAQ_H39xx: |
763 | default: | 763 | default: |
764 | d-> m_rotation = Rot270; | 764 | d-> m_rotation = Rot270; |
765 | break; | 765 | break; |
766 | } | 766 | } |
767 | 767 | ||
768 | f. setName ( "/etc/familiar-version" ); | 768 | f. setName ( "/etc/familiar-version" ); |
769 | if ( f. open ( IO_ReadOnly )) { | 769 | if ( f. open ( IO_ReadOnly )) { |
770 | d-> m_systemstr = "Familiar"; | 770 | d-> m_systemstr = "Familiar"; |
771 | d-> m_system = System_Familiar; | 771 | d-> m_system = System_Familiar; |
772 | 772 | ||
773 | QTextStream ts ( &f ); | 773 | QTextStream ts ( &f ); |
774 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 774 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
775 | 775 | ||
776 | f. close ( ); | 776 | f. close ( ); |
777 | } else { | 777 | } else { |
778 | f. setName ( "/etc/oz_version" ); | 778 | f. setName ( "/etc/oz_version" ); |
779 | 779 | ||
780 | if ( f. open ( IO_ReadOnly )) { | 780 | if ( f. open ( IO_ReadOnly )) { |
781 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 781 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
782 | d-> m_system = System_Familiar; | 782 | d-> m_system = System_Familiar; |
783 | 783 | ||
784 | QTextStream ts ( &f ); | 784 | QTextStream ts ( &f ); |
785 | ts.setDevice ( &f ); | 785 | ts.setDevice ( &f ); |
786 | d-> m_sysverstr = ts. readLine ( ); | 786 | d-> m_sysverstr = ts. readLine ( ); |
787 | f. close ( ); | 787 | f. close ( ); |
788 | } | 788 | } |
789 | } | 789 | } |
790 | 790 | ||
791 | 791 | ||
792 | 792 | ||
793 | 793 | ||
794 | 794 | ||
795 | m_leds [0] = m_leds [1] = Led_Off; | 795 | m_leds [0] = m_leds [1] = Led_Off; |
796 | 796 | ||
797 | m_power_timer = 0; | 797 | m_power_timer = 0; |
798 | 798 | ||
799 | } | 799 | } |
800 | 800 | ||
801 | void iPAQ::initButtons ( ) | 801 | void iPAQ::initButtons ( ) |
802 | { | 802 | { |
803 | if ( d-> m_buttons ) | 803 | if ( d-> m_buttons ) |
804 | return; | 804 | return; |
805 | 805 | ||
806 | if ( isQWS( ) ) | 806 | if ( isQWS( ) ) |
807 | QWSServer::setKeyboardFilter ( this ); | 807 | QWSServer::setKeyboardFilter ( this ); |
808 | 808 | ||
809 | d-> m_buttons = new QValueList <ODeviceButton>; | 809 | d-> m_buttons = new QValueList <ODeviceButton>; |
810 | 810 | ||
811 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 811 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
812 | i_button *ib = ipaq_buttons + i; | 812 | i_button *ib = ipaq_buttons + i; |
813 | ODeviceButton b; | 813 | ODeviceButton b; |
814 | 814 | ||
815 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 815 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
816 | b. setKeycode ( ib-> code ); | 816 | b. setKeycode ( ib-> code ); |
817 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 817 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
818 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 818 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
819 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 819 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
820 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 820 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
821 | 821 | ||
822 | d-> m_buttons-> append ( b ); | 822 | d-> m_buttons-> append ( b ); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | reloadButtonMapping ( ); | 825 | reloadButtonMapping ( ); |
826 | 826 | ||
827 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 827 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
828 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 828 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
829 | } | 829 | } |
830 | 830 | ||
831 | 831 | ||
832 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 832 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
833 | 833 | ||
834 | typedef struct { | 834 | typedef struct { |
835 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 835 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
836 | unsigned char TotalTime; /* Units of 5 seconds */ | 836 | unsigned char TotalTime; /* Units of 5 seconds */ |
837 | unsigned char OnTime; /* units of 100m/s */ | 837 | unsigned char OnTime; /* units of 100m/s */ |
838 | unsigned char OffTime; /* units of 100m/s */ | 838 | unsigned char OffTime; /* units of 100m/s */ |
839 | } LED_IN; | 839 | } LED_IN; |
840 | 840 | ||
841 | typedef struct { | 841 | typedef struct { |
842 | unsigned char mode; | 842 | unsigned char mode; |
843 | unsigned char pwr; | 843 | unsigned char pwr; |
844 | unsigned char brightness; | 844 | unsigned char brightness; |
845 | } FLITE_IN; | 845 | } FLITE_IN; |
846 | 846 | ||
847 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 847 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
848 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 848 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
849 | 849 | ||
850 | 850 | ||
851 | QValueList <OLed> iPAQ::ledList ( ) const | 851 | QValueList <OLed> iPAQ::ledList ( ) const |
852 | { | 852 | { |
853 | QValueList <OLed> vl; | 853 | QValueList <OLed> vl; |
854 | vl << Led_Power; | 854 | vl << Led_Power; |
855 | 855 | ||
856 | if ( d-> m_model == Model_iPAQ_H38xx ) | 856 | if ( d-> m_model == Model_iPAQ_H38xx ) |
857 | vl << Led_BlueTooth; | 857 | vl << Led_BlueTooth; |
858 | return vl; | 858 | return vl; |
859 | } | 859 | } |
860 | 860 | ||
861 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 861 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
862 | { | 862 | { |
863 | QValueList <OLedState> vl; | 863 | QValueList <OLedState> vl; |
864 | 864 | ||
865 | if ( l == Led_Power ) | 865 | if ( l == Led_Power ) |
866 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 866 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
867 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 867 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
868 | vl << Led_Off; // << Led_On << ??? | 868 | vl << Led_Off; // << Led_On << ??? |
869 | 869 | ||
870 | return vl; | 870 | return vl; |
871 | } | 871 | } |
872 | 872 | ||
873 | OLedState iPAQ::ledState ( OLed l ) const | 873 | OLedState iPAQ::ledState ( OLed l ) const |
874 | { | 874 | { |
875 | switch ( l ) { | 875 | switch ( l ) { |
876 | case Led_Power: | 876 | case Led_Power: |
877 | return m_leds [0]; | 877 | return m_leds [0]; |
878 | case Led_BlueTooth: | 878 | case Led_BlueTooth: |
879 | return m_leds [1]; | 879 | return m_leds [1]; |
880 | default: | 880 | default: |
881 | return Led_Off; | 881 | return Led_Off; |
882 | } | 882 | } |
883 | } | 883 | } |
884 | 884 | ||
885 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 885 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
886 | { | 886 | { |
887 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 887 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
888 | 888 | ||
889 | if ( l == Led_Power ) { | 889 | if ( l == Led_Power ) { |
890 | if ( fd >= 0 ) { | 890 | if ( fd >= 0 ) { |
891 | LED_IN leds; | 891 | LED_IN leds; |
892 | ::memset ( &leds, 0, sizeof( leds )); | 892 | ::memset ( &leds, 0, sizeof( leds )); |
893 | leds. TotalTime = 0; | 893 | leds. TotalTime = 0; |
894 | leds. OnTime = 0; | 894 | leds. OnTime = 0; |
895 | leds. OffTime = 1; | 895 | leds. OffTime = 1; |
896 | leds. OffOnBlink = 2; | 896 | leds. OffOnBlink = 2; |
897 | 897 | ||
898 | switch ( st ) { | 898 | switch ( st ) { |
899 | case Led_Off : leds. OffOnBlink = 0; break; | 899 | case Led_Off : leds. OffOnBlink = 0; break; |
900 | case Led_On : leds. OffOnBlink = 1; break; | 900 | case Led_On : leds. OffOnBlink = 1; break; |
901 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 901 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
902 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 902 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
903 | } | 903 | } |
904 | 904 | ||
905 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 905 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
906 | m_leds [0] = st; | 906 | m_leds [0] = st; |
907 | return true; | 907 | return true; |
908 | } | 908 | } |
909 | } | 909 | } |
910 | } | 910 | } |
911 | return false; | 911 | return false; |
912 | } | 912 | } |
913 | 913 | ||
914 | 914 | ||
915 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 915 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
916 | { | 916 | { |
917 | int newkeycode = keycode; | 917 | int newkeycode = keycode; |
918 | 918 | ||
919 | switch ( keycode ) { | 919 | switch ( keycode ) { |
920 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 920 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
921 | case HardKey_Menu: { | 921 | case HardKey_Menu: { |
922 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 922 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
923 | ( d-> m_model == Model_iPAQ_H39xx )) { | 923 | ( d-> m_model == Model_iPAQ_H39xx )) { |
924 | newkeycode = HardKey_Mail; | 924 | newkeycode = HardKey_Mail; |
925 | } | 925 | } |
926 | break; | 926 | break; |
927 | } | 927 | } |
928 | 928 | ||
929 | // Rotate cursor keys 180° | 929 | // Rotate cursor keys 180° |
930 | case Key_Left : | 930 | case Key_Left : |
931 | case Key_Right: | 931 | case Key_Right: |
932 | case Key_Up : | 932 | case Key_Up : |
933 | case Key_Down : { | 933 | case Key_Down : { |
934 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 934 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
935 | ( d-> m_model == Model_iPAQ_H38xx )) { | 935 | ( d-> m_model == Model_iPAQ_H38xx )) { |
936 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 936 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
937 | } | 937 | } |
938 | break; | 938 | break; |
939 | } | 939 | } |
940 | 940 | ||
941 | // map Power Button short/long press to F34/F35 | 941 | // map Power Button short/long press to F34/F35 |
942 | case Key_SysReq: { | 942 | case Key_SysReq: { |
943 | if ( isPress ) { | 943 | if ( isPress ) { |
944 | if ( m_power_timer ) | 944 | if ( m_power_timer ) |
945 | killTimer ( m_power_timer ); | 945 | killTimer ( m_power_timer ); |
946 | m_power_timer = startTimer ( 500 ); | 946 | m_power_timer = startTimer ( 500 ); |
947 | } | 947 | } |
948 | else if ( m_power_timer ) { | 948 | else if ( m_power_timer ) { |
949 | killTimer ( m_power_timer ); | 949 | killTimer ( m_power_timer ); |
950 | m_power_timer = 0; | 950 | m_power_timer = 0; |
951 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 951 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
952 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 952 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
953 | } | 953 | } |
954 | newkeycode = Key_unknown; | 954 | newkeycode = Key_unknown; |
955 | break; | 955 | break; |
956 | } | 956 | } |
957 | } | 957 | } |
958 | 958 | ||
959 | if ( newkeycode != keycode ) { | 959 | if ( newkeycode != keycode ) { |
960 | if ( newkeycode != Key_unknown ) | 960 | if ( newkeycode != Key_unknown ) |
961 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 961 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
962 | return true; | 962 | return true; |
963 | } | 963 | } |
964 | else | 964 | else |
965 | return false; | 965 | return false; |
966 | } | 966 | } |
967 | 967 | ||
968 | void iPAQ::timerEvent ( QTimerEvent * ) | 968 | void iPAQ::timerEvent ( QTimerEvent * ) |
969 | { | 969 | { |
970 | killTimer ( m_power_timer ); | 970 | killTimer ( m_power_timer ); |
971 | m_power_timer = 0; | 971 | m_power_timer = 0; |
972 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 972 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
973 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 973 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
974 | } | 974 | } |
975 | 975 | ||
976 | 976 | ||
977 | void iPAQ::alarmSound ( ) | 977 | void iPAQ::alarmSound ( ) |
978 | { | 978 | { |
979 | #ifndef QT_NO_SOUND | 979 | #ifndef QT_NO_SOUND |
980 | static Sound snd ( "alarm" ); | 980 | static Sound snd ( "alarm" ); |
981 | int fd; | 981 | int fd; |
982 | int vol; | 982 | int vol; |
983 | bool vol_reset = false; | 983 | bool vol_reset = false; |
984 | 984 | ||
985 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 985 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
986 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 986 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
987 | Config cfg ( "qpe" ); | 987 | Config cfg ( "qpe" ); |
988 | cfg. setGroup ( "Volume" ); | 988 | cfg. setGroup ( "Volume" ); |
989 | 989 | ||
990 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 990 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
991 | if ( volalarm < 0 ) | 991 | if ( volalarm < 0 ) |
992 | volalarm = 0; | 992 | volalarm = 0; |
993 | else if ( volalarm > 100 ) | 993 | else if ( volalarm > 100 ) |
994 | volalarm = 100; | 994 | volalarm = 100; |
995 | volalarm |= ( volalarm << 8 ); | 995 | volalarm |= ( volalarm << 8 ); |
996 | 996 | ||
997 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 997 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
998 | vol_reset = true; | 998 | vol_reset = true; |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | snd. play ( ); | 1002 | snd. play ( ); |
1003 | while ( !snd. isFinished ( )) | 1003 | while ( !snd. isFinished ( )) |
1004 | qApp-> processEvents ( ); | 1004 | qApp-> processEvents ( ); |
1005 | 1005 | ||
1006 | if ( fd >= 0 ) { | 1006 | if ( fd >= 0 ) { |
1007 | if ( vol_reset ) | 1007 | if ( vol_reset ) |
1008 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1008 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1009 | ::close ( fd ); | 1009 | ::close ( fd ); |
1010 | } | 1010 | } |
1011 | #endif | 1011 | #endif |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | 1014 | ||
1015 | bool iPAQ::setSoftSuspend ( bool soft ) | 1015 | bool iPAQ::setSoftSuspend ( bool soft ) |
1016 | { | 1016 | { |
1017 | bool res = false; | 1017 | bool res = false; |
1018 | int fd; | 1018 | int fd; |
1019 | 1019 | ||
1020 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1020 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1021 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1021 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1022 | res = true; | 1022 | res = true; |
1023 | else | 1023 | else |
1024 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1024 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1025 | 1025 | ||
1026 | ::close ( fd ); | 1026 | ::close ( fd ); |
1027 | } | 1027 | } |
1028 | else | 1028 | else |
1029 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1029 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1030 | 1030 | ||
1031 | return res; | 1031 | return res; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | 1034 | ||
1035 | bool iPAQ::setDisplayBrightness ( int bright ) | 1035 | bool iPAQ::setDisplayBrightness ( int bright ) |
1036 | { | 1036 | { |
1037 | bool res = false; | 1037 | bool res = false; |
1038 | int fd; | 1038 | int fd; |
1039 | 1039 | ||
1040 | if ( bright > 255 ) | 1040 | if ( bright > 255 ) |
1041 | bright = 255; | 1041 | bright = 255; |
1042 | if ( bright < 0 ) | 1042 | if ( bright < 0 ) |
1043 | bright = 0; | 1043 | bright = 0; |
1044 | 1044 | ||
1045 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1045 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1046 | FLITE_IN bl; | 1046 | FLITE_IN bl; |
1047 | bl. mode = 1; | 1047 | bl. mode = 1; |
1048 | bl. pwr = bright ? 1 : 0; | 1048 | bl. pwr = bright ? 1 : 0; |
1049 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1049 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1050 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1050 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1051 | ::close ( fd ); | 1051 | ::close ( fd ); |
1052 | } | 1052 | } |
1053 | return res; | 1053 | return res; |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | int iPAQ::displayBrightnessResolution ( ) const | 1056 | int iPAQ::displayBrightnessResolution ( ) const |
1057 | { | 1057 | { |
1058 | switch ( model ( )) { | 1058 | switch ( model ( )) { |
1059 | case Model_iPAQ_H31xx: | 1059 | case Model_iPAQ_H31xx: |
1060 | case Model_iPAQ_H36xx: | 1060 | case Model_iPAQ_H36xx: |
1061 | case Model_iPAQ_H37xx: | 1061 | case Model_iPAQ_H37xx: |
1062 | return 128; // really 256, but >128 could damage the LCD | 1062 | return 128; // really 256, but >128 could damage the LCD |
1063 | 1063 | ||
1064 | case Model_iPAQ_H38xx: | 1064 | case Model_iPAQ_H38xx: |
1065 | case Model_iPAQ_H39xx: | 1065 | case Model_iPAQ_H39xx: |
1066 | return 64; | 1066 | return 64; |
1067 | 1067 | ||
1068 | default: | 1068 | default: |
1069 | return 2; | 1069 | return 2; |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | 1073 | ||
1074 | bool iPAQ::hasLightSensor ( ) const | 1074 | bool iPAQ::hasLightSensor ( ) const |
1075 | { | 1075 | { |
1076 | return true; | 1076 | return true; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | int iPAQ::readLightSensor ( ) | 1079 | int iPAQ::readLightSensor ( ) |
1080 | { | 1080 | { |
1081 | int fd; | 1081 | int fd; |
1082 | int val = -1; | 1082 | int val = -1; |
1083 | 1083 | ||
1084 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1084 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1085 | char buffer [8]; | 1085 | char buffer [8]; |
1086 | 1086 | ||
1087 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1087 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1088 | char *endptr; | 1088 | char *endptr; |
1089 | 1089 | ||
1090 | buffer [4] = 0; | 1090 | buffer [4] = 0; |
1091 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1091 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1092 | 1092 | ||
1093 | if ( *endptr != 0 ) | 1093 | if ( *endptr != 0 ) |
1094 | val = -1; | 1094 | val = -1; |
1095 | } | 1095 | } |
1096 | ::close ( fd ); | 1096 | ::close ( fd ); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | return val; | 1099 | return val; |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | int iPAQ::lightSensorResolution ( ) const | 1102 | int iPAQ::lightSensorResolution ( ) const |
1103 | { | 1103 | { |
1104 | return 256; | 1104 | return 256; |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | /************************************************** | 1107 | /************************************************** |
1108 | * | 1108 | * |
1109 | * Zaurus | 1109 | * Zaurus |
1110 | * | 1110 | * |
1111 | **************************************************/ | 1111 | **************************************************/ |
1112 | 1112 | ||
1113 | 1113 | ||
1114 | 1114 | ||
1115 | void Zaurus::init ( ) | 1115 | void Zaurus::init ( ) |
1116 | { | 1116 | { |
1117 | d-> m_vendorstr = "Sharp"; | 1117 | d-> m_vendorstr = "Sharp"; |
1118 | d-> m_vendor = Vendor_Sharp; | 1118 | d-> m_vendor = Vendor_Sharp; |
1119 | 1119 | ||
1120 | QFile f ( "/proc/filesystems" ); | 1120 | QFile f ( "/proc/filesystems" ); |
1121 | QString model; | 1121 | QString model; |
1122 | 1122 | ||
1123 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1123 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1124 | d-> m_vendorstr = "OpenZaurus Team"; | 1124 | d-> m_vendorstr = "OpenZaurus Team"; |
1125 | d-> m_systemstr = "OpenZaurus"; | 1125 | d-> m_systemstr = "OpenZaurus"; |
1126 | d-> m_system = System_OpenZaurus; | 1126 | d-> m_system = System_OpenZaurus; |
1127 | 1127 | ||
1128 | f. close ( ); | 1128 | f. close ( ); |
1129 | 1129 | ||
1130 | f. setName ( "/etc/oz_version" ); | 1130 | f. setName ( "/etc/oz_version" ); |
1131 | if ( f. open ( IO_ReadOnly )) { | 1131 | if ( f. open ( IO_ReadOnly )) { |
1132 | QTextStream ts ( &f ); | 1132 | QTextStream ts ( &f ); |
1133 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1133 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1134 | f. close ( ); | 1134 | f. close ( ); |
1135 | } | 1135 | } |
1136 | } | 1136 | } |
1137 | else { | 1137 | else { |
1138 | d-> m_systemstr = "Zaurus"; | 1138 | d-> m_systemstr = "Zaurus"; |
1139 | d-> m_system = System_Zaurus; | 1139 | d-> m_system = System_Zaurus; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | f. setName ( "/proc/cpuinfo" ); | 1142 | f. setName ( "/proc/cpuinfo" ); |
1143 | if ( f. open ( IO_ReadOnly ) ) { | 1143 | if ( f. open ( IO_ReadOnly ) ) { |
1144 | QTextStream ts ( &f ); | 1144 | QTextStream ts ( &f ); |
1145 | QString line; | 1145 | QString line; |
1146 | while( line = ts. readLine ( ) ) { | 1146 | while( line = ts. readLine ( ) ) { |
1147 | if ( line. left ( 8 ) == "Hardware" ) | 1147 | if ( line. left ( 8 ) == "Hardware" ) |
1148 | break; | 1148 | break; |
1149 | } | 1149 | } |
1150 | int loc = line. find ( ":" ); | 1150 | int loc = line. find ( ":" ); |
1151 | if ( loc != -1 ) | 1151 | if ( loc != -1 ) |
1152 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1152 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | if ( model == "SHARP Corgi" ) { | 1155 | if ( model == "SHARP Corgi" ) { |
1156 | d-> m_model = Model_Zaurus_SLC700; | 1156 | d-> m_model = Model_Zaurus_SLC700; |
1157 | d-> m_modelstr = "Zaurus SL-C700"; | 1157 | d-> m_modelstr = "Zaurus SL-C700"; |
1158 | } else if ( model == "SHARP Poodle" ) { | 1158 | } else if ( model == "SHARP Poodle" ) { |
1159 | d-> m_model = Model_Zaurus_SLB600; | 1159 | d-> m_model = Model_Zaurus_SLB600; |
1160 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1160 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1161 | } else if ( model = "Sharp-Collie" ) { | 1161 | } else if ( model = "Sharp-Collie" ) { |
1162 | d-> m_model = Model_Zaurus_SL5500; | 1162 | d-> m_model = Model_Zaurus_SL5500; |
1163 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1163 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1164 | } else { | 1164 | } else { |
1165 | d-> m_model = Model_Zaurus_SL5500; | 1165 | d-> m_model = Model_Zaurus_SL5500; |
1166 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1166 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | bool flipstate = false; | 1169 | bool flipstate = false; |
1170 | switch ( d-> m_model ) { | 1170 | switch ( d-> m_model ) { |
1171 | case Model_Zaurus_SLA300: | 1171 | case Model_Zaurus_SLA300: |
1172 | d-> m_rotation = Rot0; | 1172 | d-> m_rotation = Rot0; |
1173 | break; | 1173 | break; |
1174 | case Model_Zaurus_SLC700: | 1174 | case Model_Zaurus_SLC700: |
1175 | // Note: need to 1) set flipstate based on physical screen orientation | 1175 | // Note: need to 1) set flipstate based on physical screen orientation |
1176 | // and 2) check to see if the user overrode the rotation direction | 1176 | // and 2) check to see if the user overrode the rotation direction |
1177 | // using appearance, and if so, remove that item from the Config to | 1177 | // using appearance, and if so, remove that item from the Config to |
1178 | // ensure the rotate applet flips us back to the previous state. | 1178 | // ensure the rotate applet flips us back to the previous state. |
1179 | if ( flipstate ) { | 1179 | if ( flipstate ) { |
1180 | // 480x640 | 1180 | // 480x640 |
1181 | d-> m_rotation = Rot0; | 1181 | d-> m_rotation = Rot0; |
1182 | d-> m_direction = CW; | 1182 | d-> m_direction = CW; |
1183 | } else { | 1183 | } else { |
1184 | // 640x480 | 1184 | // 640x480 |
1185 | d-> m_rotation = Rot270; | 1185 | d-> m_rotation = Rot270; |
1186 | d-> m_direction = CCW; | 1186 | d-> m_direction = CCW; |
1187 | } | 1187 | } |
1188 | break; | 1188 | break; |
1189 | case Model_Zaurus_SLB600: | 1189 | case Model_Zaurus_SLB600: |
1190 | case Model_Zaurus_SL5500: | 1190 | case Model_Zaurus_SL5500: |
1191 | case Model_Zaurus_SL5000: | 1191 | case Model_Zaurus_SL5000: |
1192 | default: | 1192 | default: |
1193 | d-> m_rotation = Rot270; | 1193 | d-> m_rotation = Rot270; |
1194 | break; | 1194 | break; |
1195 | } | 1195 | } |
1196 | m_leds [0] = Led_Off; | 1196 | m_leds [0] = Led_Off; |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | void Zaurus::initButtons ( ) | 1199 | void Zaurus::initButtons ( ) |
1200 | { | 1200 | { |
1201 | if ( d-> m_buttons ) | 1201 | if ( d-> m_buttons ) |
1202 | return; | 1202 | return; |
1203 | 1203 | ||
1204 | d-> m_buttons = new QValueList <ODeviceButton>; | 1204 | d-> m_buttons = new QValueList <ODeviceButton>; |
1205 | 1205 | ||
1206 | struct z_button * pz_buttons; | 1206 | struct z_button * pz_buttons; |
1207 | int buttoncount; | 1207 | int buttoncount; |
1208 | switch ( d-> m_model ) { | 1208 | switch ( d-> m_model ) { |
1209 | case Model_Zaurus_SLC700: | 1209 | case Model_Zaurus_SLC700: |
1210 | pz_buttons = z_buttons_c700; | 1210 | pz_buttons = z_buttons_c700; |
1211 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1211 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1212 | break; | 1212 | break; |
1213 | default: | 1213 | default: |
1214 | pz_buttons = z_buttons; | 1214 | pz_buttons = z_buttons; |
1215 | buttoncount = ARRAY_SIZE(z_buttons); | 1215 | buttoncount = ARRAY_SIZE(z_buttons); |
1216 | break; | 1216 | break; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | for ( int i = 0; i < buttoncount; i++ ) { | 1219 | for ( int i = 0; i < buttoncount; i++ ) { |
1220 | struct z_button *zb = pz_buttons + i; | 1220 | struct z_button *zb = pz_buttons + i; |
1221 | ODeviceButton b; | 1221 | ODeviceButton b; |
1222 | 1222 | ||
1223 | b. setKeycode ( zb-> code ); | 1223 | b. setKeycode ( zb-> code ); |
1224 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1224 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1225 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1225 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1226 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1226 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1227 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1227 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1228 | 1228 | ||
1229 | d-> m_buttons-> append ( b ); | 1229 | d-> m_buttons-> append ( b ); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | reloadButtonMapping ( ); | 1232 | reloadButtonMapping ( ); |
1233 | 1233 | ||
1234 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1234 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1235 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1235 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | #include <unistd.h> | 1238 | #include <unistd.h> |
1239 | #include <fcntl.h> | 1239 | #include <fcntl.h> |
1240 | #include <sys/ioctl.h> | 1240 | #include <sys/ioctl.h> |
1241 | 1241 | ||
1242 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1242 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1243 | 1243 | ||
1244 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1244 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1245 | 1245 | ||
1246 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1246 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1247 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1247 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1248 | 1248 | ||
1249 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1249 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1250 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1250 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1251 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1251 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1252 | 1252 | ||
1253 | /* --- for SHARP_BUZZER device --- */ | 1253 | /* --- for SHARP_BUZZER device --- */ |
1254 | 1254 | ||
1255 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1255 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1256 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1256 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1257 | 1257 | ||
1258 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1258 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1259 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1259 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1260 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1260 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1261 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1261 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1262 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1262 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1263 | 1263 | ||
1264 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1264 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1265 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1265 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1266 | 1266 | ||
1267 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1267 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1268 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1268 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1269 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1269 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1270 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1270 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1271 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1271 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1272 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1272 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1273 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1273 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1274 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1274 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1275 | 1275 | ||
1276 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1276 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1277 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1277 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1278 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1278 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1279 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1279 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1280 | // | 1280 | // |
1281 | 1281 | ||
1282 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1282 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1283 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1283 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1284 | 1284 | ||
1285 | typedef struct sharp_led_status { | 1285 | typedef struct sharp_led_status { |
1286 | int which; /* select which LED status is wanted. */ | 1286 | int which; /* select which LED status is wanted. */ |
1287 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1287 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1288 | } sharp_led_status; | 1288 | } sharp_led_status; |
1289 | 1289 | ||
1290 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1290 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1291 | 1291 | ||
1292 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1292 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1293 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1293 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1294 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1294 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1295 | 1295 | ||
1296 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1296 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1297 | 1297 | ||
1298 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1298 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1299 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1299 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1300 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1300 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1301 | 1301 | ||
1302 | #define FL_IOCTL_STEP_CONTRAST 100 | 1302 | #define FL_IOCTL_STEP_CONTRAST 100 |
1303 | 1303 | ||
1304 | 1304 | ||
1305 | void Zaurus::buzzer ( int sound ) | 1305 | void Zaurus::buzzer ( int sound ) |
1306 | { | 1306 | { |
1307 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1307 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1308 | 1308 | ||
1309 | if ( fd >= 0 ) { | 1309 | if ( fd >= 0 ) { |
1310 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1310 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1311 | ::close ( fd ); | 1311 | ::close ( fd ); |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | 1315 | ||
1316 | void Zaurus::alarmSound ( ) | 1316 | void Zaurus::alarmSound ( ) |
1317 | { | 1317 | { |
1318 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1318 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | void Zaurus::touchSound ( ) | 1321 | void Zaurus::touchSound ( ) |
1322 | { | 1322 | { |
1323 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1323 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | void Zaurus::keySound ( ) | 1326 | void Zaurus::keySound ( ) |
1327 | { | 1327 | { |
1328 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1328 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | 1331 | ||
1332 | QValueList <OLed> Zaurus::ledList ( ) const | 1332 | QValueList <OLed> Zaurus::ledList ( ) const |
1333 | { | 1333 | { |
1334 | QValueList <OLed> vl; | 1334 | QValueList <OLed> vl; |
1335 | vl << Led_Mail; | 1335 | vl << Led_Mail; |
1336 | return vl; | 1336 | return vl; |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1339 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1340 | { | 1340 | { |
1341 | QValueList <OLedState> vl; | 1341 | QValueList <OLedState> vl; |
1342 | 1342 | ||
1343 | if ( l == Led_Mail ) | 1343 | if ( l == Led_Mail ) |
1344 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1344 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1345 | return vl; | 1345 | return vl; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | OLedState Zaurus::ledState ( OLed which ) const | 1348 | OLedState Zaurus::ledState ( OLed which ) const |
1349 | { | 1349 | { |
1350 | if ( which == Led_Mail ) | 1350 | if ( which == Led_Mail ) |
1351 | return m_leds [0]; | 1351 | return m_leds [0]; |
1352 | else | 1352 | else |
1353 | return Led_Off; | 1353 | return Led_Off; |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1356 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1357 | { | 1357 | { |
1358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1359 | 1359 | ||
1360 | if ( which == Led_Mail ) { | 1360 | if ( which == Led_Mail ) { |
1361 | if ( fd >= 0 ) { | 1361 | if ( fd >= 0 ) { |
1362 | struct sharp_led_status leds; | 1362 | struct sharp_led_status leds; |
1363 | ::memset ( &leds, 0, sizeof( leds )); | 1363 | ::memset ( &leds, 0, sizeof( leds )); |
1364 | leds. which = SHARP_LED_MAIL_EXISTS; | 1364 | leds. which = SHARP_LED_MAIL_EXISTS; |
1365 | bool ok = true; | 1365 | bool ok = true; |
1366 | 1366 | ||
1367 | switch ( st ) { | 1367 | switch ( st ) { |
1368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1371 | default : ok = false; | 1371 | default : ok = false; |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1375 | m_leds [0] = st; | 1375 | m_leds [0] = st; |
1376 | return true; | 1376 | return true; |
1377 | } | 1377 | } |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | return false; | 1380 | return false; |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | bool Zaurus::setSoftSuspend ( bool soft ) | 1383 | bool Zaurus::setSoftSuspend ( bool soft ) |
1384 | { | 1384 | { |
1385 | bool res = false; | 1385 | bool res = false; |
1386 | int fd; | 1386 | int fd; |
1387 | 1387 | ||
1388 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1388 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1389 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1389 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1390 | 1390 | ||
1391 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1391 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1392 | 1392 | ||
1393 | if ( sources >= 0 ) { | 1393 | if ( sources >= 0 ) { |
1394 | if ( soft ) | 1394 | if ( soft ) |
1395 | sources &= ~APM_EVT_POWER_BUTTON; | 1395 | sources &= ~APM_EVT_POWER_BUTTON; |
1396 | else | 1396 | else |
1397 | sources |= APM_EVT_POWER_BUTTON; | 1397 | sources |= APM_EVT_POWER_BUTTON; |
1398 | 1398 | ||
1399 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1399 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1400 | res = true; | 1400 | res = true; |
1401 | else | 1401 | else |
1402 | perror ( "APM_IOCGEVTSRC" ); | 1402 | perror ( "APM_IOCGEVTSRC" ); |
1403 | } | 1403 | } |
1404 | else | 1404 | else |
1405 | perror ( "APM_IOCGEVTSRC" ); | 1405 | perror ( "APM_IOCGEVTSRC" ); |
1406 | 1406 | ||
1407 | ::close ( fd ); | 1407 | ::close ( fd ); |
1408 | } | 1408 | } |
1409 | else | 1409 | else |
1410 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1410 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1411 | 1411 | ||
1412 | return res; | 1412 | return res; |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | 1415 | ||
1416 | bool Zaurus::setDisplayBrightness ( int bright ) | 1416 | bool Zaurus::setDisplayBrightness ( int bright ) |
1417 | { | 1417 | { |
1418 | bool res = false; | 1418 | bool res = false; |
1419 | int fd; | 1419 | int fd; |
1420 | 1420 | ||
1421 | if ( bright > 255 ) | 1421 | if ( bright > 255 ) |
1422 | bright = 255; | 1422 | bright = 255; |
1423 | if ( bright < 0 ) | 1423 | if ( bright < 0 ) |
1424 | bright = 0; | 1424 | bright = 0; |
1425 | 1425 | ||
1426 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1426 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1427 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1427 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1428 | if ( bright && !bl ) | 1428 | if ( bright && !bl ) |
1429 | bl = 1; | 1429 | bl = 1; |
1430 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1430 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1431 | ::close ( fd ); | 1431 | ::close ( fd ); |
1432 | } | 1432 | } |
1433 | return res; | 1433 | return res; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | 1436 | ||
1437 | int Zaurus::displayBrightnessResolution ( ) const | 1437 | int Zaurus::displayBrightnessResolution ( ) const |
1438 | { | 1438 | { |
1439 | return 5; | 1439 | return 5; |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | 1442 | ||