author | mickeyl <mickeyl> | 2005-02-06 22:53:53 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-06 22:53:53 (UTC) |
commit | ab32151cd8e85deb354bab04e25efb1f3f399dee (patch) (unidiff) | |
tree | 66ab72d210bbc50c0e535986c61ca23f68efbfd1 /libopie2 | |
parent | ec33239c6edd9927fe2f82953fa48dec47d19567 (diff) | |
download | opie-ab32151cd8e85deb354bab04e25efb1f3f399dee.zip opie-ab32151cd8e85deb354bab04e25efb1f3f399dee.tar.gz opie-ab32151cd8e85deb354bab04e25efb1f3f399dee.tar.bz2 |
make autorotate also work on kernel 2.6
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 88 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 22 |
2 files changed, 35 insertions, 75 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 3d69614..2c5190c 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -185,7 +185,7 @@ ODevice::ODevice() | |||
185 | 185 | ||
186 | /* mixer */ | 186 | /* mixer */ |
187 | d->m_sound = d->m_vol = d->m_mixer = -1; | 187 | d->m_sound = d->m_vol = d->m_mixer = -1; |
188 | 188 | ||
189 | /* System QCopChannel created */ | 189 | /* System QCopChannel created */ |
190 | d->m_initializedButtonQcop = false; | 190 | d->m_initializedButtonQcop = false; |
191 | 191 | ||
@@ -271,33 +271,7 @@ ODevice::~ODevice() | |||
271 | */ | 271 | */ |
272 | bool ODevice::suspend() | 272 | bool ODevice::suspend() |
273 | { | 273 | { |
274 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 274 | return false; // default implementation == unknown device or qvfb |
275 | return false; | ||
276 | |||
277 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | ||
278 | return false; | ||
279 | |||
280 | bool res = false; | ||
281 | ODevice::sendSuspendmsg(); | ||
282 | |||
283 | struct timeval tvs, tvn; | ||
284 | ::gettimeofday ( &tvs, 0 ); | ||
285 | |||
286 | ::sync(); // flush fs caches | ||
287 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
288 | |||
289 | // This is needed because the iPAQ apm implementation is asynchronous and we | ||
290 | // can not be sure when exactly the device is really suspended | ||
291 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | ||
292 | |||
293 | if ( res ) { | ||
294 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | ||
295 | ::usleep ( 200 * 1000 ); | ||
296 | ::gettimeofday ( &tvn, 0 ); | ||
297 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | ||
298 | } | ||
299 | |||
300 | return res; | ||
301 | } | 275 | } |
302 | 276 | ||
303 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 277 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
@@ -313,25 +287,10 @@ bool ODevice::suspend() | |||
313 | /** | 287 | /** |
314 | * This sets the display on or off | 288 | * This sets the display on or off |
315 | */ | 289 | */ |
316 | bool ODevice::setDisplayStatus ( bool on ) | 290 | bool ODevice::setDisplayStatus( bool on ) |
317 | { | 291 | { |
318 | qDebug("ODevice::setDisplayStatus(%d)", on); | 292 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); |
319 | 293 | return false; // don't do anything for unknown models | |
320 | if ( d->m_model == Model_Unknown ) | ||
321 | return false; | ||
322 | |||
323 | bool res = false; | ||
324 | int fd; | ||
325 | |||
326 | #ifdef QT_QWS_DEVFS | ||
327 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
328 | #else | ||
329 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | ||
330 | #endif | ||
331 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | ||
332 | ::close ( fd ); | ||
333 | } | ||
334 | return res; | ||
335 | } | 294 | } |
336 | 295 | ||
337 | /** | 296 | /** |
@@ -340,16 +299,16 @@ bool ODevice::setDisplayStatus ( bool on ) | |||
340 | * @param b The brightness to be set on a scale from 0 to 255 | 299 | * @param b The brightness to be set on a scale from 0 to 255 |
341 | * @return success or failure | 300 | * @return success or failure |
342 | */ | 301 | */ |
343 | bool ODevice::setDisplayBrightness ( int b) | 302 | bool ODevice::setDisplayBrightness( int b ) |
344 | { | 303 | { |
345 | Q_UNUSED( b ) | 304 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); |
346 | return false; | 305 | return false; |
347 | } | 306 | } |
348 | 307 | ||
349 | /** | 308 | /** |
350 | * | 309 | * |
351 | * @return Returns the number of steppings on the brightness slider | 310 | * @returns the number of steppings on the brightness slider |
352 | * in the Light-'n-Power settings. Values smaller zero and bigger | 311 | * in the Light-'n-Power settings. Values smaller than zero and bigger |
353 | * than 255 do not make sense. | 312 | * than 255 do not make sense. |
354 | * | 313 | * |
355 | * \sa QSlider::setLineStep | 314 | * \sa QSlider::setLineStep |
@@ -357,26 +316,28 @@ bool ODevice::setDisplayBrightness ( int b) | |||
357 | */ | 316 | */ |
358 | int ODevice::displayBrightnessResolution() const | 317 | int ODevice::displayBrightnessResolution() const |
359 | { | 318 | { |
319 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | ||
360 | return 16; | 320 | return 16; |
361 | } | 321 | } |
362 | 322 | ||
363 | /** | 323 | /** |
364 | * This sets the display contrast | 324 | * This sets the display contrast |
365 | * @param p The contrast to be set on a scale from 0 to 255 | 325 | * @param p The contrast to be set on a scale from 0 to 255 |
366 | * @return success or failure | 326 | * @returns success or failure |
367 | */ | 327 | */ |
368 | bool ODevice::setDisplayContrast ( int p) | 328 | bool ODevice::setDisplayContrast( int p ) |
369 | { | 329 | { |
370 | Q_UNUSED( p ) | 330 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); |
371 | return false; | 331 | return false; |
372 | } | 332 | } |
373 | 333 | ||
374 | /** | 334 | /** |
375 | * @return return the max value for the brightness settings slider | 335 | * @returns the maximum value for the contrast settings slider |
376 | * or 0 if the device doesn't support setting of a contrast | 336 | * or 0 if the device doesn't support setting of a contrast |
377 | */ | 337 | */ |
378 | int ODevice::displayContrastResolution() const | 338 | int ODevice::displayContrastResolution() const |
379 | { | 339 | { |
340 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | ||
380 | return 0; | 341 | return 0; |
381 | } | 342 | } |
382 | 343 | ||
@@ -639,7 +600,7 @@ const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | |||
639 | initButtons(); | 600 | initButtons(); |
640 | 601 | ||
641 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 602 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
642 | if ( (*it). keycode() == code ) | 603 | if ( (*it).keycode() == code ) |
643 | return &(*it); | 604 | return &(*it); |
644 | } | 605 | } |
645 | return 0; | 606 | return 0; |
@@ -649,7 +610,7 @@ void ODevice::reloadButtonMapping() | |||
649 | { | 610 | { |
650 | if(!d->m_buttons) | 611 | if(!d->m_buttons) |
651 | initButtons(); | 612 | initButtons(); |
652 | 613 | ||
653 | if(!d->m_initializedButtonQcop) { | 614 | if(!d->m_initializedButtonQcop) { |
654 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); | 615 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); |
655 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), | 616 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), |
@@ -679,7 +640,6 @@ void ODevice::reloadButtonMapping() | |||
679 | } | 640 | } |
680 | 641 | ||
681 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 642 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
682 | |||
683 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 643 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
684 | } | 644 | } |
685 | } | 645 | } |
@@ -741,10 +701,10 @@ void ODevice::virtual_hook(int, void* ){ | |||
741 | * Sends a QCOP message to channel QPE/System | 701 | * Sends a QCOP message to channel QPE/System |
742 | * with the message "aboutToSuspend()" if this | 702 | * with the message "aboutToSuspend()" if this |
743 | * is the windowing server. | 703 | * is the windowing server. |
744 | * | 704 | * |
745 | * Call this in your custom \sa suspend() Method | 705 | * Call this in your custom \sa suspend() Method |
746 | * before going to suspend. | 706 | * before going to suspend. |
747 | * | 707 | * |
748 | */ | 708 | */ |
749 | void ODevice::sendSuspendmsg() | 709 | void ODevice::sendSuspendmsg() |
750 | { | 710 | { |
@@ -787,7 +747,7 @@ void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | |||
787 | 747 | ||
788 | /** | 748 | /** |
789 | * @internal | 749 | * @internal |
790 | * | 750 | * |
791 | * @see changeMixerForAlarm | 751 | * @see changeMixerForAlarm |
792 | */ | 752 | */ |
793 | void ODevice::playingStopped() { | 753 | void ODevice::playingStopped() { |
@@ -829,13 +789,13 @@ void ODevice::playingStopped() { | |||
829 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); | 789 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); |
830 | * snd.play() | 790 | * snd.play() |
831 | * \endcode | 791 | * \endcode |
832 | * | 792 | * |
833 | * | 793 | * |
834 | * | 794 | * |
835 | * @param mixer The mixer number/channel to use | 795 | * @param mixer The mixer number/channel to use |
836 | * @param file The file name. If you convert from QString use QFile::encodeName | 796 | * @param file The file name. If you convert from QString use QFile::encodeName |
837 | * @param snd The sound to wait for finishing | 797 | * @param snd The sound to wait for finishing |
838 | * | 798 | * |
839 | */ | 799 | */ |
840 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 800 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
841 | #ifndef QT_NO_SOUND | 801 | #ifndef QT_NO_SOUND |
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 7377965..82e127e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -102,18 +102,18 @@ struct z_button z_buttons_c700 [] = { | |||
102 | "opiemail", "raise()", | 102 | "opiemail", "raise()", |
103 | "opiemail", "newMail()" }, | 103 | "opiemail", "newMail()" }, |
104 | 104 | ||
105 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 105 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), |
106 | "devicebuttons/z_hinge", | 106 | "devicebuttons/z_hinge1", |
107 | "QPE/Rotation", "rotateDefault()", | 107 | "QPE/Rotation", "rotateDefault()", |
108 | "QPE/Dummy", "doNothing()" }, | 108 | "QPE/Rotation", "rotateDefault()" }, |
109 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 109 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
110 | "devicebuttons/z_hinge", | 110 | "devicebuttons/z_hinge2", |
111 | "QPE/Rotation", "rotateDefault()", | 111 | "QPE/Rotation", "rotateDefault()", |
112 | "QPE/Dummy", "doNothing()" }, | 112 | "QPE/Rotation", "rotateDefault()" }, |
113 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 113 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
114 | "devicebuttons/z_hinge", | 114 | "devicebuttons/z_hinge3", |
115 | "QPE/Rotation", "rotateDefault()", | 115 | "QPE/Rotation", "rotateDefault()", |
116 | "QPE/Dummy", "doNothing()" }, | 116 | "QPE/Rotation", "rotateDefault()" }, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 119 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
@@ -488,7 +488,7 @@ bool Zaurus::suspend() | |||
488 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 488 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
489 | return false; | 489 | return false; |
490 | 490 | ||
491 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 491 | if ( d->m_model == Model_Unknown ) // better don't suspend on unknown devices |
492 | return false; | 492 | return false; |
493 | 493 | ||
494 | bool res = false; | 494 | bool res = false; |
@@ -534,7 +534,7 @@ Transformation Zaurus::rotation() const | |||
534 | } | 534 | } |
535 | else | 535 | else |
536 | { | 536 | { |
537 | if ( hs == CASE_PORTRAIT ) rot = Rot270; | 537 | if ( hs == CASE_PORTRAIT ) rot = Rot90; |
538 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 538 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
539 | else rot = Rot0; | 539 | else rot = Rot0; |
540 | } | 540 | } |