summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-23 13:28:27 (UTC)
committer mickeyl <mickeyl>2003-05-23 13:28:27 (UTC)
commitf6d7ed30f034b318d77f36f81b0aa4588cea63fb (patch) (unidiff)
tree8083be660da5876e555686475dd8f5f8a024d7bf
parentcbacd38e4b8e0e706fa43cd3e88041217c6fdaf9 (diff)
downloadopie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.zip
opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.tar.gz
opie-f6d7ed30f034b318d77f36f81b0aa4588cea63fb.tar.bz2
more handling of SIMpad specifica
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp40
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
@@ -94,97 +94,99 @@ public:
94 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
95 95
96 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
99 99
100protected: 100protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
103 103
104 int m_power_timer; 104 int m_power_timer;
105 105
106 OLedState m_leds [2]; 106 OLedState m_leds [2];
107}; 107};
108 108
109class Zaurus : public ODevice { 109class Zaurus : public ODevice {
110protected: 110protected:
111 virtual void init ( ); 111 virtual void init ( );
112 virtual void initButtons ( ); 112 virtual void initButtons ( );
113 113
114public: 114public:
115 virtual bool setSoftSuspend ( bool soft ); 115 virtual bool setSoftSuspend ( bool soft );
116 116
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 119
120 virtual void alarmSound ( ); 120 virtual void alarmSound ( );
121 virtual void keySound ( ); 121 virtual void keySound ( );
122 virtual void touchSound ( ); 122 virtual void touchSound ( );
123 123
124 virtual QValueList <OLed> ledList ( ) const; 124 virtual QValueList <OLed> ledList ( ) const;
125 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 125 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
126 virtual OLedState ledState ( OLed led ) const; 126 virtual OLedState ledState ( OLed led ) const;
127 virtual bool setLedState ( OLed led, OLedState st ); 127 virtual bool setLedState ( OLed led, OLedState st );
128 128
129protected: 129protected:
130 virtual void buzzer ( int snd ); 130 virtual void buzzer ( int snd );
131 131
132 OLedState m_leds [1]; 132 OLedState m_leds [1];
133}; 133};
134 134
135class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 135class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
136protected: 136protected:
137 virtual void init ( ); 137 virtual void init ( );
138 virtual void initButtons ( ); 138 virtual void initButtons ( );
139 139
140public: 140public:
141 virtual bool setSoftSuspend ( bool soft ); 141 virtual bool setSoftSuspend ( bool soft );
142 virtual bool suspend();
142 143
144 virtual bool setDisplayStatus( bool on );
143 virtual bool setDisplayBrightness ( int b ); 145 virtual bool setDisplayBrightness ( int b );
144 virtual int displayBrightnessResolution ( ) const; 146 virtual int displayBrightnessResolution ( ) const;
145 147
146 virtual void alarmSound ( ); 148 virtual void alarmSound ( );
147 149
148 virtual QValueList <OLed> ledList ( ) const; 150 virtual QValueList <OLed> ledList ( ) const;
149 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 151 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
150 virtual OLedState ledState ( OLed led ) const; 152 virtual OLedState ledState ( OLed led ) const;
151 virtual bool setLedState ( OLed led, OLedState st ); 153 virtual bool setLedState ( OLed led, OLedState st );
152 154
153protected: 155protected:
154 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 156 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
155 virtual void timerEvent ( QTimerEvent *te ); 157 virtual void timerEvent ( QTimerEvent *te );
156 158
157 int m_power_timer; 159 int m_power_timer;
158 160
159 OLedState m_leds [1]; //FIXME check if really only one 161 OLedState m_leds [1]; //FIXME check if really only one
160}; 162};
161 163
162struct i_button { 164struct i_button {
163 uint model; 165 uint model;
164 Qt::Key code; 166 Qt::Key code;
165 char *utext; 167 char *utext;
166 char *pix; 168 char *pix;
167 char *fpressedservice; 169 char *fpressedservice;
168 char *fpressedaction; 170 char *fpressedaction;
169 char *fheldservice; 171 char *fheldservice;
170 char *fheldaction; 172 char *fheldaction;
171} ipaq_buttons [] = { 173} ipaq_buttons [] = {
172 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 174 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
173 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 175 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
174 "devicebuttons/ipaq_calendar", 176 "devicebuttons/ipaq_calendar",
175 "datebook", "nextView()", 177 "datebook", "nextView()",
176 "today", "raise()" }, 178 "today", "raise()" },
177 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 179 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
178 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 180 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
179 "devicebuttons/ipaq_contact", 181 "devicebuttons/ipaq_contact",
180 "addressbook", "raise()", 182 "addressbook", "raise()",
181 "addressbook", "beamBusinessCard()" }, 183 "addressbook", "beamBusinessCard()" },
182 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 184 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
183 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 185 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
184 "devicebuttons/ipaq_menu", 186 "devicebuttons/ipaq_menu",
185 "QPE/TaskBar", "toggleMenu()", 187 "QPE/TaskBar", "toggleMenu()",
186 "QPE/TaskBar", "toggleStartMenu()" }, 188 "QPE/TaskBar", "toggleStartMenu()" },
187 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 189 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
188 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 190 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
189 "devicebuttons/ipaq_mail", 191 "devicebuttons/ipaq_mail",
190 "mail", "raise()", 192 "mail", "raise()",
@@ -1670,93 +1672,129 @@ bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress,
1670 1672
1671void SIMpad::timerEvent ( QTimerEvent * ) 1673void SIMpad::timerEvent ( QTimerEvent * )
1672{ 1674{
1673 killTimer ( m_power_timer ); 1675 killTimer ( m_power_timer );
1674 m_power_timer = 0; 1676 m_power_timer = 0;
1675 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1677 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1676 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1678 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1677} 1679}
1678 1680
1679 1681
1680void SIMpad::alarmSound ( ) 1682void SIMpad::alarmSound ( )
1681{ 1683{
1682#ifndef QT_NO_SOUND 1684#ifndef QT_NO_SOUND
1683 static Sound snd ( "alarm" ); 1685 static Sound snd ( "alarm" );
1684 int fd; 1686 int fd;
1685 int vol; 1687 int vol;
1686 bool vol_reset = false; 1688 bool vol_reset = false;
1687 1689
1688 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1690 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1689 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1691 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1690 Config cfg ( "qpe" ); 1692 Config cfg ( "qpe" );
1691 cfg. setGroup ( "Volume" ); 1693 cfg. setGroup ( "Volume" );
1692 1694
1693 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1695 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1694 if ( volalarm < 0 ) 1696 if ( volalarm < 0 )
1695 volalarm = 0; 1697 volalarm = 0;
1696 else if ( volalarm > 100 ) 1698 else if ( volalarm > 100 )
1697 volalarm = 100; 1699 volalarm = 100;
1698 volalarm |= ( volalarm << 8 ); 1700 volalarm |= ( volalarm << 8 );
1699 1701
1700 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1702 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1701 vol_reset = true; 1703 vol_reset = true;
1702 } 1704 }
1703 } 1705 }
1704 1706
1705 snd. play ( ); 1707 snd. play ( );
1706 while ( !snd. isFinished ( )) 1708 while ( !snd. isFinished ( ))
1707 qApp-> processEvents ( ); 1709 qApp-> processEvents ( );
1708 1710
1709 if ( fd >= 0 ) { 1711 if ( fd >= 0 ) {
1710 if ( vol_reset ) 1712 if ( vol_reset )
1711 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1713 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1712 ::close ( fd ); 1714 ::close ( fd );
1713 } 1715 }
1714#endif 1716#endif
1715} 1717}
1716 1718
1717 1719
1720bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1721{
1722 qDebug( "ODevice for SIMpad: suspend()" );
1723 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1724 return false;
1725
1726 bool res = false;
1727
1728 struct timeval tvs, tvn;
1729 ::gettimeofday ( &tvs, 0 );
1730
1731 ::sync ( ); // flush fs caches
1732 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
1733
1734 return res;
1735}
1736
1737
1718bool SIMpad::setSoftSuspend ( bool soft ) 1738bool SIMpad::setSoftSuspend ( bool soft )
1719{ 1739{
1720 //TODO 1740 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1721 return false; 1741 return false;
1722} 1742}
1723 1743
1724 1744
1745bool SIMpad::setDisplayStatus ( bool on )
1746{
1747 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1748
1749 bool res = false;
1750 int fd;
1751
1752 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1753
1754 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
1755 res = ( ::system( (const char*) cmdline ) == 0 );
1756 ::close ( fd );
1757 }
1758 return res;
1759}
1760
1761
1725bool SIMpad::setDisplayBrightness ( int bright ) 1762bool SIMpad::setDisplayBrightness ( int bright )
1726{ 1763{
1764 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1727 bool res = false; 1765 bool res = false;
1728 int fd; 1766 int fd;
1729 1767
1730 if ( bright > 255 ) 1768 if ( bright > 255 )
1731 bright = 255; 1769 bright = 255;
1732 if ( bright < 0 ) 1770 if ( bright < 0 )
1733 bright = 0; 1771 bright = 0;
1734 1772
1735 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1773 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1736 int value = 255 - bright; 1774 int value = 255 - bright;
1737 const int mask = SIMPAD_BACKLIGHT_MASK; 1775 const int mask = SIMPAD_BACKLIGHT_MASK;
1738 value = value << 8; 1776 value = value << 8;
1739 value += mask; 1777 value += mask;
1740 char writeCommand[100]; 1778 char writeCommand[100];
1741 const int count = sprintf( writeCommand, "0x%x\n", value ); 1779 const int count = sprintf( writeCommand, "0x%x\n", value );
1742 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1780 res = ( ::write ( fd, writeCommand, count ) != -1 );
1743 ::close ( fd ); 1781 ::close ( fd );
1744 } 1782 }
1745 return res; 1783 return res;
1746} 1784}
1747 1785
1748 1786
1749int SIMpad::displayBrightnessResolution ( ) const 1787int SIMpad::displayBrightnessResolution ( ) const
1750{ 1788{
1751 switch ( model ( )) { 1789 switch ( model ( )) {
1752 case Model_SIMpad_CL4: 1790 case Model_SIMpad_CL4:
1753 case Model_SIMpad_SL4: 1791 case Model_SIMpad_SL4:
1754 case Model_SIMpad_SLC: 1792 case Model_SIMpad_SLC:
1755 case Model_SIMpad_TSinus: 1793 case Model_SIMpad_TSinus:
1756 return 255; //TODO find out if this is save 1794 return 255; //TODO find out if this is save
1757 1795
1758 default: 1796 default:
1759 return 2; 1797 return 2;
1760 } 1798 }
1761} 1799}
1762 1800