author | mickeyl <mickeyl> | 2005-06-26 12:27:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-06-26 12:27:37 (UTC) |
commit | b4d2fa56d4b4608656f6b5cf3ff9375708395e91 (patch) (unidiff) | |
tree | 7b087a487929d9b0f9de67860b9fe123773239f0 | |
parent | 53f924947144ddbb3e15d3bd1ddc877073c7ec7f (diff) | |
download | opie-b4d2fa56d4b4608656f6b5cf3ff9375708395e91.zip opie-b4d2fa56d4b4608656f6b5cf3ff9375708395e91.tar.gz opie-b4d2fa56d4b4608656f6b5cf3ff9375708395e91.tar.bz2 |
ODevice now features a method to gather the preferred qte driver.
The default driver is "Transformed". C7x0 Zaurus devices use "W100" from now on.
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 6 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 6 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 17 |
3 files changed, 24 insertions, 5 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 5e91d8b..56f305f 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,660 +1,666 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> | 3 | =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #include "odevice_beagle.h" | 31 | #include "odevice_beagle.h" |
32 | #include "odevice_ipaq.h" | 32 | #include "odevice_ipaq.h" |
33 | #include "odevice_jornada.h" | 33 | #include "odevice_jornada.h" |
34 | #include "odevice_ramses.h" | 34 | #include "odevice_ramses.h" |
35 | #include "odevice_simpad.h" | 35 | #include "odevice_simpad.h" |
36 | #include "odevice_yopy.h" | 36 | #include "odevice_yopy.h" |
37 | #include "odevice_zaurus.h" | 37 | #include "odevice_zaurus.h" |
38 | #include "odevice_genuineintel.h" | 38 | #include "odevice_genuineintel.h" |
39 | 39 | ||
40 | /* QT */ | 40 | /* QT */ |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
44 | #include <qwindowsystem_qws.h> | 44 | #include <qwindowsystem_qws.h> |
45 | 45 | ||
46 | /* OPIE */ | 46 | /* OPIE */ |
47 | #include <qpe/config.h> | 47 | #include <qpe/config.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 | 51 | ||
52 | #include <opie2/okeyfilter.h> | 52 | #include <opie2/okeyfilter.h> |
53 | #include <opie2/oresource.h> | 53 | #include <opie2/oresource.h> |
54 | 54 | ||
55 | /* STD */ | 55 | /* STD */ |
56 | #include <fcntl.h> | 56 | #include <fcntl.h> |
57 | #include <math.h> | 57 | #include <math.h> |
58 | #include <stdlib.h> | 58 | #include <stdlib.h> |
59 | #include <signal.h> | 59 | #include <signal.h> |
60 | #include <sys/ioctl.h> | 60 | #include <sys/ioctl.h> |
61 | #include <sys/time.h> | 61 | #include <sys/time.h> |
62 | #include <unistd.h> | 62 | #include <unistd.h> |
63 | #ifndef QT_NO_SOUND | 63 | #ifndef QT_NO_SOUND |
64 | #include <linux/soundcard.h> | 64 | #include <linux/soundcard.h> |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | namespace Opie { | 67 | namespace Opie { |
68 | namespace Core { | 68 | namespace Core { |
69 | 69 | ||
70 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 70 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
71 | 71 | ||
72 | 72 | ||
73 | /* STATIC and common implementation */ | 73 | /* STATIC and common implementation */ |
74 | /* EXPORT */ ODistribution distributions[] = { | 74 | /* EXPORT */ ODistribution distributions[] = { |
75 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 75 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
76 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 76 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
77 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 77 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
78 | { System_Unknown, "Linux", "/etc/issue" }, | 78 | { System_Unknown, "Linux", "/etc/issue" }, |
79 | }; | 79 | }; |
80 | 80 | ||
81 | 81 | ||
82 | /* EXPORT */ bool isQWS(){ | 82 | /* EXPORT */ bool isQWS(){ |
83 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 83 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
84 | } | 84 | } |
85 | 85 | ||
86 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 86 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
87 | if ( str && !::strchr ( str, '/' )) | 87 | if ( str && !::strchr ( str, '/' )) |
88 | return QCString ( "QPE/Application/" ) + str; | 88 | return QCString ( "QPE/Application/" ) + str; |
89 | else | 89 | else |
90 | return str; | 90 | return str; |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | 94 | ||
95 | /* Now the default implementation of ODevice */ | 95 | /* Now the default implementation of ODevice */ |
96 | 96 | ||
97 | struct default_button default_buttons [] = { | 97 | struct default_button default_buttons [] = { |
98 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 98 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
99 | "devicebuttons/z_calendar", | 99 | "devicebuttons/z_calendar", |
100 | "datebook", "nextView()", | 100 | "datebook", "nextView()", |
101 | "today", "raise()" }, | 101 | "today", "raise()" }, |
102 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 102 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
103 | "devicebuttons/z_contact", | 103 | "devicebuttons/z_contact", |
104 | "addressbook", "raise()", | 104 | "addressbook", "raise()", |
105 | "addressbook", "beamBusinessCard()" }, | 105 | "addressbook", "beamBusinessCard()" }, |
106 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 106 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
107 | "devicebuttons/z_home", | 107 | "devicebuttons/z_home", |
108 | "QPE/Launcher", "home()", | 108 | "QPE/Launcher", "home()", |
109 | "buttonsettings", "raise()" }, | 109 | "buttonsettings", "raise()" }, |
110 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 110 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
111 | "devicebuttons/z_menu", | 111 | "devicebuttons/z_menu", |
112 | "QPE/TaskBar", "toggleMenu()", | 112 | "QPE/TaskBar", "toggleMenu()", |
113 | "QPE/TaskBar", "toggleStartMenu()" }, | 113 | "QPE/TaskBar", "toggleStartMenu()" }, |
114 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 114 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
115 | "devicebuttons/z_mail", | 115 | "devicebuttons/z_mail", |
116 | "opiemail", "raise()", | 116 | "opiemail", "raise()", |
117 | "opiemail", "newMail()" }, | 117 | "opiemail", "newMail()" }, |
118 | }; | 118 | }; |
119 | 119 | ||
120 | ODevice *ODevice::inst() | 120 | ODevice *ODevice::inst() |
121 | { | 121 | { |
122 | static ODevice *dev = 0; | 122 | static ODevice *dev = 0; |
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 | d->m_qteDriver = "Transformed"; | ||
180 | 181 | ||
181 | d->m_holdtime = 1000; // 1000ms | 182 | d->m_holdtime = 1000; // 1000ms |
182 | d->m_buttons = 0; | 183 | d->m_buttons = 0; |
183 | d->m_cpu_frequencies = new QStrList; | 184 | d->m_cpu_frequencies = new QStrList; |
184 | 185 | ||
185 | 186 | ||
186 | /* mixer */ | 187 | /* mixer */ |
187 | d->m_sound = d->m_vol = d->m_mixer = -1; | 188 | d->m_sound = d->m_vol = d->m_mixer = -1; |
188 | 189 | ||
189 | /* System QCopChannel created */ | 190 | /* System QCopChannel created */ |
190 | d->m_initializedButtonQcop = false; | 191 | d->m_initializedButtonQcop = false; |
191 | 192 | ||
192 | // New distribution detection code first checks for legacy distributions, | 193 | // New distribution detection code first checks for legacy distributions, |
193 | // identified by /etc/familiar-version or /etc/oz_version. | 194 | // identified by /etc/familiar-version or /etc/oz_version. |
194 | // Then check for OpenEmbedded and lastly, read /etc/issue | 195 | // Then check for OpenEmbedded and lastly, read /etc/issue |
195 | 196 | ||
196 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) | 197 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) |
197 | { | 198 | { |
198 | if ( QFile::exists( distributions[i].sysvfile ) ) | 199 | if ( QFile::exists( distributions[i].sysvfile ) ) |
199 | { | 200 | { |
200 | d->m_systemstr = distributions[i].sysstr; | 201 | d->m_systemstr = distributions[i].sysstr; |
201 | d->m_system = distributions[i].system; | 202 | d->m_system = distributions[i].system; |
202 | d->m_sysverstr = "<Unknown>"; | 203 | d->m_sysverstr = "<Unknown>"; |
203 | QFile f( distributions[i].sysvfile ); | 204 | QFile f( distributions[i].sysvfile ); |
204 | if ( f.open( IO_ReadOnly ) ) | 205 | if ( f.open( IO_ReadOnly ) ) |
205 | { | 206 | { |
206 | QTextStream ts( &f ); | 207 | QTextStream ts( &f ); |
207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 208 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
208 | } | 209 | } |
209 | break; | 210 | break; |
210 | } | 211 | } |
211 | } | 212 | } |
212 | } | 213 | } |
213 | 214 | ||
214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 215 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
215 | { | 216 | { |
216 | if ( msg == "deviceButtonMappingChanged()" ) { | 217 | if ( msg == "deviceButtonMappingChanged()" ) { |
217 | reloadButtonMapping(); | 218 | reloadButtonMapping(); |
218 | } | 219 | } |
219 | } | 220 | } |
220 | 221 | ||
221 | void ODevice::init(const QString&) | 222 | void ODevice::init(const QString&) |
222 | { | 223 | { |
223 | } | 224 | } |
224 | 225 | ||
225 | /** | 226 | /** |
226 | * This method initialises the button mapping | 227 | * This method initialises the button mapping |
227 | */ | 228 | */ |
228 | void ODevice::initButtons() | 229 | void ODevice::initButtons() |
229 | { | 230 | { |
230 | if ( d->m_buttons ) | 231 | if ( d->m_buttons ) |
231 | return; | 232 | return; |
232 | 233 | ||
233 | qDebug ( "init Buttons" ); | 234 | qDebug ( "init Buttons" ); |
234 | d->m_buttons = new QValueList <ODeviceButton>; | 235 | d->m_buttons = new QValueList <ODeviceButton>; |
235 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 236 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
236 | default_button *db = default_buttons + i; | 237 | default_button *db = default_buttons + i; |
237 | ODeviceButton b; | 238 | ODeviceButton b; |
238 | b. setKeycode ( db->code ); | 239 | b. setKeycode ( db->code ); |
239 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 240 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
240 | b. setPixmap ( OResource::loadPixmap ( db->pix )); | 241 | b. setPixmap ( OResource::loadPixmap ( db->pix )); |
241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 242 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 243 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
243 | d->m_buttons->append ( b ); | 244 | d->m_buttons->append ( b ); |
244 | } | 245 | } |
245 | 246 | ||
246 | reloadButtonMapping(); | 247 | reloadButtonMapping(); |
247 | } | 248 | } |
248 | 249 | ||
249 | ODevice::~ODevice() | 250 | ODevice::~ODevice() |
250 | { | 251 | { |
251 | // we leak m_devicebuttons and m_cpu_frequency | 252 | // we leak m_devicebuttons and m_cpu_frequency |
252 | // but it's a singleton and it is not so importantant | 253 | // but it's a singleton and it is not so importantant |
253 | // -zecke | 254 | // -zecke |
254 | delete d; | 255 | delete d; |
255 | } | 256 | } |
256 | 257 | ||
257 | /** | 258 | /** |
258 | * This method will try to suspend the device | 259 | * This method will try to suspend the device |
259 | * It only works if the user is the QWS Server and the apm application | 260 | * It only works if the user is the QWS Server and the apm application |
260 | * is installed. | 261 | * is installed. |
261 | * It tries to suspend and then waits some time cause some distributions | 262 | * It tries to suspend and then waits some time cause some distributions |
262 | * do have asynchronus apm implementations. | 263 | * do have asynchronus apm implementations. |
263 | * This method will either fail and return false or it'll suspend the | 264 | * This method will either fail and return false or it'll suspend the |
264 | * device and return once the device got woken up | 265 | * device and return once the device got woken up |
265 | * | 266 | * |
266 | * @return if the device got suspended | 267 | * @return if the device got suspended |
267 | */ | 268 | */ |
268 | bool ODevice::suspend() | 269 | bool ODevice::suspend() |
269 | { | 270 | { |
270 | return false; // default implementation == unknown device or qvfb | 271 | return false; // default implementation == unknown device or qvfb |
271 | } | 272 | } |
272 | 273 | ||
273 | /** | 274 | /** |
274 | * This sets the display on or off | 275 | * This sets the display on or off |
275 | */ | 276 | */ |
276 | bool ODevice::setDisplayStatus( bool on ) | 277 | bool ODevice::setDisplayStatus( bool on ) |
277 | { | 278 | { |
278 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); | 279 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); |
279 | return false; // don't do anything for unknown models | 280 | return false; // don't do anything for unknown models |
280 | } | 281 | } |
281 | 282 | ||
282 | /** | 283 | /** |
283 | * This sets the display brightness | 284 | * This sets the display brightness |
284 | * | 285 | * |
285 | * @param b The brightness to be set on a scale from 0 to 255 | 286 | * @param b The brightness to be set on a scale from 0 to 255 |
286 | * @return success or failure | 287 | * @return success or failure |
287 | */ | 288 | */ |
288 | bool ODevice::setDisplayBrightness( int b ) | 289 | bool ODevice::setDisplayBrightness( int b ) |
289 | { | 290 | { |
290 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); | 291 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); |
291 | return false; | 292 | return false; |
292 | } | 293 | } |
293 | 294 | ||
294 | /** | 295 | /** |
295 | * | 296 | * |
296 | * @returns the number of steppings on the brightness slider | 297 | * @returns the number of steppings on the brightness slider |
297 | * in the Light-'n-Power settings. Values smaller than zero and bigger | 298 | * in the Light-'n-Power settings. Values smaller than zero and bigger |
298 | * than 255 do not make sense. | 299 | * than 255 do not make sense. |
299 | * | 300 | * |
300 | * \sa QSlider::setLineStep | 301 | * \sa QSlider::setLineStep |
301 | * \sa QSlider::setPageStep | 302 | * \sa QSlider::setPageStep |
302 | */ | 303 | */ |
303 | int ODevice::displayBrightnessResolution() const | 304 | int ODevice::displayBrightnessResolution() const |
304 | { | 305 | { |
305 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 306 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
306 | return 16; | 307 | return 16; |
307 | } | 308 | } |
308 | 309 | ||
309 | /** | 310 | /** |
310 | * This sets the display contrast | 311 | * This sets the display contrast |
311 | * @param p The contrast to be set on a scale from 0 to 255 | 312 | * @param p The contrast to be set on a scale from 0 to 255 |
312 | * @returns success or failure | 313 | * @returns success or failure |
313 | */ | 314 | */ |
314 | bool ODevice::setDisplayContrast( int p ) | 315 | bool ODevice::setDisplayContrast( int p ) |
315 | { | 316 | { |
316 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); | 317 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); |
317 | return false; | 318 | return false; |
318 | } | 319 | } |
319 | 320 | ||
320 | /** | 321 | /** |
321 | * @returns the maximum value for the contrast settings slider | 322 | * @returns the maximum value for the contrast settings slider |
322 | * or 0 if the device doesn't support setting of a contrast | 323 | * or 0 if the device doesn't support setting of a contrast |
323 | */ | 324 | */ |
324 | int ODevice::displayContrastResolution() const | 325 | int ODevice::displayContrastResolution() const |
325 | { | 326 | { |
326 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 327 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
327 | return 0; | 328 | return 0; |
328 | } | 329 | } |
329 | 330 | ||
330 | /** | 331 | /** |
331 | * This returns the vendor as string | 332 | * This returns the vendor as string |
332 | * @return Vendor as QString | 333 | * @return Vendor as QString |
333 | */ | 334 | */ |
334 | QString ODevice::vendorString() const | 335 | QString ODevice::vendorString() const |
335 | { | 336 | { |
336 | return d->m_vendorstr; | 337 | return d->m_vendorstr; |
337 | } | 338 | } |
338 | 339 | ||
339 | /** | 340 | /** |
340 | * This returns the vendor as one of the values of OVendor | 341 | * This returns the vendor as one of the values of OVendor |
341 | * @return OVendor | 342 | * @return OVendor |
342 | */ | 343 | */ |
343 | OVendor ODevice::vendor() const | 344 | OVendor ODevice::vendor() const |
344 | { | 345 | { |
345 | return d->m_vendor; | 346 | return d->m_vendor; |
346 | } | 347 | } |
347 | 348 | ||
348 | /** | 349 | /** |
349 | * This returns the model as a string | 350 | * This returns the model as a string |
350 | * @return A string representing the model | 351 | * @return A string representing the model |
351 | */ | 352 | */ |
352 | QString ODevice::modelString() const | 353 | QString ODevice::modelString() const |
353 | { | 354 | { |
354 | return d->m_modelstr; | 355 | return d->m_modelstr; |
355 | } | 356 | } |
356 | 357 | ||
357 | /** | 358 | /** |
358 | * This does return the OModel used | 359 | * This does return the OModel used |
359 | */ | 360 | */ |
360 | OModel ODevice::model() const | 361 | OModel ODevice::model() const |
361 | { | 362 | { |
362 | return d->m_model; | 363 | return d->m_model; |
363 | } | 364 | } |
364 | 365 | ||
365 | /** | 366 | /** |
366 | * This does return the systen name | 367 | * This does return the systen name |
367 | */ | 368 | */ |
368 | QString ODevice::systemString() const | 369 | QString ODevice::systemString() const |
369 | { | 370 | { |
370 | return d->m_systemstr; | 371 | return d->m_systemstr; |
371 | } | 372 | } |
372 | 373 | ||
373 | /** | 374 | /** |
374 | * Return System as OSystem value | 375 | * Return System as OSystem value |
375 | */ | 376 | */ |
376 | OSystem ODevice::system() const | 377 | OSystem ODevice::system() const |
377 | { | 378 | { |
378 | return d->m_system; | 379 | return d->m_system; |
379 | } | 380 | } |
380 | 381 | ||
381 | /** | 382 | /** |
382 | * @return the version string of the base system | 383 | * @return the version string of the base system |
383 | */ | 384 | */ |
384 | QString ODevice::systemVersionString() const | 385 | QString ODevice::systemVersionString() const |
385 | { | 386 | { |
386 | return d->m_sysverstr; | 387 | return d->m_sysverstr; |
387 | } | 388 | } |
388 | 389 | ||
389 | /** | 390 | /** |
390 | * @return the current Transformation | 391 | * @return the current Transformation |
391 | */ | 392 | */ |
392 | Transformation ODevice::rotation() const | 393 | Transformation ODevice::rotation() const |
393 | { | 394 | { |
394 | return d->m_rotation; | 395 | return d->m_rotation; |
395 | } | 396 | } |
396 | 397 | ||
397 | /** | 398 | /** |
398 | * @return the current rotation direction | 399 | * @return the current rotation direction |
399 | */ | 400 | */ |
400 | ODirection ODevice::direction() const | 401 | ODirection ODevice::direction() const |
401 | { | 402 | { |
402 | return d->m_direction; | 403 | return d->m_direction; |
403 | } | 404 | } |
404 | 405 | ||
406 | QString ODevice::qteDriver() const | ||
407 | { | ||
408 | return d->m_qteDriver; | ||
409 | } | ||
410 | |||
405 | /** | 411 | /** |
406 | * This plays an alarm sound | 412 | * This plays an alarm sound |
407 | */ | 413 | */ |
408 | void ODevice::playAlarmSound() | 414 | void ODevice::playAlarmSound() |
409 | { | 415 | { |
410 | #ifndef QT_NO_SOUND | 416 | #ifndef QT_NO_SOUND |
411 | static Sound snd ( "alarm" ); | 417 | static Sound snd ( "alarm" ); |
412 | 418 | ||
413 | if ( snd. isFinished()) | 419 | if ( snd. isFinished()) |
414 | snd. play(); | 420 | snd. play(); |
415 | #endif | 421 | #endif |
416 | } | 422 | } |
417 | 423 | ||
418 | /** | 424 | /** |
419 | * This plays a key sound | 425 | * This plays a key sound |
420 | */ | 426 | */ |
421 | void ODevice::playKeySound() | 427 | void ODevice::playKeySound() |
422 | { | 428 | { |
423 | #ifndef QT_NO_SOUND | 429 | #ifndef QT_NO_SOUND |
424 | static Sound snd ( "keysound" ); | 430 | static Sound snd ( "keysound" ); |
425 | 431 | ||
426 | if ( snd. isFinished()) | 432 | if ( snd. isFinished()) |
427 | snd. play(); | 433 | snd. play(); |
428 | #endif | 434 | #endif |
429 | } | 435 | } |
430 | 436 | ||
431 | /** | 437 | /** |
432 | * This plays a touch sound | 438 | * This plays a touch sound |
433 | */ | 439 | */ |
434 | void ODevice::playTouchSound() | 440 | void ODevice::playTouchSound() |
435 | { | 441 | { |
436 | #ifndef QT_NO_SOUND | 442 | #ifndef QT_NO_SOUND |
437 | static Sound snd ( "touchsound" ); | 443 | static Sound snd ( "touchsound" ); |
438 | 444 | ||
439 | if ( snd. isFinished()) | 445 | if ( snd. isFinished()) |
440 | snd. play(); | 446 | snd. play(); |
441 | #endif | 447 | #endif |
442 | } | 448 | } |
443 | 449 | ||
444 | /** | 450 | /** |
445 | * This method will return a list of leds | 451 | * This method will return a list of leds |
446 | * available on this device | 452 | * available on this device |
447 | * @return a list of LEDs. | 453 | * @return a list of LEDs. |
448 | */ | 454 | */ |
449 | QValueList <OLed> ODevice::ledList() const | 455 | QValueList <OLed> ODevice::ledList() const |
450 | { | 456 | { |
451 | return QValueList <OLed>(); | 457 | return QValueList <OLed>(); |
452 | } | 458 | } |
453 | 459 | ||
454 | /** | 460 | /** |
455 | * This does return the state of the LEDs | 461 | * This does return the state of the LEDs |
456 | */ | 462 | */ |
457 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 463 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
458 | { | 464 | { |
459 | return QValueList <OLedState>(); | 465 | return QValueList <OLedState>(); |
460 | } | 466 | } |
461 | 467 | ||
462 | /** | 468 | /** |
463 | * @return the state for a given OLed | 469 | * @return the state for a given OLed |
464 | */ | 470 | */ |
465 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 471 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
466 | { | 472 | { |
467 | return Led_Off; | 473 | return Led_Off; |
468 | } | 474 | } |
469 | 475 | ||
470 | /** | 476 | /** |
471 | * Set the state for a LED | 477 | * Set the state for a LED |
472 | * @param which Which OLed to use | 478 | * @param which Which OLed to use |
473 | * @param st The state to set | 479 | * @param st The state to set |
474 | * @return success or failure | 480 | * @return success or failure |
475 | */ | 481 | */ |
476 | bool ODevice::setLedState ( OLed which, OLedState st ) | 482 | bool ODevice::setLedState ( OLed which, OLedState st ) |
477 | { | 483 | { |
478 | Q_UNUSED( which ) | 484 | Q_UNUSED( which ) |
479 | Q_UNUSED( st ) | 485 | Q_UNUSED( st ) |
480 | return false; | 486 | return false; |
481 | } | 487 | } |
482 | 488 | ||
483 | /** | 489 | /** |
484 | * @return if the device has a light sensor | 490 | * @return if the device has a light sensor |
485 | */ | 491 | */ |
486 | bool ODevice::hasLightSensor() const | 492 | bool ODevice::hasLightSensor() const |
487 | { | 493 | { |
488 | return false; | 494 | return false; |
489 | } | 495 | } |
490 | 496 | ||
491 | /** | 497 | /** |
492 | * @return a value from the light sensor | 498 | * @return a value from the light sensor |
493 | */ | 499 | */ |
494 | int ODevice::readLightSensor() | 500 | int ODevice::readLightSensor() |
495 | { | 501 | { |
496 | return -1; | 502 | return -1; |
497 | } | 503 | } |
498 | 504 | ||
499 | /** | 505 | /** |
500 | * @return the light sensor resolution | 506 | * @return the light sensor resolution |
501 | */ | 507 | */ |
502 | int ODevice::lightSensorResolution() const | 508 | int ODevice::lightSensorResolution() const |
503 | { | 509 | { |
504 | return 0; | 510 | return 0; |
505 | } | 511 | } |
506 | 512 | ||
507 | /** | 513 | /** |
508 | * @return if the device has a hinge sensor | 514 | * @return if the device has a hinge sensor |
509 | */ | 515 | */ |
510 | bool ODevice::hasHingeSensor() const | 516 | bool ODevice::hasHingeSensor() const |
511 | { | 517 | { |
512 | return false; | 518 | return false; |
513 | } | 519 | } |
514 | 520 | ||
515 | /** | 521 | /** |
516 | * @return a value from the hinge sensor | 522 | * @return a value from the hinge sensor |
517 | */ | 523 | */ |
518 | OHingeStatus ODevice::readHingeSensor()const | 524 | OHingeStatus ODevice::readHingeSensor()const |
519 | { | 525 | { |
520 | return CASE_UNKNOWN; | 526 | return CASE_UNKNOWN; |
521 | } | 527 | } |
522 | 528 | ||
523 | /** | 529 | /** |
524 | * @return a list with CPU frequencies supported by the hardware | 530 | * @return a list with CPU frequencies supported by the hardware |
525 | */ | 531 | */ |
526 | const QStrList &ODevice::allowedCpuFrequencies() const | 532 | const QStrList &ODevice::allowedCpuFrequencies() const |
527 | { | 533 | { |
528 | return *d->m_cpu_frequencies; | 534 | return *d->m_cpu_frequencies; |
529 | } | 535 | } |
530 | 536 | ||
531 | 537 | ||
532 | /** | 538 | /** |
533 | * Set desired CPU frequency | 539 | * Set desired CPU frequency |
534 | * | 540 | * |
535 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 541 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
536 | */ | 542 | */ |
537 | bool ODevice::setCurrentCpuFrequency(uint index) | 543 | bool ODevice::setCurrentCpuFrequency(uint index) |
538 | { | 544 | { |
539 | if (index >= d->m_cpu_frequencies->count()) | 545 | if (index >= d->m_cpu_frequencies->count()) |
540 | return false; | 546 | return false; |
541 | 547 | ||
542 | char *freq = d->m_cpu_frequencies->at(index); | 548 | char *freq = d->m_cpu_frequencies->at(index); |
543 | qWarning("set freq to %s", freq); | 549 | qWarning("set freq to %s", freq); |
544 | 550 | ||
545 | int fd; | 551 | int fd; |
546 | 552 | ||
547 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 553 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
548 | char writeCommand[50]; | 554 | char writeCommand[50]; |
549 | const int count = sprintf(writeCommand, "%s\n", freq); | 555 | const int count = sprintf(writeCommand, "%s\n", freq); |
550 | int res = (::write(fd, writeCommand, count) != -1); | 556 | int res = (::write(fd, writeCommand, count) != -1); |
551 | ::close(fd); | 557 | ::close(fd); |
552 | return res; | 558 | return res; |
553 | } | 559 | } |
554 | 560 | ||
555 | return false; | 561 | return false; |
556 | } | 562 | } |
557 | 563 | ||
558 | 564 | ||
559 | /** | 565 | /** |
560 | * @return a list of hardware buttons | 566 | * @return a list of hardware buttons |
561 | */ | 567 | */ |
562 | const QValueList <ODeviceButton> &ODevice::buttons() | 568 | const QValueList <ODeviceButton> &ODevice::buttons() |
563 | { | 569 | { |
564 | initButtons(); | 570 | initButtons(); |
565 | 571 | ||
566 | return *d->m_buttons; | 572 | return *d->m_buttons; |
567 | } | 573 | } |
568 | 574 | ||
569 | /** | 575 | /** |
570 | * @return The amount of time that would count as a hold | 576 | * @return The amount of time that would count as a hold |
571 | */ | 577 | */ |
572 | uint ODevice::buttonHoldTime() const | 578 | uint ODevice::buttonHoldTime() const |
573 | { | 579 | { |
574 | return d->m_holdtime; | 580 | return d->m_holdtime; |
575 | } | 581 | } |
576 | 582 | ||
577 | /** | 583 | /** |
578 | * This method return a ODeviceButton for a key code | 584 | * This method return a ODeviceButton for a key code |
579 | * or 0 if no special hardware button is available for the device | 585 | * or 0 if no special hardware button is available for the device |
580 | * | 586 | * |
581 | * @return The devicebutton or 0l | 587 | * @return The devicebutton or 0l |
582 | * @see ODeviceButton | 588 | * @see ODeviceButton |
583 | */ | 589 | */ |
584 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 590 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
585 | { | 591 | { |
586 | initButtons(); | 592 | initButtons(); |
587 | 593 | ||
588 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 594 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
589 | if ( (*it).keycode() == code ) | 595 | if ( (*it).keycode() == code ) |
590 | return &(*it); | 596 | return &(*it); |
591 | } | 597 | } |
592 | return 0; | 598 | return 0; |
593 | } | 599 | } |
594 | 600 | ||
595 | void ODevice::reloadButtonMapping() | 601 | void ODevice::reloadButtonMapping() |
596 | { | 602 | { |
597 | if(!d->m_buttons) | 603 | if(!d->m_buttons) |
598 | initButtons(); | 604 | initButtons(); |
599 | 605 | ||
600 | if(!d->m_initializedButtonQcop) { | 606 | if(!d->m_initializedButtonQcop) { |
601 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); | 607 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); |
602 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), | 608 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), |
603 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); | 609 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); |
604 | d->m_initializedButtonQcop = true; | 610 | d->m_initializedButtonQcop = true; |
605 | } | 611 | } |
606 | 612 | ||
607 | Config cfg ( "ButtonSettings" ); | 613 | Config cfg ( "ButtonSettings" ); |
608 | 614 | ||
609 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 615 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
610 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 616 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
611 | QString group = "Button" + QString::number ( i ); | 617 | QString group = "Button" + QString::number ( i ); |
612 | 618 | ||
613 | QCString pch, hch; | 619 | QCString pch, hch; |
614 | QCString pm, hm; | 620 | QCString pm, hm; |
615 | QByteArray pdata, hdata; | 621 | QByteArray pdata, hdata; |
616 | 622 | ||
617 | if ( cfg. hasGroup ( group )) { | 623 | if ( cfg. hasGroup ( group )) { |
618 | cfg. setGroup ( group ); | 624 | cfg. setGroup ( group ); |
619 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 625 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
620 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 626 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
621 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 627 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
622 | 628 | ||
623 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 629 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
624 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 630 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
625 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 631 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
626 | } | 632 | } |
627 | 633 | ||
628 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 634 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
629 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 635 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
630 | } | 636 | } |
631 | } | 637 | } |
632 | 638 | ||
633 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 639 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
634 | { | 640 | { |
635 | initButtons(); | 641 | initButtons(); |
636 | 642 | ||
637 | QString mb_chan; | 643 | QString mb_chan; |
638 | 644 | ||
639 | if ( button >= (int) d->m_buttons->count()) | 645 | if ( button >= (int) d->m_buttons->count()) |
640 | return; | 646 | return; |
641 | 647 | ||
642 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 648 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
643 | b. setPressedAction ( action ); | 649 | b. setPressedAction ( action ); |
644 | 650 | ||
645 | mb_chan=b. pressedAction(). channel(); | 651 | mb_chan=b. pressedAction(). channel(); |
646 | 652 | ||
647 | Config buttonFile ( "ButtonSettings" ); | 653 | Config buttonFile ( "ButtonSettings" ); |
648 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 654 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
649 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 655 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
650 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 656 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
651 | 657 | ||
652 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 658 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
653 | 659 | ||
654 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 660 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
655 | } | 661 | } |
656 | 662 | ||
657 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 663 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
658 | { | 664 | { |
659 | initButtons(); | 665 | initButtons(); |
660 | 666 | ||
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 5db43ff..b8478b9 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -1,380 +1,382 @@ | |||
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 | #ifndef ODEVICE_H_ | 30 | #ifndef ODEVICE_H_ |
31 | #define ODEVICE_H_ | 31 | #define ODEVICE_H_ |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odevicebutton.h> | 34 | #include <opie2/odevicebutton.h> |
35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qnamespace.h> | 38 | #include <qnamespace.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | 41 | ||
42 | 42 | ||
43 | #include <qstrlist.h> | 43 | #include <qstrlist.h> |
44 | #include <qwindowsystem_qws.h> | 44 | #include <qwindowsystem_qws.h> |
45 | 45 | ||
46 | 46 | ||
47 | class Sound; | 47 | class Sound; |
48 | 48 | ||
49 | namespace Opie{ | 49 | namespace Opie{ |
50 | namespace Core{ | 50 | namespace Core{ |
51 | 51 | ||
52 | class ODeviceData; | 52 | class ODeviceData; |
53 | /** | 53 | /** |
54 | * The available devices | 54 | * The available devices |
55 | */ | 55 | */ |
56 | enum OModel { | 56 | enum OModel { |
57 | Model_Unknown, // = 0 | 57 | Model_Unknown, // = 0 |
58 | 58 | ||
59 | Model_Series_Mask = 0xff000000, | 59 | Model_Series_Mask = 0xff000000, |
60 | 60 | ||
61 | Model_iPAQ = ( 1 << 24 ), | 61 | Model_iPAQ = ( 1 << 24 ), |
62 | 62 | ||
63 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 63 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), | 69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), |
70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), | 70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), |
71 | 71 | ||
72 | Model_Jornada = ( 6 << 24 ), | 72 | Model_Jornada = ( 6 << 24 ), |
73 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | 73 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), |
74 | Model_Jornada_720 = ( Model_Jornada | 0x000002 ), | 74 | Model_Jornada_720 = ( Model_Jornada | 0x000002 ), |
75 | 75 | ||
76 | Model_Zaurus = ( 2 << 24 ), | 76 | Model_Zaurus = ( 2 << 24 ), |
77 | 77 | ||
78 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 78 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
79 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 79 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
80 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 80 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
81 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 81 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
82 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | 82 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), |
83 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), | 83 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), |
84 | Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ), | 84 | Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ), |
85 | Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x000008 ), | 85 | Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x000008 ), |
86 | 86 | ||
87 | Model_SIMpad = ( 3 << 24 ), | 87 | Model_SIMpad = ( 3 << 24 ), |
88 | 88 | ||
89 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 89 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
90 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 90 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
91 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 91 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
92 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 92 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
93 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 93 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
94 | 94 | ||
95 | Model_Ramses = ( 4 << 24 ), | 95 | Model_Ramses = ( 4 << 24 ), |
96 | 96 | ||
97 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 97 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
98 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 98 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
99 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), | 99 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), |
100 | 100 | ||
101 | Model_Yopy = ( 5 << 24 ), | 101 | Model_Yopy = ( 5 << 24 ), |
102 | 102 | ||
103 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | 103 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), |
104 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | 104 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), |
105 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | 105 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), |
106 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | 106 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), |
107 | 107 | ||
108 | Model_Beagle = ( 6 << 24 ), | 108 | Model_Beagle = ( 6 << 24 ), |
109 | 109 | ||
110 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), | 110 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), |
111 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), | 111 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), |
112 | 112 | ||
113 | Model_GenuineIntel = ( 7 << 24 ) | 113 | Model_GenuineIntel = ( 7 << 24 ) |
114 | 114 | ||
115 | }; | 115 | }; |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * The vendor of the device | 118 | * The vendor of the device |
119 | */ | 119 | */ |
120 | enum OVendor { | 120 | enum OVendor { |
121 | Vendor_Unknown, | 121 | Vendor_Unknown, |
122 | 122 | ||
123 | Vendor_HP, | 123 | Vendor_HP, |
124 | Vendor_Sharp, | 124 | Vendor_Sharp, |
125 | Vendor_SIEMENS, | 125 | Vendor_SIEMENS, |
126 | Vendor_MundN, | 126 | Vendor_MundN, |
127 | Vendor_GMate, | 127 | Vendor_GMate, |
128 | Vendor_MasterIA, | 128 | Vendor_MasterIA, |
129 | Vendor_GenuineIntel | 129 | Vendor_GenuineIntel |
130 | }; | 130 | }; |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * The System used | 133 | * The System used |
134 | */ | 134 | */ |
135 | enum OSystem { | 135 | enum OSystem { |
136 | System_Unknown, | 136 | System_Unknown, |
137 | 137 | ||
138 | System_Familiar, | 138 | System_Familiar, |
139 | System_Zaurus, | 139 | System_Zaurus, |
140 | System_OpenZaurus, | 140 | System_OpenZaurus, |
141 | System_Linupy, | 141 | System_Linupy, |
142 | System_OpenEmbedded, | 142 | System_OpenEmbedded, |
143 | System_PC | 143 | System_PC |
144 | }; | 144 | }; |
145 | 145 | ||
146 | typedef struct { | 146 | typedef struct { |
147 | OSystem system; | 147 | OSystem system; |
148 | char* sysstr; | 148 | char* sysstr; |
149 | char* sysvfile; | 149 | char* sysvfile; |
150 | } ODistribution; | 150 | } ODistribution; |
151 | 151 | ||
152 | extern ODistribution distributions[]; | 152 | extern ODistribution distributions[]; |
153 | 153 | ||
154 | 154 | ||
155 | enum OLedState { | 155 | enum OLedState { |
156 | Led_Off, | 156 | Led_Off, |
157 | Led_On, | 157 | Led_On, |
158 | Led_BlinkSlow, | 158 | Led_BlinkSlow, |
159 | Led_BlinkFast | 159 | Led_BlinkFast |
160 | }; | 160 | }; |
161 | 161 | ||
162 | enum OLed { | 162 | enum OLed { |
163 | Led_Mail, | 163 | Led_Mail, |
164 | Led_Power, | 164 | Led_Power, |
165 | Led_BlueTooth | 165 | Led_BlueTooth |
166 | }; | 166 | }; |
167 | 167 | ||
168 | enum OHardKey { | 168 | enum OHardKey { |
169 | HardKey_Datebook = Qt::Key_F9, | 169 | HardKey_Datebook = Qt::Key_F9, |
170 | HardKey_Contacts = Qt::Key_F10, | 170 | HardKey_Contacts = Qt::Key_F10, |
171 | HardKey_Menu = Qt::Key_F11, | 171 | HardKey_Menu = Qt::Key_F11, |
172 | HardKey_Home = Qt::Key_F12, | 172 | HardKey_Home = Qt::Key_F12, |
173 | HardKey_Mail = Qt::Key_F13, | 173 | HardKey_Mail = Qt::Key_F13, |
174 | HardKey_Record = Qt::Key_F24, | 174 | HardKey_Record = Qt::Key_F24, |
175 | HardKey_Suspend = Qt::Key_F34, | 175 | HardKey_Suspend = Qt::Key_F34, |
176 | HardKey_Backlight = Qt::Key_F35, | 176 | HardKey_Backlight = Qt::Key_F35, |
177 | HardKey_Action = Qt::Key_F10, | 177 | HardKey_Action = Qt::Key_F10, |
178 | HardKey_OK = Qt::Key_F11, | 178 | HardKey_OK = Qt::Key_F11, |
179 | HardKey_End = Qt::Key_F12, | 179 | HardKey_End = Qt::Key_F12, |
180 | }; | 180 | }; |
181 | 181 | ||
182 | enum ODirection { | 182 | enum ODirection { |
183 | CW = 0, | 183 | CW = 0, |
184 | CCW = 1, | 184 | CCW = 1, |
185 | Flip = 2, | 185 | Flip = 2, |
186 | }; | 186 | }; |
187 | 187 | ||
188 | enum OHingeStatus { | 188 | enum OHingeStatus { |
189 | CASE_CLOSED = 3, | 189 | CASE_CLOSED = 3, |
190 | CASE_PORTRAIT = 2, | 190 | CASE_PORTRAIT = 2, |
191 | CASE_LANDSCAPE = 0, | 191 | CASE_LANDSCAPE = 0, |
192 | CASE_UNKNOWN = 1, | 192 | CASE_UNKNOWN = 1, |
193 | }; | 193 | }; |
194 | 194 | ||
195 | /* default button for qvfb or such | 195 | /* default button for qvfb or such |
196 | * see odevice.cpp for details. | 196 | * see odevice.cpp for details. |
197 | * hint: manage a user defined button for qvfb? | 197 | * hint: manage a user defined button for qvfb? |
198 | * alwin | 198 | * alwin |
199 | */ | 199 | */ |
200 | struct default_button { | 200 | struct default_button { |
201 | Qt::Key code; | 201 | Qt::Key code; |
202 | char *utext; | 202 | char *utext; |
203 | char *pix; | 203 | char *pix; |
204 | char *fpressedservice; | 204 | char *fpressedservice; |
205 | char *fpressedaction; | 205 | char *fpressedaction; |
206 | char *fheldservice; | 206 | char *fheldservice; |
207 | char *fheldaction; | 207 | char *fheldaction; |
208 | }; | 208 | }; |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * A singleton which gives informations about device specefic option | 211 | * A singleton which gives informations about device specefic option |
212 | * like the Hardware used, LEDs, the Base Distribution and | 212 | * like the Hardware used, LEDs, the Base Distribution and |
213 | * hardware key mappings. | 213 | * hardware key mappings. |
214 | * | 214 | * |
215 | * @short A small class for device specefic options | 215 | * @short A small class for device specefic options |
216 | * @see QObject | 216 | * @see QObject |
217 | * @author Robert Griebl | 217 | * @author Robert Griebl |
218 | * @version 1.0 | 218 | * @version 1.0 |
219 | */ | 219 | */ |
220 | class ODevice : public QObject | 220 | class ODevice : public QObject |
221 | { | 221 | { |
222 | Q_OBJECT | 222 | Q_OBJECT |
223 | 223 | ||
224 | private: | 224 | private: |
225 | /* disable copy */ | 225 | /* disable copy */ |
226 | ODevice ( const ODevice & ); | 226 | ODevice ( const ODevice & ); |
227 | 227 | ||
228 | protected: | 228 | protected: |
229 | ODevice(); | 229 | ODevice(); |
230 | virtual void init(const QString&); | 230 | virtual void init(const QString&); |
231 | virtual void initButtons(); | 231 | virtual void initButtons(); |
232 | static void sendSuspendmsg(); | 232 | static void sendSuspendmsg(); |
233 | 233 | ||
234 | ODeviceData *d; | 234 | ODeviceData *d; |
235 | 235 | ||
236 | public: | 236 | public: |
237 | // sandman do we want to allow destructions? -zecke? | 237 | // sandman do we want to allow destructions? -zecke? |
238 | virtual ~ODevice(); | 238 | virtual ~ODevice(); |
239 | |||
240 | static ODevice *inst(); | 239 | static ODevice *inst(); |
241 | 240 | ||
242 | // information | 241 | // information |
243 | |||
244 | QString modelString() const; | 242 | QString modelString() const; |
245 | OModel model() const; | 243 | OModel model() const; |
246 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | 244 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } |
247 | 245 | ||
248 | QString vendorString() const; | 246 | QString vendorString() const; |
249 | OVendor vendor() const; | 247 | OVendor vendor() const; |
250 | 248 | ||
251 | QString systemString() const; | 249 | QString systemString() const; |
252 | OSystem system() const; | 250 | OSystem system() const; |
253 | 251 | ||
254 | QString systemVersionString() const; | 252 | QString systemVersionString() const; |
255 | 253 | ||
256 | virtual Transformation rotation() const; | 254 | virtual Transformation rotation() const; |
257 | virtual ODirection direction() const; | 255 | virtual ODirection direction() const; |
258 | 256 | ||
257 | QString qteDriver() const; | ||
258 | |||
259 | // system | 259 | // system |
260 | virtual bool suspend(); | 260 | virtual bool suspend(); |
261 | 261 | ||
262 | virtual bool setDisplayStatus ( bool on ); | 262 | virtual bool setDisplayStatus ( bool on ); |
263 | virtual bool setDisplayBrightness ( int brightness ); | 263 | virtual bool setDisplayBrightness ( int brightness ); |
264 | virtual int displayBrightnessResolution() const; | 264 | virtual int displayBrightnessResolution() const; |
265 | virtual bool setDisplayContrast ( int contrast ); | 265 | virtual bool setDisplayContrast ( int contrast ); |
266 | virtual int displayContrastResolution() const; | 266 | virtual int displayContrastResolution() const; |
267 | 267 | ||
268 | // don't add new virtual methods, use this: | 268 | // don't add new virtual methods, use this: |
269 | // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | 269 | // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; |
270 | // and in your subclass do overwrite | 270 | // and in your subclass do overwrite |
271 | // protected virtual int virtual_hook(int, void *) | 271 | // protected virtual int virtual_hook(int, void *) |
272 | // which is defined below | 272 | // which is defined below |
273 | 273 | ||
274 | // input / output | 274 | // input / output |
275 | virtual void playAlarmSound(); | 275 | virtual void playAlarmSound(); |
276 | virtual void playKeySound(); | 276 | virtual void playKeySound(); |
277 | virtual void playTouchSound(); | 277 | virtual void playTouchSound(); |
278 | 278 | ||
279 | virtual QValueList <OLed> ledList() const; | 279 | virtual QValueList <OLed> ledList() const; |
280 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 280 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
281 | virtual OLedState ledState ( OLed led ) const; | 281 | virtual OLedState ledState ( OLed led ) const; |
282 | virtual bool setLedState ( OLed led, OLedState st ); | 282 | virtual bool setLedState ( OLed led, OLedState st ); |
283 | 283 | ||
284 | virtual bool hasLightSensor() const; | 284 | virtual bool hasLightSensor() const; |
285 | virtual int readLightSensor(); | 285 | virtual int readLightSensor(); |
286 | virtual int lightSensorResolution() const; | 286 | virtual int lightSensorResolution() const; |
287 | 287 | ||
288 | virtual bool hasHingeSensor() const; | 288 | virtual bool hasHingeSensor() const; |
289 | virtual OHingeStatus readHingeSensor()const; | 289 | virtual OHingeStatus readHingeSensor()const; |
290 | 290 | ||
291 | const QStrList &allowedCpuFrequencies() const; | 291 | const QStrList &allowedCpuFrequencies() const; |
292 | bool setCurrentCpuFrequency(uint index); | 292 | bool setCurrentCpuFrequency(uint index); |
293 | 293 | ||
294 | /** | 294 | /** |
295 | * Returns the available buttons on this device. The number and location | 295 | * Returns the available buttons on this device. The number and location |
296 | * of buttons will vary depending on the device. Button numbers will be assigned | 296 | * of buttons will vary depending on the device. Button numbers will be assigned |
297 | * by the device manufacturer and will be from most preferred button to least preffered | 297 | * by the device manufacturer and will be from most preferred button to least preffered |
298 | * button. Note that this list only contains "user mappable" buttons. | 298 | * button. Note that this list only contains "user mappable" buttons. |
299 | * | 299 | * |
300 | * @todo Make method const and take care of calling initButtons or make that const too | 300 | * @todo Make method const and take care of calling initButtons or make that const too |
301 | * | 301 | * |
302 | */ | 302 | */ |
303 | const QValueList<ODeviceButton> &buttons(); | 303 | const QValueList<ODeviceButton> &buttons(); |
304 | 304 | ||
305 | /** | 305 | /** |
306 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 306 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
307 | * returns 0L | 307 | * returns 0L |
308 | */ | 308 | */ |
309 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 309 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
310 | 310 | ||
311 | /** | 311 | /** |
312 | * Reassigns the pressed action for \a button. To return to the factory | 312 | * Reassigns the pressed action for \a button. To return to the factory |
313 | * default pass an empty string as \a qcopMessage. | 313 | * default pass an empty string as \a qcopMessage. |
314 | */ | 314 | */ |
315 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 315 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | * Reassigns the held action for \a button. To return to the factory | 318 | * Reassigns the held action for \a button. To return to the factory |
319 | * default pass an empty string as \a qcopMessage. | 319 | * default pass an empty string as \a qcopMessage. |
320 | */ | 320 | */ |
321 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 321 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | * How long (in ms) you have to press a button for a "hold" action | 324 | * How long (in ms) you have to press a button for a "hold" action |
325 | */ | 325 | */ |
326 | uint buttonHoldTime() const; | 326 | uint buttonHoldTime() const; |
327 | 327 | ||
328 | signals: | 328 | signals: |
329 | void buttonMappingChanged(); | 329 | void buttonMappingChanged(); |
330 | 330 | ||
331 | private slots: | 331 | private slots: |
332 | void systemMessage ( const QCString &, const QByteArray & ); | 332 | void systemMessage ( const QCString &, const QByteArray & ); |
333 | void playingStopped(); | 333 | void playingStopped(); |
334 | 334 | ||
335 | protected: | 335 | protected: |
336 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); | 336 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); |
337 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); | 337 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); |
338 | void reloadButtonMapping(); | 338 | void reloadButtonMapping(); |
339 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); | 339 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); |
340 | 340 | ||
341 | /* ugly virtual hook */ | 341 | /* ugly virtual hook */ |
342 | virtual void virtual_hook( int id, void* data ); | 342 | virtual void virtual_hook( int id, void* data ); |
343 | }; | 343 | }; |
344 | 344 | ||
345 | class ODeviceData { | 345 | class ODeviceData { |
346 | 346 | ||
347 | public: | 347 | public: |
348 | QString m_vendorstr; | 348 | QString m_vendorstr; |
349 | OVendor m_vendor; | 349 | OVendor m_vendor; |
350 | 350 | ||
351 | QString m_modelstr; | 351 | QString m_modelstr; |
352 | OModel m_model; | 352 | OModel m_model; |
353 | 353 | ||
354 | QString m_systemstr; | 354 | QString m_systemstr; |
355 | OSystem m_system; | 355 | OSystem m_system; |
356 | 356 | ||
357 | QString m_sysverstr; | 357 | QString m_sysverstr; |
358 | 358 | ||
359 | Transformation m_rotation; | 359 | Transformation m_rotation; |
360 | ODirection m_direction; | 360 | ODirection m_direction; |
361 | 361 | ||
362 | QString m_qteDriver; | ||
363 | |||
362 | QValueList <ODeviceButton> *m_buttons; | 364 | QValueList <ODeviceButton> *m_buttons; |
363 | uint m_holdtime; | 365 | uint m_holdtime; |
364 | QStrList *m_cpu_frequencies; | 366 | QStrList *m_cpu_frequencies; |
365 | bool m_initializedButtonQcop : 1; | 367 | bool m_initializedButtonQcop : 1; |
366 | 368 | ||
367 | /* values for changeMixerForAlarm */ | 369 | /* values for changeMixerForAlarm */ |
368 | int m_sound, m_vol, m_mixer; | 370 | int m_sound, m_vol, m_mixer; |
369 | }; | 371 | }; |
370 | 372 | ||
371 | extern bool isQWS(); | 373 | extern bool isQWS(); |
372 | extern QCString makeChannel ( const char *str ); | 374 | extern QCString makeChannel ( const char *str ); |
373 | } | 375 | } |
374 | } | 376 | } |
375 | 377 | ||
376 | 378 | ||
377 | 379 | ||
378 | 380 | ||
379 | #endif | 381 | #endif |
380 | 382 | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 21d2342..0c421e3 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,489 +1,500 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) 2002-2005 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; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
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 <opie2/oresource.h> | 40 | #include <opie2/oresource.h> |
41 | 41 | ||
42 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
43 | #include <qpe/sound.h> | 43 | #include <qpe/sound.h> |
44 | #include <qpe/qcopenvelope_qws.h> | 44 | #include <qpe/qcopenvelope_qws.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | #include <math.h> | 48 | #include <math.h> |
49 | #include <stdlib.h> | 49 | #include <stdlib.h> |
50 | #include <signal.h> | 50 | #include <signal.h> |
51 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
52 | #include <sys/time.h> | 52 | #include <sys/time.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #ifndef QT_NO_SOUND | 54 | #ifndef QT_NO_SOUND |
55 | #include <linux/soundcard.h> | 55 | #include <linux/soundcard.h> |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | using namespace Opie::Core; | 58 | using namespace Opie::Core; |
59 | using namespace Opie::Core::Internal; | 59 | using namespace Opie::Core::Internal; |
60 | 60 | ||
61 | struct z_button z_buttons [] = { | 61 | struct z_button z_buttons [] = { |
62 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 62 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
63 | "devicebuttons/z_calendar", | 63 | "devicebuttons/z_calendar", |
64 | "datebook", "nextView()", | 64 | "datebook", "nextView()", |
65 | "today", "raise()" }, | 65 | "today", "raise()" }, |
66 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 66 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
67 | "devicebuttons/z_contact", | 67 | "devicebuttons/z_contact", |
68 | "addressbook", "raise()", | 68 | "addressbook", "raise()", |
69 | "addressbook", "beamBusinessCard()" }, | 69 | "addressbook", "beamBusinessCard()" }, |
70 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 70 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
71 | "devicebuttons/z_home", | 71 | "devicebuttons/z_home", |
72 | "QPE/Launcher", "home()", | 72 | "QPE/Launcher", "home()", |
73 | "buttonsettings", "raise()" }, | 73 | "buttonsettings", "raise()" }, |
74 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 74 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
75 | "devicebuttons/z_menu", | 75 | "devicebuttons/z_menu", |
76 | "QPE/TaskBar", "toggleMenu()", | 76 | "QPE/TaskBar", "toggleMenu()", |
77 | "QPE/TaskBar", "toggleStartMenu()" }, | 77 | "QPE/TaskBar", "toggleStartMenu()" }, |
78 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 78 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
79 | "devicebuttons/z_mail", | 79 | "devicebuttons/z_mail", |
80 | "opiemail", "raise()", | 80 | "opiemail", "raise()", |
81 | "opiemail", "newMail()" }, | 81 | "opiemail", "newMail()" }, |
82 | }; | 82 | }; |
83 | 83 | ||
84 | struct z_button z_buttons_c700 [] = { | 84 | struct z_button z_buttons_c700 [] = { |
85 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 85 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
86 | "devicebuttons/z_calendar", | 86 | "devicebuttons/z_calendar", |
87 | "datebook", "nextView()", | 87 | "datebook", "nextView()", |
88 | "today", "raise()" }, | 88 | "today", "raise()" }, |
89 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 89 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
90 | "devicebuttons/z_contact", | 90 | "devicebuttons/z_contact", |
91 | "addressbook", "raise()", | 91 | "addressbook", "raise()", |
92 | "addressbook", "beamBusinessCard()" }, | 92 | "addressbook", "beamBusinessCard()" }, |
93 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 93 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
94 | "devicebuttons/z_home", | 94 | "devicebuttons/z_home", |
95 | "QPE/Launcher", "home()", | 95 | "QPE/Launcher", "home()", |
96 | "buttonsettings", "raise()" }, | 96 | "buttonsettings", "raise()" }, |
97 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 97 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
98 | "devicebuttons/z_menu", | 98 | "devicebuttons/z_menu", |
99 | "QPE/TaskBar", "toggleMenu()", | 99 | "QPE/TaskBar", "toggleMenu()", |
100 | "QPE/TaskBar", "toggleStartMenu()" }, | 100 | "QPE/TaskBar", "toggleStartMenu()" }, |
101 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 101 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
102 | "devicebuttons/z_mail", | 102 | "devicebuttons/z_mail", |
103 | "opiemail", "raise()", | 103 | "opiemail", "raise()", |
104 | "opiemail", "newMail()" }, | 104 | "opiemail", "newMail()" }, |
105 | 105 | ||
106 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), | 106 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), |
107 | "devicebuttons/z_hinge1", | 107 | "devicebuttons/z_hinge1", |
108 | "QPE/Rotation", "rotateDefault()",0}, | 108 | "QPE/Rotation", "rotateDefault()",0}, |
109 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), | 109 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
110 | "devicebuttons/z_hinge2", | 110 | "devicebuttons/z_hinge2", |
111 | "QPE/Rotation", "rotateDefault()",0}, | 111 | "QPE/Rotation", "rotateDefault()",0}, |
112 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 112 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
113 | "devicebuttons/z_hinge3", | 113 | "devicebuttons/z_hinge3", |
114 | "QPE/Rotation", "rotateDefault()",0}, | 114 | "QPE/Rotation", "rotateDefault()",0}, |
115 | }; | 115 | }; |
116 | 116 | ||
117 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 117 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
118 | // class up into individual classes. We would need three classes | 118 | // class up into individual classes. We would need three classes |
119 | // | 119 | // |
120 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 120 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
121 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 121 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
122 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100) | 122 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100) |
123 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 123 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
124 | 124 | ||
125 | void Zaurus::init(const QString& cpu_info) | 125 | void Zaurus::init(const QString& cpu_info) |
126 | { | 126 | { |
127 | // Set the time to wait until the system is really suspended | 127 | // Set the time to wait until the system is really suspended |
128 | // the delta between apm --suspend and sleeping | 128 | // the delta between apm --suspend and sleeping |
129 | setAPMTimeOut( 15000 ); | 129 | setAPMTimeOut( 15000 ); |
130 | 130 | ||
131 | // generic distribution code already scanned /etc/issue at that point - | 131 | // generic distribution code already scanned /etc/issue at that point - |
132 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 132 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
133 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 133 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
134 | { | 134 | { |
135 | d->m_vendorstr = "Sharp"; | 135 | d->m_vendorstr = "Sharp"; |
136 | d->m_vendor = Vendor_Sharp; | 136 | d->m_vendor = Vendor_Sharp; |
137 | d->m_systemstr = "Zaurus"; | 137 | d->m_systemstr = "Zaurus"; |
138 | d->m_system = System_Zaurus; | 138 | d->m_system = System_Zaurus; |
139 | m_embedix = true; | 139 | m_embedix = true; |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | { |
143 | d->m_vendorstr = "OpenZaurus Team"; | 143 | d->m_vendorstr = "OpenZaurus Team"; |
144 | d->m_systemstr = "OpenZaurus"; | 144 | d->m_systemstr = "OpenZaurus"; |
145 | d->m_system = System_OpenZaurus; | 145 | d->m_system = System_OpenZaurus; |
146 | // sysver already gathered | 146 | // sysver already gathered |
147 | 147 | ||
148 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one | 148 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one |
149 | FILE *uname = popen("uname -r", "r"); | 149 | FILE *uname = popen("uname -r", "r"); |
150 | QFile f; | 150 | QFile f; |
151 | QString line; | 151 | QString line; |
152 | if ( f.open(IO_ReadOnly, uname) ) { | 152 | if ( f.open(IO_ReadOnly, uname) ) { |
153 | QTextStream ts ( &f ); | 153 | QTextStream ts ( &f ); |
154 | line = ts.readLine(); | 154 | line = ts.readLine(); |
155 | m_embedix = line.startsWith( "2.4." ); | 155 | m_embedix = line.startsWith( "2.4." ); |
156 | f.close(); | 156 | f.close(); |
157 | } | 157 | } |
158 | pclose(uname); | 158 | pclose(uname); |
159 | } | 159 | } |
160 | 160 | ||
161 | // check the Zaurus model | 161 | // check the Zaurus model |
162 | QString model; | 162 | QString model; |
163 | int loc = cpu_info.find( ":" ); | 163 | int loc = cpu_info.find( ":" ); |
164 | if ( loc != -1 ) | 164 | if ( loc != -1 ) |
165 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 165 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
166 | else | 166 | else |
167 | model = cpu_info; | 167 | model = cpu_info; |
168 | 168 | ||
169 | if ( model == "SHARP Corgi" ) { | 169 | if ( model == "SHARP Corgi" ) { |
170 | d->m_model = Model_Zaurus_SLC7x0; | 170 | d->m_model = Model_Zaurus_SLC7x0; |
171 | d->m_modelstr = "Zaurus SL-C700"; | 171 | d->m_modelstr = "Zaurus SL-C700"; |
172 | } else if ( model == "SHARP Shepherd" ) { | 172 | } else if ( model == "SHARP Shepherd" ) { |
173 | d->m_model = Model_Zaurus_SLC7x0; | 173 | d->m_model = Model_Zaurus_SLC7x0; |
174 | d->m_modelstr = "Zaurus SL-C750"; | 174 | d->m_modelstr = "Zaurus SL-C750"; |
175 | } else if ( model == "SHARP Husky" ) { | 175 | } else if ( model == "SHARP Husky" ) { |
176 | d->m_model = Model_Zaurus_SLC7x0; | 176 | d->m_model = Model_Zaurus_SLC7x0; |
177 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 177 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
178 | } else if ( model == "SHARP Boxer" ) { | 178 | } else if ( model == "SHARP Boxer" ) { |
179 | d->m_model = Model_Zaurus_SLC7x0; | 179 | d->m_model = Model_Zaurus_SLC7x0; |
180 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 180 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
181 | } else if ( model == "SHARP Poodle" ) { | 181 | } else if ( model == "SHARP Poodle" ) { |
182 | d->m_model = Model_Zaurus_SLB600; | 182 | d->m_model = Model_Zaurus_SLB600; |
183 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 183 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
184 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 184 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
185 | d->m_model = Model_Zaurus_SL5500; | 185 | d->m_model = Model_Zaurus_SL5500; |
186 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 186 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
187 | } else if ( model == "SHARP Tosa" ) { | 187 | } else if ( model == "SHARP Tosa" ) { |
188 | d->m_model = Model_Zaurus_SL6000; | 188 | d->m_model = Model_Zaurus_SL6000; |
189 | d->m_modelstr = "Zaurus SL-6000"; | 189 | d->m_modelstr = "Zaurus SL-6000"; |
190 | } else if ( model == "SHARP Spitz" ) { | 190 | } else if ( model == "SHARP Spitz" ) { |
191 | d->m_model = Model_Zaurus_SLC3000; | 191 | d->m_model = Model_Zaurus_SLC3000; |
192 | d->m_modelstr = "Zaurus SL-C3000"; | 192 | d->m_modelstr = "Zaurus SL-C3000"; |
193 | } else if ( model == "SHARP Akita" ) { | 193 | } else if ( model == "SHARP Akita" ) { |
194 | d->m_model = Model_Zaurus_SLC1000; | 194 | d->m_model = Model_Zaurus_SLC1000; |
195 | d->m_modelstr = "Zaurus SL-C1000"; | 195 | d->m_modelstr = "Zaurus SL-C1000"; |
196 | } else { | 196 | } else { |
197 | d->m_model = Model_Zaurus_SL5500; | 197 | d->m_model = Model_Zaurus_SL5500; |
198 | d->m_modelstr = "Unknown Zaurus"; | 198 | d->m_modelstr = "Unknown Zaurus"; |
199 | } | 199 | } |
200 | 200 | ||
201 | // set path to backlight device in kernel 2.6 | 201 | // set path to backlight device in kernel 2.6 |
202 | switch ( d->m_model ) { | 202 | switch ( d->m_model ) |
203 | { | ||
203 | case Model_Zaurus_SLB600: // fallthrough | 204 | case Model_Zaurus_SLB600: // fallthrough |
204 | case Model_Zaurus_SL5500: | 205 | case Model_Zaurus_SL5500: |
205 | m_backlightdev = "/sys/class/backlight/locomo-backlight/"; | 206 | m_backlightdev = "/sys/class/backlight/locomo-backlight/"; |
206 | break; | 207 | break; |
207 | case Model_Zaurus_SL6000: | 208 | case Model_Zaurus_SL6000: |
208 | m_backlightdev = "/sys/class/backlight/tosa-bl/"; | 209 | m_backlightdev = "/sys/class/backlight/tosa-bl/"; |
209 | break; | 210 | break; |
210 | default: | 211 | default: |
211 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; | 212 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
212 | break; | ||
213 | } | 213 | } |
214 | 214 | ||
215 | // set initial rotation | 215 | // set initial rotation |
216 | switch( d->m_model ) { | 216 | switch( d->m_model ) |
217 | { | ||
217 | case Model_Zaurus_SL6000: // fallthrough | 218 | case Model_Zaurus_SL6000: // fallthrough |
218 | case Model_Zaurus_SLA300: | 219 | case Model_Zaurus_SLA300: |
219 | d->m_rotation = Rot0; | 220 | d->m_rotation = Rot0; |
220 | break; | 221 | break; |
221 | case Model_Zaurus_SLC3000: // fallthrough | 222 | case Model_Zaurus_SLC3000: // fallthrough |
222 | case Model_Zaurus_SLC1000: // fallthrough | 223 | case Model_Zaurus_SLC1000: // fallthrough |
223 | case Model_Zaurus_SLC7x0: | 224 | case Model_Zaurus_SLC7x0: |
224 | d->m_rotation = rotation(); | 225 | d->m_rotation = rotation(); |
225 | d->m_direction = direction(); | 226 | d->m_direction = direction(); |
226 | break; | 227 | break; |
227 | case Model_Zaurus_SLB600: // fallthrough | 228 | case Model_Zaurus_SLB600: // fallthrough |
228 | case Model_Zaurus_SL5000: // fallthrough | 229 | case Model_Zaurus_SL5000: // fallthrough |
229 | case Model_Zaurus_SL5500: // fallthrough | 230 | case Model_Zaurus_SL5500: // fallthrough |
230 | default: | 231 | default: |
231 | d->m_rotation = Rot270; | 232 | d->m_rotation = Rot270; |
233 | } | ||
234 | |||
235 | // set default qte driver | ||
236 | switch( d->m_model ) | ||
237 | { | ||
238 | case Model_Zaurus_SLC7x0: | ||
239 | d->m_qteDriver = "W100"; | ||
232 | break; | 240 | break; |
241 | default: | ||
242 | d->m_qteDriver = "Transformed"; | ||
233 | } | 243 | } |
244 | |||
234 | m_leds[0] = Led_Off; | 245 | m_leds[0] = Led_Off; |
235 | 246 | ||
236 | if ( m_embedix ) | 247 | if ( m_embedix ) |
237 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | 248 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); |
238 | else | 249 | else |
239 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 250 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
240 | } | 251 | } |
241 | 252 | ||
242 | void Zaurus::initButtons() | 253 | void Zaurus::initButtons() |
243 | { | 254 | { |
244 | if ( d->m_buttons ) | 255 | if ( d->m_buttons ) |
245 | return; | 256 | return; |
246 | 257 | ||
247 | 258 | ||
248 | d->m_buttons = new QValueList <ODeviceButton>; | 259 | d->m_buttons = new QValueList <ODeviceButton>; |
249 | 260 | ||
250 | struct z_button * pz_buttons; | 261 | struct z_button * pz_buttons; |
251 | int buttoncount; | 262 | int buttoncount; |
252 | switch ( d->m_model ) { | 263 | switch ( d->m_model ) { |
253 | case Model_Zaurus_SLC3000: // fallthrough | 264 | case Model_Zaurus_SLC3000: // fallthrough |
254 | case Model_Zaurus_SLC1000: // fallthrough | 265 | case Model_Zaurus_SLC1000: // fallthrough |
255 | case Model_Zaurus_SLC7x0: | 266 | case Model_Zaurus_SLC7x0: |
256 | if ( isQWS( ) ) { | 267 | if ( isQWS( ) ) { |
257 | addPreHandler(this); // hinge-sensor-handler | 268 | addPreHandler(this); // hinge-sensor-handler |
258 | } | 269 | } |
259 | pz_buttons = z_buttons_c700; | 270 | pz_buttons = z_buttons_c700; |
260 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 271 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
261 | break; | 272 | break; |
262 | default: | 273 | default: |
263 | pz_buttons = z_buttons; | 274 | pz_buttons = z_buttons; |
264 | buttoncount = ARRAY_SIZE(z_buttons); | 275 | buttoncount = ARRAY_SIZE(z_buttons); |
265 | break; | 276 | break; |
266 | } | 277 | } |
267 | 278 | ||
268 | for ( int i = 0; i < buttoncount; i++ ) { | 279 | for ( int i = 0; i < buttoncount; i++ ) { |
269 | struct z_button *zb = pz_buttons + i; | 280 | struct z_button *zb = pz_buttons + i; |
270 | ODeviceButton b; | 281 | ODeviceButton b; |
271 | 282 | ||
272 | b.setKeycode( zb->code ); | 283 | b.setKeycode( zb->code ); |
273 | b.setUserText( QObject::tr( "Button", zb->utext )); | 284 | b.setUserText( QObject::tr( "Button", zb->utext )); |
274 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 285 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
275 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 286 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
276 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 287 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
277 | d->m_buttons->append( b ); | 288 | d->m_buttons->append( b ); |
278 | } | 289 | } |
279 | 290 | ||
280 | reloadButtonMapping(); | 291 | reloadButtonMapping(); |
281 | } | 292 | } |
282 | 293 | ||
283 | 294 | ||
284 | 295 | ||
285 | typedef struct sharp_led_status { | 296 | typedef struct sharp_led_status { |
286 | int which; /* select which LED status is wanted. */ | 297 | int which; /* select which LED status is wanted. */ |
287 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 298 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
288 | } sharp_led_status; | 299 | } sharp_led_status; |
289 | 300 | ||
290 | void Zaurus::buzzer( int sound ) | 301 | void Zaurus::buzzer( int sound ) |
291 | { | 302 | { |
292 | #ifndef QT_NO_SOUND | 303 | #ifndef QT_NO_SOUND |
293 | Sound *snd = 0; | 304 | Sound *snd = 0; |
294 | 305 | ||
295 | // All devices except SL5500 have a DSP device | 306 | // All devices except SL5500 have a DSP device |
296 | if ( d->m_model != Model_Zaurus_SL5000 | 307 | if ( d->m_model != Model_Zaurus_SL5000 |
297 | && d->m_model != Model_Zaurus_SL5500 ) { | 308 | && d->m_model != Model_Zaurus_SL5500 ) { |
298 | 309 | ||
299 | switch ( sound ){ | 310 | switch ( sound ){ |
300 | case SHARP_BUZ_TOUCHSOUND: { | 311 | case SHARP_BUZ_TOUCHSOUND: { |
301 | static Sound touch_sound("touchsound"); | 312 | static Sound touch_sound("touchsound"); |
302 | snd = &touch_sound; | 313 | snd = &touch_sound; |
303 | } | 314 | } |
304 | break; | 315 | break; |
305 | case SHARP_BUZ_KEYSOUND: { | 316 | case SHARP_BUZ_KEYSOUND: { |
306 | static Sound key_sound( "keysound" ); | 317 | static Sound key_sound( "keysound" ); |
307 | snd = &key_sound; | 318 | snd = &key_sound; |
308 | } | 319 | } |
309 | break; | 320 | break; |
310 | case SHARP_BUZ_SCHEDULE_ALARM: | 321 | case SHARP_BUZ_SCHEDULE_ALARM: |
311 | default: { | 322 | default: { |
312 | static Sound alarm_sound("alarm"); | 323 | static Sound alarm_sound("alarm"); |
313 | snd = &alarm_sound; | 324 | snd = &alarm_sound; |
314 | } | 325 | } |
315 | break; | 326 | break; |
316 | } | 327 | } |
317 | } | 328 | } |
318 | 329 | ||
319 | // If a soundname is defined, we expect that this device has | 330 | // If a soundname is defined, we expect that this device has |
320 | // sound capabilities.. Otherwise we expect to have the buzzer | 331 | // sound capabilities.. Otherwise we expect to have the buzzer |
321 | // device.. | 332 | // device.. |
322 | if ( snd && snd->isFinished() ){ | 333 | if ( snd && snd->isFinished() ){ |
323 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 334 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
324 | snd->play(); | 335 | snd->play(); |
325 | } else if( !snd ) { | 336 | } else if( !snd ) { |
326 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 337 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
327 | 338 | ||
328 | if ( fd >= 0 ) { | 339 | if ( fd >= 0 ) { |
329 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 340 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
330 | ::close ( fd ); | 341 | ::close ( fd ); |
331 | } | 342 | } |
332 | 343 | ||
333 | } | 344 | } |
334 | #endif | 345 | #endif |
335 | } | 346 | } |
336 | 347 | ||
337 | 348 | ||
338 | void Zaurus::playAlarmSound() | 349 | void Zaurus::playAlarmSound() |
339 | { | 350 | { |
340 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 351 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
341 | } | 352 | } |
342 | 353 | ||
343 | void Zaurus::playTouchSound() | 354 | void Zaurus::playTouchSound() |
344 | { | 355 | { |
345 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 356 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
346 | } | 357 | } |
347 | 358 | ||
348 | void Zaurus::playKeySound() | 359 | void Zaurus::playKeySound() |
349 | { | 360 | { |
350 | buzzer( SHARP_BUZ_KEYSOUND ); | 361 | buzzer( SHARP_BUZ_KEYSOUND ); |
351 | } | 362 | } |
352 | 363 | ||
353 | 364 | ||
354 | QValueList <OLed> Zaurus::ledList() const | 365 | QValueList <OLed> Zaurus::ledList() const |
355 | { | 366 | { |
356 | QValueList <OLed> vl; | 367 | QValueList <OLed> vl; |
357 | vl << Led_Mail; | 368 | vl << Led_Mail; |
358 | return vl; | 369 | return vl; |
359 | } | 370 | } |
360 | 371 | ||
361 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 372 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
362 | { | 373 | { |
363 | QValueList <OLedState> vl; | 374 | QValueList <OLedState> vl; |
364 | 375 | ||
365 | if ( l == Led_Mail ) | 376 | if ( l == Led_Mail ) |
366 | vl << Led_Off << Led_On << Led_BlinkSlow; | 377 | vl << Led_Off << Led_On << Led_BlinkSlow; |
367 | return vl; | 378 | return vl; |
368 | } | 379 | } |
369 | 380 | ||
370 | OLedState Zaurus::ledState( OLed which ) const | 381 | OLedState Zaurus::ledState( OLed which ) const |
371 | { | 382 | { |
372 | if ( which == Led_Mail ) | 383 | if ( which == Led_Mail ) |
373 | return m_leds [0]; | 384 | return m_leds [0]; |
374 | else | 385 | else |
375 | return Led_Off; | 386 | return Led_Off; |
376 | } | 387 | } |
377 | 388 | ||
378 | bool Zaurus::setLedState( OLed which, OLedState st ) | 389 | bool Zaurus::setLedState( OLed which, OLedState st ) |
379 | { | 390 | { |
380 | // Currently not supported on non_embedix kernels | 391 | // Currently not supported on non_embedix kernels |
381 | if (!m_embedix) | 392 | if (!m_embedix) |
382 | { | 393 | { |
383 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 394 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
384 | return false; | 395 | return false; |
385 | } | 396 | } |
386 | 397 | ||
387 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 398 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
388 | 399 | ||
389 | if ( which == Led_Mail ) { | 400 | if ( which == Led_Mail ) { |
390 | if ( fd >= 0 ) { | 401 | if ( fd >= 0 ) { |
391 | struct sharp_led_status leds; | 402 | struct sharp_led_status leds; |
392 | ::memset ( &leds, 0, sizeof( leds )); | 403 | ::memset ( &leds, 0, sizeof( leds )); |
393 | leds. which = SHARP_LED_MAIL_EXISTS; | 404 | leds. which = SHARP_LED_MAIL_EXISTS; |
394 | bool ok = true; | 405 | bool ok = true; |
395 | 406 | ||
396 | switch ( st ) { | 407 | switch ( st ) { |
397 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 408 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
398 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 409 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
399 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 410 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
400 | default : ok = false; | 411 | default : ok = false; |
401 | } | 412 | } |
402 | 413 | ||
403 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 414 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
404 | m_leds [0] = st; | 415 | m_leds [0] = st; |
405 | return true; | 416 | return true; |
406 | } | 417 | } |
407 | } | 418 | } |
408 | } | 419 | } |
409 | return false; | 420 | return false; |
410 | } | 421 | } |
411 | 422 | ||
412 | int Zaurus::displayBrightnessResolution() const | 423 | int Zaurus::displayBrightnessResolution() const |
413 | { | 424 | { |
414 | int res = 1; | 425 | int res = 1; |
415 | if (m_embedix) | 426 | if (m_embedix) |
416 | { | 427 | { |
417 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 428 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
418 | if ( fd ) | 429 | if ( fd ) |
419 | { | 430 | { |
420 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 431 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
421 | ::close( fd ); | 432 | ::close( fd ); |
422 | return value ? value : res; | 433 | return value ? value : res; |
423 | } | 434 | } |
424 | } | 435 | } |
425 | else | 436 | else |
426 | { | 437 | { |
427 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 438 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
428 | if ( fd ) | 439 | if ( fd ) |
429 | { | 440 | { |
430 | char buf[100]; | 441 | char buf[100]; |
431 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 442 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
432 | ::close( fd ); | 443 | ::close( fd ); |
433 | } | 444 | } |
434 | } | 445 | } |
435 | return res; | 446 | return res; |
436 | } | 447 | } |
437 | 448 | ||
438 | bool Zaurus::setDisplayBrightness( int bright ) | 449 | bool Zaurus::setDisplayBrightness( int bright ) |
439 | { | 450 | { |
440 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 451 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
441 | bool res = false; | 452 | bool res = false; |
442 | 453 | ||
443 | if ( bright > 255 ) bright = 255; | 454 | if ( bright > 255 ) bright = 255; |
444 | if ( bright < 0 ) bright = 0; | 455 | if ( bright < 0 ) bright = 0; |
445 | 456 | ||
446 | int numberOfSteps = displayBrightnessResolution(); | 457 | int numberOfSteps = displayBrightnessResolution(); |
447 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 458 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
448 | 459 | ||
449 | if ( m_embedix ) | 460 | if ( m_embedix ) |
450 | { | 461 | { |
451 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 462 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
452 | if ( fd ) | 463 | if ( fd ) |
453 | { | 464 | { |
454 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 465 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
455 | ::close( fd ); | 466 | ::close( fd ); |
456 | } | 467 | } |
457 | } | 468 | } |
458 | else | 469 | else |
459 | { | 470 | { |
460 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 471 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
461 | if ( fd ) | 472 | if ( fd ) |
462 | { | 473 | { |
463 | char buf[100]; | 474 | char buf[100]; |
464 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 475 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
465 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 476 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
466 | ::close( fd ); | 477 | ::close( fd ); |
467 | } | 478 | } |
468 | } | 479 | } |
469 | return res; | 480 | return res; |
470 | } | 481 | } |
471 | 482 | ||
472 | bool Zaurus::setDisplayStatus( bool on ) | 483 | bool Zaurus::setDisplayStatus( bool on ) |
473 | { | 484 | { |
474 | bool res = false; | 485 | bool res = false; |
475 | if ( m_embedix ) | 486 | if ( m_embedix ) |
476 | { | 487 | { |
477 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 488 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
478 | if ( fd ) | 489 | if ( fd ) |
479 | { | 490 | { |
480 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 491 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
481 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 492 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
482 | ::close ( fd ); | 493 | ::close ( fd ); |
483 | } | 494 | } |
484 | } | 495 | } |
485 | else | 496 | else |
486 | { | 497 | { |
487 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 498 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
488 | if ( fd ) | 499 | if ( fd ) |
489 | { | 500 | { |