author | mickeyl <mickeyl> | 2003-05-23 13:28:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-23 13:28:27 (UTC) |
commit | f6d7ed30f034b318d77f36f81b0aa4588cea63fb (patch) (side-by-side diff) | |
tree | 8083be660da5876e555686475dd8f5f8a024d7bf /libopie/odevice.cpp | |
parent | cbacd38e4b8e0e706fa43cd3e88041217c6fdaf9 (diff) | |
download | opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.zip opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.tar.gz opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.tar.bz2 |
more handling of SIMpad specifica
-rw-r--r-- | libopie/odevice.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 103104f..02f13b5 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -118,49 +118,51 @@ public: virtual int displayBrightnessResolution ( ) const; virtual void alarmSound ( ); virtual void keySound ( ); virtual void touchSound ( ); virtual QValueList <OLed> ledList ( ) const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState ( OLed led ) const; virtual bool setLedState ( OLed led, OLedState st ); protected: virtual void buzzer ( int snd ); OLedState m_leds [1]; }; class SIMpad : public ODevice, public QWSServer::KeyboardFilter { protected: virtual void init ( ); virtual void initButtons ( ); public: virtual bool setSoftSuspend ( bool soft ); + virtual bool suspend(); + virtual bool setDisplayStatus( bool on ); virtual bool setDisplayBrightness ( int b ); virtual int displayBrightnessResolution ( ) const; virtual void alarmSound ( ); virtual QValueList <OLed> ledList ( ) const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState ( OLed led ) const; virtual bool setLedState ( OLed led, OLedState st ); protected: virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); virtual void timerEvent ( QTimerEvent *te ); int m_power_timer; OLedState m_leds [1]; //FIXME check if really only one }; struct i_button { uint model; Qt::Key code; char *utext; char *pix; @@ -1694,57 +1696,93 @@ void SIMpad::alarmSound ( ) if ( volalarm < 0 ) volalarm = 0; else if ( volalarm > 100 ) volalarm = 100; volalarm |= ( volalarm << 8 ); if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) vol_reset = true; } } snd. play ( ); while ( !snd. isFinished ( )) qApp-> processEvents ( ); if ( fd >= 0 ) { if ( vol_reset ) ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); ::close ( fd ); } #endif } +bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm +{ + qDebug( "ODevice for SIMpad: suspend()" ); + if ( !isQWS( ) ) // only qwsserver is allowed to suspend + return false; + + bool res = false; + + struct timeval tvs, tvn; + ::gettimeofday ( &tvs, 0 ); + + ::sync ( ); // flush fs caches + res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) + + return res; +} + + bool SIMpad::setSoftSuspend ( bool soft ) { - //TODO + qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); return false; } +bool SIMpad::setDisplayStatus ( bool on ) +{ + qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); + + bool res = false; + int fd; + + QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) + + if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { + res = ( ::system( (const char*) cmdline ) == 0 ); + ::close ( fd ); + } + return res; +} + + bool SIMpad::setDisplayBrightness ( int bright ) { + qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); bool res = false; int fd; if ( bright > 255 ) bright = 255; if ( bright < 0 ) bright = 0; if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { int value = 255 - bright; const int mask = SIMPAD_BACKLIGHT_MASK; value = value << 8; value += mask; char writeCommand[100]; const int count = sprintf( writeCommand, "0x%x\n", value ); res = ( ::write ( fd, writeCommand, count ) != -1 ); ::close ( fd ); } return res; } int SIMpad::displayBrightnessResolution ( ) const { |