author | schurig <schurig> | 2003-06-10 16:35:43 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-10 16:35:43 (UTC) |
commit | d2f78d2aba17a491739d10bd73f6fce033849537 (patch) (unidiff) | |
tree | 0d8e5683afaa6da476001e00fc6db2ebc5c1a0df /libopie/odevice.cpp | |
parent | 8ffea5d37080bd173d55a458296c1fc461a54d13 (diff) | |
download | opie-d2f78d2aba17a491739d10bd73f6fce033849537.zip opie-d2f78d2aba17a491739d10bd73f6fce033849537.tar.gz opie-d2f78d2aba17a491739d10bd73f6fce033849537.tar.bz2 |
renamed frequency access methods
-rw-r--r-- | libopie/odevice.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 4c33a0e..d6e6892 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -266,1038 +266,1038 @@ struct z_button z_buttons_c700 [] = { | |||
266 | "addressbook", "raise()", | 266 | "addressbook", "raise()", |
267 | "addressbook", "beamBusinessCard()" }, | 267 | "addressbook", "beamBusinessCard()" }, |
268 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 268 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
269 | "devicebuttons/z_home", | 269 | "devicebuttons/z_home", |
270 | "QPE/Launcher", "home()", | 270 | "QPE/Launcher", "home()", |
271 | "buttonsettings", "raise()" }, | 271 | "buttonsettings", "raise()" }, |
272 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 272 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
273 | "devicebuttons/z_menu", | 273 | "devicebuttons/z_menu", |
274 | "QPE/TaskBar", "toggleMenu()", | 274 | "QPE/TaskBar", "toggleMenu()", |
275 | "QPE/TaskBar", "toggleStartMenu()" }, | 275 | "QPE/TaskBar", "toggleStartMenu()" }, |
276 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 276 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
277 | "", | 277 | "", |
278 | "QPE/Rotation", "flip()", | 278 | "QPE/Rotation", "flip()", |
279 | "QPE/Rotation", "flip()" }, | 279 | "QPE/Rotation", "flip()" }, |
280 | }; | 280 | }; |
281 | 281 | ||
282 | struct s_button { | 282 | struct s_button { |
283 | uint model; | 283 | uint model; |
284 | Qt::Key code; | 284 | Qt::Key code; |
285 | char *utext; | 285 | char *utext; |
286 | char *pix; | 286 | char *pix; |
287 | char *fpressedservice; | 287 | char *fpressedservice; |
288 | char *fpressedaction; | 288 | char *fpressedaction; |
289 | char *fheldservice; | 289 | char *fheldservice; |
290 | char *fheldaction; | 290 | char *fheldaction; |
291 | } simpad_buttons [] = { | 291 | } simpad_buttons [] = { |
292 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 292 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
293 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 293 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
294 | "devicebuttons/simpad_lower_up", | 294 | "devicebuttons/simpad_lower_up", |
295 | "datebook", "nextView()", | 295 | "datebook", "nextView()", |
296 | "today", "raise()" }, | 296 | "today", "raise()" }, |
297 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 297 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
298 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 298 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
299 | "devicebuttons/simpad_lower_down", | 299 | "devicebuttons/simpad_lower_down", |
300 | "addressbook", "raise()", | 300 | "addressbook", "raise()", |
301 | "addressbook", "beamBusinessCard()" }, | 301 | "addressbook", "beamBusinessCard()" }, |
302 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 302 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
303 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 303 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
304 | "devicebuttons/simpad_lower_right", | 304 | "devicebuttons/simpad_lower_right", |
305 | "QPE/TaskBar", "toggleMenu()", | 305 | "QPE/TaskBar", "toggleMenu()", |
306 | "QPE/TaskBar", "toggleStartMenu()" }, | 306 | "QPE/TaskBar", "toggleStartMenu()" }, |
307 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 307 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
308 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 308 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
309 | "devicebuttons/simpad_lower_left", | 309 | "devicebuttons/simpad_lower_left", |
310 | "mail", "raise()", | 310 | "mail", "raise()", |
311 | "mail", "newMail()" }, | 311 | "mail", "newMail()" }, |
312 | 312 | ||
313 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 313 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
314 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 314 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
315 | "devicebuttons/simpad_upper_up", | 315 | "devicebuttons/simpad_upper_up", |
316 | "QPE/Launcher", "home()", | 316 | "QPE/Launcher", "home()", |
317 | "buttonsettings", "raise()" }, | 317 | "buttonsettings", "raise()" }, |
318 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 318 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
319 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 319 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
320 | "devicebuttons/simpad_upper_down", | 320 | "devicebuttons/simpad_upper_down", |
321 | "addressbook", "raise()", | 321 | "addressbook", "raise()", |
322 | "addressbook", "beamBusinessCard()" }, | 322 | "addressbook", "beamBusinessCard()" }, |
323 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 323 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
324 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 324 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
325 | "devicebuttons/simpad_upper_right", | 325 | "devicebuttons/simpad_upper_right", |
326 | "QPE/TaskBar", "toggleMenu()", | 326 | "QPE/TaskBar", "toggleMenu()", |
327 | "QPE/TaskBar", "toggleStartMenu()" }, | 327 | "QPE/TaskBar", "toggleStartMenu()" }, |
328 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 328 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
329 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 329 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
330 | "devicebuttons/simpad_upper_left", | 330 | "devicebuttons/simpad_upper_left", |
331 | "QPE/Rotation", "flip()", | 331 | "QPE/Rotation", "flip()", |
332 | "QPE/Rotation", "flip()" }, | 332 | "QPE/Rotation", "flip()" }, |
333 | /* | 333 | /* |
334 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 334 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
335 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 335 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
336 | "devicebuttons/simpad_lower_upper", | 336 | "devicebuttons/simpad_lower_upper", |
337 | "QPE/Launcher", "home()", | 337 | "QPE/Launcher", "home()", |
338 | "buttonsettings", "raise()" }, | 338 | "buttonsettings", "raise()" }, |
339 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 339 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
340 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 340 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
341 | "devicebuttons/simpad_upper_lower", | 341 | "devicebuttons/simpad_upper_lower", |
342 | "QPE/Launcher", "home()", | 342 | "QPE/Launcher", "home()", |
343 | "buttonsettings", "raise()" }, | 343 | "buttonsettings", "raise()" }, |
344 | */ | 344 | */ |
345 | }; | 345 | }; |
346 | 346 | ||
347 | struct r_button { | 347 | struct r_button { |
348 | uint model; | 348 | uint model; |
349 | Qt::Key code; | 349 | Qt::Key code; |
350 | char *utext; | 350 | char *utext; |
351 | char *pix; | 351 | char *pix; |
352 | char *fpressedservice; | 352 | char *fpressedservice; |
353 | char *fpressedaction; | 353 | char *fpressedaction; |
354 | char *fheldservice; | 354 | char *fheldservice; |
355 | char *fheldaction; | 355 | char *fheldaction; |
356 | } ramses_buttons [] = { | 356 | } ramses_buttons [] = { |
357 | { Model_Ramses_MNCI, | 357 | { Model_Ramses_MNCI, |
358 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 358 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
359 | "devicebuttons/z_menu", | 359 | "devicebuttons/z_menu", |
360 | "QPE/TaskBar", "toggleMenu()", | 360 | "QPE/TaskBar", "toggleMenu()", |
361 | "QPE/TaskBar", "toggleStartMenu()" }, | 361 | "QPE/TaskBar", "toggleStartMenu()" }, |
362 | { Model_Ramses_MNCI, | 362 | { Model_Ramses_MNCI, |
363 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 363 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
364 | "devicebuttons/ipaq_home", | 364 | "devicebuttons/ipaq_home", |
365 | "QPE/Launcher", "home()", | 365 | "QPE/Launcher", "home()", |
366 | "buttonsettings", "raise()" }, | 366 | "buttonsettings", "raise()" }, |
367 | }; | 367 | }; |
368 | 368 | ||
369 | static QCString makeChannel ( const char *str ) | 369 | static QCString makeChannel ( const char *str ) |
370 | { | 370 | { |
371 | if ( str && !::strchr ( str, '/' )) | 371 | if ( str && !::strchr ( str, '/' )) |
372 | return QCString ( "QPE/Application/" ) + str; | 372 | return QCString ( "QPE/Application/" ) + str; |
373 | else | 373 | else |
374 | return str; | 374 | return str; |
375 | } | 375 | } |
376 | 376 | ||
377 | static inline bool isQWS() | 377 | static inline bool isQWS() |
378 | { | 378 | { |
379 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 379 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
380 | } | 380 | } |
381 | 381 | ||
382 | ODevice *ODevice::inst ( ) | 382 | ODevice *ODevice::inst ( ) |
383 | { | 383 | { |
384 | static ODevice *dev = 0; | 384 | static ODevice *dev = 0; |
385 | 385 | ||
386 | if ( !dev ) { | 386 | if ( !dev ) { |
387 | if ( QFile::exists ( "/proc/hal/model" )) | 387 | if ( QFile::exists ( "/proc/hal/model" )) |
388 | dev = new iPAQ ( ); | 388 | dev = new iPAQ ( ); |
389 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 389 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
390 | dev = new Zaurus ( ); | 390 | dev = new Zaurus ( ); |
391 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 391 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
392 | dev = new SIMpad ( ); | 392 | dev = new SIMpad ( ); |
393 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 393 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
394 | dev = new Ramses ( ); | 394 | dev = new Ramses ( ); |
395 | else | 395 | else |
396 | dev = new ODevice ( ); | 396 | dev = new ODevice ( ); |
397 | 397 | ||
398 | dev-> init ( ); | 398 | dev-> init ( ); |
399 | } | 399 | } |
400 | return dev; | 400 | return dev; |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | /************************************************** | 404 | /************************************************** |
405 | * | 405 | * |
406 | * common | 406 | * common |
407 | * | 407 | * |
408 | **************************************************/ | 408 | **************************************************/ |
409 | 409 | ||
410 | 410 | ||
411 | ODevice::ODevice ( ) | 411 | ODevice::ODevice ( ) |
412 | { | 412 | { |
413 | d = new ODeviceData; | 413 | d = new ODeviceData; |
414 | 414 | ||
415 | d-> m_modelstr = "Unknown"; | 415 | d-> m_modelstr = "Unknown"; |
416 | d-> m_model = Model_Unknown; | 416 | d-> m_model = Model_Unknown; |
417 | d-> m_vendorstr = "Unknown"; | 417 | d-> m_vendorstr = "Unknown"; |
418 | d-> m_vendor = Vendor_Unknown; | 418 | d-> m_vendor = Vendor_Unknown; |
419 | d-> m_systemstr = "Unknown"; | 419 | d-> m_systemstr = "Unknown"; |
420 | d-> m_system = System_Unknown; | 420 | d-> m_system = System_Unknown; |
421 | d-> m_sysverstr = "0.0"; | 421 | d-> m_sysverstr = "0.0"; |
422 | d-> m_rotation = Rot0; | 422 | d-> m_rotation = Rot0; |
423 | d-> m_direction = CW; | 423 | d-> m_direction = CW; |
424 | 424 | ||
425 | d-> m_holdtime = 1000; // 1000ms | 425 | d-> m_holdtime = 1000; // 1000ms |
426 | d-> m_buttons = 0; | 426 | d-> m_buttons = 0; |
427 | d-> m_cpu_frequencies = new QStrList; | 427 | d-> m_cpu_frequencies = new QStrList; |
428 | } | 428 | } |
429 | 429 | ||
430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
431 | { | 431 | { |
432 | if ( msg == "deviceButtonMappingChanged()" ) { | 432 | if ( msg == "deviceButtonMappingChanged()" ) { |
433 | reloadButtonMapping ( ); | 433 | reloadButtonMapping ( ); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | void ODevice::init ( ) | 437 | void ODevice::init ( ) |
438 | { | 438 | { |
439 | } | 439 | } |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * This method initialises the button mapping | 442 | * This method initialises the button mapping |
443 | */ | 443 | */ |
444 | void ODevice::initButtons ( ) | 444 | void ODevice::initButtons ( ) |
445 | { | 445 | { |
446 | if ( d-> m_buttons ) | 446 | if ( d-> m_buttons ) |
447 | return; | 447 | return; |
448 | 448 | ||
449 | // Simulation uses iPAQ 3660 device buttons | 449 | // Simulation uses iPAQ 3660 device buttons |
450 | 450 | ||
451 | qDebug ( "init Buttons" ); | 451 | qDebug ( "init Buttons" ); |
452 | d-> m_buttons = new QValueList <ODeviceButton>; | 452 | d-> m_buttons = new QValueList <ODeviceButton>; |
453 | 453 | ||
454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
455 | i_button *ib = ipaq_buttons + i; | 455 | i_button *ib = ipaq_buttons + i; |
456 | ODeviceButton b; | 456 | ODeviceButton b; |
457 | 457 | ||
458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
459 | b. setKeycode ( ib-> code ); | 459 | b. setKeycode ( ib-> code ); |
460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
464 | d-> m_buttons-> append ( b ); | 464 | d-> m_buttons-> append ( b ); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | reloadButtonMapping ( ); | 467 | reloadButtonMapping ( ); |
468 | 468 | ||
469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
471 | } | 471 | } |
472 | 472 | ||
473 | ODevice::~ODevice ( ) | 473 | ODevice::~ODevice ( ) |
474 | { | 474 | { |
475 | delete d; | 475 | delete d; |
476 | } | 476 | } |
477 | 477 | ||
478 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 478 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
479 | { | 479 | { |
480 | return false; | 480 | return false; |
481 | } | 481 | } |
482 | 482 | ||
483 | //#include <linux/apm_bios.h> | 483 | //#include <linux/apm_bios.h> |
484 | 484 | ||
485 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 485 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
486 | 486 | ||
487 | /** | 487 | /** |
488 | * This method will try to suspend the device | 488 | * This method will try to suspend the device |
489 | * It only works if the user is the QWS Server and the apm application | 489 | * It only works if the user is the QWS Server and the apm application |
490 | * is installed. | 490 | * is installed. |
491 | * It tries to suspend and then waits some time cause some distributions | 491 | * It tries to suspend and then waits some time cause some distributions |
492 | * do have asynchronus apm implementations. | 492 | * do have asynchronus apm implementations. |
493 | * This method will either fail and return false or it'll suspend the | 493 | * This method will either fail and return false or it'll suspend the |
494 | * device and return once the device got woken up | 494 | * device and return once the device got woken up |
495 | * | 495 | * |
496 | * @return if the device got suspended | 496 | * @return if the device got suspended |
497 | */ | 497 | */ |
498 | bool ODevice::suspend ( ) | 498 | bool ODevice::suspend ( ) |
499 | { | 499 | { |
500 | qDebug("ODevice::suspend"); | 500 | qDebug("ODevice::suspend"); |
501 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 501 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
502 | return false; | 502 | return false; |
503 | 503 | ||
504 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 504 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
505 | return false; | 505 | return false; |
506 | 506 | ||
507 | bool res = false; | 507 | bool res = false; |
508 | 508 | ||
509 | struct timeval tvs, tvn; | 509 | struct timeval tvs, tvn; |
510 | ::gettimeofday ( &tvs, 0 ); | 510 | ::gettimeofday ( &tvs, 0 ); |
511 | 511 | ||
512 | ::sync ( ); // flush fs caches | 512 | ::sync ( ); // flush fs caches |
513 | res = ( ::system ( "apm --suspend" ) == 0 ); | 513 | res = ( ::system ( "apm --suspend" ) == 0 ); |
514 | 514 | ||
515 | // This is needed because the iPAQ apm implementation is asynchronous and we | 515 | // This is needed because the iPAQ apm implementation is asynchronous and we |
516 | // can not be sure when exactly the device is really suspended | 516 | // can not be sure when exactly the device is really suspended |
517 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 517 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
518 | 518 | ||
519 | if ( res ) { | 519 | if ( res ) { |
520 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 520 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
521 | ::usleep ( 200 * 1000 ); | 521 | ::usleep ( 200 * 1000 ); |
522 | ::gettimeofday ( &tvn, 0 ); | 522 | ::gettimeofday ( &tvn, 0 ); |
523 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 523 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
524 | } | 524 | } |
525 | 525 | ||
526 | return res; | 526 | return res; |
527 | } | 527 | } |
528 | 528 | ||
529 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 529 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
530 | 530 | ||
531 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 531 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
532 | 532 | ||
533 | /* VESA Blanking Levels */ | 533 | /* VESA Blanking Levels */ |
534 | #define VESA_NO_BLANKING 0 | 534 | #define VESA_NO_BLANKING 0 |
535 | #define VESA_VSYNC_SUSPEND 1 | 535 | #define VESA_VSYNC_SUSPEND 1 |
536 | #define VESA_HSYNC_SUSPEND 2 | 536 | #define VESA_HSYNC_SUSPEND 2 |
537 | #define VESA_POWERDOWN 3 | 537 | #define VESA_POWERDOWN 3 |
538 | 538 | ||
539 | /** | 539 | /** |
540 | * This sets the display on or off | 540 | * This sets the display on or off |
541 | */ | 541 | */ |
542 | bool ODevice::setDisplayStatus ( bool on ) | 542 | bool ODevice::setDisplayStatus ( bool on ) |
543 | { | 543 | { |
544 | qDebug("ODevice::setDisplayStatus(%d)", on); | 544 | qDebug("ODevice::setDisplayStatus(%d)", on); |
545 | 545 | ||
546 | if ( d-> m_model == Model_Unknown ) | 546 | if ( d-> m_model == Model_Unknown ) |
547 | return false; | 547 | return false; |
548 | 548 | ||
549 | bool res = false; | 549 | bool res = false; |
550 | int fd; | 550 | int fd; |
551 | 551 | ||
552 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 552 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
553 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 553 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
554 | ::close ( fd ); | 554 | ::close ( fd ); |
555 | } | 555 | } |
556 | return res; | 556 | return res; |
557 | } | 557 | } |
558 | 558 | ||
559 | /** | 559 | /** |
560 | * This sets the display brightness | 560 | * This sets the display brightness |
561 | * | 561 | * |
562 | * @param p The brightness to be set on a scale from 0 to 255 | 562 | * @param p The brightness to be set on a scale from 0 to 255 |
563 | * @return success or failure | 563 | * @return success or failure |
564 | */ | 564 | */ |
565 | bool ODevice::setDisplayBrightness ( int p) | 565 | bool ODevice::setDisplayBrightness ( int p) |
566 | { | 566 | { |
567 | Q_UNUSED( p ) | 567 | Q_UNUSED( p ) |
568 | return false; | 568 | return false; |
569 | } | 569 | } |
570 | 570 | ||
571 | /** | 571 | /** |
572 | * @return returns the number of steppings on the brightness slider | 572 | * @return returns the number of steppings on the brightness slider |
573 | * in the Light-'n-Power settings. | 573 | * in the Light-'n-Power settings. |
574 | */ | 574 | */ |
575 | int ODevice::displayBrightnessResolution ( ) const | 575 | int ODevice::displayBrightnessResolution ( ) const |
576 | { | 576 | { |
577 | return 16; | 577 | return 16; |
578 | } | 578 | } |
579 | 579 | ||
580 | /** | 580 | /** |
581 | * This sets the display contrast | 581 | * This sets the display contrast |
582 | * @param p The contrast to be set on a scale from 0 to 255 | 582 | * @param p The contrast to be set on a scale from 0 to 255 |
583 | * @return success or failure | 583 | * @return success or failure |
584 | */ | 584 | */ |
585 | bool ODevice::setDisplayContrast ( int p) | 585 | bool ODevice::setDisplayContrast ( int p) |
586 | { | 586 | { |
587 | Q_UNUSED( p ) | 587 | Q_UNUSED( p ) |
588 | return false; | 588 | return false; |
589 | } | 589 | } |
590 | 590 | ||
591 | /** | 591 | /** |
592 | * @return return the max value for the brightness settings slider | 592 | * @return return the max value for the brightness settings slider |
593 | * or 0 if the device doesn't support setting of a contrast | 593 | * or 0 if the device doesn't support setting of a contrast |
594 | */ | 594 | */ |
595 | int ODevice::displayContrastResolution ( ) const | 595 | int ODevice::displayContrastResolution ( ) const |
596 | { | 596 | { |
597 | return 0; | 597 | return 0; |
598 | } | 598 | } |
599 | 599 | ||
600 | /** | 600 | /** |
601 | * This returns the vendor as string | 601 | * This returns the vendor as string |
602 | * @return Vendor as QString | 602 | * @return Vendor as QString |
603 | */ | 603 | */ |
604 | QString ODevice::vendorString ( ) const | 604 | QString ODevice::vendorString ( ) const |
605 | { | 605 | { |
606 | return d-> m_vendorstr; | 606 | return d-> m_vendorstr; |
607 | } | 607 | } |
608 | 608 | ||
609 | /** | 609 | /** |
610 | * This returns the vendor as one of the values of OVendor | 610 | * This returns the vendor as one of the values of OVendor |
611 | * @return OVendor | 611 | * @return OVendor |
612 | */ | 612 | */ |
613 | OVendor ODevice::vendor ( ) const | 613 | OVendor ODevice::vendor ( ) const |
614 | { | 614 | { |
615 | return d-> m_vendor; | 615 | return d-> m_vendor; |
616 | } | 616 | } |
617 | 617 | ||
618 | /** | 618 | /** |
619 | * This returns the model as a string | 619 | * This returns the model as a string |
620 | * @return A string representing the model | 620 | * @return A string representing the model |
621 | */ | 621 | */ |
622 | QString ODevice::modelString ( ) const | 622 | QString ODevice::modelString ( ) const |
623 | { | 623 | { |
624 | return d-> m_modelstr; | 624 | return d-> m_modelstr; |
625 | } | 625 | } |
626 | 626 | ||
627 | /** | 627 | /** |
628 | * This does return the OModel used | 628 | * This does return the OModel used |
629 | */ | 629 | */ |
630 | OModel ODevice::model ( ) const | 630 | OModel ODevice::model ( ) const |
631 | { | 631 | { |
632 | return d-> m_model; | 632 | return d-> m_model; |
633 | } | 633 | } |
634 | 634 | ||
635 | /** | 635 | /** |
636 | * This does return the systen name | 636 | * This does return the systen name |
637 | */ | 637 | */ |
638 | QString ODevice::systemString ( ) const | 638 | QString ODevice::systemString ( ) const |
639 | { | 639 | { |
640 | return d-> m_systemstr; | 640 | return d-> m_systemstr; |
641 | } | 641 | } |
642 | 642 | ||
643 | /** | 643 | /** |
644 | * Return System as OSystem value | 644 | * Return System as OSystem value |
645 | */ | 645 | */ |
646 | OSystem ODevice::system ( ) const | 646 | OSystem ODevice::system ( ) const |
647 | { | 647 | { |
648 | return d-> m_system; | 648 | return d-> m_system; |
649 | } | 649 | } |
650 | 650 | ||
651 | /** | 651 | /** |
652 | * @return the version string of the base system | 652 | * @return the version string of the base system |
653 | */ | 653 | */ |
654 | QString ODevice::systemVersionString ( ) const | 654 | QString ODevice::systemVersionString ( ) const |
655 | { | 655 | { |
656 | return d-> m_sysverstr; | 656 | return d-> m_sysverstr; |
657 | } | 657 | } |
658 | 658 | ||
659 | /** | 659 | /** |
660 | * @return the current Transformation | 660 | * @return the current Transformation |
661 | */ | 661 | */ |
662 | Transformation ODevice::rotation ( ) const | 662 | Transformation ODevice::rotation ( ) const |
663 | { | 663 | { |
664 | return d-> m_rotation; | 664 | return d-> m_rotation; |
665 | } | 665 | } |
666 | 666 | ||
667 | /** | 667 | /** |
668 | * @return the current rotation direction | 668 | * @return the current rotation direction |
669 | */ | 669 | */ |
670 | ODirection ODevice::direction ( ) const | 670 | ODirection ODevice::direction ( ) const |
671 | { | 671 | { |
672 | return d-> m_direction; | 672 | return d-> m_direction; |
673 | } | 673 | } |
674 | 674 | ||
675 | /** | 675 | /** |
676 | * This plays an alarmSound | 676 | * This plays an alarmSound |
677 | */ | 677 | */ |
678 | void ODevice::alarmSound ( ) | 678 | void ODevice::alarmSound ( ) |
679 | { | 679 | { |
680 | #ifndef QT_NO_SOUND | 680 | #ifndef QT_NO_SOUND |
681 | static Sound snd ( "alarm" ); | 681 | static Sound snd ( "alarm" ); |
682 | 682 | ||
683 | if ( snd. isFinished ( )) | 683 | if ( snd. isFinished ( )) |
684 | snd. play ( ); | 684 | snd. play ( ); |
685 | #endif | 685 | #endif |
686 | } | 686 | } |
687 | 687 | ||
688 | /** | 688 | /** |
689 | * This plays a key sound | 689 | * This plays a key sound |
690 | */ | 690 | */ |
691 | void ODevice::keySound ( ) | 691 | void ODevice::keySound ( ) |
692 | { | 692 | { |
693 | #ifndef QT_NO_SOUND | 693 | #ifndef QT_NO_SOUND |
694 | static Sound snd ( "keysound" ); | 694 | static Sound snd ( "keysound" ); |
695 | 695 | ||
696 | if ( snd. isFinished ( )) | 696 | if ( snd. isFinished ( )) |
697 | snd. play ( ); | 697 | snd. play ( ); |
698 | #endif | 698 | #endif |
699 | } | 699 | } |
700 | 700 | ||
701 | /** | 701 | /** |
702 | * This plays a touch sound | 702 | * This plays a touch sound |
703 | */ | 703 | */ |
704 | void ODevice::touchSound ( ) | 704 | void ODevice::touchSound ( ) |
705 | { | 705 | { |
706 | #ifndef QT_NO_SOUND | 706 | #ifndef QT_NO_SOUND |
707 | static Sound snd ( "touchsound" ); | 707 | static Sound snd ( "touchsound" ); |
708 | 708 | ||
709 | if ( snd. isFinished ( )) | 709 | if ( snd. isFinished ( )) |
710 | snd. play ( ); | 710 | snd. play ( ); |
711 | #endif | 711 | #endif |
712 | } | 712 | } |
713 | 713 | ||
714 | /** | 714 | /** |
715 | * This method will return a list of leds | 715 | * This method will return a list of leds |
716 | * available on this device | 716 | * available on this device |
717 | * @return a list of LEDs. | 717 | * @return a list of LEDs. |
718 | */ | 718 | */ |
719 | QValueList <OLed> ODevice::ledList ( ) const | 719 | QValueList <OLed> ODevice::ledList ( ) const |
720 | { | 720 | { |
721 | return QValueList <OLed> ( ); | 721 | return QValueList <OLed> ( ); |
722 | } | 722 | } |
723 | 723 | ||
724 | /** | 724 | /** |
725 | * This does return the state of the LEDs | 725 | * This does return the state of the LEDs |
726 | */ | 726 | */ |
727 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 727 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
728 | { | 728 | { |
729 | return QValueList <OLedState> ( ); | 729 | return QValueList <OLedState> ( ); |
730 | } | 730 | } |
731 | 731 | ||
732 | /** | 732 | /** |
733 | * @return the state for a given OLed | 733 | * @return the state for a given OLed |
734 | */ | 734 | */ |
735 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 735 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
736 | { | 736 | { |
737 | return Led_Off; | 737 | return Led_Off; |
738 | } | 738 | } |
739 | 739 | ||
740 | /** | 740 | /** |
741 | * Set the state for a LED | 741 | * Set the state for a LED |
742 | * @param which Which OLed to use | 742 | * @param which Which OLed to use |
743 | * @param st The state to set | 743 | * @param st The state to set |
744 | * @return success or failure | 744 | * @return success or failure |
745 | */ | 745 | */ |
746 | bool ODevice::setLedState ( OLed which, OLedState st ) | 746 | bool ODevice::setLedState ( OLed which, OLedState st ) |
747 | { | 747 | { |
748 | Q_UNUSED( which ) | 748 | Q_UNUSED( which ) |
749 | Q_UNUSED( st ) | 749 | Q_UNUSED( st ) |
750 | return false; | 750 | return false; |
751 | } | 751 | } |
752 | 752 | ||
753 | /** | 753 | /** |
754 | * @return if the device has a light sensor | 754 | * @return if the device has a light sensor |
755 | */ | 755 | */ |
756 | bool ODevice::hasLightSensor ( ) const | 756 | bool ODevice::hasLightSensor ( ) const |
757 | { | 757 | { |
758 | return false; | 758 | return false; |
759 | } | 759 | } |
760 | 760 | ||
761 | /** | 761 | /** |
762 | * @return a value from the light senso | 762 | * @return a value from the light senso |
763 | */ | 763 | */ |
764 | int ODevice::readLightSensor ( ) | 764 | int ODevice::readLightSensor ( ) |
765 | { | 765 | { |
766 | return -1; | 766 | return -1; |
767 | } | 767 | } |
768 | 768 | ||
769 | /** | 769 | /** |
770 | * @return the light sensor resolution whatever that is ;) | 770 | * @return the light sensor resolution whatever that is ;) |
771 | */ | 771 | */ |
772 | int ODevice::lightSensorResolution ( ) const | 772 | int ODevice::lightSensorResolution ( ) const |
773 | { | 773 | { |
774 | return 0; | 774 | return 0; |
775 | } | 775 | } |
776 | 776 | ||
777 | /** | 777 | /** |
778 | * @return a list with valid CPU frequency | 778 | * @return a list with CPU frequencies supported by the hardware |
779 | */ | 779 | */ |
780 | QStrList &ODevice::cpuFrequencies ( ) const | 780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
781 | { | 781 | { |
782 | return *d->m_cpu_frequencies; | 782 | return *d->m_cpu_frequencies; |
783 | } | 783 | } |
784 | 784 | ||
785 | 785 | ||
786 | /** | 786 | /** |
787 | * Set desired cpu frequency | 787 | * Set desired CPU frequency |
788 | * | 788 | * |
789 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 789 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
790 | */ | 790 | */ |
791 | bool ODevice::setCpuFrequency(uint index) | 791 | bool ODevice::setCurrentCpuFrequency(uint index) |
792 | { | 792 | { |
793 | if (index >= d->m_cpu_frequencies->count()) | 793 | if (index >= d->m_cpu_frequencies->count()) |
794 | return false; | 794 | return false; |
795 | 795 | ||
796 | char *freq = d->m_cpu_frequencies->at(index); | 796 | char *freq = d->m_cpu_frequencies->at(index); |
797 | qWarning("set freq to %s", freq); | 797 | qWarning("set freq to %s", freq); |
798 | 798 | ||
799 | int fd; | 799 | int fd; |
800 | 800 | ||
801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
802 | char writeCommand[50]; | 802 | char writeCommand[50]; |
803 | const int count = sprintf(writeCommand, "%s\n", freq); | 803 | const int count = sprintf(writeCommand, "%s\n", freq); |
804 | int res = (::write(fd, writeCommand, count) != -1); | 804 | int res = (::write(fd, writeCommand, count) != -1); |
805 | ::close(fd); | 805 | ::close(fd); |
806 | return res; | 806 | return res; |
807 | } | 807 | } |
808 | 808 | ||
809 | return false; | 809 | return false; |
810 | } | 810 | } |
811 | 811 | ||
812 | 812 | ||
813 | /** | 813 | /** |
814 | * @return a list of hardware buttons | 814 | * @return a list of hardware buttons |
815 | */ | 815 | */ |
816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
817 | { | 817 | { |
818 | initButtons ( ); | 818 | initButtons ( ); |
819 | 819 | ||
820 | return *d-> m_buttons; | 820 | return *d-> m_buttons; |
821 | } | 821 | } |
822 | 822 | ||
823 | /** | 823 | /** |
824 | * @return The amount of time that would count as a hold | 824 | * @return The amount of time that would count as a hold |
825 | */ | 825 | */ |
826 | uint ODevice::buttonHoldTime ( ) const | 826 | uint ODevice::buttonHoldTime ( ) const |
827 | { | 827 | { |
828 | return d-> m_holdtime; | 828 | return d-> m_holdtime; |
829 | } | 829 | } |
830 | 830 | ||
831 | /** | 831 | /** |
832 | * This method return a ODeviceButton for a key code | 832 | * This method return a ODeviceButton for a key code |
833 | * or 0 if no special hardware button is available for the device | 833 | * or 0 if no special hardware button is available for the device |
834 | * | 834 | * |
835 | * @return The devicebutton or 0l | 835 | * @return The devicebutton or 0l |
836 | * @see ODeviceButton | 836 | * @see ODeviceButton |
837 | */ | 837 | */ |
838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
839 | { | 839 | { |
840 | initButtons ( ); | 840 | initButtons ( ); |
841 | 841 | ||
842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
843 | if ( (*it). keycode ( ) == code ) | 843 | if ( (*it). keycode ( ) == code ) |
844 | return &(*it); | 844 | return &(*it); |
845 | } | 845 | } |
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | 848 | ||
849 | void ODevice::reloadButtonMapping ( ) | 849 | void ODevice::reloadButtonMapping ( ) |
850 | { | 850 | { |
851 | initButtons ( ); | 851 | initButtons ( ); |
852 | 852 | ||
853 | Config cfg ( "ButtonSettings" ); | 853 | Config cfg ( "ButtonSettings" ); |
854 | 854 | ||
855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
857 | QString group = "Button" + QString::number ( i ); | 857 | QString group = "Button" + QString::number ( i ); |
858 | 858 | ||
859 | QCString pch, hch; | 859 | QCString pch, hch; |
860 | QCString pm, hm; | 860 | QCString pm, hm; |
861 | QByteArray pdata, hdata; | 861 | QByteArray pdata, hdata; |
862 | 862 | ||
863 | if ( cfg. hasGroup ( group )) { | 863 | if ( cfg. hasGroup ( group )) { |
864 | cfg. setGroup ( group ); | 864 | cfg. setGroup ( group ); |
865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
868 | 868 | ||
869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
872 | } | 872 | } |
873 | 873 | ||
874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
875 | 875 | ||
876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
881 | { | 881 | { |
882 | initButtons ( ); | 882 | initButtons ( ); |
883 | 883 | ||
884 | QString mb_chan; | 884 | QString mb_chan; |
885 | 885 | ||
886 | if ( button >= (int) d-> m_buttons-> count ( )) | 886 | if ( button >= (int) d-> m_buttons-> count ( )) |
887 | return; | 887 | return; |
888 | 888 | ||
889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
890 | b. setPressedAction ( action ); | 890 | b. setPressedAction ( action ); |
891 | 891 | ||
892 | mb_chan=b. pressedAction ( ). channel ( ); | 892 | mb_chan=b. pressedAction ( ). channel ( ); |
893 | 893 | ||
894 | Config buttonFile ( "ButtonSettings" ); | 894 | Config buttonFile ( "ButtonSettings" ); |
895 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 895 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
898 | 898 | ||
899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
900 | 900 | ||
901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
902 | } | 902 | } |
903 | 903 | ||
904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
905 | { | 905 | { |
906 | initButtons ( ); | 906 | initButtons ( ); |
907 | 907 | ||
908 | if ( button >= (int) d-> m_buttons-> count ( )) | 908 | if ( button >= (int) d-> m_buttons-> count ( )) |
909 | return; | 909 | return; |
910 | 910 | ||
911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
912 | b. setHeldAction ( action ); | 912 | b. setHeldAction ( action ); |
913 | 913 | ||
914 | Config buttonFile ( "ButtonSettings" ); | 914 | Config buttonFile ( "ButtonSettings" ); |
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 915 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 918 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 920 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 922 | } |
923 | 923 | ||
924 | 924 | ||
925 | 925 | ||
926 | 926 | ||
927 | /************************************************** | 927 | /************************************************** |
928 | * | 928 | * |
929 | * iPAQ | 929 | * iPAQ |
930 | * | 930 | * |
931 | **************************************************/ | 931 | **************************************************/ |
932 | 932 | ||
933 | void iPAQ::init ( ) | 933 | void iPAQ::init ( ) |
934 | { | 934 | { |
935 | d-> m_vendorstr = "HP"; | 935 | d-> m_vendorstr = "HP"; |
936 | d-> m_vendor = Vendor_HP; | 936 | d-> m_vendor = Vendor_HP; |
937 | 937 | ||
938 | QFile f ( "/proc/hal/model" ); | 938 | QFile f ( "/proc/hal/model" ); |
939 | 939 | ||
940 | if ( f. open ( IO_ReadOnly )) { | 940 | if ( f. open ( IO_ReadOnly )) { |
941 | QTextStream ts ( &f ); | 941 | QTextStream ts ( &f ); |
942 | 942 | ||
943 | d-> m_modelstr = "H" + ts. readLine ( ); | 943 | d-> m_modelstr = "H" + ts. readLine ( ); |
944 | 944 | ||
945 | if ( d-> m_modelstr == "H3100" ) | 945 | if ( d-> m_modelstr == "H3100" ) |
946 | d-> m_model = Model_iPAQ_H31xx; | 946 | d-> m_model = Model_iPAQ_H31xx; |
947 | else if ( d-> m_modelstr == "H3600" ) | 947 | else if ( d-> m_modelstr == "H3600" ) |
948 | d-> m_model = Model_iPAQ_H36xx; | 948 | d-> m_model = Model_iPAQ_H36xx; |
949 | else if ( d-> m_modelstr == "H3700" ) | 949 | else if ( d-> m_modelstr == "H3700" ) |
950 | d-> m_model = Model_iPAQ_H37xx; | 950 | d-> m_model = Model_iPAQ_H37xx; |
951 | else if ( d-> m_modelstr == "H3800" ) | 951 | else if ( d-> m_modelstr == "H3800" ) |
952 | d-> m_model = Model_iPAQ_H38xx; | 952 | d-> m_model = Model_iPAQ_H38xx; |
953 | else if ( d-> m_modelstr == "H3900" ) | 953 | else if ( d-> m_modelstr == "H3900" ) |
954 | d-> m_model = Model_iPAQ_H39xx; | 954 | d-> m_model = Model_iPAQ_H39xx; |
955 | else | 955 | else |
956 | d-> m_model = Model_Unknown; | 956 | d-> m_model = Model_Unknown; |
957 | 957 | ||
958 | f. close ( ); | 958 | f. close ( ); |
959 | } | 959 | } |
960 | 960 | ||
961 | switch ( d-> m_model ) { | 961 | switch ( d-> m_model ) { |
962 | case Model_iPAQ_H31xx: | 962 | case Model_iPAQ_H31xx: |
963 | case Model_iPAQ_H38xx: | 963 | case Model_iPAQ_H38xx: |
964 | d-> m_rotation = Rot90; | 964 | d-> m_rotation = Rot90; |
965 | break; | 965 | break; |
966 | case Model_iPAQ_H36xx: | 966 | case Model_iPAQ_H36xx: |
967 | case Model_iPAQ_H37xx: | 967 | case Model_iPAQ_H37xx: |
968 | case Model_iPAQ_H39xx: | 968 | case Model_iPAQ_H39xx: |
969 | default: | 969 | default: |
970 | d-> m_rotation = Rot270; | 970 | d-> m_rotation = Rot270; |
971 | break; | 971 | break; |
972 | } | 972 | } |
973 | 973 | ||
974 | f. setName ( "/etc/familiar-version" ); | 974 | f. setName ( "/etc/familiar-version" ); |
975 | if ( f. open ( IO_ReadOnly )) { | 975 | if ( f. open ( IO_ReadOnly )) { |
976 | d-> m_systemstr = "Familiar"; | 976 | d-> m_systemstr = "Familiar"; |
977 | d-> m_system = System_Familiar; | 977 | d-> m_system = System_Familiar; |
978 | 978 | ||
979 | QTextStream ts ( &f ); | 979 | QTextStream ts ( &f ); |
980 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 980 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
981 | 981 | ||
982 | f. close ( ); | 982 | f. close ( ); |
983 | } else { | 983 | } else { |
984 | f. setName ( "/etc/oz_version" ); | 984 | f. setName ( "/etc/oz_version" ); |
985 | 985 | ||
986 | if ( f. open ( IO_ReadOnly )) { | 986 | if ( f. open ( IO_ReadOnly )) { |
987 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 987 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
988 | d-> m_system = System_Familiar; | 988 | d-> m_system = System_Familiar; |
989 | 989 | ||
990 | QTextStream ts ( &f ); | 990 | QTextStream ts ( &f ); |
991 | ts.setDevice ( &f ); | 991 | ts.setDevice ( &f ); |
992 | d-> m_sysverstr = ts. readLine ( ); | 992 | d-> m_sysverstr = ts. readLine ( ); |
993 | f. close ( ); | 993 | f. close ( ); |
994 | } | 994 | } |
995 | } | 995 | } |
996 | 996 | ||
997 | 997 | ||
998 | 998 | ||
999 | 999 | ||
1000 | 1000 | ||
1001 | m_leds [0] = m_leds [1] = Led_Off; | 1001 | m_leds [0] = m_leds [1] = Led_Off; |
1002 | 1002 | ||
1003 | m_power_timer = 0; | 1003 | m_power_timer = 0; |
1004 | 1004 | ||
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void iPAQ::initButtons ( ) | 1007 | void iPAQ::initButtons ( ) |
1008 | { | 1008 | { |
1009 | if ( d-> m_buttons ) | 1009 | if ( d-> m_buttons ) |
1010 | return; | 1010 | return; |
1011 | 1011 | ||
1012 | if ( isQWS( ) ) | 1012 | if ( isQWS( ) ) |
1013 | QWSServer::setKeyboardFilter ( this ); | 1013 | QWSServer::setKeyboardFilter ( this ); |
1014 | 1014 | ||
1015 | d-> m_buttons = new QValueList <ODeviceButton>; | 1015 | d-> m_buttons = new QValueList <ODeviceButton>; |
1016 | 1016 | ||
1017 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1017 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1018 | i_button *ib = ipaq_buttons + i; | 1018 | i_button *ib = ipaq_buttons + i; |
1019 | ODeviceButton b; | 1019 | ODeviceButton b; |
1020 | 1020 | ||
1021 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1021 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1022 | b. setKeycode ( ib-> code ); | 1022 | b. setKeycode ( ib-> code ); |
1023 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1023 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1024 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1024 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1025 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1025 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1026 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1026 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1027 | 1027 | ||
1028 | d-> m_buttons-> append ( b ); | 1028 | d-> m_buttons-> append ( b ); |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | reloadButtonMapping ( ); | 1031 | reloadButtonMapping ( ); |
1032 | 1032 | ||
1033 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1033 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1034 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1034 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | 1037 | ||
1038 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1038 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1039 | 1039 | ||
1040 | typedef struct { | 1040 | typedef struct { |
1041 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1041 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1042 | unsigned char TotalTime; /* Units of 5 seconds */ | 1042 | unsigned char TotalTime; /* Units of 5 seconds */ |
1043 | unsigned char OnTime; /* units of 100m/s */ | 1043 | unsigned char OnTime; /* units of 100m/s */ |
1044 | unsigned char OffTime; /* units of 100m/s */ | 1044 | unsigned char OffTime; /* units of 100m/s */ |
1045 | } LED_IN; | 1045 | } LED_IN; |
1046 | 1046 | ||
1047 | typedef struct { | 1047 | typedef struct { |
1048 | unsigned char mode; | 1048 | unsigned char mode; |
1049 | unsigned char pwr; | 1049 | unsigned char pwr; |
1050 | unsigned char brightness; | 1050 | unsigned char brightness; |
1051 | } FLITE_IN; | 1051 | } FLITE_IN; |
1052 | 1052 | ||
1053 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1053 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1054 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1054 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1055 | 1055 | ||
1056 | 1056 | ||
1057 | QValueList <OLed> iPAQ::ledList ( ) const | 1057 | QValueList <OLed> iPAQ::ledList ( ) const |
1058 | { | 1058 | { |
1059 | QValueList <OLed> vl; | 1059 | QValueList <OLed> vl; |
1060 | vl << Led_Power; | 1060 | vl << Led_Power; |
1061 | 1061 | ||
1062 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1062 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1063 | vl << Led_BlueTooth; | 1063 | vl << Led_BlueTooth; |
1064 | return vl; | 1064 | return vl; |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1067 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1068 | { | 1068 | { |
1069 | QValueList <OLedState> vl; | 1069 | QValueList <OLedState> vl; |
1070 | 1070 | ||
1071 | if ( l == Led_Power ) | 1071 | if ( l == Led_Power ) |
1072 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1072 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1073 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1073 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1074 | vl << Led_Off; // << Led_On << ??? | 1074 | vl << Led_Off; // << Led_On << ??? |
1075 | 1075 | ||
1076 | return vl; | 1076 | return vl; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | OLedState iPAQ::ledState ( OLed l ) const | 1079 | OLedState iPAQ::ledState ( OLed l ) const |
1080 | { | 1080 | { |
1081 | switch ( l ) { | 1081 | switch ( l ) { |
1082 | case Led_Power: | 1082 | case Led_Power: |
1083 | return m_leds [0]; | 1083 | return m_leds [0]; |
1084 | case Led_BlueTooth: | 1084 | case Led_BlueTooth: |
1085 | return m_leds [1]; | 1085 | return m_leds [1]; |
1086 | default: | 1086 | default: |
1087 | return Led_Off; | 1087 | return Led_Off; |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1091 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1092 | { | 1092 | { |
1093 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1093 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1094 | 1094 | ||
1095 | if ( l == Led_Power ) { | 1095 | if ( l == Led_Power ) { |
1096 | if ( fd >= 0 ) { | 1096 | if ( fd >= 0 ) { |
1097 | LED_IN leds; | 1097 | LED_IN leds; |
1098 | ::memset ( &leds, 0, sizeof( leds )); | 1098 | ::memset ( &leds, 0, sizeof( leds )); |
1099 | leds. TotalTime = 0; | 1099 | leds. TotalTime = 0; |
1100 | leds. OnTime = 0; | 1100 | leds. OnTime = 0; |
1101 | leds. OffTime = 1; | 1101 | leds. OffTime = 1; |
1102 | leds. OffOnBlink = 2; | 1102 | leds. OffOnBlink = 2; |
1103 | 1103 | ||
1104 | switch ( st ) { | 1104 | switch ( st ) { |
1105 | case Led_Off : leds. OffOnBlink = 0; break; | 1105 | case Led_Off : leds. OffOnBlink = 0; break; |
1106 | case Led_On : leds. OffOnBlink = 1; break; | 1106 | case Led_On : leds. OffOnBlink = 1; break; |
1107 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1107 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1108 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1108 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1111 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1112 | m_leds [0] = st; | 1112 | m_leds [0] = st; |
1113 | return true; | 1113 | return true; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | return false; | 1117 | return false; |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | 1120 | ||
1121 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1121 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1122 | { | 1122 | { |
1123 | int newkeycode = keycode; | 1123 | int newkeycode = keycode; |
1124 | 1124 | ||
1125 | switch ( keycode ) { | 1125 | switch ( keycode ) { |
1126 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1126 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1127 | case HardKey_Menu: { | 1127 | case HardKey_Menu: { |
1128 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1128 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1129 | ( d-> m_model == Model_iPAQ_H39xx )) { | 1129 | ( d-> m_model == Model_iPAQ_H39xx )) { |
1130 | newkeycode = HardKey_Mail; | 1130 | newkeycode = HardKey_Mail; |
1131 | } | 1131 | } |
1132 | break; | 1132 | break; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | // Rotate cursor keys 180° | 1135 | // Rotate cursor keys 180° |
1136 | case Key_Left : | 1136 | case Key_Left : |
1137 | case Key_Right: | 1137 | case Key_Right: |
1138 | case Key_Up : | 1138 | case Key_Up : |
1139 | case Key_Down : { | 1139 | case Key_Down : { |
1140 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1140 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1141 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1141 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1142 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1142 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1143 | } | 1143 | } |
1144 | break; | 1144 | break; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | // map Power Button short/long press to F34/F35 | 1147 | // map Power Button short/long press to F34/F35 |
1148 | case Key_SysReq: { | 1148 | case Key_SysReq: { |
1149 | if ( isPress ) { | 1149 | if ( isPress ) { |
1150 | if ( m_power_timer ) | 1150 | if ( m_power_timer ) |
1151 | killTimer ( m_power_timer ); | 1151 | killTimer ( m_power_timer ); |
1152 | m_power_timer = startTimer ( 500 ); | 1152 | m_power_timer = startTimer ( 500 ); |
1153 | } | 1153 | } |
1154 | else if ( m_power_timer ) { | 1154 | else if ( m_power_timer ) { |
1155 | killTimer ( m_power_timer ); | 1155 | killTimer ( m_power_timer ); |
1156 | m_power_timer = 0; | 1156 | m_power_timer = 0; |
1157 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1157 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1158 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1158 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1159 | } | 1159 | } |
1160 | newkeycode = Key_unknown; | 1160 | newkeycode = Key_unknown; |
1161 | break; | 1161 | break; |
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | if ( newkeycode != keycode ) { | 1165 | if ( newkeycode != keycode ) { |
1166 | if ( newkeycode != Key_unknown ) | 1166 | if ( newkeycode != Key_unknown ) |
1167 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1167 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1168 | return true; | 1168 | return true; |
1169 | } | 1169 | } |
1170 | else | 1170 | else |
1171 | return false; | 1171 | return false; |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | void iPAQ::timerEvent ( QTimerEvent * ) | 1174 | void iPAQ::timerEvent ( QTimerEvent * ) |
1175 | { | 1175 | { |
1176 | killTimer ( m_power_timer ); | 1176 | killTimer ( m_power_timer ); |
1177 | m_power_timer = 0; | 1177 | m_power_timer = 0; |
1178 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1178 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1179 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1179 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | 1182 | ||
1183 | void iPAQ::alarmSound ( ) | 1183 | void iPAQ::alarmSound ( ) |
1184 | { | 1184 | { |
1185 | #ifndef QT_NO_SOUND | 1185 | #ifndef QT_NO_SOUND |
1186 | static Sound snd ( "alarm" ); | 1186 | static Sound snd ( "alarm" ); |
1187 | int fd; | 1187 | int fd; |
1188 | int vol; | 1188 | int vol; |
1189 | bool vol_reset = false; | 1189 | bool vol_reset = false; |
1190 | 1190 | ||
1191 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1191 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1192 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1192 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1193 | Config cfg ( "qpe" ); | 1193 | Config cfg ( "qpe" ); |
1194 | cfg. setGroup ( "Volume" ); | 1194 | cfg. setGroup ( "Volume" ); |
1195 | 1195 | ||
1196 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1196 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1197 | if ( volalarm < 0 ) | 1197 | if ( volalarm < 0 ) |
1198 | volalarm = 0; | 1198 | volalarm = 0; |
1199 | else if ( volalarm > 100 ) | 1199 | else if ( volalarm > 100 ) |
1200 | volalarm = 100; | 1200 | volalarm = 100; |
1201 | volalarm |= ( volalarm << 8 ); | 1201 | volalarm |= ( volalarm << 8 ); |
1202 | 1202 | ||
1203 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1203 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1204 | vol_reset = true; | 1204 | vol_reset = true; |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | snd. play ( ); | 1208 | snd. play ( ); |
1209 | while ( !snd. isFinished ( )) | 1209 | while ( !snd. isFinished ( )) |
1210 | qApp-> processEvents ( ); | 1210 | qApp-> processEvents ( ); |
1211 | 1211 | ||
1212 | if ( fd >= 0 ) { | 1212 | if ( fd >= 0 ) { |
1213 | if ( vol_reset ) | 1213 | if ( vol_reset ) |
1214 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1214 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1215 | ::close ( fd ); | 1215 | ::close ( fd ); |
1216 | } | 1216 | } |
1217 | #endif | 1217 | #endif |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | 1220 | ||
1221 | bool iPAQ::setSoftSuspend ( bool soft ) | 1221 | bool iPAQ::setSoftSuspend ( bool soft ) |
1222 | { | 1222 | { |
1223 | bool res = false; | 1223 | bool res = false; |
1224 | int fd; | 1224 | int fd; |
1225 | 1225 | ||
1226 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1226 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1227 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1227 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1228 | res = true; | 1228 | res = true; |
1229 | else | 1229 | else |
1230 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1230 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1231 | 1231 | ||
1232 | ::close ( fd ); | 1232 | ::close ( fd ); |
1233 | } | 1233 | } |
1234 | else | 1234 | else |
1235 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1235 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1236 | 1236 | ||
1237 | return res; | 1237 | return res; |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | 1240 | ||
1241 | bool iPAQ::setDisplayBrightness ( int bright ) | 1241 | bool iPAQ::setDisplayBrightness ( int bright ) |
1242 | { | 1242 | { |
1243 | bool res = false; | 1243 | bool res = false; |
1244 | int fd; | 1244 | int fd; |
1245 | 1245 | ||
1246 | if ( bright > 255 ) | 1246 | if ( bright > 255 ) |
1247 | bright = 255; | 1247 | bright = 255; |
1248 | if ( bright < 0 ) | 1248 | if ( bright < 0 ) |
1249 | bright = 0; | 1249 | bright = 0; |
1250 | 1250 | ||
1251 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1251 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1252 | FLITE_IN bl; | 1252 | FLITE_IN bl; |
1253 | bl. mode = 1; | 1253 | bl. mode = 1; |
1254 | bl. pwr = bright ? 1 : 0; | 1254 | bl. pwr = bright ? 1 : 0; |
1255 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1255 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1256 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1256 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1257 | ::close ( fd ); | 1257 | ::close ( fd ); |
1258 | } | 1258 | } |
1259 | return res; | 1259 | return res; |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | int iPAQ::displayBrightnessResolution ( ) const | 1262 | int iPAQ::displayBrightnessResolution ( ) const |
1263 | { | 1263 | { |
1264 | switch ( model ( )) { | 1264 | switch ( model ( )) { |
1265 | case Model_iPAQ_H31xx: | 1265 | case Model_iPAQ_H31xx: |
1266 | case Model_iPAQ_H36xx: | 1266 | case Model_iPAQ_H36xx: |
1267 | case Model_iPAQ_H37xx: | 1267 | case Model_iPAQ_H37xx: |
1268 | return 128; // really 256, but >128 could damage the LCD | 1268 | return 128; // really 256, but >128 could damage the LCD |
1269 | 1269 | ||
1270 | case Model_iPAQ_H38xx: | 1270 | case Model_iPAQ_H38xx: |
1271 | case Model_iPAQ_H39xx: | 1271 | case Model_iPAQ_H39xx: |
1272 | return 64; | 1272 | return 64; |
1273 | 1273 | ||
1274 | default: | 1274 | default: |
1275 | return 2; | 1275 | return 2; |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | 1279 | ||
1280 | bool iPAQ::hasLightSensor ( ) const | 1280 | bool iPAQ::hasLightSensor ( ) const |
1281 | { | 1281 | { |
1282 | return true; | 1282 | return true; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | int iPAQ::readLightSensor ( ) | 1285 | int iPAQ::readLightSensor ( ) |
1286 | { | 1286 | { |
1287 | int fd; | 1287 | int fd; |
1288 | int val = -1; | 1288 | int val = -1; |
1289 | 1289 | ||
1290 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1290 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1291 | char buffer [8]; | 1291 | char buffer [8]; |
1292 | 1292 | ||
1293 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1293 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1294 | char *endptr; | 1294 | char *endptr; |
1295 | 1295 | ||
1296 | buffer [4] = 0; | 1296 | buffer [4] = 0; |
1297 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1297 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1298 | 1298 | ||
1299 | if ( *endptr != 0 ) | 1299 | if ( *endptr != 0 ) |
1300 | val = -1; | 1300 | val = -1; |
1301 | } | 1301 | } |
1302 | ::close ( fd ); | 1302 | ::close ( fd ); |
1303 | } | 1303 | } |