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 | |
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 | |||
@@ -1,863 +1,823 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_beagle.h" | 30 | #include "odevice_beagle.h" |
31 | #include "odevice_ipaq.h" | 31 | #include "odevice_ipaq.h" |
32 | #include "odevice_jornada.h" | 32 | #include "odevice_jornada.h" |
33 | #include "odevice_ramses.h" | 33 | #include "odevice_ramses.h" |
34 | #include "odevice_simpad.h" | 34 | #include "odevice_simpad.h" |
35 | #include "odevice_yopy.h" | 35 | #include "odevice_yopy.h" |
36 | #include "odevice_zaurus.h" | 36 | #include "odevice_zaurus.h" |
37 | #include "odevice_genuineintel.h" | 37 | #include "odevice_genuineintel.h" |
38 | 38 | ||
39 | /* QT */ | 39 | /* QT */ |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qwindowsystem_qws.h> | 43 | #include <qwindowsystem_qws.h> |
44 | 44 | ||
45 | /* OPIE */ | 45 | /* OPIE */ |
46 | #include <qpe/config.h> | 46 | #include <qpe/config.h> |
47 | #include <qpe/resource.h> | 47 | #include <qpe/resource.h> |
48 | #include <qpe/sound.h> | 48 | #include <qpe/sound.h> |
49 | #include <qpe/qcopenvelope_qws.h> | 49 | #include <qpe/qcopenvelope_qws.h> |
50 | #include <qpe/sound.h> | 50 | #include <qpe/sound.h> |
51 | #include <opie2/okeyfilter.h> | 51 | #include <opie2/okeyfilter.h> |
52 | 52 | ||
53 | /* STD */ | 53 | /* STD */ |
54 | #include <fcntl.h> | 54 | #include <fcntl.h> |
55 | #include <math.h> | 55 | #include <math.h> |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | #include <signal.h> | 57 | #include <signal.h> |
58 | #include <sys/ioctl.h> | 58 | #include <sys/ioctl.h> |
59 | #include <sys/time.h> | 59 | #include <sys/time.h> |
60 | #include <unistd.h> | 60 | #include <unistd.h> |
61 | #ifndef QT_NO_SOUND | 61 | #ifndef QT_NO_SOUND |
62 | #include <linux/soundcard.h> | 62 | #include <linux/soundcard.h> |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | namespace Opie { | 65 | namespace Opie { |
66 | namespace Core { | 66 | namespace Core { |
67 | 67 | ||
68 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 68 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
69 | 69 | ||
70 | 70 | ||
71 | /* STATIC and common implementation */ | 71 | /* STATIC and common implementation */ |
72 | /* EXPORT */ ODistribution distributions[] = { | 72 | /* EXPORT */ ODistribution distributions[] = { |
73 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 73 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
74 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 74 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
75 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 75 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
76 | { System_Unknown, "Linux", "/etc/issue" }, | 76 | { System_Unknown, "Linux", "/etc/issue" }, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | /* EXPORT */ bool isQWS(){ | 80 | /* EXPORT */ bool isQWS(){ |
81 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 81 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
82 | } | 82 | } |
83 | 83 | ||
84 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 84 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
85 | if ( str && !::strchr ( str, '/' )) | 85 | if ( str && !::strchr ( str, '/' )) |
86 | return QCString ( "QPE/Application/" ) + str; | 86 | return QCString ( "QPE/Application/" ) + str; |
87 | else | 87 | else |
88 | return str; | 88 | return str; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | /* Now the default implementation of ODevice */ | 93 | /* Now the default implementation of ODevice */ |
94 | 94 | ||
95 | struct default_button default_buttons [] = { | 95 | struct default_button default_buttons [] = { |
96 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 96 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
97 | "devicebuttons/z_calendar", | 97 | "devicebuttons/z_calendar", |
98 | "datebook", "nextView()", | 98 | "datebook", "nextView()", |
99 | "today", "raise()" }, | 99 | "today", "raise()" }, |
100 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 100 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
101 | "devicebuttons/z_contact", | 101 | "devicebuttons/z_contact", |
102 | "addressbook", "raise()", | 102 | "addressbook", "raise()", |
103 | "addressbook", "beamBusinessCard()" }, | 103 | "addressbook", "beamBusinessCard()" }, |
104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
105 | "devicebuttons/z_home", | 105 | "devicebuttons/z_home", |
106 | "QPE/Launcher", "home()", | 106 | "QPE/Launcher", "home()", |
107 | "buttonsettings", "raise()" }, | 107 | "buttonsettings", "raise()" }, |
108 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 108 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
109 | "devicebuttons/z_menu", | 109 | "devicebuttons/z_menu", |
110 | "QPE/TaskBar", "toggleMenu()", | 110 | "QPE/TaskBar", "toggleMenu()", |
111 | "QPE/TaskBar", "toggleStartMenu()" }, | 111 | "QPE/TaskBar", "toggleStartMenu()" }, |
112 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 112 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
113 | "devicebuttons/z_mail", | 113 | "devicebuttons/z_mail", |
114 | "opiemail", "raise()", | 114 | "opiemail", "raise()", |
115 | "opiemail", "newMail()" }, | 115 | "opiemail", "newMail()" }, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | ODevice *ODevice::inst() | 118 | ODevice *ODevice::inst() |
119 | { | 119 | { |
120 | static ODevice *dev = 0; | 120 | static ODevice *dev = 0; |
121 | 121 | ||
122 | // rewrite this to only use /proc/cpuinfo or so | 122 | // rewrite this to only use /proc/cpuinfo or so |
123 | QString cpu_info; | 123 | QString cpu_info; |
124 | 124 | ||
125 | if ( !dev ) | 125 | if ( !dev ) |
126 | { | 126 | { |
127 | QFile f( PATH_PROC_CPUINFO ); | 127 | QFile f( PATH_PROC_CPUINFO ); |
128 | if ( f.open( IO_ReadOnly ) ) | 128 | if ( f.open( IO_ReadOnly ) ) |
129 | { | 129 | { |
130 | QTextStream s( &f ); | 130 | QTextStream s( &f ); |
131 | while ( !s.atEnd() ) | 131 | while ( !s.atEnd() ) |
132 | { | 132 | { |
133 | QString line; | 133 | QString line; |
134 | line = s.readLine(); | 134 | line = s.readLine(); |
135 | if ( line.startsWith( "Hardware" ) ) | 135 | if ( line.startsWith( "Hardware" ) ) |
136 | { | 136 | { |
137 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 137 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
138 | cpu_info = line; | 138 | cpu_info = line; |
139 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 139 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
140 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 140 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
141 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 141 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
142 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 142 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
143 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 143 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
144 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | 144 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); |
145 | else qWarning( "ODevice() - unknown hardware - using default." ); | 145 | else qWarning( "ODevice() - unknown hardware - using default." ); |
146 | break; | 146 | break; |
147 | } else if ( line.startsWith( "vendor_id" ) ) { | 147 | } else if ( line.startsWith( "vendor_id" ) ) { |
148 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 148 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
149 | cpu_info = line; | 149 | cpu_info = line; |
150 | if( line.contains( "genuineintel", false ) ) { | 150 | if( line.contains( "genuineintel", false ) ) { |
151 | dev = new Internal::GenuineIntel(); | 151 | dev = new Internal::GenuineIntel(); |
152 | break; | 152 | break; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
159 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 159 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
160 | } | 160 | } |
161 | if ( !dev ) dev = new ODevice(); | 161 | if ( !dev ) dev = new ODevice(); |
162 | dev->init(cpu_info); | 162 | dev->init(cpu_info); |
163 | } | 163 | } |
164 | return dev; | 164 | return dev; |
165 | } | 165 | } |
166 | 166 | ||
167 | ODevice::ODevice() | 167 | ODevice::ODevice() |
168 | { | 168 | { |
169 | d = new ODeviceData; | 169 | d = new ODeviceData; |
170 | 170 | ||
171 | d->m_modelstr = "Unknown"; | 171 | d->m_modelstr = "Unknown"; |
172 | d->m_model = Model_Unknown; | 172 | d->m_model = Model_Unknown; |
173 | d->m_vendorstr = "Unknown"; | 173 | d->m_vendorstr = "Unknown"; |
174 | d->m_vendor = Vendor_Unknown; | 174 | d->m_vendor = Vendor_Unknown; |
175 | d->m_systemstr = "Unknown"; | 175 | d->m_systemstr = "Unknown"; |
176 | d->m_system = System_Unknown; | 176 | d->m_system = System_Unknown; |
177 | d->m_sysverstr = "0.0"; | 177 | d->m_sysverstr = "0.0"; |
178 | d->m_rotation = Rot0; | 178 | d->m_rotation = Rot0; |
179 | d->m_direction = CW; | 179 | d->m_direction = CW; |
180 | 180 | ||
181 | d->m_holdtime = 1000; // 1000ms | 181 | d->m_holdtime = 1000; // 1000ms |
182 | d->m_buttons = 0; | 182 | d->m_buttons = 0; |
183 | d->m_cpu_frequencies = new QStrList; | 183 | d->m_cpu_frequencies = new QStrList; |
184 | 184 | ||
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 | ||
192 | // New distribution detection code first checks for legacy distributions, | 192 | // New distribution detection code first checks for legacy distributions, |
193 | // identified by /etc/familiar-version or /etc/oz_version. | 193 | // identified by /etc/familiar-version or /etc/oz_version. |
194 | // Then check for OpenEmbedded and lastly, read /etc/issue | 194 | // Then check for OpenEmbedded and lastly, read /etc/issue |
195 | 195 | ||
196 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 196 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
197 | { | 197 | { |
198 | if ( QFile::exists( distributions[i].sysvfile ) ) | 198 | if ( QFile::exists( distributions[i].sysvfile ) ) |
199 | { | 199 | { |
200 | d->m_systemstr = distributions[i].sysstr; | 200 | d->m_systemstr = distributions[i].sysstr; |
201 | d->m_system = distributions[i].system; | 201 | d->m_system = distributions[i].system; |
202 | d->m_sysverstr = "<Unknown>"; | 202 | d->m_sysverstr = "<Unknown>"; |
203 | QFile f( distributions[i].sysvfile ); | 203 | QFile f( distributions[i].sysvfile ); |
204 | if ( f.open( IO_ReadOnly ) ) | 204 | if ( f.open( IO_ReadOnly ) ) |
205 | { | 205 | { |
206 | QTextStream ts( &f ); | 206 | QTextStream ts( &f ); |
207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
208 | } | 208 | } |
209 | break; | 209 | break; |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
215 | { | 215 | { |
216 | if ( msg == "deviceButtonMappingChanged()" ) { | 216 | if ( msg == "deviceButtonMappingChanged()" ) { |
217 | reloadButtonMapping(); | 217 | reloadButtonMapping(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | void ODevice::init(const QString&) | 221 | void ODevice::init(const QString&) |
222 | { | 222 | { |
223 | } | 223 | } |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * This method initialises the button mapping | 226 | * This method initialises the button mapping |
227 | */ | 227 | */ |
228 | void ODevice::initButtons() | 228 | void ODevice::initButtons() |
229 | { | 229 | { |
230 | if ( d->m_buttons ) | 230 | if ( d->m_buttons ) |
231 | return; | 231 | return; |
232 | 232 | ||
233 | qDebug ( "init Buttons" ); | 233 | qDebug ( "init Buttons" ); |
234 | d->m_buttons = new QValueList <ODeviceButton>; | 234 | d->m_buttons = new QValueList <ODeviceButton>; |
235 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 235 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
236 | default_button *db = default_buttons + i; | 236 | default_button *db = default_buttons + i; |
237 | ODeviceButton b; | 237 | ODeviceButton b; |
238 | b. setKeycode ( db->code ); | 238 | b. setKeycode ( db->code ); |
239 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 239 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
240 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 240 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
243 | d->m_buttons->append ( b ); | 243 | d->m_buttons->append ( b ); |
244 | } | 244 | } |
245 | 245 | ||
246 | reloadButtonMapping(); | 246 | reloadButtonMapping(); |
247 | } | 247 | } |
248 | 248 | ||
249 | ODevice::~ODevice() | 249 | ODevice::~ODevice() |
250 | { | 250 | { |
251 | // we leak m_devicebuttons and m_cpu_frequency | 251 | // we leak m_devicebuttons and m_cpu_frequency |
252 | // but it's a singleton and it is not so importantant | 252 | // but it's a singleton and it is not so importantant |
253 | // -zecke | 253 | // -zecke |
254 | delete d; | 254 | delete d; |
255 | } | 255 | } |
256 | 256 | ||
257 | //#include <linux/apm_bios.h> | 257 | //#include <linux/apm_bios.h> |
258 | 258 | ||
259 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 259 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
260 | 260 | ||
261 | /** | 261 | /** |
262 | * This method will try to suspend the device | 262 | * This method will try to suspend the device |
263 | * It only works if the user is the QWS Server and the apm application | 263 | * It only works if the user is the QWS Server and the apm application |
264 | * is installed. | 264 | * is installed. |
265 | * It tries to suspend and then waits some time cause some distributions | 265 | * It tries to suspend and then waits some time cause some distributions |
266 | * do have asynchronus apm implementations. | 266 | * do have asynchronus apm implementations. |
267 | * This method will either fail and return false or it'll suspend the | 267 | * This method will either fail and return false or it'll suspend the |
268 | * device and return once the device got woken up | 268 | * device and return once the device got woken up |
269 | * | 269 | * |
270 | * @return if the device got suspended | 270 | * @return if the device got suspended |
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 ... |
304 | 278 | ||
305 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 279 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
306 | 280 | ||
307 | /* VESA Blanking Levels */ | 281 | /* VESA Blanking Levels */ |
308 | #define VESA_NO_BLANKING 0 | 282 | #define VESA_NO_BLANKING 0 |
309 | #define VESA_VSYNC_SUSPEND 1 | 283 | #define VESA_VSYNC_SUSPEND 1 |
310 | #define VESA_HSYNC_SUSPEND 2 | 284 | #define VESA_HSYNC_SUSPEND 2 |
311 | #define VESA_POWERDOWN 3 | 285 | #define VESA_POWERDOWN 3 |
312 | 286 | ||
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 | /** |
338 | * This sets the display brightness | 297 | * This sets the display brightness |
339 | * | 298 | * |
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 |
356 | * \sa QSlider::setPageStep | 315 | * \sa QSlider::setPageStep |
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 | ||
383 | /** | 344 | /** |
384 | * This returns the vendor as string | 345 | * This returns the vendor as string |
385 | * @return Vendor as QString | 346 | * @return Vendor as QString |
386 | */ | 347 | */ |
387 | QString ODevice::vendorString() const | 348 | QString ODevice::vendorString() const |
388 | { | 349 | { |
389 | return d->m_vendorstr; | 350 | return d->m_vendorstr; |
390 | } | 351 | } |
391 | 352 | ||
392 | /** | 353 | /** |
393 | * This returns the vendor as one of the values of OVendor | 354 | * This returns the vendor as one of the values of OVendor |
394 | * @return OVendor | 355 | * @return OVendor |
395 | */ | 356 | */ |
396 | OVendor ODevice::vendor() const | 357 | OVendor ODevice::vendor() const |
397 | { | 358 | { |
398 | return d->m_vendor; | 359 | return d->m_vendor; |
399 | } | 360 | } |
400 | 361 | ||
401 | /** | 362 | /** |
402 | * This returns the model as a string | 363 | * This returns the model as a string |
403 | * @return A string representing the model | 364 | * @return A string representing the model |
404 | */ | 365 | */ |
405 | QString ODevice::modelString() const | 366 | QString ODevice::modelString() const |
406 | { | 367 | { |
407 | return d->m_modelstr; | 368 | return d->m_modelstr; |
408 | } | 369 | } |
409 | 370 | ||
410 | /** | 371 | /** |
411 | * This does return the OModel used | 372 | * This does return the OModel used |
412 | */ | 373 | */ |
413 | OModel ODevice::model() const | 374 | OModel ODevice::model() const |
414 | { | 375 | { |
415 | return d->m_model; | 376 | return d->m_model; |
416 | } | 377 | } |
417 | 378 | ||
418 | /** | 379 | /** |
419 | * This does return the systen name | 380 | * This does return the systen name |
420 | */ | 381 | */ |
421 | QString ODevice::systemString() const | 382 | QString ODevice::systemString() const |
422 | { | 383 | { |
423 | return d->m_systemstr; | 384 | return d->m_systemstr; |
424 | } | 385 | } |
425 | 386 | ||
426 | /** | 387 | /** |
427 | * Return System as OSystem value | 388 | * Return System as OSystem value |
428 | */ | 389 | */ |
429 | OSystem ODevice::system() const | 390 | OSystem ODevice::system() const |
430 | { | 391 | { |
431 | return d->m_system; | 392 | return d->m_system; |
432 | } | 393 | } |
433 | 394 | ||
434 | /** | 395 | /** |
435 | * @return the version string of the base system | 396 | * @return the version string of the base system |
436 | */ | 397 | */ |
437 | QString ODevice::systemVersionString() const | 398 | QString ODevice::systemVersionString() const |
438 | { | 399 | { |
439 | return d->m_sysverstr; | 400 | return d->m_sysverstr; |
440 | } | 401 | } |
441 | 402 | ||
442 | /** | 403 | /** |
443 | * @return the current Transformation | 404 | * @return the current Transformation |
444 | */ | 405 | */ |
445 | Transformation ODevice::rotation() const | 406 | Transformation ODevice::rotation() const |
446 | { | 407 | { |
447 | return d->m_rotation; | 408 | return d->m_rotation; |
448 | } | 409 | } |
449 | 410 | ||
450 | /** | 411 | /** |
451 | * @return the current rotation direction | 412 | * @return the current rotation direction |
452 | */ | 413 | */ |
453 | ODirection ODevice::direction() const | 414 | ODirection ODevice::direction() const |
454 | { | 415 | { |
455 | return d->m_direction; | 416 | return d->m_direction; |
456 | } | 417 | } |
457 | 418 | ||
458 | /** | 419 | /** |
459 | * This plays an alarm sound | 420 | * This plays an alarm sound |
460 | */ | 421 | */ |
461 | void ODevice::playAlarmSound() | 422 | void ODevice::playAlarmSound() |
462 | { | 423 | { |
463 | #ifndef QT_NO_SOUND | 424 | #ifndef QT_NO_SOUND |
464 | static Sound snd ( "alarm" ); | 425 | static Sound snd ( "alarm" ); |
465 | 426 | ||
466 | if ( snd. isFinished()) | 427 | if ( snd. isFinished()) |
467 | snd. play(); | 428 | snd. play(); |
468 | #endif | 429 | #endif |
469 | } | 430 | } |
470 | 431 | ||
471 | /** | 432 | /** |
472 | * This plays a key sound | 433 | * This plays a key sound |
473 | */ | 434 | */ |
474 | void ODevice::playKeySound() | 435 | void ODevice::playKeySound() |
475 | { | 436 | { |
476 | #ifndef QT_NO_SOUND | 437 | #ifndef QT_NO_SOUND |
477 | static Sound snd ( "keysound" ); | 438 | static Sound snd ( "keysound" ); |
478 | 439 | ||
479 | if ( snd. isFinished()) | 440 | if ( snd. isFinished()) |
480 | snd. play(); | 441 | snd. play(); |
481 | #endif | 442 | #endif |
482 | } | 443 | } |
483 | 444 | ||
484 | /** | 445 | /** |
485 | * This plays a touch sound | 446 | * This plays a touch sound |
486 | */ | 447 | */ |
487 | void ODevice::playTouchSound() | 448 | void ODevice::playTouchSound() |
488 | { | 449 | { |
489 | #ifndef QT_NO_SOUND | 450 | #ifndef QT_NO_SOUND |
490 | static Sound snd ( "touchsound" ); | 451 | static Sound snd ( "touchsound" ); |
491 | 452 | ||
492 | if ( snd. isFinished()) | 453 | if ( snd. isFinished()) |
493 | snd. play(); | 454 | snd. play(); |
494 | #endif | 455 | #endif |
495 | } | 456 | } |
496 | 457 | ||
497 | /** | 458 | /** |
498 | * This method will return a list of leds | 459 | * This method will return a list of leds |
499 | * available on this device | 460 | * available on this device |
500 | * @return a list of LEDs. | 461 | * @return a list of LEDs. |
501 | */ | 462 | */ |
502 | QValueList <OLed> ODevice::ledList() const | 463 | QValueList <OLed> ODevice::ledList() const |
503 | { | 464 | { |
504 | return QValueList <OLed>(); | 465 | return QValueList <OLed>(); |
505 | } | 466 | } |
506 | 467 | ||
507 | /** | 468 | /** |
508 | * This does return the state of the LEDs | 469 | * This does return the state of the LEDs |
509 | */ | 470 | */ |
510 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 471 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
511 | { | 472 | { |
512 | return QValueList <OLedState>(); | 473 | return QValueList <OLedState>(); |
513 | } | 474 | } |
514 | 475 | ||
515 | /** | 476 | /** |
516 | * @return the state for a given OLed | 477 | * @return the state for a given OLed |
517 | */ | 478 | */ |
518 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 479 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
519 | { | 480 | { |
520 | return Led_Off; | 481 | return Led_Off; |
521 | } | 482 | } |
522 | 483 | ||
523 | /** | 484 | /** |
524 | * Set the state for a LED | 485 | * Set the state for a LED |
525 | * @param which Which OLed to use | 486 | * @param which Which OLed to use |
526 | * @param st The state to set | 487 | * @param st The state to set |
527 | * @return success or failure | 488 | * @return success or failure |
528 | */ | 489 | */ |
529 | bool ODevice::setLedState ( OLed which, OLedState st ) | 490 | bool ODevice::setLedState ( OLed which, OLedState st ) |
530 | { | 491 | { |
531 | Q_UNUSED( which ) | 492 | Q_UNUSED( which ) |
532 | Q_UNUSED( st ) | 493 | Q_UNUSED( st ) |
533 | return false; | 494 | return false; |
534 | } | 495 | } |
535 | 496 | ||
536 | /** | 497 | /** |
537 | * @return if the device has a light sensor | 498 | * @return if the device has a light sensor |
538 | */ | 499 | */ |
539 | bool ODevice::hasLightSensor() const | 500 | bool ODevice::hasLightSensor() const |
540 | { | 501 | { |
541 | return false; | 502 | return false; |
542 | } | 503 | } |
543 | 504 | ||
544 | /** | 505 | /** |
545 | * @return a value from the light sensor | 506 | * @return a value from the light sensor |
546 | */ | 507 | */ |
547 | int ODevice::readLightSensor() | 508 | int ODevice::readLightSensor() |
548 | { | 509 | { |
549 | return -1; | 510 | return -1; |
550 | } | 511 | } |
551 | 512 | ||
552 | /** | 513 | /** |
553 | * @return the light sensor resolution | 514 | * @return the light sensor resolution |
554 | */ | 515 | */ |
555 | int ODevice::lightSensorResolution() const | 516 | int ODevice::lightSensorResolution() const |
556 | { | 517 | { |
557 | return 0; | 518 | return 0; |
558 | } | 519 | } |
559 | 520 | ||
560 | /** | 521 | /** |
561 | * @return if the device has a hinge sensor | 522 | * @return if the device has a hinge sensor |
562 | */ | 523 | */ |
563 | bool ODevice::hasHingeSensor() const | 524 | bool ODevice::hasHingeSensor() const |
564 | { | 525 | { |
565 | return false; | 526 | return false; |
566 | } | 527 | } |
567 | 528 | ||
568 | /** | 529 | /** |
569 | * @return a value from the hinge sensor | 530 | * @return a value from the hinge sensor |
570 | */ | 531 | */ |
571 | OHingeStatus ODevice::readHingeSensor() | 532 | OHingeStatus ODevice::readHingeSensor() |
572 | { | 533 | { |
573 | return CASE_UNKNOWN; | 534 | return CASE_UNKNOWN; |
574 | } | 535 | } |
575 | 536 | ||
576 | /** | 537 | /** |
577 | * @return a list with CPU frequencies supported by the hardware | 538 | * @return a list with CPU frequencies supported by the hardware |
578 | */ | 539 | */ |
579 | const QStrList &ODevice::allowedCpuFrequencies() const | 540 | const QStrList &ODevice::allowedCpuFrequencies() const |
580 | { | 541 | { |
581 | return *d->m_cpu_frequencies; | 542 | return *d->m_cpu_frequencies; |
582 | } | 543 | } |
583 | 544 | ||
584 | 545 | ||
585 | /** | 546 | /** |
586 | * Set desired CPU frequency | 547 | * Set desired CPU frequency |
587 | * | 548 | * |
588 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 549 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
589 | */ | 550 | */ |
590 | bool ODevice::setCurrentCpuFrequency(uint index) | 551 | bool ODevice::setCurrentCpuFrequency(uint index) |
591 | { | 552 | { |
592 | if (index >= d->m_cpu_frequencies->count()) | 553 | if (index >= d->m_cpu_frequencies->count()) |
593 | return false; | 554 | return false; |
594 | 555 | ||
595 | char *freq = d->m_cpu_frequencies->at(index); | 556 | char *freq = d->m_cpu_frequencies->at(index); |
596 | qWarning("set freq to %s", freq); | 557 | qWarning("set freq to %s", freq); |
597 | 558 | ||
598 | int fd; | 559 | int fd; |
599 | 560 | ||
600 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 561 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
601 | char writeCommand[50]; | 562 | char writeCommand[50]; |
602 | const int count = sprintf(writeCommand, "%s\n", freq); | 563 | const int count = sprintf(writeCommand, "%s\n", freq); |
603 | int res = (::write(fd, writeCommand, count) != -1); | 564 | int res = (::write(fd, writeCommand, count) != -1); |
604 | ::close(fd); | 565 | ::close(fd); |
605 | return res; | 566 | return res; |
606 | } | 567 | } |
607 | 568 | ||
608 | return false; | 569 | return false; |
609 | } | 570 | } |
610 | 571 | ||
611 | 572 | ||
612 | /** | 573 | /** |
613 | * @return a list of hardware buttons | 574 | * @return a list of hardware buttons |
614 | */ | 575 | */ |
615 | const QValueList <ODeviceButton> &ODevice::buttons() | 576 | const QValueList <ODeviceButton> &ODevice::buttons() |
616 | { | 577 | { |
617 | initButtons(); | 578 | initButtons(); |
618 | 579 | ||
619 | return *d->m_buttons; | 580 | return *d->m_buttons; |
620 | } | 581 | } |
621 | 582 | ||
622 | /** | 583 | /** |
623 | * @return The amount of time that would count as a hold | 584 | * @return The amount of time that would count as a hold |
624 | */ | 585 | */ |
625 | uint ODevice::buttonHoldTime() const | 586 | uint ODevice::buttonHoldTime() const |
626 | { | 587 | { |
627 | return d->m_holdtime; | 588 | return d->m_holdtime; |
628 | } | 589 | } |
629 | 590 | ||
630 | /** | 591 | /** |
631 | * This method return a ODeviceButton for a key code | 592 | * This method return a ODeviceButton for a key code |
632 | * or 0 if no special hardware button is available for the device | 593 | * or 0 if no special hardware button is available for the device |
633 | * | 594 | * |
634 | * @return The devicebutton or 0l | 595 | * @return The devicebutton or 0l |
635 | * @see ODeviceButton | 596 | * @see ODeviceButton |
636 | */ | 597 | */ |
637 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 598 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
638 | { | 599 | { |
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; |
646 | } | 607 | } |
647 | 608 | ||
648 | void ODevice::reloadButtonMapping() | 609 | 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&)), |
656 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); | 617 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); |
657 | d->m_initializedButtonQcop = true; | 618 | d->m_initializedButtonQcop = true; |
658 | } | 619 | } |
659 | 620 | ||
660 | Config cfg ( "ButtonSettings" ); | 621 | Config cfg ( "ButtonSettings" ); |
661 | 622 | ||
662 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 623 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
663 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 624 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
664 | QString group = "Button" + QString::number ( i ); | 625 | QString group = "Button" + QString::number ( i ); |
665 | 626 | ||
666 | QCString pch, hch; | 627 | QCString pch, hch; |
667 | QCString pm, hm; | 628 | QCString pm, hm; |
668 | QByteArray pdata, hdata; | 629 | QByteArray pdata, hdata; |
669 | 630 | ||
670 | if ( cfg. hasGroup ( group )) { | 631 | if ( cfg. hasGroup ( group )) { |
671 | cfg. setGroup ( group ); | 632 | cfg. setGroup ( group ); |
672 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 633 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
673 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 634 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
674 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 635 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
675 | 636 | ||
676 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 637 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
677 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 638 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
678 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 639 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
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 | } |
686 | 646 | ||
687 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 647 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
688 | { | 648 | { |
689 | initButtons(); | 649 | initButtons(); |
690 | 650 | ||
691 | QString mb_chan; | 651 | QString mb_chan; |
692 | 652 | ||
693 | if ( button >= (int) d->m_buttons->count()) | 653 | if ( button >= (int) d->m_buttons->count()) |
694 | return; | 654 | return; |
695 | 655 | ||
696 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 656 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
697 | b. setPressedAction ( action ); | 657 | b. setPressedAction ( action ); |
698 | 658 | ||
699 | mb_chan=b. pressedAction(). channel(); | 659 | mb_chan=b. pressedAction(). channel(); |
700 | 660 | ||
701 | Config buttonFile ( "ButtonSettings" ); | 661 | Config buttonFile ( "ButtonSettings" ); |
702 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 662 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
703 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 663 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
704 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 664 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
705 | 665 | ||
706 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 666 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
707 | 667 | ||
708 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 668 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
709 | } | 669 | } |
710 | 670 | ||
711 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 671 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
712 | { | 672 | { |
713 | initButtons(); | 673 | initButtons(); |
714 | 674 | ||
715 | if ( button >= (int) d->m_buttons->count()) | 675 | if ( button >= (int) d->m_buttons->count()) |
716 | return; | 676 | return; |
717 | 677 | ||
718 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 678 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
719 | b. setHeldAction ( action ); | 679 | b. setHeldAction ( action ); |
720 | 680 | ||
721 | Config buttonFile ( "ButtonSettings" ); | 681 | Config buttonFile ( "ButtonSettings" ); |
722 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 682 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
723 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 683 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
724 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 684 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
725 | 685 | ||
726 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 686 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
727 | 687 | ||
728 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 688 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
729 | } | 689 | } |
730 | 690 | ||
731 | /** | 691 | /** |
732 | * @internal | 692 | * @internal |
733 | */ | 693 | */ |
734 | void ODevice::virtual_hook(int, void* ){ | 694 | void ODevice::virtual_hook(int, void* ){ |
735 | 695 | ||
736 | } | 696 | } |
737 | 697 | ||
738 | /** | 698 | /** |
739 | * \brief Send a QCOP Message before suspending | 699 | * \brief Send a QCOP Message before suspending |
740 | * | 700 | * |
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 | { |
751 | if ( isQWS() ) | 711 | if ( isQWS() ) |
752 | return; | 712 | return; |
753 | 713 | ||
754 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 714 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
755 | } | 715 | } |
756 | 716 | ||
757 | /** | 717 | /** |
758 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 718 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
759 | * | 719 | * |
760 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 720 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
761 | * Filters. This function is the only way to prepend a KeyFilter. | 721 | * Filters. This function is the only way to prepend a KeyFilter. |
762 | * | 722 | * |
763 | * @param aFilter The KeyFilter to be prepended to the list of filters | 723 | * @param aFilter The KeyFilter to be prepended to the list of filters |
764 | * | 724 | * |
765 | * @see Opie::Core::OKeyFilter | 725 | * @see Opie::Core::OKeyFilter |
766 | * @see Opie::Core::OKeyFilter::inst() | 726 | * @see Opie::Core::OKeyFilter::inst() |
767 | */ | 727 | */ |
768 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 728 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
769 | { | 729 | { |
770 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 730 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
771 | } | 731 | } |
772 | 732 | ||
773 | /** | 733 | /** |
774 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 734 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
775 | * | 735 | * |
776 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 736 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
777 | * of Keyfilters. Call this when you delete the KeyFilter! | 737 | * of Keyfilters. Call this when you delete the KeyFilter! |
778 | * | 738 | * |
779 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 739 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
780 | * @see Opie::Core::ODevice::addPreHandler | 740 | * @see Opie::Core::ODevice::addPreHandler |
781 | */ | 741 | */ |
782 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 742 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
783 | { | 743 | { |
784 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 744 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
785 | } | 745 | } |
786 | 746 | ||
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() { |
794 | if ( sender() ) | 754 | if ( sender() ) |
795 | const_cast<QObject*>(sender())->disconnect( this ); | 755 | const_cast<QObject*>(sender())->disconnect( this ); |
796 | 756 | ||
797 | #ifndef QT_NO_SOUND | 757 | #ifndef QT_NO_SOUND |
798 | if ( d->m_sound >= 0 ) { | 758 | if ( d->m_sound >= 0 ) { |
799 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 759 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); |
800 | ::close ( d->m_sound ); | 760 | ::close ( d->m_sound ); |
801 | } | 761 | } |
802 | #endif | 762 | #endif |
803 | } | 763 | } |
804 | 764 | ||
805 | 765 | ||
806 | /** | 766 | /** |
807 | * \brief Change the Volume for the Alarm and set it back after playing is finished | 767 | * \brief Change the Volume for the Alarm and set it back after playing is finished |
808 | * | 768 | * |
809 | * If you play an Alarm Sound you might want to change the Mixer to | 769 | * If you play an Alarm Sound you might want to change the Mixer to |
810 | * full volume and ignore the user setting. After it \sa Sound::isFinished | 770 | * full volume and ignore the user setting. After it \sa Sound::isFinished |
811 | * you would turn the volume back to the user preference. | 771 | * you would turn the volume back to the user preference. |
812 | * The problem is that we used to enter the event loop while waiting | 772 | * The problem is that we used to enter the event loop while waiting |
813 | * for the sound to be finished triggering all kind of reentrance | 773 | * for the sound to be finished triggering all kind of reentrance |
814 | * problems what a library shouldn't introduce. | 774 | * problems what a library shouldn't introduce. |
815 | * Instead of manually waiting for the sound to be finished use | 775 | * Instead of manually waiting for the sound to be finished use |
816 | * this Method and it will automatically restore the Mixer to | 776 | * this Method and it will automatically restore the Mixer to |
817 | * the user configuration after the sound finished playing. | 777 | * the user configuration after the sound finished playing. |
818 | * | 778 | * |
819 | * Note: The onwership of \param snd is not transfered and playing | 779 | * Note: The onwership of \param snd is not transfered and playing |
820 | * is not started in this method. If 'snd' gets deleted before | 780 | * is not started in this method. If 'snd' gets deleted before |
821 | * playing is finished the volume doesn't get set back to | 781 | * playing is finished the volume doesn't get set back to |
822 | * the user preference! | 782 | * the user preference! |
823 | * | 783 | * |
824 | * \code | 784 | * \code |
825 | * static Sound snd("alarm"); | 785 | * static Sound snd("alarm"); |
826 | * if(!snd.isFinished()) | 786 | * if(!snd.isFinished()) |
827 | * return; | 787 | * return; |
828 | * | 788 | * |
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 |
842 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 802 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
843 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 803 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
844 | Config cfg ( "qpe" ); | 804 | Config cfg ( "qpe" ); |
845 | cfg. setGroup ( "Volume" ); | 805 | cfg. setGroup ( "Volume" ); |
846 | 806 | ||
847 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 807 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
848 | if ( volalarm < 0 ) | 808 | if ( volalarm < 0 ) |
849 | volalarm = 0; | 809 | volalarm = 0; |
850 | else if ( volalarm > 100 ) | 810 | else if ( volalarm > 100 ) |
851 | volalarm = 100; | 811 | volalarm = 100; |
852 | volalarm |= ( volalarm << 8 ); | 812 | volalarm |= ( volalarm << 8 ); |
853 | 813 | ||
854 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) | 814 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) |
855 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); | 815 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); |
856 | } | 816 | } |
857 | d->m_mixer = mixer; | 817 | d->m_mixer = mixer; |
858 | } | 818 | } |
859 | #endif | 819 | #endif |
860 | } | 820 | } |
861 | 821 | ||
862 | } | 822 | } |
863 | } | 823 | } |
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 | |||
@@ -1,621 +1,621 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/oinputsystem.h> | 39 | #include <opie2/oinputsystem.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | #include <math.h> | 47 | #include <math.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <signal.h> | 49 | #include <signal.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/time.h> | 51 | #include <sys/time.h> |
52 | #include <unistd.h> | 52 | #include <unistd.h> |
53 | #ifndef QT_NO_SOUND | 53 | #ifndef QT_NO_SOUND |
54 | #include <linux/soundcard.h> | 54 | #include <linux/soundcard.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | using namespace Opie::Core; | 57 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 58 | using namespace Opie::Core::Internal; |
59 | 59 | ||
60 | struct z_button z_buttons [] = { | 60 | struct z_button z_buttons [] = { |
61 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 61 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
62 | "devicebuttons/z_calendar", | 62 | "devicebuttons/z_calendar", |
63 | "datebook", "nextView()", | 63 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 64 | "today", "raise()" }, |
65 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 65 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
66 | "devicebuttons/z_contact", | 66 | "devicebuttons/z_contact", |
67 | "addressbook", "raise()", | 67 | "addressbook", "raise()", |
68 | "addressbook", "beamBusinessCard()" }, | 68 | "addressbook", "beamBusinessCard()" }, |
69 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 69 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
70 | "devicebuttons/z_home", | 70 | "devicebuttons/z_home", |
71 | "QPE/Launcher", "home()", | 71 | "QPE/Launcher", "home()", |
72 | "buttonsettings", "raise()" }, | 72 | "buttonsettings", "raise()" }, |
73 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 73 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
74 | "devicebuttons/z_menu", | 74 | "devicebuttons/z_menu", |
75 | "QPE/TaskBar", "toggleMenu()", | 75 | "QPE/TaskBar", "toggleMenu()", |
76 | "QPE/TaskBar", "toggleStartMenu()" }, | 76 | "QPE/TaskBar", "toggleStartMenu()" }, |
77 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 77 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
78 | "devicebuttons/z_mail", | 78 | "devicebuttons/z_mail", |
79 | "opiemail", "raise()", | 79 | "opiemail", "raise()", |
80 | "opiemail", "newMail()" }, | 80 | "opiemail", "newMail()" }, |
81 | }; | 81 | }; |
82 | 82 | ||
83 | struct z_button z_buttons_c700 [] = { | 83 | struct z_button z_buttons_c700 [] = { |
84 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 84 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
85 | "devicebuttons/z_calendar", | 85 | "devicebuttons/z_calendar", |
86 | "datebook", "nextView()", | 86 | "datebook", "nextView()", |
87 | "today", "raise()" }, | 87 | "today", "raise()" }, |
88 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 88 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
89 | "devicebuttons/z_contact", | 89 | "devicebuttons/z_contact", |
90 | "addressbook", "raise()", | 90 | "addressbook", "raise()", |
91 | "addressbook", "beamBusinessCard()" }, | 91 | "addressbook", "beamBusinessCard()" }, |
92 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 92 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
93 | "devicebuttons/z_home", | 93 | "devicebuttons/z_home", |
94 | "QPE/Launcher", "home()", | 94 | "QPE/Launcher", "home()", |
95 | "buttonsettings", "raise()" }, | 95 | "buttonsettings", "raise()" }, |
96 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 96 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
97 | "devicebuttons/z_menu", | 97 | "devicebuttons/z_menu", |
98 | "QPE/TaskBar", "toggleMenu()", | 98 | "QPE/TaskBar", "toggleMenu()", |
99 | "QPE/TaskBar", "toggleStartMenu()" }, | 99 | "QPE/TaskBar", "toggleStartMenu()" }, |
100 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 100 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
101 | "devicebuttons/z_mail", | 101 | "devicebuttons/z_mail", |
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 |
120 | // class up into individual classes. We need three classes | 120 | // class up into individual classes. We need three classes |
121 | // | 121 | // |
122 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 122 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
123 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 123 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
124 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) | 124 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) |
125 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 125 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
126 | // | 126 | // |
127 | // Only question right now is: Do we really need to do it? Because as soon | 127 | // Only question right now is: Do we really need to do it? Because as soon |
128 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 128 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
129 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 129 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
130 | // | 130 | // |
131 | // Comments? - mickeyl. | 131 | // Comments? - mickeyl. |
132 | 132 | ||
133 | void Zaurus::init(const QString& cpu_info) | 133 | void Zaurus::init(const QString& cpu_info) |
134 | { | 134 | { |
135 | // generic distribution code already scanned /etc/issue at that point - | 135 | // generic distribution code already scanned /etc/issue at that point - |
136 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 136 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
137 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 137 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
138 | { | 138 | { |
139 | d->m_vendorstr = "Sharp"; | 139 | d->m_vendorstr = "Sharp"; |
140 | d->m_vendor = Vendor_Sharp; | 140 | d->m_vendor = Vendor_Sharp; |
141 | d->m_systemstr = "Zaurus"; | 141 | d->m_systemstr = "Zaurus"; |
142 | d->m_system = System_Zaurus; | 142 | d->m_system = System_Zaurus; |
143 | m_embedix = true; | 143 | m_embedix = true; |
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | d->m_vendorstr = "OpenZaurus Team"; | 147 | d->m_vendorstr = "OpenZaurus Team"; |
148 | d->m_systemstr = "OpenZaurus"; | 148 | d->m_systemstr = "OpenZaurus"; |
149 | d->m_system = System_OpenZaurus; | 149 | d->m_system = System_OpenZaurus; |
150 | // sysver already gathered | 150 | // sysver already gathered |
151 | 151 | ||
152 | // OpenZaurus sometimes uses the embedix kernel, check if this is one | 152 | // OpenZaurus sometimes uses the embedix kernel, check if this is one |
153 | FILE *uname = popen("uname -r", "r"); | 153 | FILE *uname = popen("uname -r", "r"); |
154 | QFile f; | 154 | QFile f; |
155 | QString line; | 155 | QString line; |
156 | if ( f.open(IO_ReadOnly, uname) ) { | 156 | if ( f.open(IO_ReadOnly, uname) ) { |
157 | QTextStream ts ( &f ); | 157 | QTextStream ts ( &f ); |
158 | line = ts. readLine(); | 158 | line = ts. readLine(); |
159 | int loc = line. find ( "embedix" ); | 159 | int loc = line. find ( "embedix" ); |
160 | if ( loc != -1 ) | 160 | if ( loc != -1 ) |
161 | m_embedix = true; | 161 | m_embedix = true; |
162 | else | 162 | else |
163 | m_embedix = false; | 163 | m_embedix = false; |
164 | f.close(); | 164 | f.close(); |
165 | } | 165 | } |
166 | pclose(uname); | 166 | pclose(uname); |
167 | } | 167 | } |
168 | 168 | ||
169 | // check the Zaurus model | 169 | // check the Zaurus model |
170 | QString model; | 170 | QString model; |
171 | int loc = cpu_info.find( ":" ); | 171 | int loc = cpu_info.find( ":" ); |
172 | if ( loc != -1 ) | 172 | if ( loc != -1 ) |
173 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 173 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
174 | else | 174 | else |
175 | model = cpu_info; | 175 | model = cpu_info; |
176 | 176 | ||
177 | if ( model == "SHARP Corgi" ) { | 177 | if ( model == "SHARP Corgi" ) { |
178 | d->m_model = Model_Zaurus_SLC7x0; | 178 | d->m_model = Model_Zaurus_SLC7x0; |
179 | d->m_modelstr = "Zaurus SL-C700"; | 179 | d->m_modelstr = "Zaurus SL-C700"; |
180 | } else if ( model == "SHARP Shepherd" ) { | 180 | } else if ( model == "SHARP Shepherd" ) { |
181 | d->m_model = Model_Zaurus_SLC7x0; | 181 | d->m_model = Model_Zaurus_SLC7x0; |
182 | d->m_modelstr = "Zaurus SL-C750"; | 182 | d->m_modelstr = "Zaurus SL-C750"; |
183 | } else if ( model == "SHARP Husky" ) { | 183 | } else if ( model == "SHARP Husky" ) { |
184 | d->m_model = Model_Zaurus_SLC7x0; | 184 | d->m_model = Model_Zaurus_SLC7x0; |
185 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 185 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
186 | } else if ( model == "SHARP Boxer" ) { | 186 | } else if ( model == "SHARP Boxer" ) { |
187 | d->m_model = Model_Zaurus_SLC7x0; | 187 | d->m_model = Model_Zaurus_SLC7x0; |
188 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 188 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
189 | } else if ( model == "SHARP Poodle" ) { | 189 | } else if ( model == "SHARP Poodle" ) { |
190 | d->m_model = Model_Zaurus_SLB600; | 190 | d->m_model = Model_Zaurus_SLB600; |
191 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 191 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
192 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 192 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
193 | d->m_model = Model_Zaurus_SL5500; | 193 | d->m_model = Model_Zaurus_SL5500; |
194 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 194 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
195 | } else if ( model == "SHARP Tosa" ) { | 195 | } else if ( model == "SHARP Tosa" ) { |
196 | d->m_model = Model_Zaurus_SL6000; | 196 | d->m_model = Model_Zaurus_SL6000; |
197 | d->m_modelstr = "Zaurus SL-6000"; | 197 | d->m_modelstr = "Zaurus SL-6000"; |
198 | } else if ( model == "SHARP Spitz" ) { | 198 | } else if ( model == "SHARP Spitz" ) { |
199 | d->m_model = Model_Zaurus_SLC3000; | 199 | d->m_model = Model_Zaurus_SLC3000; |
200 | d->m_modelstr = "Zaurus SL-C3000"; | 200 | d->m_modelstr = "Zaurus SL-C3000"; |
201 | } else { | 201 | } else { |
202 | d->m_model = Model_Zaurus_SL5500; | 202 | d->m_model = Model_Zaurus_SL5500; |
203 | d->m_modelstr = "Unknown Zaurus"; | 203 | d->m_modelstr = "Unknown Zaurus"; |
204 | } | 204 | } |
205 | 205 | ||
206 | // set initial rotation | 206 | // set initial rotation |
207 | switch( d->m_model ) { | 207 | switch( d->m_model ) { |
208 | case Model_Zaurus_SL6000: // fallthrough | 208 | case Model_Zaurus_SL6000: // fallthrough |
209 | case Model_Zaurus_SLA300: | 209 | case Model_Zaurus_SLA300: |
210 | d->m_rotation = Rot0; | 210 | d->m_rotation = Rot0; |
211 | break; | 211 | break; |
212 | case Model_Zaurus_SLC3000: // fallthrough | 212 | case Model_Zaurus_SLC3000: // fallthrough |
213 | case Model_Zaurus_SLC7x0: | 213 | case Model_Zaurus_SLC7x0: |
214 | d->m_rotation = rotation(); | 214 | d->m_rotation = rotation(); |
215 | d->m_direction = direction(); | 215 | d->m_direction = direction(); |
216 | break; | 216 | break; |
217 | case Model_Zaurus_SLB600: // fallthrough | 217 | case Model_Zaurus_SLB600: // fallthrough |
218 | case Model_Zaurus_SL5000: // fallthrough | 218 | case Model_Zaurus_SL5000: // fallthrough |
219 | case Model_Zaurus_SL5500: // fallthrough | 219 | case Model_Zaurus_SL5500: // fallthrough |
220 | default: | 220 | default: |
221 | d->m_rotation = Rot270; | 221 | d->m_rotation = Rot270; |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | m_leds[0] = Led_Off; | 224 | m_leds[0] = Led_Off; |
225 | 225 | ||
226 | if ( m_embedix ) | 226 | if ( m_embedix ) |
227 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); | 227 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); |
228 | else | 228 | else |
229 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 229 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void Zaurus::initButtons() | 232 | void Zaurus::initButtons() |
233 | { | 233 | { |
234 | if ( d->m_buttons ) | 234 | if ( d->m_buttons ) |
235 | return; | 235 | return; |
236 | 236 | ||
237 | d->m_buttons = new QValueList <ODeviceButton>; | 237 | d->m_buttons = new QValueList <ODeviceButton>; |
238 | 238 | ||
239 | struct z_button * pz_buttons; | 239 | struct z_button * pz_buttons; |
240 | int buttoncount; | 240 | int buttoncount; |
241 | switch ( d->m_model ) { | 241 | switch ( d->m_model ) { |
242 | case Model_Zaurus_SLC3000: // fallthrough | 242 | case Model_Zaurus_SLC3000: // fallthrough |
243 | case Model_Zaurus_SLC7x0: | 243 | case Model_Zaurus_SLC7x0: |
244 | pz_buttons = z_buttons_c700; | 244 | pz_buttons = z_buttons_c700; |
245 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 245 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
246 | break; | 246 | break; |
247 | default: | 247 | default: |
248 | pz_buttons = z_buttons; | 248 | pz_buttons = z_buttons; |
249 | buttoncount = ARRAY_SIZE(z_buttons); | 249 | buttoncount = ARRAY_SIZE(z_buttons); |
250 | break; | 250 | break; |
251 | } | 251 | } |
252 | 252 | ||
253 | for ( int i = 0; i < buttoncount; i++ ) { | 253 | for ( int i = 0; i < buttoncount; i++ ) { |
254 | struct z_button *zb = pz_buttons + i; | 254 | struct z_button *zb = pz_buttons + i; |
255 | ODeviceButton b; | 255 | ODeviceButton b; |
256 | 256 | ||
257 | b.setKeycode( zb->code ); | 257 | b.setKeycode( zb->code ); |
258 | b.setUserText( QObject::tr( "Button", zb->utext )); | 258 | b.setUserText( QObject::tr( "Button", zb->utext )); |
259 | b.setPixmap( Resource::loadPixmap( zb->pix )); | 259 | b.setPixmap( Resource::loadPixmap( zb->pix )); |
260 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 260 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
261 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 261 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
262 | d->m_buttons->append( b ); | 262 | d->m_buttons->append( b ); |
263 | } | 263 | } |
264 | 264 | ||
265 | reloadButtonMapping(); | 265 | reloadButtonMapping(); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | 269 | ||
270 | typedef struct sharp_led_status { | 270 | typedef struct sharp_led_status { |
271 | int which; /* select which LED status is wanted. */ | 271 | int which; /* select which LED status is wanted. */ |
272 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 272 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
273 | } sharp_led_status; | 273 | } sharp_led_status; |
274 | 274 | ||
275 | void Zaurus::buzzer( int sound ) | 275 | void Zaurus::buzzer( int sound ) |
276 | { | 276 | { |
277 | #ifndef QT_NO_SOUND | 277 | #ifndef QT_NO_SOUND |
278 | Sound *snd = 0; | 278 | Sound *snd = 0; |
279 | 279 | ||
280 | // All devices except SL5500 have a DSP device | 280 | // All devices except SL5500 have a DSP device |
281 | if ( d->m_model != Model_Zaurus_SL5000 | 281 | if ( d->m_model != Model_Zaurus_SL5000 |
282 | && d->m_model != Model_Zaurus_SL5500 ) { | 282 | && d->m_model != Model_Zaurus_SL5500 ) { |
283 | 283 | ||
284 | switch ( sound ){ | 284 | switch ( sound ){ |
285 | case SHARP_BUZ_TOUCHSOUND: { | 285 | case SHARP_BUZ_TOUCHSOUND: { |
286 | static Sound touch_sound("touchsound"); | 286 | static Sound touch_sound("touchsound"); |
287 | snd = &touch_sound; | 287 | snd = &touch_sound; |
288 | } | 288 | } |
289 | break; | 289 | break; |
290 | case SHARP_BUZ_KEYSOUND: { | 290 | case SHARP_BUZ_KEYSOUND: { |
291 | static Sound key_sound( "keysound" ); | 291 | static Sound key_sound( "keysound" ); |
292 | snd = &key_sound; | 292 | snd = &key_sound; |
293 | } | 293 | } |
294 | break; | 294 | break; |
295 | case SHARP_BUZ_SCHEDULE_ALARM: | 295 | case SHARP_BUZ_SCHEDULE_ALARM: |
296 | default: { | 296 | default: { |
297 | static Sound alarm_sound("alarm"); | 297 | static Sound alarm_sound("alarm"); |
298 | snd = &alarm_sound; | 298 | snd = &alarm_sound; |
299 | } | 299 | } |
300 | break; | 300 | break; |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | // If a soundname is defined, we expect that this device has | 304 | // If a soundname is defined, we expect that this device has |
305 | // sound capabilities.. Otherwise we expect to have the buzzer | 305 | // sound capabilities.. Otherwise we expect to have the buzzer |
306 | // device.. | 306 | // device.. |
307 | if ( snd && snd->isFinished() ){ | 307 | if ( snd && snd->isFinished() ){ |
308 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 308 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
309 | snd->play(); | 309 | snd->play(); |
310 | } else if( !snd ) { | 310 | } else if( !snd ) { |
311 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 311 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
312 | 312 | ||
313 | if ( fd >= 0 ) { | 313 | if ( fd >= 0 ) { |
314 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 314 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
315 | ::close ( fd ); | 315 | ::close ( fd ); |
316 | } | 316 | } |
317 | 317 | ||
318 | } | 318 | } |
319 | #endif | 319 | #endif |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void Zaurus::playAlarmSound() | 323 | void Zaurus::playAlarmSound() |
324 | { | 324 | { |
325 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 325 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void Zaurus::playTouchSound() | 328 | void Zaurus::playTouchSound() |
329 | { | 329 | { |
330 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 330 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
331 | } | 331 | } |
332 | 332 | ||
333 | void Zaurus::playKeySound() | 333 | void Zaurus::playKeySound() |
334 | { | 334 | { |
335 | buzzer( SHARP_BUZ_KEYSOUND ); | 335 | buzzer( SHARP_BUZ_KEYSOUND ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | QValueList <OLed> Zaurus::ledList() const | 339 | QValueList <OLed> Zaurus::ledList() const |
340 | { | 340 | { |
341 | QValueList <OLed> vl; | 341 | QValueList <OLed> vl; |
342 | vl << Led_Mail; | 342 | vl << Led_Mail; |
343 | return vl; | 343 | return vl; |
344 | } | 344 | } |
345 | 345 | ||
346 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 346 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
347 | { | 347 | { |
348 | QValueList <OLedState> vl; | 348 | QValueList <OLedState> vl; |
349 | 349 | ||
350 | if ( l == Led_Mail ) | 350 | if ( l == Led_Mail ) |
351 | vl << Led_Off << Led_On << Led_BlinkSlow; | 351 | vl << Led_Off << Led_On << Led_BlinkSlow; |
352 | return vl; | 352 | return vl; |
353 | } | 353 | } |
354 | 354 | ||
355 | OLedState Zaurus::ledState( OLed which ) const | 355 | OLedState Zaurus::ledState( OLed which ) const |
356 | { | 356 | { |
357 | if ( which == Led_Mail ) | 357 | if ( which == Led_Mail ) |
358 | return m_leds [0]; | 358 | return m_leds [0]; |
359 | else | 359 | else |
360 | return Led_Off; | 360 | return Led_Off; |
361 | } | 361 | } |
362 | 362 | ||
363 | bool Zaurus::setLedState( OLed which, OLedState st ) | 363 | bool Zaurus::setLedState( OLed which, OLedState st ) |
364 | { | 364 | { |
365 | // Currently not supported on non_embedix kernels | 365 | // Currently not supported on non_embedix kernels |
366 | if (!m_embedix) | 366 | if (!m_embedix) |
367 | { | 367 | { |
368 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 368 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
369 | return false; | 369 | return false; |
370 | } | 370 | } |
371 | 371 | ||
372 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 372 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
373 | 373 | ||
374 | if ( which == Led_Mail ) { | 374 | if ( which == Led_Mail ) { |
375 | if ( fd >= 0 ) { | 375 | if ( fd >= 0 ) { |
376 | struct sharp_led_status leds; | 376 | struct sharp_led_status leds; |
377 | ::memset ( &leds, 0, sizeof( leds )); | 377 | ::memset ( &leds, 0, sizeof( leds )); |
378 | leds. which = SHARP_LED_MAIL_EXISTS; | 378 | leds. which = SHARP_LED_MAIL_EXISTS; |
379 | bool ok = true; | 379 | bool ok = true; |
380 | 380 | ||
381 | switch ( st ) { | 381 | switch ( st ) { |
382 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 382 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
383 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 383 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
384 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 384 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
385 | default : ok = false; | 385 | default : ok = false; |
386 | } | 386 | } |
387 | 387 | ||
388 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 388 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
389 | m_leds [0] = st; | 389 | m_leds [0] = st; |
390 | return true; | 390 | return true; |
391 | } | 391 | } |
392 | } | 392 | } |
393 | } | 393 | } |
394 | return false; | 394 | return false; |
395 | } | 395 | } |
396 | 396 | ||
397 | int Zaurus::displayBrightnessResolution() const | 397 | int Zaurus::displayBrightnessResolution() const |
398 | { | 398 | { |
399 | int res = 1; | 399 | int res = 1; |
400 | if (m_embedix) | 400 | if (m_embedix) |
401 | { | 401 | { |
402 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 402 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
403 | if ( fd ) | 403 | if ( fd ) |
404 | { | 404 | { |
405 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 405 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
406 | ::close( fd ); | 406 | ::close( fd ); |
407 | return value ? value : res; | 407 | return value ? value : res; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | else | 410 | else |
411 | { | 411 | { |
412 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); | 412 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); |
413 | if ( fd ) | 413 | if ( fd ) |
414 | { | 414 | { |
415 | char buf[100]; | 415 | char buf[100]; |
416 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 416 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
417 | ::close( fd ); | 417 | ::close( fd ); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | return res; | 420 | return res; |
421 | } | 421 | } |
422 | 422 | ||
423 | bool Zaurus::setDisplayBrightness( int bright ) | 423 | bool Zaurus::setDisplayBrightness( int bright ) |
424 | { | 424 | { |
425 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 425 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
426 | bool res = false; | 426 | bool res = false; |
427 | 427 | ||
428 | if ( bright > 255 ) bright = 255; | 428 | if ( bright > 255 ) bright = 255; |
429 | if ( bright < 0 ) bright = 0; | 429 | if ( bright < 0 ) bright = 0; |
430 | 430 | ||
431 | int numberOfSteps = displayBrightnessResolution(); | 431 | int numberOfSteps = displayBrightnessResolution(); |
432 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 432 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
433 | 433 | ||
434 | if ( m_embedix ) | 434 | if ( m_embedix ) |
435 | { | 435 | { |
436 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 436 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
437 | if ( fd ) | 437 | if ( fd ) |
438 | { | 438 | { |
439 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 439 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
440 | ::close( fd ); | 440 | ::close( fd ); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | else | 443 | else |
444 | { | 444 | { |
445 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); | 445 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); |
446 | if ( fd ) | 446 | if ( fd ) |
447 | { | 447 | { |
448 | char buf[100]; | 448 | char buf[100]; |
449 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 449 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
450 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 450 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
451 | ::close( fd ); | 451 | ::close( fd ); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | return res; | 454 | return res; |
455 | } | 455 | } |
456 | 456 | ||
457 | bool Zaurus::setDisplayStatus( bool on ) | 457 | bool Zaurus::setDisplayStatus( bool on ) |
458 | { | 458 | { |
459 | bool res = false; | 459 | bool res = false; |
460 | if ( m_embedix ) | 460 | if ( m_embedix ) |
461 | { | 461 | { |
462 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 462 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
463 | if ( fd ) | 463 | if ( fd ) |
464 | { | 464 | { |
465 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 465 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
466 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 466 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
467 | ::close ( fd ); | 467 | ::close ( fd ); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | else | 470 | else |
471 | { | 471 | { |
472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
473 | if ( fd ) | 473 | if ( fd ) |
474 | { | 474 | { |
475 | char buf[10]; | 475 | char buf[10]; |
476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
477 | buf[1] = '\0'; | 477 | buf[1] = '\0'; |
478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
479 | ::close( fd ); | 479 | ::close( fd ); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | return res; | 482 | return res; |
483 | } | 483 | } |
484 | 484 | ||
485 | bool Zaurus::suspend() | 485 | bool Zaurus::suspend() |
486 | { | 486 | { |
487 | qDebug("ODevice::suspend"); | 487 | qDebug("ODevice::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; |
495 | ODevice::sendSuspendmsg(); | 495 | ODevice::sendSuspendmsg(); |
496 | 496 | ||
497 | struct timeval tvs, tvn; | 497 | struct timeval tvs, tvn; |
498 | ::gettimeofday ( &tvs, 0 ); | 498 | ::gettimeofday ( &tvs, 0 ); |
499 | 499 | ||
500 | ::sync(); // flush fs caches | 500 | ::sync(); // flush fs caches |
501 | res = ( ::system ( "apm --suspend" ) == 0 ); | 501 | res = ( ::system ( "apm --suspend" ) == 0 ); |
502 | 502 | ||
503 | // This is needed because the apm implementation is asynchronous and we | 503 | // This is needed because the apm implementation is asynchronous and we |
504 | // can not be sure when exactly the device is really suspended | 504 | // can not be sure when exactly the device is really suspended |
505 | if ( res ) { | 505 | if ( res ) { |
506 | do { // Yes, wait 15 seconds. This APM sucks big time. | 506 | do { // Yes, wait 15 seconds. This APM sucks big time. |
507 | ::usleep ( 200 * 1000 ); | 507 | ::usleep ( 200 * 1000 ); |
508 | ::gettimeofday ( &tvn, 0 ); | 508 | ::gettimeofday ( &tvn, 0 ); |
509 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 509 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
510 | } | 510 | } |
511 | 511 | ||
512 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 512 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
513 | return res; | 513 | return res; |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | Transformation Zaurus::rotation() const | 517 | Transformation Zaurus::rotation() const |
518 | { | 518 | { |
519 | qDebug( "Zaurus::rotation()" ); | 519 | qDebug( "Zaurus::rotation()" ); |
520 | Transformation rot; | 520 | Transformation rot; |
521 | 521 | ||
522 | switch ( d->m_model ) { | 522 | switch ( d->m_model ) { |
523 | case Model_Zaurus_SLC3000: // fallthrough | 523 | case Model_Zaurus_SLC3000: // fallthrough |
524 | case Model_Zaurus_SLC7x0: | 524 | case Model_Zaurus_SLC7x0: |
525 | { | 525 | { |
526 | OHingeStatus hs = readHingeSensor(); | 526 | OHingeStatus hs = readHingeSensor(); |
527 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 527 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
528 | 528 | ||
529 | if ( m_embedix ) | 529 | if ( m_embedix ) |
530 | { | 530 | { |
531 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 531 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
532 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 532 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
533 | else rot = Rot270; | 533 | else rot = Rot270; |
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 | } |
541 | } | 541 | } |
542 | break; | 542 | break; |
543 | case Model_Zaurus_SL6000: | 543 | case Model_Zaurus_SL6000: |
544 | case Model_Zaurus_SLB600: | 544 | case Model_Zaurus_SLB600: |
545 | case Model_Zaurus_SLA300: | 545 | case Model_Zaurus_SLA300: |
546 | case Model_Zaurus_SL5500: | 546 | case Model_Zaurus_SL5500: |
547 | case Model_Zaurus_SL5000: | 547 | case Model_Zaurus_SL5000: |
548 | default: | 548 | default: |
549 | rot = d->m_rotation; | 549 | rot = d->m_rotation; |
550 | break; | 550 | break; |
551 | } | 551 | } |
552 | 552 | ||
553 | return rot; | 553 | return rot; |
554 | } | 554 | } |
555 | ODirection Zaurus::direction() const | 555 | ODirection Zaurus::direction() const |
556 | { | 556 | { |
557 | ODirection dir; | 557 | ODirection dir; |
558 | 558 | ||
559 | switch ( d->m_model ) { | 559 | switch ( d->m_model ) { |
560 | case Model_Zaurus_SLC3000: // fallthrough | 560 | case Model_Zaurus_SLC3000: // fallthrough |
561 | case Model_Zaurus_SLC7x0: { | 561 | case Model_Zaurus_SLC7x0: { |
562 | OHingeStatus hs = readHingeSensor(); | 562 | OHingeStatus hs = readHingeSensor(); |
563 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 563 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
564 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 564 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
565 | else dir = CW; | 565 | else dir = CW; |
566 | } | 566 | } |
567 | break; | 567 | break; |
568 | case Model_Zaurus_SL6000: | 568 | case Model_Zaurus_SL6000: |
569 | case Model_Zaurus_SLA300: | 569 | case Model_Zaurus_SLA300: |
570 | case Model_Zaurus_SLB600: | 570 | case Model_Zaurus_SLB600: |
571 | case Model_Zaurus_SL5500: | 571 | case Model_Zaurus_SL5500: |
572 | case Model_Zaurus_SL5000: | 572 | case Model_Zaurus_SL5000: |
573 | default: dir = d->m_direction; | 573 | default: dir = d->m_direction; |
574 | break; | 574 | break; |
575 | } | 575 | } |
576 | return dir; | 576 | return dir; |
577 | 577 | ||
578 | } | 578 | } |
579 | 579 | ||
580 | bool Zaurus::hasHingeSensor() const | 580 | bool Zaurus::hasHingeSensor() const |
581 | { | 581 | { |
582 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; | 582 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
583 | } | 583 | } |
584 | 584 | ||
585 | OHingeStatus Zaurus::readHingeSensor() const | 585 | OHingeStatus Zaurus::readHingeSensor() const |
586 | { | 586 | { |
587 | if (m_embedix) | 587 | if (m_embedix) |
588 | { | 588 | { |
589 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 589 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
590 | if (handle == -1) | 590 | if (handle == -1) |
591 | { | 591 | { |
592 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 592 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
593 | return CASE_UNKNOWN; | 593 | return CASE_UNKNOWN; |
594 | } | 594 | } |
595 | else | 595 | else |
596 | { | 596 | { |
597 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 597 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
598 | ::close (handle); | 598 | ::close (handle); |
599 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 599 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
600 | { | 600 | { |
601 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 601 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
602 | return static_cast<OHingeStatus>( retval ); | 602 | return static_cast<OHingeStatus>( retval ); |
603 | } | 603 | } |
604 | else | 604 | else |
605 | { | 605 | { |
606 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 606 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
607 | return CASE_UNKNOWN; | 607 | return CASE_UNKNOWN; |
608 | } | 608 | } |
609 | } | 609 | } |
610 | } | 610 | } |
611 | else | 611 | else |
612 | { | 612 | { |
613 | // corgi keyboard is event source 0 in OZ kernel 2.6 | 613 | // corgi keyboard is event source 0 in OZ kernel 2.6 |
614 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 614 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
615 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; | 615 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; |
616 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; | 616 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; |
617 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; | 617 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; |
618 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 618 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
619 | return CASE_UNKNOWN; | 619 | return CASE_UNKNOWN; |
620 | } | 620 | } |
621 | } | 621 | } |