author | groucho <groucho> | 2003-03-19 11:36:34 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-03-19 11:36:34 (UTC) |
commit | 28be0fcc9bda71175c3ee17e79fce2ac24340ff2 (patch) (unidiff) | |
tree | f09c80460e4f0219eb308d612a2e67df57f2c254 /libopie/odevice.cpp | |
parent | 18c6c51705de3b1897f671e54b25929e74d11f23 (diff) | |
download | opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.zip opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.gz opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.bz2 |
Fixed bug #744 where non mapped buttons in buttonsettings were not saved by introducing the "
ignore" statement.
Also removed unsed debug code
-rw-r--r-- | libopie/odevice.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9e97c56..d5e3c5c 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -235,97 +235,96 @@ ODevice *ODevice::inst ( ) | |||
235 | * | 235 | * |
236 | * common | 236 | * common |
237 | * | 237 | * |
238 | **************************************************/ | 238 | **************************************************/ |
239 | 239 | ||
240 | 240 | ||
241 | ODevice::ODevice ( ) | 241 | ODevice::ODevice ( ) |
242 | { | 242 | { |
243 | d = new ODeviceData; | 243 | d = new ODeviceData; |
244 | 244 | ||
245 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 245 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
246 | 246 | ||
247 | d-> m_modelstr = "Unknown"; | 247 | d-> m_modelstr = "Unknown"; |
248 | d-> m_model = Model_Unknown; | 248 | d-> m_model = Model_Unknown; |
249 | d-> m_vendorstr = "Unknown"; | 249 | d-> m_vendorstr = "Unknown"; |
250 | d-> m_vendor = Vendor_Unknown; | 250 | d-> m_vendor = Vendor_Unknown; |
251 | d-> m_systemstr = "Unknown"; | 251 | d-> m_systemstr = "Unknown"; |
252 | d-> m_system = System_Unknown; | 252 | d-> m_system = System_Unknown; |
253 | d-> m_sysverstr = "0.0"; | 253 | d-> m_sysverstr = "0.0"; |
254 | d-> m_rotation = Rot0; | 254 | d-> m_rotation = Rot0; |
255 | 255 | ||
256 | d-> m_holdtime = 1000; // 1000ms | 256 | d-> m_holdtime = 1000; // 1000ms |
257 | 257 | ||
258 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 258 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
259 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 259 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
260 | } | 260 | } |
261 | 261 | ||
262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
263 | { | 263 | { |
264 | if ( msg == "deviceButtonMappingChanged()" ) { | 264 | if ( msg == "deviceButtonMappingChanged()" ) { |
265 | reloadButtonMapping ( ); | 265 | reloadButtonMapping ( ); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | void ODevice::init ( ) | 269 | void ODevice::init ( ) |
270 | { | 270 | { |
271 | // Simulation uses iPAQ 3660 device buttons | 271 | // Simulation uses iPAQ 3660 device buttons |
272 | 272 | ||
273 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 273 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
274 | i_button *ib = ipaq_buttons + i; | 274 | i_button *ib = ipaq_buttons + i; |
275 | ODeviceButton b; | 275 | ODeviceButton b; |
276 | 276 | ||
277 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 277 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
278 | b. setKeycode ( ib-> code ); | 278 | b. setKeycode ( ib-> code ); |
279 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); | 279 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); |
280 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 280 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
281 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 281 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
282 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 282 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
283 | |||
284 | d-> m_buttons. append ( b ); | 283 | d-> m_buttons. append ( b ); |
285 | } | 284 | } |
286 | } | 285 | } |
287 | reloadButtonMapping ( ); | 286 | reloadButtonMapping ( ); |
288 | } | 287 | } |
289 | 288 | ||
290 | ODevice::~ODevice ( ) | 289 | ODevice::~ODevice ( ) |
291 | { | 290 | { |
292 | delete d; | 291 | delete d; |
293 | } | 292 | } |
294 | 293 | ||
295 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 294 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
296 | { | 295 | { |
297 | return false; | 296 | return false; |
298 | } | 297 | } |
299 | 298 | ||
300 | //#include <linux/apm_bios.h> | 299 | //#include <linux/apm_bios.h> |
301 | 300 | ||
302 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 301 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
303 | 302 | ||
304 | 303 | ||
305 | bool ODevice::suspend ( ) | 304 | bool ODevice::suspend ( ) |
306 | { | 305 | { |
307 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 306 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
308 | return false; | 307 | return false; |
309 | 308 | ||
310 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 309 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
311 | return false; | 310 | return false; |
312 | 311 | ||
313 | bool res = false; | 312 | bool res = false; |
314 | 313 | ||
315 | struct timeval tvs, tvn; | 314 | struct timeval tvs, tvn; |
316 | ::gettimeofday ( &tvs, 0 ); | 315 | ::gettimeofday ( &tvs, 0 ); |
317 | 316 | ||
318 | ::sync ( ); // flush fs caches | 317 | ::sync ( ); // flush fs caches |
319 | res = ( ::system ( "apm --suspend" ) == 0 ); | 318 | res = ( ::system ( "apm --suspend" ) == 0 ); |
320 | 319 | ||
321 | // This is needed because the iPAQ apm implementation is asynchronous and we | 320 | // This is needed because the iPAQ apm implementation is asynchronous and we |
322 | // can not be sure when exactly the device is really suspended | 321 | // can not be sure when exactly the device is really suspended |
323 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 322 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
324 | 323 | ||
325 | if ( res ) { | 324 | if ( res ) { |
326 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 325 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
327 | ::usleep ( 200 * 1000 ); | 326 | ::usleep ( 200 * 1000 ); |
328 | ::gettimeofday ( &tvn, 0 ); | 327 | ::gettimeofday ( &tvn, 0 ); |
329 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 328 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
330 | } | 329 | } |
331 | 330 | ||
@@ -471,127 +470,133 @@ int ODevice::readLightSensor ( ) | |||
471 | } | 470 | } |
472 | 471 | ||
473 | int ODevice::lightSensorResolution ( ) const | 472 | int ODevice::lightSensorResolution ( ) const |
474 | { | 473 | { |
475 | return 0; | 474 | return 0; |
476 | } | 475 | } |
477 | 476 | ||
478 | const QValueList <ODeviceButton> &ODevice::buttons ( ) const | 477 | const QValueList <ODeviceButton> &ODevice::buttons ( ) const |
479 | { | 478 | { |
480 | return d-> m_buttons; | 479 | return d-> m_buttons; |
481 | } | 480 | } |
482 | 481 | ||
483 | uint ODevice::buttonHoldTime ( ) const | 482 | uint ODevice::buttonHoldTime ( ) const |
484 | { | 483 | { |
485 | return d-> m_holdtime; | 484 | return d-> m_holdtime; |
486 | } | 485 | } |
487 | 486 | ||
488 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 487 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
489 | { | 488 | { |
490 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { | 489 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { |
491 | if ( (*it). keycode ( ) == code ) | 490 | if ( (*it). keycode ( ) == code ) |
492 | return &(*it); | 491 | return &(*it); |
493 | } | 492 | } |
494 | return 0; | 493 | return 0; |
495 | } | 494 | } |
496 | 495 | ||
497 | void ODevice::reloadButtonMapping ( ) | 496 | void ODevice::reloadButtonMapping ( ) |
498 | { | 497 | { |
499 | Config cfg ( "ButtonSettings" ); | 498 | Config cfg ( "ButtonSettings" ); |
500 | 499 | ||
501 | for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { | 500 | for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { |
502 | ODeviceButton &b = d-> m_buttons [i]; | 501 | ODeviceButton &b = d-> m_buttons [i]; |
503 | QString group = "Button" + QString::number ( i ); | 502 | QString group = "Button" + QString::number ( i ); |
504 | 503 | ||
505 | QCString pch, hch; | 504 | QCString pch, hch; |
506 | QCString pm, hm; | 505 | QCString pm, hm; |
507 | QByteArray pdata, hdata; | 506 | QByteArray pdata, hdata; |
508 | 507 | ||
509 | if ( cfg. hasGroup ( group )) { | 508 | if ( cfg. hasGroup ( group )) { |
510 | cfg. setGroup ( group ); | 509 | cfg. setGroup ( group ); |
511 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 510 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
512 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 511 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
513 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 512 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
514 | 513 | ||
515 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 514 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
516 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 515 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
517 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 516 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
518 | } | 517 | } |
519 | 518 | ||
520 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 519 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
520 | |||
521 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 521 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 525 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
526 | { | 526 | { |
527 | QString mb_chan; | ||
528 | |||
527 | if ( button >= (int) d-> m_buttons. count ( )) | 529 | if ( button >= (int) d-> m_buttons. count ( )) |
528 | return; | 530 | return; |
531 | |||
529 | 532 | ||
530 | ODeviceButton &b = d-> m_buttons [button]; | 533 | ODeviceButton &b = d-> m_buttons [button]; |
531 | b. setPressedAction ( action ); | 534 | b. setPressedAction ( action ); |
535 | |||
536 | mb_chan=b. pressedAction ( ). channel ( ); | ||
532 | 537 | ||
533 | Config buttonFile ( "ButtonSettings" ); | 538 | Config buttonFile ( "ButtonSettings" ); |
534 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 539 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
535 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); | 540 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
536 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 541 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
537 | 542 | ||
538 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 543 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
539 | 544 | ||
540 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 545 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
541 | } | 546 | } |
542 | 547 | ||
543 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 548 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
544 | { | 549 | { |
545 | if ( button >= (int) d-> m_buttons. count ( )) | 550 | if ( button >= (int) d-> m_buttons. count ( )) |
546 | return; | 551 | return; |
547 | 552 | ||
548 | ODeviceButton &b = d-> m_buttons [button]; | 553 | ODeviceButton &b = d-> m_buttons [button]; |
549 | b. setHeldAction ( action ); | 554 | b. setHeldAction ( action ); |
550 | 555 | ||
551 | Config buttonFile ( "ButtonSettings" ); | 556 | Config buttonFile ( "ButtonSettings" ); |
552 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 557 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
553 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 558 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
554 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 559 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
555 | 560 | ||
556 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 561 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
557 | 562 | ||
558 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 563 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
559 | } | 564 | } |
560 | 565 | ||
561 | 566 | ||
562 | 567 | ||
563 | 568 | ||
564 | /************************************************** | 569 | /************************************************** |
565 | * | 570 | * |
566 | * iPAQ | 571 | * iPAQ |
567 | * | 572 | * |
568 | **************************************************/ | 573 | **************************************************/ |
569 | 574 | ||
570 | void iPAQ::init ( ) | 575 | void iPAQ::init ( ) |
571 | { | 576 | { |
572 | d-> m_vendorstr = "HP"; | 577 | d-> m_vendorstr = "HP"; |
573 | d-> m_vendor = Vendor_HP; | 578 | d-> m_vendor = Vendor_HP; |
574 | 579 | ||
575 | QFile f ( "/proc/hal/model" ); | 580 | QFile f ( "/proc/hal/model" ); |
576 | 581 | ||
577 | if ( f. open ( IO_ReadOnly )) { | 582 | if ( f. open ( IO_ReadOnly )) { |
578 | QTextStream ts ( &f ); | 583 | QTextStream ts ( &f ); |
579 | 584 | ||
580 | d-> m_modelstr = "H" + ts. readLine ( ); | 585 | d-> m_modelstr = "H" + ts. readLine ( ); |
581 | 586 | ||
582 | if ( d-> m_modelstr == "H3100" ) | 587 | if ( d-> m_modelstr == "H3100" ) |
583 | d-> m_model = Model_iPAQ_H31xx; | 588 | d-> m_model = Model_iPAQ_H31xx; |
584 | else if ( d-> m_modelstr == "H3600" ) | 589 | else if ( d-> m_modelstr == "H3600" ) |
585 | d-> m_model = Model_iPAQ_H36xx; | 590 | d-> m_model = Model_iPAQ_H36xx; |
586 | else if ( d-> m_modelstr == "H3700" ) | 591 | else if ( d-> m_modelstr == "H3700" ) |
587 | d-> m_model = Model_iPAQ_H37xx; | 592 | d-> m_model = Model_iPAQ_H37xx; |
588 | else if ( d-> m_modelstr == "H3800" ) | 593 | else if ( d-> m_modelstr == "H3800" ) |
589 | d-> m_model = Model_iPAQ_H38xx; | 594 | d-> m_model = Model_iPAQ_H38xx; |
590 | else if ( d-> m_modelstr == "H3900" ) | 595 | else if ( d-> m_modelstr == "H3900" ) |
591 | d-> m_model = Model_iPAQ_H39xx; | 596 | d-> m_model = Model_iPAQ_H39xx; |
592 | else | 597 | else |
593 | d-> m_model = Model_Unknown; | 598 | d-> m_model = Model_Unknown; |
594 | 599 | ||
595 | f. close ( ); | 600 | f. close ( ); |
596 | } | 601 | } |
597 | 602 | ||