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