-rw-r--r-- | libopie/odevice.cpp | 91 | ||||
-rw-r--r-- | libopie/odevice.h | 3 |
2 files changed, 70 insertions, 24 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 80975c9..377945d 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -47,86 +47,88 @@ | |||
47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
51 | 51 | ||
52 | using namespace Opie; | 52 | using namespace Opie; |
53 | 53 | ||
54 | class ODeviceData { | 54 | class ODeviceData { |
55 | public: | 55 | public: |
56 | bool m_qwsserver; | 56 | bool m_qwsserver; |
57 | 57 | ||
58 | QString m_vendorstr; | 58 | QString m_vendorstr; |
59 | OVendor m_vendor; | 59 | OVendor m_vendor; |
60 | 60 | ||
61 | QString m_modelstr; | 61 | QString m_modelstr; |
62 | OModel m_model; | 62 | OModel m_model; |
63 | 63 | ||
64 | QString m_systemstr; | 64 | QString m_systemstr; |
65 | OSystem m_system; | 65 | OSystem m_system; |
66 | 66 | ||
67 | QString m_sysverstr; | 67 | QString m_sysverstr; |
68 | 68 | ||
69 | Transformation m_rotation; | 69 | Transformation m_rotation; |
70 | 70 | ||
71 | QValueList <ODeviceButton> m_buttons; | 71 | QValueList <ODeviceButton> *m_buttons; |
72 | uint m_holdtime; | 72 | uint m_holdtime; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
77 | protected: | 77 | protected: |
78 | virtual void init ( ); | 78 | virtual void init ( ); |
79 | virtual void initButtons ( ); | ||
79 | 80 | ||
80 | public: | 81 | public: |
81 | virtual bool setSoftSuspend ( bool soft ); | 82 | virtual bool setSoftSuspend ( bool soft ); |
82 | 83 | ||
83 | virtual bool setDisplayBrightness ( int b ); | 84 | virtual bool setDisplayBrightness ( int b ); |
84 | virtual int displayBrightnessResolution ( ) const; | 85 | virtual int displayBrightnessResolution ( ) const; |
85 | 86 | ||
86 | virtual void alarmSound ( ); | 87 | virtual void alarmSound ( ); |
87 | 88 | ||
88 | virtual QValueList <OLed> ledList ( ) const; | 89 | virtual QValueList <OLed> ledList ( ) const; |
89 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 90 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
90 | virtual OLedState ledState ( OLed led ) const; | 91 | virtual OLedState ledState ( OLed led ) const; |
91 | virtual bool setLedState ( OLed led, OLedState st ); | 92 | virtual bool setLedState ( OLed led, OLedState st ); |
92 | 93 | ||
93 | virtual bool hasLightSensor ( ) const; | 94 | virtual bool hasLightSensor ( ) const; |
94 | virtual int readLightSensor ( ); | 95 | virtual int readLightSensor ( ); |
95 | virtual int lightSensorResolution ( ) const; | 96 | virtual int lightSensorResolution ( ) const; |
96 | 97 | ||
97 | protected: | 98 | protected: |
98 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 99 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
99 | virtual void timerEvent ( QTimerEvent *te ); | 100 | virtual void timerEvent ( QTimerEvent *te ); |
100 | 101 | ||
101 | int m_power_timer; | 102 | int m_power_timer; |
102 | 103 | ||
103 | OLedState m_leds [2]; | 104 | OLedState m_leds [2]; |
104 | }; | 105 | }; |
105 | 106 | ||
106 | class Zaurus : public ODevice { | 107 | class Zaurus : public ODevice { |
107 | protected: | 108 | protected: |
108 | virtual void init ( ); | 109 | virtual void init ( ); |
110 | virtual void initButtons ( ); | ||
109 | 111 | ||
110 | public: | 112 | public: |
111 | virtual bool setSoftSuspend ( bool soft ); | 113 | virtual bool setSoftSuspend ( bool soft ); |
112 | 114 | ||
113 | virtual bool setDisplayBrightness ( int b ); | 115 | virtual bool setDisplayBrightness ( int b ); |
114 | virtual int displayBrightnessResolution ( ) const; | 116 | virtual int displayBrightnessResolution ( ) const; |
115 | 117 | ||
116 | virtual void alarmSound ( ); | 118 | virtual void alarmSound ( ); |
117 | virtual void keySound ( ); | 119 | virtual void keySound ( ); |
118 | virtual void touchSound ( ); | 120 | virtual void touchSound ( ); |
119 | 121 | ||
120 | virtual QValueList <OLed> ledList ( ) const; | 122 | virtual QValueList <OLed> ledList ( ) const; |
121 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 123 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
122 | virtual OLedState ledState ( OLed led ) const; | 124 | virtual OLedState ledState ( OLed led ) const; |
123 | virtual bool setLedState ( OLed led, OLedState st ); | 125 | virtual bool setLedState ( OLed led, OLedState st ); |
124 | 126 | ||
125 | protected: | 127 | protected: |
126 | virtual void buzzer ( int snd ); | 128 | virtual void buzzer ( int snd ); |
127 | 129 | ||
128 | OLedState m_leds [1]; | 130 | OLedState m_leds [1]; |
129 | }; | 131 | }; |
130 | 132 | ||
131 | 133 | ||
132 | struct i_button { | 134 | struct i_button { |
@@ -233,78 +235,89 @@ ODevice *ODevice::inst ( ) | |||
233 | 235 | ||
234 | /************************************************** | 236 | /************************************************** |
235 | * | 237 | * |
236 | * common | 238 | * common |
237 | * | 239 | * |
238 | **************************************************/ | 240 | **************************************************/ |
239 | 241 | ||
240 | 242 | ||
241 | ODevice::ODevice ( ) | 243 | ODevice::ODevice ( ) |
242 | { | 244 | { |
243 | d = new ODeviceData; | 245 | d = new ODeviceData; |
244 | 246 | ||
245 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
246 | 248 | ||
247 | d-> m_modelstr = "Unknown"; | 249 | d-> m_modelstr = "Unknown"; |
248 | d-> m_model = Model_Unknown; | 250 | d-> m_model = Model_Unknown; |
249 | d-> m_vendorstr = "Unknown"; | 251 | d-> m_vendorstr = "Unknown"; |
250 | d-> m_vendor = Vendor_Unknown; | 252 | d-> m_vendor = Vendor_Unknown; |
251 | d-> m_systemstr = "Unknown"; | 253 | d-> m_systemstr = "Unknown"; |
252 | d-> m_system = System_Unknown; | 254 | d-> m_system = System_Unknown; |
253 | d-> m_sysverstr = "0.0"; | 255 | d-> m_sysverstr = "0.0"; |
254 | d-> m_rotation = Rot0; | 256 | d-> m_rotation = Rot0; |
255 | 257 | ||
256 | d-> m_holdtime = 1000; // 1000ms | 258 | d-> m_holdtime = 1000; // 1000ms |
257 | 259 | d-> m_buttons = 0; | |
258 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | ||
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 | } | ||
272 | |||
273 | void ODevice::initButtons ( ) | ||
274 | { | ||
275 | if ( d-> m_buttons ) | ||
276 | return; | ||
277 | |||
271 | // Simulation uses iPAQ 3660 device buttons | 278 | // Simulation uses iPAQ 3660 device buttons |
272 | 279 | ||
280 | qDebug ( "init Buttons" ); | ||
281 | d-> m_buttons = new QValueList <ODeviceButton>; | ||
282 | |||
273 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 283 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
274 | i_button *ib = ipaq_buttons + i; | 284 | i_button *ib = ipaq_buttons + i; |
275 | ODeviceButton b; | 285 | ODeviceButton b; |
276 | 286 | ||
277 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 287 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
278 | b. setKeycode ( ib-> code ); | 288 | b. setKeycode ( ib-> code ); |
279 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 289 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
280 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 290 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
281 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 291 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
282 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 292 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
283 | d-> m_buttons. append ( b ); | 293 | d-> m_buttons-> append ( b ); |
284 | } | 294 | } |
285 | } | 295 | } |
286 | reloadButtonMapping ( ); | 296 | reloadButtonMapping ( ); |
297 | |||
298 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | ||
299 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
287 | } | 300 | } |
288 | 301 | ||
289 | ODevice::~ODevice ( ) | 302 | ODevice::~ODevice ( ) |
290 | { | 303 | { |
291 | delete d; | 304 | delete d; |
292 | } | 305 | } |
293 | 306 | ||
294 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 307 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
295 | { | 308 | { |
296 | return false; | 309 | return false; |
297 | } | 310 | } |
298 | 311 | ||
299 | //#include <linux/apm_bios.h> | 312 | //#include <linux/apm_bios.h> |
300 | 313 | ||
301 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 314 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
302 | 315 | ||
303 | 316 | ||
304 | bool ODevice::suspend ( ) | 317 | bool ODevice::suspend ( ) |
305 | { | 318 | { |
306 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 319 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
307 | return false; | 320 | return false; |
308 | 321 | ||
309 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 322 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
310 | return false; | 323 | return false; |
@@ -453,125 +466,134 @@ OLedState ODevice::ledState ( OLed /*which*/ ) const | |||
453 | { | 466 | { |
454 | return Led_Off; | 467 | return Led_Off; |
455 | } | 468 | } |
456 | 469 | ||
457 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 470 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
458 | { | 471 | { |
459 | return false; | 472 | return false; |
460 | } | 473 | } |
461 | 474 | ||
462 | bool ODevice::hasLightSensor ( ) const | 475 | bool ODevice::hasLightSensor ( ) const |
463 | { | 476 | { |
464 | return false; | 477 | return false; |
465 | } | 478 | } |
466 | 479 | ||
467 | int ODevice::readLightSensor ( ) | 480 | int ODevice::readLightSensor ( ) |
468 | { | 481 | { |
469 | return -1; | 482 | return -1; |
470 | } | 483 | } |
471 | 484 | ||
472 | int ODevice::lightSensorResolution ( ) const | 485 | int ODevice::lightSensorResolution ( ) const |
473 | { | 486 | { |
474 | return 0; | 487 | return 0; |
475 | } | 488 | } |
476 | 489 | ||
477 | const QValueList <ODeviceButton> &ODevice::buttons ( ) const | 490 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
478 | { | 491 | { |
479 | return d-> m_buttons; | 492 | initButtons ( ); |
493 | |||
494 | return *d-> m_buttons; | ||
480 | } | 495 | } |
481 | 496 | ||
482 | uint ODevice::buttonHoldTime ( ) const | 497 | uint ODevice::buttonHoldTime ( ) const |
483 | { | 498 | { |
484 | return d-> m_holdtime; | 499 | return d-> m_holdtime; |
485 | } | 500 | } |
486 | 501 | ||
487 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 502 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
488 | { | 503 | { |
489 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { | 504 | initButtons ( ); |
505 | |||
506 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | ||
490 | if ( (*it). keycode ( ) == code ) | 507 | if ( (*it). keycode ( ) == code ) |
491 | return &(*it); | 508 | return &(*it); |
492 | } | 509 | } |
493 | return 0; | 510 | return 0; |
494 | } | 511 | } |
495 | 512 | ||
496 | void ODevice::reloadButtonMapping ( ) | 513 | void ODevice::reloadButtonMapping ( ) |
497 | { | 514 | { |
515 | initButtons ( ); | ||
516 | |||
498 | Config cfg ( "ButtonSettings" ); | 517 | Config cfg ( "ButtonSettings" ); |
499 | 518 | ||
500 | for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { | 519 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
501 | ODeviceButton &b = d-> m_buttons [i]; | 520 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
502 | QString group = "Button" + QString::number ( i ); | 521 | QString group = "Button" + QString::number ( i ); |
503 | 522 | ||
504 | QCString pch, hch; | 523 | QCString pch, hch; |
505 | QCString pm, hm; | 524 | QCString pm, hm; |
506 | QByteArray pdata, hdata; | 525 | QByteArray pdata, hdata; |
507 | 526 | ||
508 | if ( cfg. hasGroup ( group )) { | 527 | if ( cfg. hasGroup ( group )) { |
509 | cfg. setGroup ( group ); | 528 | cfg. setGroup ( group ); |
510 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 529 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
511 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 530 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
512 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 531 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
513 | 532 | ||
514 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 533 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
515 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 534 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
516 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 535 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
517 | } | 536 | } |
518 | 537 | ||
519 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 538 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
520 | 539 | ||
521 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 540 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
522 | } | 541 | } |
523 | } | 542 | } |
524 | 543 | ||
525 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 544 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
526 | { | 545 | { |
546 | initButtons ( ); | ||
547 | |||
527 | QString mb_chan; | 548 | QString mb_chan; |
528 | 549 | ||
529 | if ( button >= (int) d-> m_buttons. count ( )) | 550 | if ( button >= (int) d-> m_buttons-> count ( )) |
530 | return; | 551 | return; |
531 | |||
532 | 552 | ||
533 | ODeviceButton &b = d-> m_buttons [button]; | 553 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
534 | b. setPressedAction ( action ); | 554 | b. setPressedAction ( action ); |
535 | 555 | ||
536 | mb_chan=b. pressedAction ( ). channel ( ); | 556 | mb_chan=b. pressedAction ( ). channel ( ); |
537 | 557 | ||
538 | Config buttonFile ( "ButtonSettings" ); | 558 | Config buttonFile ( "ButtonSettings" ); |
539 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 559 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
540 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 560 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
541 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 561 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
542 | 562 | ||
543 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 563 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
544 | 564 | ||
545 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 565 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
546 | } | 566 | } |
547 | 567 | ||
548 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 568 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
549 | { | 569 | { |
550 | if ( button >= (int) d-> m_buttons. count ( )) | 570 | initButtons ( ); |
571 | |||
572 | if ( button >= (int) d-> m_buttons-> count ( )) | ||
551 | return; | 573 | return; |
552 | 574 | ||
553 | ODeviceButton &b = d-> m_buttons [button]; | 575 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
554 | b. setHeldAction ( action ); | 576 | b. setHeldAction ( action ); |
555 | 577 | ||
556 | Config buttonFile ( "ButtonSettings" ); | 578 | Config buttonFile ( "ButtonSettings" ); |
557 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 579 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
558 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 580 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
559 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 581 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
560 | 582 | ||
561 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 583 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
562 | 584 | ||
563 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 585 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
564 | } | 586 | } |
565 | 587 | ||
566 | 588 | ||
567 | 589 | ||
568 | 590 | ||
569 | /************************************************** | 591 | /************************************************** |
570 | * | 592 | * |
571 | * iPAQ | 593 | * iPAQ |
572 | * | 594 | * |
573 | **************************************************/ | 595 | **************************************************/ |
574 | 596 | ||
575 | void iPAQ::init ( ) | 597 | void iPAQ::init ( ) |
576 | { | 598 | { |
577 | d-> m_vendorstr = "HP"; | 599 | d-> m_vendorstr = "HP"; |
@@ -607,68 +629,80 @@ void iPAQ::init ( ) | |||
607 | break; | 629 | break; |
608 | case Model_iPAQ_H36xx: | 630 | case Model_iPAQ_H36xx: |
609 | case Model_iPAQ_H37xx: | 631 | case Model_iPAQ_H37xx: |
610 | case Model_iPAQ_H39xx: | 632 | case Model_iPAQ_H39xx: |
611 | default: | 633 | default: |
612 | d-> m_rotation = Rot270; | 634 | d-> m_rotation = Rot270; |
613 | break; | 635 | break; |
614 | } | 636 | } |
615 | 637 | ||
616 | f. setName ( "/etc/familiar-version" ); | 638 | f. setName ( "/etc/familiar-version" ); |
617 | if ( f. open ( IO_ReadOnly )) { | 639 | if ( f. open ( IO_ReadOnly )) { |
618 | d-> m_systemstr = "Familiar"; | 640 | d-> m_systemstr = "Familiar"; |
619 | d-> m_system = System_Familiar; | 641 | d-> m_system = System_Familiar; |
620 | 642 | ||
621 | QTextStream ts ( &f ); | 643 | QTextStream ts ( &f ); |
622 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 644 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
623 | 645 | ||
624 | f. close ( ); | 646 | f. close ( ); |
625 | } | 647 | } |
626 | 648 | ||
627 | m_leds [0] = m_leds [1] = Led_Off; | 649 | m_leds [0] = m_leds [1] = Led_Off; |
628 | 650 | ||
629 | m_power_timer = 0; | 651 | m_power_timer = 0; |
630 | 652 | ||
653 | if ( d-> m_qwsserver ) | ||
654 | QWSServer::setKeyboardFilter ( this ); | ||
655 | } | ||
656 | |||
657 | void iPAQ::initButtons ( ) | ||
658 | { | ||
659 | if ( d-> m_buttons ) | ||
660 | return; | ||
661 | |||
662 | d-> m_buttons = new QValueList <ODeviceButton>; | ||
663 | |||
631 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 664 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
632 | i_button *ib = ipaq_buttons + i; | 665 | i_button *ib = ipaq_buttons + i; |
633 | ODeviceButton b; | 666 | ODeviceButton b; |
634 | 667 | ||
635 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 668 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
636 | b. setKeycode ( ib-> code ); | 669 | b. setKeycode ( ib-> code ); |
637 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 670 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
638 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 671 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
639 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 672 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
640 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 673 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
641 | 674 | ||
642 | d-> m_buttons. append ( b ); | 675 | d-> m_buttons-> append ( b ); |
643 | } | 676 | } |
644 | } | 677 | } |
645 | reloadButtonMapping ( ); | 678 | reloadButtonMapping ( ); |
646 | 679 | ||
647 | if ( d-> m_qwsserver ) | 680 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
648 | QWSServer::setKeyboardFilter ( this ); | 681 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
649 | } | 682 | } |
650 | 683 | ||
684 | |||
651 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 685 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
652 | 686 | ||
653 | typedef struct { | 687 | typedef struct { |
654 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 688 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
655 | unsigned char TotalTime; /* Units of 5 seconds */ | 689 | unsigned char TotalTime; /* Units of 5 seconds */ |
656 | unsigned char OnTime; /* units of 100m/s */ | 690 | unsigned char OnTime; /* units of 100m/s */ |
657 | unsigned char OffTime; /* units of 100m/s */ | 691 | unsigned char OffTime; /* units of 100m/s */ |
658 | } LED_IN; | 692 | } LED_IN; |
659 | 693 | ||
660 | typedef struct { | 694 | typedef struct { |
661 | unsigned char mode; | 695 | unsigned char mode; |
662 | unsigned char pwr; | 696 | unsigned char pwr; |
663 | unsigned char brightness; | 697 | unsigned char brightness; |
664 | } FLITE_IN; | 698 | } FLITE_IN; |
665 | 699 | ||
666 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 700 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
667 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 701 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
668 | 702 | ||
669 | 703 | ||
670 | QValueList <OLed> iPAQ::ledList ( ) const | 704 | QValueList <OLed> iPAQ::ledList ( ) const |
671 | { | 705 | { |
672 | QValueList <OLed> vl; | 706 | QValueList <OLed> vl; |
673 | vl << Led_Power; | 707 | vl << Led_Power; |
674 | 708 | ||
@@ -972,64 +1006,75 @@ void Zaurus::init ( ) | |||
972 | d-> m_model = Model_Zaurus_SLA300; | 1006 | d-> m_model = Model_Zaurus_SLA300; |
973 | else if ( model == "SL-B600" || model == "SL-5600" ) | 1007 | else if ( model == "SL-B600" || model == "SL-5600" ) |
974 | d-> m_model = Model_Zaurus_SLB600; | 1008 | d-> m_model = Model_Zaurus_SLB600; |
975 | else | 1009 | else |
976 | d-> m_model = Model_Zaurus_SL5000; | 1010 | d-> m_model = Model_Zaurus_SL5000; |
977 | } | 1011 | } |
978 | else { | 1012 | else { |
979 | d-> m_model = Model_Zaurus_SL5000; | 1013 | d-> m_model = Model_Zaurus_SL5000; |
980 | d-> m_modelstr = "Zaurus (model unknown)"; | 1014 | d-> m_modelstr = "Zaurus (model unknown)"; |
981 | } | 1015 | } |
982 | 1016 | ||
983 | switch ( d-> m_model ) { | 1017 | switch ( d-> m_model ) { |
984 | case Model_Zaurus_SLC700: | 1018 | case Model_Zaurus_SLC700: |
985 | /* note for C700, we must check the display rotation | 1019 | /* note for C700, we must check the display rotation |
986 | * sensor to set an appropriate value | 1020 | * sensor to set an appropriate value |
987 | */ | 1021 | */ |
988 | case Model_Zaurus_SLA300: | 1022 | case Model_Zaurus_SLA300: |
989 | case Model_Zaurus_SLB600: | 1023 | case Model_Zaurus_SLB600: |
990 | case Model_Zaurus_SL5500: | 1024 | case Model_Zaurus_SL5500: |
991 | case Model_Zaurus_SL5000: | 1025 | case Model_Zaurus_SL5000: |
992 | default: | 1026 | default: |
993 | d-> m_rotation = Rot270; | 1027 | d-> m_rotation = Rot270; |
994 | break; | 1028 | break; |
995 | } | 1029 | } |
1030 | m_leds [0] = Led_Off; | ||
1031 | } | ||
1032 | |||
1033 | void Zaurus::initButtons ( ) | ||
1034 | { | ||
1035 | if ( d-> m_buttons ) | ||
1036 | return; | ||
1037 | |||
1038 | d-> m_buttons = new QValueList <ODeviceButton>; | ||
996 | 1039 | ||
997 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1040 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
998 | z_button *zb = z_buttons + i; | 1041 | z_button *zb = z_buttons + i; |
999 | ODeviceButton b; | 1042 | ODeviceButton b; |
1000 | 1043 | ||
1001 | b. setKeycode ( zb-> code ); | 1044 | b. setKeycode ( zb-> code ); |
1002 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1045 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1003 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1046 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1004 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1047 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1005 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1048 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1006 | 1049 | ||
1007 | d-> m_buttons. append ( b ); | 1050 | d-> m_buttons-> append ( b ); |
1008 | } | 1051 | } |
1052 | |||
1009 | reloadButtonMapping ( ); | 1053 | reloadButtonMapping ( ); |
1010 | 1054 | ||
1011 | m_leds [0] = Led_Off; | 1055 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1056 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
1012 | } | 1057 | } |
1013 | 1058 | ||
1014 | #include <unistd.h> | 1059 | #include <unistd.h> |
1015 | #include <fcntl.h> | 1060 | #include <fcntl.h> |
1016 | #include <sys/ioctl.h> | 1061 | #include <sys/ioctl.h> |
1017 | 1062 | ||
1018 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1063 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1019 | 1064 | ||
1020 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1065 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1021 | 1066 | ||
1022 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1067 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1023 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1068 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1024 | 1069 | ||
1025 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1070 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1026 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1071 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1027 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1072 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1028 | 1073 | ||
1029 | /* --- for SHARP_BUZZER device --- */ | 1074 | /* --- for SHARP_BUZZER device --- */ |
1030 | 1075 | ||
1031 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1076 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1032 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1077 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1033 | 1078 | ||
1034 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1079 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1035 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1080 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 575e1fe..ff578d8 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -82,48 +82,49 @@ enum OLed { | |||
82 | Led_Power, | 82 | Led_Power, |
83 | Led_BlueTooth | 83 | Led_BlueTooth |
84 | }; | 84 | }; |
85 | 85 | ||
86 | enum OHardKey { | 86 | enum OHardKey { |
87 | HardKey_Datebook = Qt::Key_F9, | 87 | HardKey_Datebook = Qt::Key_F9, |
88 | HardKey_Contacts = Qt::Key_F10, | 88 | HardKey_Contacts = Qt::Key_F10, |
89 | HardKey_Menu = Qt::Key_F11, | 89 | HardKey_Menu = Qt::Key_F11, |
90 | HardKey_Home = Qt::Key_F12, | 90 | HardKey_Home = Qt::Key_F12, |
91 | HardKey_Mail = Qt::Key_F13, | 91 | HardKey_Mail = Qt::Key_F13, |
92 | HardKey_Record = Qt::Key_F24, | 92 | HardKey_Record = Qt::Key_F24, |
93 | HardKey_Suspend = Qt::Key_F34, | 93 | HardKey_Suspend = Qt::Key_F34, |
94 | HardKey_Backlight = Qt::Key_F35, | 94 | HardKey_Backlight = Qt::Key_F35, |
95 | }; | 95 | }; |
96 | 96 | ||
97 | class ODevice : public QObject { | 97 | class ODevice : public QObject { |
98 | Q_OBJECT | 98 | Q_OBJECT |
99 | 99 | ||
100 | private: | 100 | private: |
101 | ODevice ( const ODevice & ); | 101 | ODevice ( const ODevice & ); |
102 | 102 | ||
103 | protected: | 103 | protected: |
104 | ODevice ( ); | 104 | ODevice ( ); |
105 | virtual void init ( ); | 105 | virtual void init ( ); |
106 | virtual void initButtons ( ); | ||
106 | 107 | ||
107 | ODeviceData *d; | 108 | ODeviceData *d; |
108 | 109 | ||
109 | public: | 110 | public: |
110 | virtual ~ODevice ( ); | 111 | virtual ~ODevice ( ); |
111 | 112 | ||
112 | static ODevice *inst ( ); | 113 | static ODevice *inst ( ); |
113 | 114 | ||
114 | // information | 115 | // information |
115 | 116 | ||
116 | QString modelString ( ) const; | 117 | QString modelString ( ) const; |
117 | OModel model ( ) const; | 118 | OModel model ( ) const; |
118 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 119 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
119 | 120 | ||
120 | QString vendorString ( ) const; | 121 | QString vendorString ( ) const; |
121 | OVendor vendor ( ) const; | 122 | OVendor vendor ( ) const; |
122 | 123 | ||
123 | QString systemString ( ) const; | 124 | QString systemString ( ) const; |
124 | OSystem system ( ) const; | 125 | OSystem system ( ) const; |
125 | 126 | ||
126 | QString systemVersionString ( ) const; | 127 | QString systemVersionString ( ) const; |
127 | 128 | ||
128 | Transformation rotation ( ) const; | 129 | Transformation rotation ( ) const; |
129 | 130 | ||
@@ -136,49 +137,49 @@ public: | |||
136 | virtual bool setDisplayBrightness ( int brightness ); | 137 | virtual bool setDisplayBrightness ( int brightness ); |
137 | virtual int displayBrightnessResolution ( ) const; | 138 | virtual int displayBrightnessResolution ( ) const; |
138 | 139 | ||
139 | // input / output | 140 | // input / output |
140 | 141 | ||
141 | virtual void alarmSound ( ); | 142 | virtual void alarmSound ( ); |
142 | virtual void keySound ( ); | 143 | virtual void keySound ( ); |
143 | virtual void touchSound ( ); | 144 | virtual void touchSound ( ); |
144 | 145 | ||
145 | virtual QValueList <OLed> ledList ( ) const; | 146 | virtual QValueList <OLed> ledList ( ) const; |
146 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 147 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
147 | virtual OLedState ledState ( OLed led ) const; | 148 | virtual OLedState ledState ( OLed led ) const; |
148 | virtual bool setLedState ( OLed led, OLedState st ); | 149 | virtual bool setLedState ( OLed led, OLedState st ); |
149 | 150 | ||
150 | virtual bool hasLightSensor ( ) const; | 151 | virtual bool hasLightSensor ( ) const; |
151 | virtual int readLightSensor ( ); | 152 | virtual int readLightSensor ( ); |
152 | virtual int lightSensorResolution ( ) const; | 153 | virtual int lightSensorResolution ( ) const; |
153 | 154 | ||
154 | /** | 155 | /** |
155 | * Returns the available buttons on this device. The number and location | 156 | * Returns the available buttons on this device. The number and location |
156 | * of buttons will vary depending on the device. Button numbers will be assigned | 157 | * of buttons will vary depending on the device. Button numbers will be assigned |
157 | * by the device manufacturer and will be from most preferred button to least preffered | 158 | * by the device manufacturer and will be from most preferred button to least preffered |
158 | * button. Note that this list only contains "user mappable" buttons. | 159 | * button. Note that this list only contains "user mappable" buttons. |
159 | */ | 160 | */ |
160 | const QValueList<ODeviceButton> &buttons ( ) const; | 161 | const QValueList<ODeviceButton> &buttons ( ); |
161 | 162 | ||
162 | /** | 163 | /** |
163 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 164 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
164 | * returns 0L | 165 | * returns 0L |
165 | */ | 166 | */ |
166 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 167 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
167 | 168 | ||
168 | /** | 169 | /** |
169 | * Reassigns the pressed action for \a button. To return to the factory | 170 | * Reassigns the pressed action for \a button. To return to the factory |
170 | * default pass an empty string as \a qcopMessage. | 171 | * default pass an empty string as \a qcopMessage. |
171 | */ | 172 | */ |
172 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 173 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
173 | 174 | ||
174 | /** | 175 | /** |
175 | * Reassigns the held action for \a button. To return to the factory | 176 | * Reassigns the held action for \a button. To return to the factory |
176 | * default pass an empty string as \a qcopMessage. | 177 | * default pass an empty string as \a qcopMessage. |
177 | */ | 178 | */ |
178 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 179 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
179 | 180 | ||
180 | /** | 181 | /** |
181 | * How long (in ms) you have to press a button for a "hold" action | 182 | * How long (in ms) you have to press a button for a "hold" action |
182 | */ | 183 | */ |
183 | uint buttonHoldTime ( ) const; | 184 | uint buttonHoldTime ( ) const; |
184 | 185 | ||