author | drw <drw> | 2005-04-05 23:01:28 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-05 23:01:28 (UTC) |
commit | 2b0e27b45eb9ff5563f786c5e45d53db49afb9f9 (patch) (unidiff) | |
tree | e5dfb23aa8e0e3778b5fa1f5633f6511789f41f2 | |
parent | 2a9ee3ea1d8d978b735f0ce3f2e54a15e37c87b3 (diff) | |
download | opie-2b0e27b45eb9ff5563f786c5e45d53db49afb9f9.zip opie-2b0e27b45eb9ff5563f786c5e45d53db49afb9f9.tar.gz opie-2b0e27b45eb9ff5563f786c5e45d53db49afb9f9.tar.bz2 |
Use OResource for loading images
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 48 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_beagle.cpp | 47 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_genuineintel.cpp | 60 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 48 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 58 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.cpp | 44 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 48 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.cpp | 58 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 54 |
9 files changed, 240 insertions, 225 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index fcdbf45..dd1e2f3 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,334 +1,336 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_beagle.h" | 31 | #include "odevice_beagle.h" |
31 | #include "odevice_ipaq.h" | 32 | #include "odevice_ipaq.h" |
32 | #include "odevice_jornada.h" | 33 | #include "odevice_jornada.h" |
33 | #include "odevice_ramses.h" | 34 | #include "odevice_ramses.h" |
34 | #include "odevice_simpad.h" | 35 | #include "odevice_simpad.h" |
35 | #include "odevice_yopy.h" | 36 | #include "odevice_yopy.h" |
36 | #include "odevice_zaurus.h" | 37 | #include "odevice_zaurus.h" |
37 | #include "odevice_genuineintel.h" | 38 | #include "odevice_genuineintel.h" |
38 | 39 | ||
39 | /* QT */ | 40 | /* QT */ |
40 | #include <qapplication.h> | 41 | #include <qapplication.h> |
41 | #include <qfile.h> | 42 | #include <qfile.h> |
42 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
43 | #include <qwindowsystem_qws.h> | 44 | #include <qwindowsystem_qws.h> |
44 | 45 | ||
45 | /* OPIE */ | 46 | /* OPIE */ |
46 | #include <qpe/config.h> | 47 | #include <qpe/config.h> |
47 | #include <qpe/resource.h> | ||
48 | #include <qpe/sound.h> | 48 | #include <qpe/sound.h> |
49 | #include <qpe/qcopenvelope_qws.h> | 49 | #include <qpe/qcopenvelope_qws.h> |
50 | #include <qpe/sound.h> | 50 | #include <qpe/sound.h> |
51 | |||
51 | #include <opie2/okeyfilter.h> | 52 | #include <opie2/okeyfilter.h> |
53 | #include <opie2/oresource.h> | ||
52 | 54 | ||
53 | /* STD */ | 55 | /* STD */ |
54 | #include <fcntl.h> | 56 | #include <fcntl.h> |
55 | #include <math.h> | 57 | #include <math.h> |
56 | #include <stdlib.h> | 58 | #include <stdlib.h> |
57 | #include <signal.h> | 59 | #include <signal.h> |
58 | #include <sys/ioctl.h> | 60 | #include <sys/ioctl.h> |
59 | #include <sys/time.h> | 61 | #include <sys/time.h> |
60 | #include <unistd.h> | 62 | #include <unistd.h> |
61 | #ifndef QT_NO_SOUND | 63 | #ifndef QT_NO_SOUND |
62 | #include <linux/soundcard.h> | 64 | #include <linux/soundcard.h> |
63 | #endif | 65 | #endif |
64 | 66 | ||
65 | namespace Opie { | 67 | namespace Opie { |
66 | namespace Core { | 68 | namespace Core { |
67 | 69 | ||
68 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 70 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
69 | 71 | ||
70 | 72 | ||
71 | /* STATIC and common implementation */ | 73 | /* STATIC and common implementation */ |
72 | /* EXPORT */ ODistribution distributions[] = { | 74 | /* EXPORT */ ODistribution distributions[] = { |
73 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 75 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
74 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 76 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
75 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 77 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
76 | { System_Unknown, "Linux", "/etc/issue" }, | 78 | { System_Unknown, "Linux", "/etc/issue" }, |
77 | }; | 79 | }; |
78 | 80 | ||
79 | 81 | ||
80 | /* EXPORT */ bool isQWS(){ | 82 | /* EXPORT */ bool isQWS(){ |
81 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 83 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
82 | } | 84 | } |
83 | 85 | ||
84 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 86 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
85 | if ( str && !::strchr ( str, '/' )) | 87 | if ( str && !::strchr ( str, '/' )) |
86 | return QCString ( "QPE/Application/" ) + str; | 88 | return QCString ( "QPE/Application/" ) + str; |
87 | else | 89 | else |
88 | return str; | 90 | return str; |
89 | } | 91 | } |
90 | 92 | ||
91 | 93 | ||
92 | 94 | ||
93 | /* Now the default implementation of ODevice */ | 95 | /* Now the default implementation of ODevice */ |
94 | 96 | ||
95 | struct default_button default_buttons [] = { | 97 | struct default_button default_buttons [] = { |
96 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 98 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
97 | "devicebuttons/z_calendar", | 99 | "devicebuttons/z_calendar", |
98 | "datebook", "nextView()", | 100 | "datebook", "nextView()", |
99 | "today", "raise()" }, | 101 | "today", "raise()" }, |
100 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 102 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
101 | "devicebuttons/z_contact", | 103 | "devicebuttons/z_contact", |
102 | "addressbook", "raise()", | 104 | "addressbook", "raise()", |
103 | "addressbook", "beamBusinessCard()" }, | 105 | "addressbook", "beamBusinessCard()" }, |
104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 106 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
105 | "devicebuttons/z_home", | 107 | "devicebuttons/z_home", |
106 | "QPE/Launcher", "home()", | 108 | "QPE/Launcher", "home()", |
107 | "buttonsettings", "raise()" }, | 109 | "buttonsettings", "raise()" }, |
108 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 110 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
109 | "devicebuttons/z_menu", | 111 | "devicebuttons/z_menu", |
110 | "QPE/TaskBar", "toggleMenu()", | 112 | "QPE/TaskBar", "toggleMenu()", |
111 | "QPE/TaskBar", "toggleStartMenu()" }, | 113 | "QPE/TaskBar", "toggleStartMenu()" }, |
112 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 114 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
113 | "devicebuttons/z_mail", | 115 | "devicebuttons/z_mail", |
114 | "opiemail", "raise()", | 116 | "opiemail", "raise()", |
115 | "opiemail", "newMail()" }, | 117 | "opiemail", "newMail()" }, |
116 | }; | 118 | }; |
117 | 119 | ||
118 | ODevice *ODevice::inst() | 120 | ODevice *ODevice::inst() |
119 | { | 121 | { |
120 | static ODevice *dev = 0; | 122 | static ODevice *dev = 0; |
121 | QString cpu_info; | 123 | QString cpu_info; |
122 | 124 | ||
123 | if ( !dev ) | 125 | if ( !dev ) |
124 | { | 126 | { |
125 | QFile f( PATH_PROC_CPUINFO ); | 127 | QFile f( PATH_PROC_CPUINFO ); |
126 | if ( f.open( IO_ReadOnly ) ) | 128 | if ( f.open( IO_ReadOnly ) ) |
127 | { | 129 | { |
128 | QTextStream s( &f ); | 130 | QTextStream s( &f ); |
129 | while ( !s.atEnd() ) | 131 | while ( !s.atEnd() ) |
130 | { | 132 | { |
131 | QString line; | 133 | QString line; |
132 | line = s.readLine(); | 134 | line = s.readLine(); |
133 | if ( line.startsWith( "Hardware" ) ) | 135 | if ( line.startsWith( "Hardware" ) ) |
134 | { | 136 | { |
135 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 137 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
136 | cpu_info = line; | 138 | cpu_info = line; |
137 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 139 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
138 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 140 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
139 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 141 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
140 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 142 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
141 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 143 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
142 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | 144 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); |
143 | else qWarning( "ODevice() - unknown hardware - using default." ); | 145 | else qWarning( "ODevice() - unknown hardware - using default." ); |
144 | break; | 146 | break; |
145 | } else if ( line.startsWith( "vendor_id" ) ) { | 147 | } else if ( line.startsWith( "vendor_id" ) ) { |
146 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 148 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
147 | cpu_info = line; | 149 | cpu_info = line; |
148 | if( line.contains( "genuineintel", false ) ) { | 150 | if( line.contains( "genuineintel", false ) ) { |
149 | dev = new Internal::GenuineIntel(); | 151 | dev = new Internal::GenuineIntel(); |
150 | break; | 152 | break; |
151 | } | 153 | } |
152 | } | 154 | } |
153 | } | 155 | } |
154 | } | 156 | } |
155 | else | 157 | else |
156 | { | 158 | { |
157 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 159 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
158 | } | 160 | } |
159 | if ( !dev ) dev = new ODevice(); | 161 | if ( !dev ) dev = new ODevice(); |
160 | dev->init(cpu_info); | 162 | dev->init(cpu_info); |
161 | } | 163 | } |
162 | return dev; | 164 | return dev; |
163 | } | 165 | } |
164 | 166 | ||
165 | ODevice::ODevice() | 167 | ODevice::ODevice() |
166 | { | 168 | { |
167 | d = new ODeviceData; | 169 | d = new ODeviceData; |
168 | 170 | ||
169 | d->m_modelstr = "Unknown"; | 171 | d->m_modelstr = "Unknown"; |
170 | d->m_model = Model_Unknown; | 172 | d->m_model = Model_Unknown; |
171 | d->m_vendorstr = "Unknown"; | 173 | d->m_vendorstr = "Unknown"; |
172 | d->m_vendor = Vendor_Unknown; | 174 | d->m_vendor = Vendor_Unknown; |
173 | d->m_systemstr = "Unknown"; | 175 | d->m_systemstr = "Unknown"; |
174 | d->m_system = System_Unknown; | 176 | d->m_system = System_Unknown; |
175 | d->m_sysverstr = "0.0"; | 177 | d->m_sysverstr = "0.0"; |
176 | d->m_rotation = Rot0; | 178 | d->m_rotation = Rot0; |
177 | d->m_direction = CW; | 179 | d->m_direction = CW; |
178 | 180 | ||
179 | d->m_holdtime = 1000; // 1000ms | 181 | d->m_holdtime = 1000; // 1000ms |
180 | d->m_buttons = 0; | 182 | d->m_buttons = 0; |
181 | d->m_cpu_frequencies = new QStrList; | 183 | d->m_cpu_frequencies = new QStrList; |
182 | 184 | ||
183 | 185 | ||
184 | /* mixer */ | 186 | /* mixer */ |
185 | d->m_sound = d->m_vol = d->m_mixer = -1; | 187 | d->m_sound = d->m_vol = d->m_mixer = -1; |
186 | 188 | ||
187 | /* System QCopChannel created */ | 189 | /* System QCopChannel created */ |
188 | d->m_initializedButtonQcop = false; | 190 | d->m_initializedButtonQcop = false; |
189 | 191 | ||
190 | // New distribution detection code first checks for legacy distributions, | 192 | // New distribution detection code first checks for legacy distributions, |
191 | // identified by /etc/familiar-version or /etc/oz_version. | 193 | // identified by /etc/familiar-version or /etc/oz_version. |
192 | // Then check for OpenEmbedded and lastly, read /etc/issue | 194 | // Then check for OpenEmbedded and lastly, read /etc/issue |
193 | 195 | ||
194 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) | 196 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) |
195 | { | 197 | { |
196 | if ( QFile::exists( distributions[i].sysvfile ) ) | 198 | if ( QFile::exists( distributions[i].sysvfile ) ) |
197 | { | 199 | { |
198 | d->m_systemstr = distributions[i].sysstr; | 200 | d->m_systemstr = distributions[i].sysstr; |
199 | d->m_system = distributions[i].system; | 201 | d->m_system = distributions[i].system; |
200 | d->m_sysverstr = "<Unknown>"; | 202 | d->m_sysverstr = "<Unknown>"; |
201 | QFile f( distributions[i].sysvfile ); | 203 | QFile f( distributions[i].sysvfile ); |
202 | if ( f.open( IO_ReadOnly ) ) | 204 | if ( f.open( IO_ReadOnly ) ) |
203 | { | 205 | { |
204 | QTextStream ts( &f ); | 206 | QTextStream ts( &f ); |
205 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
206 | } | 208 | } |
207 | break; | 209 | break; |
208 | } | 210 | } |
209 | } | 211 | } |
210 | } | 212 | } |
211 | 213 | ||
212 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
213 | { | 215 | { |
214 | if ( msg == "deviceButtonMappingChanged()" ) { | 216 | if ( msg == "deviceButtonMappingChanged()" ) { |
215 | reloadButtonMapping(); | 217 | reloadButtonMapping(); |
216 | } | 218 | } |
217 | } | 219 | } |
218 | 220 | ||
219 | void ODevice::init(const QString&) | 221 | void ODevice::init(const QString&) |
220 | { | 222 | { |
221 | } | 223 | } |
222 | 224 | ||
223 | /** | 225 | /** |
224 | * This method initialises the button mapping | 226 | * This method initialises the button mapping |
225 | */ | 227 | */ |
226 | void ODevice::initButtons() | 228 | void ODevice::initButtons() |
227 | { | 229 | { |
228 | if ( d->m_buttons ) | 230 | if ( d->m_buttons ) |
229 | return; | 231 | return; |
230 | 232 | ||
231 | qDebug ( "init Buttons" ); | 233 | qDebug ( "init Buttons" ); |
232 | d->m_buttons = new QValueList <ODeviceButton>; | 234 | d->m_buttons = new QValueList <ODeviceButton>; |
233 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 235 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
234 | default_button *db = default_buttons + i; | 236 | default_button *db = default_buttons + i; |
235 | ODeviceButton b; | 237 | ODeviceButton b; |
236 | b. setKeycode ( db->code ); | 238 | b. setKeycode ( db->code ); |
237 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 239 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
238 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 240 | b. setPixmap ( OResource::loadPixmap ( db->pix )); |
239 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
240 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
241 | d->m_buttons->append ( b ); | 243 | d->m_buttons->append ( b ); |
242 | } | 244 | } |
243 | 245 | ||
244 | reloadButtonMapping(); | 246 | reloadButtonMapping(); |
245 | } | 247 | } |
246 | 248 | ||
247 | ODevice::~ODevice() | 249 | ODevice::~ODevice() |
248 | { | 250 | { |
249 | // we leak m_devicebuttons and m_cpu_frequency | 251 | // we leak m_devicebuttons and m_cpu_frequency |
250 | // but it's a singleton and it is not so importantant | 252 | // but it's a singleton and it is not so importantant |
251 | // -zecke | 253 | // -zecke |
252 | delete d; | 254 | delete d; |
253 | } | 255 | } |
254 | 256 | ||
255 | /** | 257 | /** |
256 | * This method will try to suspend the device | 258 | * This method will try to suspend the device |
257 | * It only works if the user is the QWS Server and the apm application | 259 | * It only works if the user is the QWS Server and the apm application |
258 | * is installed. | 260 | * is installed. |
259 | * It tries to suspend and then waits some time cause some distributions | 261 | * It tries to suspend and then waits some time cause some distributions |
260 | * do have asynchronus apm implementations. | 262 | * do have asynchronus apm implementations. |
261 | * This method will either fail and return false or it'll suspend the | 263 | * This method will either fail and return false or it'll suspend the |
262 | * device and return once the device got woken up | 264 | * device and return once the device got woken up |
263 | * | 265 | * |
264 | * @return if the device got suspended | 266 | * @return if the device got suspended |
265 | */ | 267 | */ |
266 | bool ODevice::suspend() | 268 | bool ODevice::suspend() |
267 | { | 269 | { |
268 | return false; // default implementation == unknown device or qvfb | 270 | return false; // default implementation == unknown device or qvfb |
269 | } | 271 | } |
270 | 272 | ||
271 | /** | 273 | /** |
272 | * This sets the display on or off | 274 | * This sets the display on or off |
273 | */ | 275 | */ |
274 | bool ODevice::setDisplayStatus( bool on ) | 276 | bool ODevice::setDisplayStatus( bool on ) |
275 | { | 277 | { |
276 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); | 278 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); |
277 | return false; // don't do anything for unknown models | 279 | return false; // don't do anything for unknown models |
278 | } | 280 | } |
279 | 281 | ||
280 | /** | 282 | /** |
281 | * This sets the display brightness | 283 | * This sets the display brightness |
282 | * | 284 | * |
283 | * @param b The brightness to be set on a scale from 0 to 255 | 285 | * @param b The brightness to be set on a scale from 0 to 255 |
284 | * @return success or failure | 286 | * @return success or failure |
285 | */ | 287 | */ |
286 | bool ODevice::setDisplayBrightness( int b ) | 288 | bool ODevice::setDisplayBrightness( int b ) |
287 | { | 289 | { |
288 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); | 290 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); |
289 | return false; | 291 | return false; |
290 | } | 292 | } |
291 | 293 | ||
292 | /** | 294 | /** |
293 | * | 295 | * |
294 | * @returns the number of steppings on the brightness slider | 296 | * @returns the number of steppings on the brightness slider |
295 | * in the Light-'n-Power settings. Values smaller than zero and bigger | 297 | * in the Light-'n-Power settings. Values smaller than zero and bigger |
296 | * than 255 do not make sense. | 298 | * than 255 do not make sense. |
297 | * | 299 | * |
298 | * \sa QSlider::setLineStep | 300 | * \sa QSlider::setLineStep |
299 | * \sa QSlider::setPageStep | 301 | * \sa QSlider::setPageStep |
300 | */ | 302 | */ |
301 | int ODevice::displayBrightnessResolution() const | 303 | int ODevice::displayBrightnessResolution() const |
302 | { | 304 | { |
303 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 305 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
304 | return 16; | 306 | return 16; |
305 | } | 307 | } |
306 | 308 | ||
307 | /** | 309 | /** |
308 | * This sets the display contrast | 310 | * This sets the display contrast |
309 | * @param p The contrast to be set on a scale from 0 to 255 | 311 | * @param p The contrast to be set on a scale from 0 to 255 |
310 | * @returns success or failure | 312 | * @returns success or failure |
311 | */ | 313 | */ |
312 | bool ODevice::setDisplayContrast( int p ) | 314 | bool ODevice::setDisplayContrast( int p ) |
313 | { | 315 | { |
314 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); | 316 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); |
315 | return false; | 317 | return false; |
316 | } | 318 | } |
317 | 319 | ||
318 | /** | 320 | /** |
319 | * @returns the maximum value for the contrast settings slider | 321 | * @returns the maximum value for the contrast settings slider |
320 | * or 0 if the device doesn't support setting of a contrast | 322 | * or 0 if the device doesn't support setting of a contrast |
321 | */ | 323 | */ |
322 | int ODevice::displayContrastResolution() const | 324 | int ODevice::displayContrastResolution() const |
323 | { | 325 | { |
324 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 326 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||
328 | /** | 330 | /** |
329 | * This returns the vendor as string | 331 | * This returns the vendor as string |
330 | * @return Vendor as QString | 332 | * @return Vendor as QString |
331 | */ | 333 | */ |
332 | QString ODevice::vendorString() const | 334 | QString ODevice::vendorString() const |
333 | { | 335 | { |
334 | return d->m_vendorstr; | 336 | return d->m_vendorstr; |
diff --git a/libopie2/opiecore/device/odevice_beagle.cpp b/libopie2/opiecore/device/odevice_beagle.cpp index ac12ca6..8735c63 100644 --- a/libopie2/opiecore/device/odevice_beagle.cpp +++ b/libopie2/opiecore/device/odevice_beagle.cpp | |||
@@ -1,201 +1,202 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2004 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevicebutton.h" | 31 | #include "odevicebutton.h" |
31 | #include "odevice_beagle.h" | 32 | #include "odevice_beagle.h" |
32 | 33 | ||
33 | #include <qpe/resource.h> | 34 | #include <opie2/oresource.h> |
34 | 35 | ||
35 | #include <sys/types.h> | 36 | #include <sys/types.h> |
36 | #include <sys/ioctl.h> | 37 | #include <sys/ioctl.h> |
37 | #include <fcntl.h> | 38 | #include <fcntl.h> |
38 | #include <unistd.h> | 39 | #include <unistd.h> |
39 | 40 | ||
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Intel Assabat FrontLight Control | 43 | * Intel Assabat FrontLight Control |
43 | */ | 44 | */ |
44 | #define _SA1100_FL_IOCTL_ON 1 | 45 | #define _SA1100_FL_IOCTL_ON 1 |
45 | #define _SA1100_FL_IOCTL_OFF 2 | 46 | #define _SA1100_FL_IOCTL_OFF 2 |
46 | #define _SA1100_FL_IOCTL_INTENSITY3 | 47 | #define _SA1100_FL_IOCTL_INTENSITY3 |
47 | #define _SA1100_FL_IOCTL_BACKLIGHT 4 | 48 | #define _SA1100_FL_IOCTL_BACKLIGHT 4 |
48 | #define _SA1100_FL_IOCTL_CONTRAST5 | 49 | #define _SA1100_FL_IOCTL_CONTRAST5 |
49 | #define _SA1100_FL_IOCTL_GET_BACKLIGHT 6 | 50 | #define _SA1100_FL_IOCTL_GET_BACKLIGHT 6 |
50 | #define _SA1100_FL_IOCTL_GET_CONTRAST 7 | 51 | #define _SA1100_FL_IOCTL_GET_CONTRAST 7 |
51 | // added by Sean Hsieh | 52 | // added by Sean Hsieh |
52 | #define _SA1100_FL_IOCTL_PWR_TOGGLE 8 | 53 | #define _SA1100_FL_IOCTL_PWR_TOGGLE 8 |
53 | #define _SA1100_FL_IOCTL_AUTOLIGHT 10 | 54 | #define _SA1100_FL_IOCTL_AUTOLIGHT 10 |
54 | 55 | ||
55 | /* | 56 | /* |
56 | * The device | 57 | * The device |
57 | */ | 58 | */ |
58 | #define FL_MAJOR 60 | 59 | #define FL_MAJOR 60 |
59 | #define FL_NAME "sa1100-fl" | 60 | #define FL_NAME "sa1100-fl" |
60 | #define FL_FILE "/dev/sa1100-fl" | 61 | #define FL_FILE "/dev/sa1100-fl" |
61 | 62 | ||
62 | namespace Opie { | 63 | namespace Opie { |
63 | namespace Core { | 64 | namespace Core { |
64 | namespace Internal { | 65 | namespace Internal { |
65 | 66 | ||
66 | struct b_button { | 67 | struct b_button { |
67 | uint model; | 68 | uint model; |
68 | Qt::Key code; | 69 | Qt::Key code; |
69 | char *utext; | 70 | char *utext; |
70 | char *pix; | 71 | char *pix; |
71 | char *fpressedservice; | 72 | char *fpressedservice; |
72 | char *fpressedaction; | 73 | char *fpressedaction; |
73 | char *fheldservice; | 74 | char *fheldservice; |
74 | char *fheldaction; | 75 | char *fheldaction; |
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
78 | /* | 79 | /* |
79 | * The MVista Beagle kernel maps the action | 80 | * The MVista Beagle kernel maps the action |
80 | * buttons to the Qt keymap | 81 | * buttons to the Qt keymap |
81 | */ | 82 | */ |
82 | struct b_button beagle_buttons [] = { | 83 | struct b_button beagle_buttons [] = { |
83 | { Model_Beagle_PA100, | 84 | { Model_Beagle_PA100, |
84 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Record Button"), | 85 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Record Button"), |
85 | "devicebuttons/beagle_record", | 86 | "devicebuttons/beagle_record", |
86 | "QPE/VMemo", "toggleRecord()", | 87 | "QPE/VMemo", "toggleRecord()", |
87 | "sound", "raise()" }, | 88 | "sound", "raise()" }, |
88 | { Model_Beagle_PA100, | 89 | { Model_Beagle_PA100, |
89 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
90 | "devicebuttons/beagle_calendar", | 91 | "devicebuttons/beagle_calendar", |
91 | "datebook", "nextView()", | 92 | "datebook", "nextView()", |
92 | "today", "raise()" }, | 93 | "today", "raise()" }, |
93 | { Model_Beagle_PA100, | 94 | { Model_Beagle_PA100, |
94 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 95 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
95 | "devicebuttons/beagle_contact", | 96 | "devicebuttons/beagle_contact", |
96 | "addressbook", "raise()", | 97 | "addressbook", "raise()", |
97 | "addressbook", "beamBusinessCard()" }, | 98 | "addressbook", "beamBusinessCard()" }, |
98 | { Model_Beagle_PA100, | 99 | { Model_Beagle_PA100, |
99 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | 100 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), |
100 | "devicebuttons/beagle_todo", | 101 | "devicebuttons/beagle_todo", |
101 | "todolist", "raise()", | 102 | "todolist", "raise()", |
102 | "QPE/TaskBar", "toggleMenu()" }, | 103 | "QPE/TaskBar", "toggleMenu()" }, |
103 | { Model_Beagle_PA100, | 104 | { Model_Beagle_PA100, |
104 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
105 | "devicebuttons/beagle_home", | 106 | "devicebuttons/beagle_home", |
106 | "QPE/Launcher", "home()", | 107 | "QPE/Launcher", "home()", |
107 | "buttonsettings", "raise()" }, | 108 | "buttonsettings", "raise()" }, |
108 | }; | 109 | }; |
109 | 110 | ||
110 | 111 | ||
111 | Beagle::Beagle() {} | 112 | Beagle::Beagle() {} |
112 | 113 | ||
113 | Beagle::~Beagle() {} | 114 | Beagle::~Beagle() {} |
114 | 115 | ||
115 | /* | 116 | /* |
116 | * Simply set the Tradesquare.NL data | 117 | * Simply set the Tradesquare.NL data |
117 | */ | 118 | */ |
118 | void Beagle::init( const QString&) { | 119 | void Beagle::init( const QString&) { |
119 | /* | 120 | /* |
120 | * No other assabat model yet | 121 | * No other assabat model yet |
121 | */ | 122 | */ |
122 | d->m_vendorstr = "Tradesquare.NL"; | 123 | d->m_vendorstr = "Tradesquare.NL"; |
123 | d->m_vendor = Vendor_MasterIA; | 124 | d->m_vendor = Vendor_MasterIA; |
124 | d->m_modelstr = "Tuxpda 1"; | 125 | d->m_modelstr = "Tuxpda 1"; |
125 | d->m_rotation = Rot0; | 126 | d->m_rotation = Rot0; |
126 | d->m_model = Model_Beagle_PA100; | 127 | d->m_model = Model_Beagle_PA100; |
127 | } | 128 | } |
128 | 129 | ||
129 | 130 | ||
130 | /* | 131 | /* |
131 | * Initialize the Buttons. We only do it | 132 | * Initialize the Buttons. We only do it |
132 | * if not yet initialized. | 133 | * if not yet initialized. |
133 | * We go through our hardware button array | 134 | * We go through our hardware button array |
134 | * and set the 'Factory' Pressed and Held Action | 135 | * and set the 'Factory' Pressed and Held Action |
135 | * reloadButtonMapping will then apply the user | 136 | * reloadButtonMapping will then apply the user |
136 | * configuration to the buttons | 137 | * configuration to the buttons |
137 | */ | 138 | */ |
138 | void Beagle::initButtons() { | 139 | void Beagle::initButtons() { |
139 | if ( d->m_buttons ) | 140 | if ( d->m_buttons ) |
140 | return; | 141 | return; |
141 | 142 | ||
142 | d->m_buttons = new QValueList<ODeviceButton>; | 143 | d->m_buttons = new QValueList<ODeviceButton>; |
143 | uint length = sizeof( beagle_buttons )/ sizeof( b_button ); | 144 | uint length = sizeof( beagle_buttons )/ sizeof( b_button ); |
144 | for ( uint i = 0; i < length; ++i ) { | 145 | for ( uint i = 0; i < length; ++i ) { |
145 | b_button *bb = &beagle_buttons[i]; | 146 | b_button *bb = &beagle_buttons[i]; |
146 | ODeviceButton b; | 147 | ODeviceButton b; |
147 | b.setKeycode( bb->code ); | 148 | b.setKeycode( bb->code ); |
148 | b.setUserText( QObject::tr( "Button", bb->utext ) ); | 149 | b.setUserText( QObject::tr( "Button", bb->utext ) ); |
149 | b.setPixmap( Resource::loadPixmap( bb->pix ) ); | 150 | b.setPixmap( OResource::loadPixmap( bb->pix ) ); |
150 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) ); | 151 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) ); |
151 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) ); | 152 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) ); |
152 | d->m_buttons->append( b ); | 153 | d->m_buttons->append( b ); |
153 | } | 154 | } |
154 | 155 | ||
155 | reloadButtonMapping(); | 156 | reloadButtonMapping(); |
156 | } | 157 | } |
157 | 158 | ||
158 | /* | 159 | /* |
159 | * Turn the display on. We do it by ioctl on FL_FILE | 160 | * Turn the display on. We do it by ioctl on FL_FILE |
160 | */ | 161 | */ |
161 | bool Beagle::setDisplayStatus( bool on ) { | 162 | bool Beagle::setDisplayStatus( bool on ) { |
162 | int fd = ::open(FL_FILE, O_WRONLY); | 163 | int fd = ::open(FL_FILE, O_WRONLY); |
163 | 164 | ||
164 | if ( fd < 0 ) | 165 | if ( fd < 0 ) |
165 | return false; | 166 | return false; |
166 | 167 | ||
167 | return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == 0 ); | 168 | return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == 0 ); |
168 | } | 169 | } |
169 | 170 | ||
170 | /* | 171 | /* |
171 | * 0-100 are legal steps of the frontlight. | 172 | * 0-100 are legal steps of the frontlight. |
172 | */ | 173 | */ |
173 | int Beagle::displayBrightnessResolution()const { | 174 | int Beagle::displayBrightnessResolution()const { |
174 | return 100; | 175 | return 100; |
175 | } | 176 | } |
176 | 177 | ||
177 | /* | 178 | /* |
178 | * Opie uses the values 0-255 for the frontlight | 179 | * Opie uses the values 0-255 for the frontlight |
179 | * intensity and we need to map it to the range | 180 | * intensity and we need to map it to the range |
180 | * of 0-100. | 181 | * of 0-100. |
181 | * But first we do some sanity of the range of brightness | 182 | * But first we do some sanity of the range of brightness |
182 | * | 183 | * |
183 | */ | 184 | */ |
184 | bool Beagle::setDisplayBrightness( int brightness ) { | 185 | bool Beagle::setDisplayBrightness( int brightness ) { |
185 | if ( brightness > 255 ) | 186 | if ( brightness > 255 ) |
186 | brightness = 255; | 187 | brightness = 255; |
187 | else if ( brightness < 0 ) | 188 | else if ( brightness < 0 ) |
188 | brightness = 0; | 189 | brightness = 0; |
189 | brightness = (100*brightness)/255; | 190 | brightness = (100*brightness)/255; |
190 | 191 | ||
191 | int fd = ::open(FL_FILE, O_WRONLY); | 192 | int fd = ::open(FL_FILE, O_WRONLY); |
192 | 193 | ||
193 | if ( fd < 0 ) | 194 | if ( fd < 0 ) |
194 | return false; | 195 | return false; |
195 | 196 | ||
196 | return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness ) == 0 ); | 197 | return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness ) == 0 ); |
197 | } | 198 | } |
198 | 199 | ||
199 | } | 200 | } |
200 | } | 201 | } |
201 | } | 202 | } |
diff --git a/libopie2/opiecore/device/odevice_genuineintel.cpp b/libopie2/opiecore/device/odevice_genuineintel.cpp index 1584249..b980909 100644 --- a/libopie2/opiecore/device/odevice_genuineintel.cpp +++ b/libopie2/opiecore/device/odevice_genuineintel.cpp | |||
@@ -1,187 +1,189 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002, 2003, 2004 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_genuineintel.h" | 31 | #include "odevice_genuineintel.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | |||
43 | #include <opie2/okeyfilter.h> | 44 | #include <opie2/okeyfilter.h> |
45 | #include <opie2/oresource.h> | ||
44 | 46 | ||
45 | #ifndef QT_NO_SOUND | 47 | #ifndef QT_NO_SOUND |
46 | #include <linux/soundcard.h> | 48 | #include <linux/soundcard.h> |
47 | #endif | 49 | #endif |
48 | 50 | ||
49 | using namespace Opie::Core; | 51 | using namespace Opie::Core; |
50 | using namespace Opie::Core::Internal; | 52 | using namespace Opie::Core::Internal; |
51 | 53 | ||
52 | struct gi_button genuineintel_buttons [] = { | 54 | struct gi_button genuineintel_buttons [] = { |
53 | { | 55 | { |
54 | Qt::Key_F1, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 56 | Qt::Key_F1, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
55 | "devicebuttons/ipaq_calendar", | 57 | "devicebuttons/ipaq_calendar", |
56 | "datebook", "nextView()", | 58 | "datebook", "nextView()", |
57 | "today", "raise()" }, | 59 | "today", "raise()" }, |
58 | { | 60 | { |
59 | Qt::Key_F2, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 61 | Qt::Key_F2, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
60 | "devicebuttons/ipaq_contact", | 62 | "devicebuttons/ipaq_contact", |
61 | "addressbook", "raise()", | 63 | "addressbook", "raise()", |
62 | "addressbook", "beamBusinessCard()" }, | 64 | "addressbook", "beamBusinessCard()" }, |
63 | { | 65 | { |
64 | Qt::Key_F3, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 66 | Qt::Key_F3, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
65 | "devicebuttons/ipaq_menu", | 67 | "devicebuttons/ipaq_menu", |
66 | "QPE/TaskBar", "toggleMenu()", | 68 | "QPE/TaskBar", "toggleMenu()", |
67 | "QPE/TaskBar", "toggleStartMenu()" }, | 69 | "QPE/TaskBar", "toggleStartMenu()" }, |
68 | { | 70 | { |
69 | Qt::Key_F4, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 71 | Qt::Key_F4, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
70 | "devicebuttons/ipaq_mail", | 72 | "devicebuttons/ipaq_mail", |
71 | "opiemail", "raise()", | 73 | "opiemail", "raise()", |
72 | "opiemail", "newMail()" }, | 74 | "opiemail", "newMail()" }, |
73 | { | 75 | { |
74 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Home Button"), | 76 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Home Button"), |
75 | "devicebuttons/ipaq_home", | 77 | "devicebuttons/ipaq_home", |
76 | "QPE/Launcher", "home()", | 78 | "QPE/Launcher", "home()", |
77 | "buttonsettings", "raise()" }, | 79 | "buttonsettings", "raise()" }, |
78 | { | 80 | { |
79 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Record Button"), | 81 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Record Button"), |
80 | "devicebuttons/ipaq_record", | 82 | "devicebuttons/ipaq_record", |
81 | "QPE/VMemo", "toggleRecord()", | 83 | "QPE/VMemo", "toggleRecord()", |
82 | "sound", "raise()" }, | 84 | "sound", "raise()" }, |
83 | }; | 85 | }; |
84 | 86 | ||
85 | void GenuineIntel::init(const QString& model) | 87 | void GenuineIntel::init(const QString& model) |
86 | { | 88 | { |
87 | d->m_vendorstr = "Intel"; | 89 | d->m_vendorstr = "Intel"; |
88 | d->m_vendor = Vendor_GenuineIntel; | 90 | d->m_vendor = Vendor_GenuineIntel; |
89 | 91 | ||
90 | QStringList SL = QStringList::split( " ", model ); | 92 | QStringList SL = QStringList::split( " ", model ); |
91 | 93 | ||
92 | d->m_model = Model_GenuineIntel; | 94 | d->m_model = Model_GenuineIntel; |
93 | d->m_rotation = Rot0; | 95 | d->m_rotation = Rot0; |
94 | } | 96 | } |
95 | 97 | ||
96 | void GenuineIntel::initButtons() | 98 | void GenuineIntel::initButtons() |
97 | { | 99 | { |
98 | if ( d->m_buttons ) | 100 | if ( d->m_buttons ) |
99 | return; | 101 | return; |
100 | 102 | ||
101 | if ( isQWS( ) ) { | 103 | if ( isQWS( ) ) { |
102 | addPreHandler(this); | 104 | addPreHandler(this); |
103 | } | 105 | } |
104 | 106 | ||
105 | d->m_buttons = new QValueList <ODeviceButton>; | 107 | d->m_buttons = new QValueList <ODeviceButton>; |
106 | 108 | ||
107 | for ( uint i = 0; i < ( sizeof( genuineintel_buttons ) / sizeof( gi_button )); i++ ) { | 109 | for ( uint i = 0; i < ( sizeof( genuineintel_buttons ) / sizeof( gi_button )); i++ ) { |
108 | gi_button *ib = genuineintel_buttons + i; | 110 | gi_button *ib = genuineintel_buttons + i; |
109 | ODeviceButton b; | 111 | ODeviceButton b; |
110 | 112 | ||
111 | b. setKeycode ( ib->code ); | 113 | b. setKeycode ( ib->code ); |
112 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 114 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
113 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 115 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
114 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 116 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
115 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 117 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
116 | 118 | ||
117 | d->m_buttons->append ( b ); | 119 | d->m_buttons->append ( b ); |
118 | } | 120 | } |
119 | reloadButtonMapping(); | 121 | reloadButtonMapping(); |
120 | } | 122 | } |
121 | 123 | ||
122 | QValueList <OLed> GenuineIntel::ledList() const | 124 | QValueList <OLed> GenuineIntel::ledList() const |
123 | { | 125 | { |
124 | QValueList <OLed> vl; | 126 | QValueList <OLed> vl; |
125 | return vl; //none | 127 | return vl; //none |
126 | } | 128 | } |
127 | 129 | ||
128 | QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const | 130 | QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const |
129 | { | 131 | { |
130 | QValueList <OLedState> vl; | 132 | QValueList <OLedState> vl; |
131 | return vl; // none | 133 | return vl; // none |
132 | } | 134 | } |
133 | 135 | ||
134 | OLedState GenuineIntel::ledState ( OLed ) const | 136 | OLedState GenuineIntel::ledState ( OLed ) const |
135 | { | 137 | { |
136 | return Led_Off; | 138 | return Led_Off; |
137 | } | 139 | } |
138 | 140 | ||
139 | bool GenuineIntel::setLedState ( OLed , OLedState ) | 141 | bool GenuineIntel::setLedState ( OLed , OLedState ) |
140 | { | 142 | { |
141 | return false; | 143 | return false; |
142 | } | 144 | } |
143 | 145 | ||
144 | 146 | ||
145 | bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool ) | 147 | bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool ) |
146 | { | 148 | { |
147 | return false; | 149 | return false; |
148 | } | 150 | } |
149 | 151 | ||
150 | void GenuineIntel::playAlarmSound() | 152 | void GenuineIntel::playAlarmSound() |
151 | { | 153 | { |
152 | #ifndef QT_NO_SOUND | 154 | #ifndef QT_NO_SOUND |
153 | static Sound snd ( "alarm" ); | 155 | static Sound snd ( "alarm" ); |
154 | if(!snd.isFinished()) | 156 | if(!snd.isFinished()) |
155 | return; | 157 | return; |
156 | 158 | ||
157 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 159 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
158 | snd. play(); | 160 | snd. play(); |
159 | #endif | 161 | #endif |
160 | } | 162 | } |
161 | 163 | ||
162 | 164 | ||
163 | bool GenuineIntel::setDisplayBrightness ( int ) | 165 | bool GenuineIntel::setDisplayBrightness ( int ) |
164 | { | 166 | { |
165 | return false; | 167 | return false; |
166 | } | 168 | } |
167 | 169 | ||
168 | int GenuineIntel::displayBrightnessResolution() const | 170 | int GenuineIntel::displayBrightnessResolution() const |
169 | { | 171 | { |
170 | return 1; // perhaps to avoid division by zero | 172 | return 1; // perhaps to avoid division by zero |
171 | } | 173 | } |
172 | 174 | ||
173 | 175 | ||
174 | bool GenuineIntel::hasLightSensor() const | 176 | bool GenuineIntel::hasLightSensor() const |
175 | { | 177 | { |
176 | return false; | 178 | return false; |
177 | } | 179 | } |
178 | 180 | ||
179 | int GenuineIntel::readLightSensor() | 181 | int GenuineIntel::readLightSensor() |
180 | { | 182 | { |
181 | return 0; | 183 | return 0; |
182 | } | 184 | } |
183 | 185 | ||
184 | int GenuineIntel::lightSensorResolution() const | 186 | int GenuineIntel::lightSensorResolution() const |
185 | { | 187 | { |
186 | return 1; // see above | 188 | return 1; // see above |
187 | } | 189 | } |
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 2ce38a9..8bc775f 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -1,280 +1,282 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002, 2003, 2004 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_ipaq.h" | 31 | #include "odevice_ipaq.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | |||
43 | #include <opie2/okeyfilter.h> | 44 | #include <opie2/okeyfilter.h> |
45 | #include <opie2/oresource.h> | ||
44 | 46 | ||
45 | /* STD */ | 47 | /* STD */ |
46 | #include <fcntl.h> | 48 | #include <fcntl.h> |
47 | #include <math.h> | 49 | #include <math.h> |
48 | #include <stdlib.h> | 50 | #include <stdlib.h> |
49 | #include <signal.h> | 51 | #include <signal.h> |
50 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> |
51 | #include <sys/time.h> | 53 | #include <sys/time.h> |
52 | #include <unistd.h> | 54 | #include <unistd.h> |
53 | #ifndef QT_NO_SOUND | 55 | #ifndef QT_NO_SOUND |
54 | #include <linux/soundcard.h> | 56 | #include <linux/soundcard.h> |
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | 59 | ||
58 | using namespace Opie::Core; | 60 | using namespace Opie::Core; |
59 | using namespace Opie::Core::Internal; | 61 | using namespace Opie::Core::Internal; |
60 | 62 | ||
61 | /* KERNEL */ | 63 | /* KERNEL */ |
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 64 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
63 | 65 | ||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 66 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 67 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 68 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 69 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
68 | 70 | ||
69 | typedef struct { | 71 | typedef struct { |
70 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 72 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
71 | unsigned char TotalTime; /* Units of 5 seconds */ | 73 | unsigned char TotalTime; /* Units of 5 seconds */ |
72 | unsigned char OnTime; /* units of 100m/s */ | 74 | unsigned char OnTime; /* units of 100m/s */ |
73 | unsigned char OffTime; /* units of 100m/s */ | 75 | unsigned char OffTime; /* units of 100m/s */ |
74 | } LED_IN; | 76 | } LED_IN; |
75 | 77 | ||
76 | typedef struct { | 78 | typedef struct { |
77 | unsigned char mode; | 79 | unsigned char mode; |
78 | unsigned char pwr; | 80 | unsigned char pwr; |
79 | unsigned char brightness; | 81 | unsigned char brightness; |
80 | } FLITE_IN; | 82 | } FLITE_IN; |
81 | 83 | ||
82 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 84 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
83 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 85 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
84 | 86 | ||
85 | struct i_button ipaq_buttons [] = { | 87 | struct i_button ipaq_buttons [] = { |
86 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 88 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
87 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 89 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
88 | "devicebuttons/ipaq_calendar", | 90 | "devicebuttons/ipaq_calendar", |
89 | "datebook", "nextView()", | 91 | "datebook", "nextView()", |
90 | "today", "raise()" }, | 92 | "today", "raise()" }, |
91 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 93 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
92 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 94 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
93 | "devicebuttons/ipaq_contact", | 95 | "devicebuttons/ipaq_contact", |
94 | "addressbook", "raise()", | 96 | "addressbook", "raise()", |
95 | "addressbook", "beamBusinessCard()" }, | 97 | "addressbook", "beamBusinessCard()" }, |
96 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 98 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
97 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 99 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
98 | "devicebuttons/ipaq_menu", | 100 | "devicebuttons/ipaq_menu", |
99 | "QPE/TaskBar", "toggleMenu()", | 101 | "QPE/TaskBar", "toggleMenu()", |
100 | "QPE/TaskBar", "toggleStartMenu()" }, | 102 | "QPE/TaskBar", "toggleStartMenu()" }, |
101 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 103 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
102 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 104 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
103 | "devicebuttons/ipaq_mail", | 105 | "devicebuttons/ipaq_mail", |
104 | "opiemail", "raise()", | 106 | "opiemail", "raise()", |
105 | "opiemail", "newMail()" }, | 107 | "opiemail", "newMail()" }, |
106 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 108 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
107 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 109 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
108 | "devicebuttons/ipaq_home", | 110 | "devicebuttons/ipaq_home", |
109 | "QPE/Launcher", "home()", | 111 | "QPE/Launcher", "home()", |
110 | "buttonsettings", "raise()" }, | 112 | "buttonsettings", "raise()" }, |
111 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 113 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
112 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 114 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
113 | "devicebuttons/ipaq_record", | 115 | "devicebuttons/ipaq_record", |
114 | "QPE/VMemo", "toggleRecord()", | 116 | "QPE/VMemo", "toggleRecord()", |
115 | "sound", "raise()" }, | 117 | "sound", "raise()" }, |
116 | }; | 118 | }; |
117 | 119 | ||
118 | void iPAQ::init(const QString& model) | 120 | void iPAQ::init(const QString& model) |
119 | { | 121 | { |
120 | d->m_vendorstr = "HP"; | 122 | d->m_vendorstr = "HP"; |
121 | d->m_vendor = Vendor_HP; | 123 | d->m_vendor = Vendor_HP; |
122 | 124 | ||
123 | d->m_modelstr = model.mid(model.findRev('H')); | 125 | d->m_modelstr = model.mid(model.findRev('H')); |
124 | 126 | ||
125 | if ( d->m_modelstr == "H3100" ) | 127 | if ( d->m_modelstr == "H3100" ) |
126 | d->m_model = Model_iPAQ_H31xx; | 128 | d->m_model = Model_iPAQ_H31xx; |
127 | else if ( d->m_modelstr == "H3600" ) | 129 | else if ( d->m_modelstr == "H3600" ) |
128 | d->m_model = Model_iPAQ_H36xx; | 130 | d->m_model = Model_iPAQ_H36xx; |
129 | else if ( d->m_modelstr == "H3700" ) | 131 | else if ( d->m_modelstr == "H3700" ) |
130 | d->m_model = Model_iPAQ_H37xx; | 132 | d->m_model = Model_iPAQ_H37xx; |
131 | else if ( d->m_modelstr == "H3800" ) | 133 | else if ( d->m_modelstr == "H3800" ) |
132 | d->m_model = Model_iPAQ_H38xx; | 134 | d->m_model = Model_iPAQ_H38xx; |
133 | else if ( d->m_modelstr == "H3900" ) | 135 | else if ( d->m_modelstr == "H3900" ) |
134 | d->m_model = Model_iPAQ_H39xx; | 136 | d->m_model = Model_iPAQ_H39xx; |
135 | else if ( d->m_modelstr == "H5400" ) | 137 | else if ( d->m_modelstr == "H5400" ) |
136 | d->m_model = Model_iPAQ_H5xxx; | 138 | d->m_model = Model_iPAQ_H5xxx; |
137 | else if ( d->m_modelstr == "H2200" ) | 139 | else if ( d->m_modelstr == "H2200" ) |
138 | d->m_model = Model_iPAQ_H22xx; | 140 | d->m_model = Model_iPAQ_H22xx; |
139 | else | 141 | else |
140 | d->m_model = Model_Unknown; | 142 | d->m_model = Model_Unknown; |
141 | 143 | ||
142 | switch ( d->m_model ) { | 144 | switch ( d->m_model ) { |
143 | case Model_iPAQ_H31xx: | 145 | case Model_iPAQ_H31xx: |
144 | case Model_iPAQ_H38xx: | 146 | case Model_iPAQ_H38xx: |
145 | d->m_rotation = Rot90; | 147 | d->m_rotation = Rot90; |
146 | break; | 148 | break; |
147 | case Model_iPAQ_H5xxx: | 149 | case Model_iPAQ_H5xxx: |
148 | case Model_iPAQ_H22xx: | 150 | case Model_iPAQ_H22xx: |
149 | d->m_rotation = Rot0; | 151 | d->m_rotation = Rot0; |
150 | break; | 152 | break; |
151 | case Model_iPAQ_H36xx: | 153 | case Model_iPAQ_H36xx: |
152 | case Model_iPAQ_H37xx: | 154 | case Model_iPAQ_H37xx: |
153 | case Model_iPAQ_H39xx: | 155 | case Model_iPAQ_H39xx: |
154 | default: | 156 | default: |
155 | d->m_rotation = Rot270; | 157 | d->m_rotation = Rot270; |
156 | break; | 158 | break; |
157 | 159 | ||
158 | } | 160 | } |
159 | 161 | ||
160 | m_leds [0] = m_leds [1] = Led_Off; | 162 | m_leds [0] = m_leds [1] = Led_Off; |
161 | 163 | ||
162 | m_power_timer = 0; | 164 | m_power_timer = 0; |
163 | 165 | ||
164 | } | 166 | } |
165 | 167 | ||
166 | void iPAQ::initButtons() | 168 | void iPAQ::initButtons() |
167 | { | 169 | { |
168 | if ( d->m_buttons ) | 170 | if ( d->m_buttons ) |
169 | return; | 171 | return; |
170 | 172 | ||
171 | if ( isQWS( ) ) { | 173 | if ( isQWS( ) ) { |
172 | addPreHandler(this); | 174 | addPreHandler(this); |
173 | } | 175 | } |
174 | 176 | ||
175 | d->m_buttons = new QValueList <ODeviceButton>; | 177 | d->m_buttons = new QValueList <ODeviceButton>; |
176 | 178 | ||
177 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 179 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
178 | i_button *ib = ipaq_buttons + i; | 180 | i_button *ib = ipaq_buttons + i; |
179 | ODeviceButton b; | 181 | ODeviceButton b; |
180 | 182 | ||
181 | if (( ib->model & d->m_model ) == d->m_model ) { | 183 | if (( ib->model & d->m_model ) == d->m_model ) { |
182 | b. setKeycode ( ib->code ); | 184 | b. setKeycode ( ib->code ); |
183 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 185 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
184 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 186 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
185 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 187 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
186 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 188 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
187 | 189 | ||
188 | d->m_buttons->append ( b ); | 190 | d->m_buttons->append ( b ); |
189 | } | 191 | } |
190 | } | 192 | } |
191 | reloadButtonMapping(); | 193 | reloadButtonMapping(); |
192 | } | 194 | } |
193 | 195 | ||
194 | QValueList <OLed> iPAQ::ledList() const | 196 | QValueList <OLed> iPAQ::ledList() const |
195 | { | 197 | { |
196 | QValueList <OLed> vl; | 198 | QValueList <OLed> vl; |
197 | vl << Led_Power; | 199 | vl << Led_Power; |
198 | 200 | ||
199 | if ( d->m_model == Model_iPAQ_H38xx ) | 201 | if ( d->m_model == Model_iPAQ_H38xx ) |
200 | vl << Led_BlueTooth; | 202 | vl << Led_BlueTooth; |
201 | return vl; | 203 | return vl; |
202 | } | 204 | } |
203 | 205 | ||
204 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 206 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
205 | { | 207 | { |
206 | QValueList <OLedState> vl; | 208 | QValueList <OLedState> vl; |
207 | 209 | ||
208 | if ( l == Led_Power ) | 210 | if ( l == Led_Power ) |
209 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 211 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
210 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) | 212 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) |
211 | vl << Led_Off; // << Led_On << ??? | 213 | vl << Led_Off; // << Led_On << ??? |
212 | 214 | ||
213 | return vl; | 215 | return vl; |
214 | } | 216 | } |
215 | 217 | ||
216 | OLedState iPAQ::ledState ( OLed l ) const | 218 | OLedState iPAQ::ledState ( OLed l ) const |
217 | { | 219 | { |
218 | switch ( l ) { | 220 | switch ( l ) { |
219 | case Led_Power: | 221 | case Led_Power: |
220 | return m_leds [0]; | 222 | return m_leds [0]; |
221 | case Led_BlueTooth: | 223 | case Led_BlueTooth: |
222 | return m_leds [1]; | 224 | return m_leds [1]; |
223 | default: | 225 | default: |
224 | return Led_Off; | 226 | return Led_Off; |
225 | } | 227 | } |
226 | } | 228 | } |
227 | 229 | ||
228 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 230 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
229 | { | 231 | { |
230 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 232 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
231 | 233 | ||
232 | if ( l == Led_Power ) { | 234 | if ( l == Led_Power ) { |
233 | if ( fd >= 0 ) { | 235 | if ( fd >= 0 ) { |
234 | LED_IN leds; | 236 | LED_IN leds; |
235 | ::memset ( &leds, 0, sizeof( leds )); | 237 | ::memset ( &leds, 0, sizeof( leds )); |
236 | leds. TotalTime = 0; | 238 | leds. TotalTime = 0; |
237 | leds. OnTime = 0; | 239 | leds. OnTime = 0; |
238 | leds. OffTime = 1; | 240 | leds. OffTime = 1; |
239 | leds. OffOnBlink = 2; | 241 | leds. OffOnBlink = 2; |
240 | 242 | ||
241 | switch ( st ) { | 243 | switch ( st ) { |
242 | case Led_Off : leds. OffOnBlink = 0; break; | 244 | case Led_Off : leds. OffOnBlink = 0; break; |
243 | case Led_On : leds. OffOnBlink = 1; break; | 245 | case Led_On : leds. OffOnBlink = 1; break; |
244 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 246 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
245 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 247 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
246 | } | 248 | } |
247 | 249 | ||
248 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 250 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
249 | m_leds [0] = st; | 251 | m_leds [0] = st; |
250 | return true; | 252 | return true; |
251 | } | 253 | } |
252 | } | 254 | } |
253 | } | 255 | } |
254 | return false; | 256 | return false; |
255 | } | 257 | } |
256 | 258 | ||
257 | 259 | ||
258 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 260 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
259 | { | 261 | { |
260 | int newkeycode = keycode; | 262 | int newkeycode = keycode; |
261 | 263 | ||
262 | switch ( keycode ) { | 264 | switch ( keycode ) { |
263 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 265 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
264 | case HardKey_Menu: { | 266 | case HardKey_Menu: { |
265 | if (( d->m_model == Model_iPAQ_H38xx ) || | 267 | if (( d->m_model == Model_iPAQ_H38xx ) || |
266 | ( d->m_model == Model_iPAQ_H39xx ) || | 268 | ( d->m_model == Model_iPAQ_H39xx ) || |
267 | ( d->m_model == Model_iPAQ_H5xxx)) { | 269 | ( d->m_model == Model_iPAQ_H5xxx)) { |
268 | newkeycode = HardKey_Mail; | 270 | newkeycode = HardKey_Mail; |
269 | } | 271 | } |
270 | break; | 272 | break; |
271 | } | 273 | } |
272 | 274 | ||
273 | // Rotate cursor keys 180 or 270 | 275 | // Rotate cursor keys 180 or 270 |
274 | case Key_Left : | 276 | case Key_Left : |
275 | case Key_Right: | 277 | case Key_Right: |
276 | case Key_Up : | 278 | case Key_Up : |
277 | case Key_Down : { | 279 | case Key_Down : { |
278 | if (( d->m_model == Model_iPAQ_H31xx ) || | 280 | if (( d->m_model == Model_iPAQ_H31xx ) || |
279 | ( d->m_model == Model_iPAQ_H38xx )) { | 281 | ( d->m_model == Model_iPAQ_H38xx )) { |
280 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 282 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index 3acba03..7dbde48 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,213 +1,215 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_jornada.h" | 31 | #include "odevice_jornada.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | #include <opie2/oresource.h> | ||
45 | |||
44 | /* STD */ | 46 | /* STD */ |
45 | #include <fcntl.h> | 47 | #include <fcntl.h> |
46 | #include <math.h> | 48 | #include <math.h> |
47 | #include <stdlib.h> | 49 | #include <stdlib.h> |
48 | #include <signal.h> | 50 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 52 | #include <sys/time.h> |
51 | #include <unistd.h> | 53 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 54 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 55 | #include <linux/soundcard.h> |
54 | #endif | 56 | #endif |
55 | 57 | ||
56 | /* KERNEL */ | 58 | /* KERNEL */ |
57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 59 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
58 | 60 | ||
59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 61 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 62 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 63 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 64 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
63 | 65 | ||
64 | typedef struct { | 66 | typedef struct { |
65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 67 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
66 | unsigned char TotalTime; /* Units of 5 seconds */ | 68 | unsigned char TotalTime; /* Units of 5 seconds */ |
67 | unsigned char OnTime; /* units of 100m/s */ | 69 | unsigned char OnTime; /* units of 100m/s */ |
68 | unsigned char OffTime; /* units of 100m/s */ | 70 | unsigned char OffTime; /* units of 100m/s */ |
69 | } LED_IN; | 71 | } LED_IN; |
70 | 72 | ||
71 | typedef struct { | 73 | typedef struct { |
72 | unsigned char mode; | 74 | unsigned char mode; |
73 | unsigned char pwr; | 75 | unsigned char pwr; |
74 | unsigned char brightness; | 76 | unsigned char brightness; |
75 | } FLITE_IN; | 77 | } FLITE_IN; |
76 | 78 | ||
77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 79 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 80 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
79 | 81 | ||
80 | using namespace Opie::Core; | 82 | using namespace Opie::Core; |
81 | using namespace Opie::Core::Internal; | 83 | using namespace Opie::Core::Internal; |
82 | 84 | ||
83 | struct j_button jornada56x_buttons [] = { | 85 | struct j_button jornada56x_buttons [] = { |
84 | { Model_Jornada_56x, | 86 | { Model_Jornada_56x, |
85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 87 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
86 | "devicebuttons/jornada56x_calendar", | 88 | "devicebuttons/jornada56x_calendar", |
87 | "datebook", "nextView()", | 89 | "datebook", "nextView()", |
88 | "today", "raise()" }, | 90 | "today", "raise()" }, |
89 | { Model_Jornada_56x, | 91 | { Model_Jornada_56x, |
90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 92 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
91 | "devicebuttons/jornada56x_contact", | 93 | "devicebuttons/jornada56x_contact", |
92 | "addressbook", "raise()", | 94 | "addressbook", "raise()", |
93 | "addressbook", "beamBusinessCard()" }, | 95 | "addressbook", "beamBusinessCard()" }, |
94 | { Model_Jornada_56x, | 96 | { Model_Jornada_56x, |
95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | 97 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), |
96 | "devicebuttons/jornada56x_todo", | 98 | "devicebuttons/jornada56x_todo", |
97 | "todolist", "raise()", | 99 | "todolist", "raise()", |
98 | "todolist", "create()" }, | 100 | "todolist", "create()" }, |
99 | { Model_Jornada_56x, | 101 | { Model_Jornada_56x, |
100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), | 102 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), |
101 | "devicebuttons/jornada56x_home", | 103 | "devicebuttons/jornada56x_home", |
102 | "QPE/Launcher", "home()", | 104 | "QPE/Launcher", "home()", |
103 | "buttonsettings", "raise()" }, | 105 | "buttonsettings", "raise()" }, |
104 | { Model_Jornada_56x, | 106 | { Model_Jornada_56x, |
105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), | 107 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), |
106 | "devicebuttons/jornada56x_record", | 108 | "devicebuttons/jornada56x_record", |
107 | "QPE/VMemo", "toggleRecord()", | 109 | "QPE/VMemo", "toggleRecord()", |
108 | "sound", "raise()" }, | 110 | "sound", "raise()" }, |
109 | }; | 111 | }; |
110 | 112 | ||
111 | void Jornada::init(const QString& cpu_info) | 113 | void Jornada::init(const QString& cpu_info) |
112 | { | 114 | { |
113 | d->m_vendorstr = "HP"; | 115 | d->m_vendorstr = "HP"; |
114 | d->m_vendor = Vendor_HP; | 116 | d->m_vendor = Vendor_HP; |
115 | 117 | ||
116 | QString model; | 118 | QString model; |
117 | int loc = cpu_info.find( ":" ); | 119 | int loc = cpu_info.find( ":" ); |
118 | if ( loc != -1 ) | 120 | if ( loc != -1 ) |
119 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 121 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
120 | else | 122 | else |
121 | model = cpu_info; | 123 | model = cpu_info; |
122 | 124 | ||
123 | if ( model == "HP Jornada 56x" ) { | 125 | if ( model == "HP Jornada 56x" ) { |
124 | d->m_modelstr = "Jornada 56x"; | 126 | d->m_modelstr = "Jornada 56x"; |
125 | d->m_model = Model_Jornada_56x; | 127 | d->m_model = Model_Jornada_56x; |
126 | } else if ( model == "HP Jornada 720" ) { | 128 | } else if ( model == "HP Jornada 720" ) { |
127 | d->m_modelstr = "Jornada 720"; | 129 | d->m_modelstr = "Jornada 720"; |
128 | d->m_model = Model_Jornada_720; | 130 | d->m_model = Model_Jornada_720; |
129 | } | 131 | } |
130 | 132 | ||
131 | d->m_rotation = Rot0; //all Jornadas need this rotation | 133 | d->m_rotation = Rot0; //all Jornadas need this rotation |
132 | //Distribution detecting code is now in base class | 134 | //Distribution detecting code is now in base class |
133 | } | 135 | } |
134 | 136 | ||
135 | void Jornada::initButtons() | 137 | void Jornada::initButtons() |
136 | { | 138 | { |
137 | if ( d->m_buttons ) | 139 | if ( d->m_buttons ) |
138 | return; | 140 | return; |
139 | 141 | ||
140 | d->m_buttons = new QValueList <ODeviceButton>; | 142 | d->m_buttons = new QValueList <ODeviceButton>; |
141 | 143 | ||
142 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { | 144 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { |
143 | j_button *ib = jornada56x_buttons + i; | 145 | j_button *ib = jornada56x_buttons + i; |
144 | ODeviceButton b; | 146 | ODeviceButton b; |
145 | 147 | ||
146 | if (( ib->model & d->m_model ) == d->m_model ) { | 148 | if (( ib->model & d->m_model ) == d->m_model ) { |
147 | b. setKeycode ( ib->code ); | 149 | b. setKeycode ( ib->code ); |
148 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 150 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
149 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 151 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
150 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 152 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
151 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 153 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
152 | 154 | ||
153 | d->m_buttons->append ( b ); | 155 | d->m_buttons->append ( b ); |
154 | } | 156 | } |
155 | } | 157 | } |
156 | reloadButtonMapping(); | 158 | reloadButtonMapping(); |
157 | } | 159 | } |
158 | 160 | ||
159 | int Jornada::displayBrightnessResolution() const | 161 | int Jornada::displayBrightnessResolution() const |
160 | { | 162 | { |
161 | if ( d->m_model == Model_Jornada_56x ) | 163 | if ( d->m_model == Model_Jornada_56x ) |
162 | return 190; | 164 | return 190; |
163 | else if (d->m_model == Model_Jornada_720 ) | 165 | else if (d->m_model == Model_Jornada_720 ) |
164 | return 255; | 166 | return 255; |
165 | else | 167 | else |
166 | return 0; | 168 | return 0; |
167 | } | 169 | } |
168 | 170 | ||
169 | 171 | ||
170 | bool Jornada::setDisplayBrightness( int bright ) | 172 | bool Jornada::setDisplayBrightness( int bright ) |
171 | { | 173 | { |
172 | bool res = false; | 174 | bool res = false; |
173 | 175 | ||
174 | if ( bright > 255 ) | 176 | if ( bright > 255 ) |
175 | bright = 255; | 177 | bright = 255; |
176 | if ( bright < 0 ) | 178 | if ( bright < 0 ) |
177 | bright = 0; | 179 | bright = 0; |
178 | 180 | ||
179 | QString cmdline; | 181 | QString cmdline; |
180 | 182 | ||
181 | if ( d->m_model == Model_Jornada_56x ) { | 183 | if ( d->m_model == Model_Jornada_56x ) { |
182 | if ( !bright ) | 184 | if ( !bright ) |
183 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/sa1100fb/power"); | 185 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/sa1100fb/power"); |
184 | else | 186 | else |
185 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %1 > /sys/class/backlight/sa1100fb/brightness" ).arg( bright ); | 187 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %1 > /sys/class/backlight/sa1100fb/brightness" ).arg( bright ); |
186 | } else if ( d->m_model == Model_Jornada_720 ) { | 188 | } else if ( d->m_model == Model_Jornada_720 ) { |
187 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/e1356fb/brightness" ).arg( bright ); | 189 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/e1356fb/brightness" ).arg( bright ); |
188 | } | 190 | } |
189 | 191 | ||
190 | // No Global::shellQuote as we gurantee it to be sane | 192 | // No Global::shellQuote as we gurantee it to be sane |
191 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 193 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
192 | 194 | ||
193 | return res; | 195 | return res; |
194 | } | 196 | } |
195 | 197 | ||
196 | 198 | ||
197 | bool Jornada::setDisplayStatus ( bool on ) | 199 | bool Jornada::setDisplayStatus ( bool on ) |
198 | { | 200 | { |
199 | bool res = false; | 201 | bool res = false; |
200 | 202 | ||
201 | QString cmdline; | 203 | QString cmdline; |
202 | 204 | ||
203 | if ( d->m_model == Model_Jornada_56x ) { | 205 | if ( d->m_model == Model_Jornada_56x ) { |
204 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 206 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); |
205 | } else if ( d->m_model == Model_Jornada_720 ) { | 207 | } else if ( d->m_model == Model_Jornada_720 ) { |
206 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/e1356fb/power").arg( on ? "0" : "4" ); | 208 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/e1356fb/power").arg( on ? "0" : "4" ); |
207 | } | 209 | } |
208 | 210 | ||
209 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 211 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
210 | 212 | ||
211 | return res; | 213 | return res; |
212 | } | 214 | } |
213 | 215 | ||
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp index a060695..105a3a7 100644 --- a/libopie2/opiecore/device/odevice_ramses.cpp +++ b/libopie2/opiecore/device/odevice_ramses.cpp | |||
@@ -1,136 +1,136 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_ramses.h" | 31 | #include "odevice_ramses.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | using namespace Opie::Core; | 56 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 57 | using namespace Opie::Core::Internal; |
58 | 58 | ||
59 | 59 | ||
60 | void Ramses::init(const QString&) | 60 | void Ramses::init(const QString&) |
61 | { | 61 | { |
62 | d->m_vendorstr = "M und N"; | 62 | d->m_vendorstr = "M und N"; |
63 | d->m_vendor = Vendor_MundN; | 63 | d->m_vendor = Vendor_MundN; |
64 | 64 | ||
65 | // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 | 65 | // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 |
66 | //d->m_modelstr = "Ramses"; | 66 | //d->m_modelstr = "Ramses"; |
67 | //d->m_model = Model_Ramses_MNCI; | 67 | //d->m_model = Model_Ramses_MNCI; |
68 | //d->m_rotation = Rot0; | 68 | //d->m_rotation = Rot0; |
69 | 69 | ||
70 | // all current Hardware, with /proc/sys/board/lcd_type = 2 | 70 | // all current Hardware, with /proc/sys/board/lcd_type = 2 |
71 | d->m_modelstr = "MNCIRX"; | 71 | d->m_modelstr = "MNCIRX"; |
72 | d->m_model = Model_Ramses_MNCIRX; | 72 | d->m_model = Model_Ramses_MNCIRX; |
73 | d->m_rotation = Rot90; | 73 | d->m_rotation = Rot90; |
74 | 74 | ||
75 | d->m_holdtime = 500; | 75 | d->m_holdtime = 500; |
76 | 76 | ||
77 | 77 | ||
78 | // This table is true for a Intel XScale PXA 255 | 78 | // This table is true for a Intel XScale PXA 255 |
79 | 79 | ||
80 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 80 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
81 | #define OC(x...) x | 81 | #define OC(x...) x |
82 | #else | 82 | #else |
83 | #define OC(x...) | 83 | #define OC(x...) |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 86 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
87 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 87 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
88 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 88 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
89 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 89 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
90 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 90 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
91 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 91 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
92 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 92 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
93 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 93 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
94 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 94 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | void Ramses::playAlarmSound() | 98 | void Ramses::playAlarmSound() |
99 | { | 99 | { |
100 | #ifndef QT_NO_SOUND | 100 | #ifndef QT_NO_SOUND |
101 | static Sound snd ( "alarm" ); | 101 | static Sound snd ( "alarm" ); |
102 | if(!snd.isFinished()) | 102 | if(!snd.isFinished()) |
103 | return; | 103 | return; |
104 | 104 | ||
105 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 105 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
106 | snd.play(); | 106 | snd.play(); |
107 | #endif | 107 | #endif |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | bool Ramses::suspend() | 111 | bool Ramses::suspend() |
112 | { | 112 | { |
113 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 113 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
114 | return false; | 114 | return false; |
115 | 115 | ||
116 | sendSuspendmsg(); | 116 | sendSuspendmsg(); |
117 | ::sync(); | 117 | ::sync(); |
118 | 118 | ||
119 | int fd; | 119 | int fd; |
120 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | 120 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { |
121 | char writeCommand[] = "1\n"; | 121 | char writeCommand[] = "1\n"; |
122 | ::write(fd, writeCommand, sizeof(writeCommand) ); | 122 | ::write(fd, writeCommand, sizeof(writeCommand) ); |
123 | ::close(fd); | 123 | ::close(fd); |
124 | } | 124 | } |
125 | 125 | ||
126 | ::usleep ( 200 * 1000 ); | 126 | ::usleep ( 200 * 1000 ); |
127 | return true; | 127 | return true; |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | bool Ramses::setDisplayBrightness(int bright) | 131 | bool Ramses::setDisplayBrightness(int bright) |
132 | { | 132 | { |
133 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); | 133 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); |
134 | bool res = false; | 134 | bool res = false; |
135 | int fd; | 135 | int fd; |
136 | 136 | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 550da5e..f2805de 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,270 +1,272 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_simpad.h" | 31 | #include "odevice_simpad.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | #include <qwidgetlist.h> | 38 | #include <qwidgetlist.h> |
38 | 39 | ||
39 | /* OPIE */ | 40 | /* OPIE */ |
40 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
41 | #include <qpe/resource.h> | ||
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | |||
44 | #include <opie2/okeyfilter.h> | 45 | #include <opie2/okeyfilter.h> |
46 | #include <opie2/oresource.h> | ||
45 | 47 | ||
46 | /* STD */ | 48 | /* STD */ |
47 | #include <fcntl.h> | 49 | #include <fcntl.h> |
48 | #include <math.h> | 50 | #include <math.h> |
49 | #include <stdlib.h> | 51 | #include <stdlib.h> |
50 | #include <signal.h> | 52 | #include <signal.h> |
51 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
52 | #include <sys/time.h> | 54 | #include <sys/time.h> |
53 | #include <unistd.h> | 55 | #include <unistd.h> |
54 | #ifndef QT_NO_SOUND | 56 | #ifndef QT_NO_SOUND |
55 | #include <linux/soundcard.h> | 57 | #include <linux/soundcard.h> |
56 | #endif | 58 | #endif |
57 | 59 | ||
58 | namespace Opie { | 60 | namespace Opie { |
59 | namespace Core { | 61 | namespace Core { |
60 | namespace Internal { | 62 | namespace Internal { |
61 | namespace { | 63 | namespace { |
62 | struct s_button { | 64 | struct s_button { |
63 | uint model; | 65 | uint model; |
64 | Qt::Key code; | 66 | Qt::Key code; |
65 | char *utext; | 67 | char *utext; |
66 | char *pix; | 68 | char *pix; |
67 | char *fpressedservice; | 69 | char *fpressedservice; |
68 | char *fpressedaction; | 70 | char *fpressedaction; |
69 | char *fheldservice; | 71 | char *fheldservice; |
70 | char *fheldaction; | 72 | char *fheldaction; |
71 | }; | 73 | }; |
72 | 74 | ||
73 | static struct s_button simpad_buttons [] = { | 75 | static struct s_button simpad_buttons [] = { |
74 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 76 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
75 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 77 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
76 | "devicebuttons/simpad_lower_up", | 78 | "devicebuttons/simpad_lower_up", |
77 | "datebook", "nextView()", | 79 | "datebook", "nextView()", |
78 | "today", "raise()" }, | 80 | "today", "raise()" }, |
79 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 81 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
80 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 82 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
81 | "devicebuttons/simpad_lower_down", | 83 | "devicebuttons/simpad_lower_down", |
82 | "addressbook", "raise()", | 84 | "addressbook", "raise()", |
83 | "addressbook", "beamBusinessCard()" }, | 85 | "addressbook", "beamBusinessCard()" }, |
84 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 86 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
85 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 87 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
86 | "devicebuttons/simpad_lower_right", | 88 | "devicebuttons/simpad_lower_right", |
87 | "QPE/TaskBar", "toggleMenu()", | 89 | "QPE/TaskBar", "toggleMenu()", |
88 | "QPE/TaskBar", "toggleStartMenu()" }, | 90 | "QPE/TaskBar", "toggleStartMenu()" }, |
89 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 91 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
90 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 92 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
91 | "devicebuttons/simpad_lower_left", | 93 | "devicebuttons/simpad_lower_left", |
92 | "opiemail", "raise()", | 94 | "opiemail", "raise()", |
93 | "opiemail", "newMail()" }, | 95 | "opiemail", "newMail()" }, |
94 | 96 | ||
95 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 97 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
96 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 98 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
97 | "devicebuttons/simpad_upper_up", | 99 | "devicebuttons/simpad_upper_up", |
98 | "QPE/Launcher", "home()", | 100 | "QPE/Launcher", "home()", |
99 | "buttonsettings", "raise()" }, | 101 | "buttonsettings", "raise()" }, |
100 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 102 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
101 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 103 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
102 | "devicebuttons/simpad_upper_down", | 104 | "devicebuttons/simpad_upper_down", |
103 | "addressbook", "raise()", | 105 | "addressbook", "raise()", |
104 | "addressbook", "beamBusinessCard()" }, | 106 | "addressbook", "beamBusinessCard()" }, |
105 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 107 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
106 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 108 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
107 | "devicebuttons/simpad_upper_right", | 109 | "devicebuttons/simpad_upper_right", |
108 | "QPE/TaskBar", "toggleMenu()", | 110 | "QPE/TaskBar", "toggleMenu()", |
109 | "QPE/TaskBar", "toggleStartMenu()" }, | 111 | "QPE/TaskBar", "toggleStartMenu()" }, |
110 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 112 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
111 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 113 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
112 | "devicebuttons/simpad_upper_left", | 114 | "devicebuttons/simpad_upper_left", |
113 | "QPE/Rotation", "flip()", | 115 | "QPE/Rotation", "flip()", |
114 | "QPE/Rotation", "flip()" }, | 116 | "QPE/Rotation", "flip()" }, |
115 | /* | 117 | /* |
116 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 118 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
117 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 119 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
118 | "devicebuttons/simpad_lower_upper", | 120 | "devicebuttons/simpad_lower_upper", |
119 | "QPE/Launcher", "home()", | 121 | "QPE/Launcher", "home()", |
120 | "buttonsettings", "raise()" }, | 122 | "buttonsettings", "raise()" }, |
121 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 123 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
122 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 124 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
123 | "devicebuttons/simpad_upper_lower", | 125 | "devicebuttons/simpad_upper_lower", |
124 | "QPE/Launcher", "home()", | 126 | "QPE/Launcher", "home()", |
125 | "buttonsettings", "raise()" }, | 127 | "buttonsettings", "raise()" }, |
126 | */ | 128 | */ |
127 | }; | 129 | }; |
128 | } | 130 | } |
129 | 131 | ||
130 | 132 | ||
131 | void SIMpad::init(const QString&) | 133 | void SIMpad::init(const QString&) |
132 | { | 134 | { |
133 | d->m_vendorstr = "SIEMENS"; | 135 | d->m_vendorstr = "SIEMENS"; |
134 | d->m_vendor = Vendor_SIEMENS; | 136 | d->m_vendor = Vendor_SIEMENS; |
135 | 137 | ||
136 | 138 | ||
137 | //TODO Implement model checking | 139 | //TODO Implement model checking |
138 | //FIXME For now we assume an SL4 | 140 | //FIXME For now we assume an SL4 |
139 | 141 | ||
140 | d->m_modelstr = "SL4"; | 142 | d->m_modelstr = "SL4"; |
141 | d->m_model = Model_SIMpad_SL4; | 143 | d->m_model = Model_SIMpad_SL4; |
142 | 144 | ||
143 | switch ( d->m_model ) { | 145 | switch ( d->m_model ) { |
144 | default: | 146 | default: |
145 | d->m_rotation = Rot0; | 147 | d->m_rotation = Rot0; |
146 | d->m_direction = CCW; | 148 | d->m_direction = CCW; |
147 | d->m_holdtime = 1000; // 1000ms | 149 | d->m_holdtime = 1000; // 1000ms |
148 | 150 | ||
149 | break; | 151 | break; |
150 | } | 152 | } |
151 | 153 | ||
152 | //Distribution detecting code is now in base class | 154 | //Distribution detecting code is now in base class |
153 | m_leds [0] = m_leds [1] = Led_Off; | 155 | m_leds [0] = m_leds [1] = Led_Off; |
154 | 156 | ||
155 | m_power_timer = 0; | 157 | m_power_timer = 0; |
156 | 158 | ||
157 | } | 159 | } |
158 | 160 | ||
159 | void SIMpad::initButtons() | 161 | void SIMpad::initButtons() |
160 | { | 162 | { |
161 | if ( d->m_buttons ) | 163 | if ( d->m_buttons ) |
162 | return; | 164 | return; |
163 | 165 | ||
164 | d->m_buttons = new QValueList <ODeviceButton>; | 166 | d->m_buttons = new QValueList <ODeviceButton>; |
165 | 167 | ||
166 | uint size = sizeof(simpad_buttons)/sizeof(s_button); | 168 | uint size = sizeof(simpad_buttons)/sizeof(s_button); |
167 | for ( uint i = 0; i < size; i++ ) { | 169 | for ( uint i = 0; i < size; i++ ) { |
168 | s_button *sb = simpad_buttons + i; | 170 | s_button *sb = simpad_buttons + i; |
169 | ODeviceButton b; | 171 | ODeviceButton b; |
170 | 172 | ||
171 | if (( sb->model & d->m_model ) == d->m_model ) { | 173 | if (( sb->model & d->m_model ) == d->m_model ) { |
172 | b. setKeycode ( sb->code ); | 174 | b. setKeycode ( sb->code ); |
173 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 175 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
174 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 176 | b. setPixmap ( OResource::loadPixmap ( sb->pix )); |
175 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 177 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
176 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 178 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
177 | 179 | ||
178 | d->m_buttons->append ( b ); | 180 | d->m_buttons->append ( b ); |
179 | } | 181 | } |
180 | } | 182 | } |
181 | reloadButtonMapping(); | 183 | reloadButtonMapping(); |
182 | } | 184 | } |
183 | 185 | ||
184 | // SIMpad boardcontrol register CS3 | 186 | // SIMpad boardcontrol register CS3 |
185 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 187 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
186 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 188 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
187 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 189 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
188 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 190 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
189 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 191 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
190 | #define SIMPAD_DISPLAY_ON 0x0010 | 192 | #define SIMPAD_DISPLAY_ON 0x0010 |
191 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 193 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
192 | #define SIMPAD_MQ_RESET 0x0040 | 194 | #define SIMPAD_MQ_RESET 0x0040 |
193 | #define SIMPAD_PCMCIA_RESET 0x0080 | 195 | #define SIMPAD_PCMCIA_RESET 0x0080 |
194 | #define SIMPAD_DECT_POWER_ON 0x0100 | 196 | #define SIMPAD_DECT_POWER_ON 0x0100 |
195 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 197 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
196 | #define SIMPAD_RS232_ON 0x0400 | 198 | #define SIMPAD_RS232_ON 0x0400 |
197 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 199 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
198 | #define SIMPAD_LED2_ON 0x1000 | 200 | #define SIMPAD_LED2_ON 0x1000 |
199 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 201 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
200 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 202 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
201 | #define SIMPAD_RESET_SIMCARD 0x8000 | 203 | #define SIMPAD_RESET_SIMCARD 0x8000 |
202 | 204 | ||
203 | //SIMpad touchscreen backlight strength control | 205 | //SIMpad touchscreen backlight strength control |
204 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" | 206 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" |
205 | 207 | ||
206 | 208 | ||
207 | /* | 209 | /* |
208 | * The SIMpad exposes ChipSelect3 to userspace | 210 | * The SIMpad exposes ChipSelect3 to userspace |
209 | * via a proc filesystem file. Using this register | 211 | * via a proc filesystem file. Using this register |
210 | * one can toggle power of serial, irda, dect circuits | 212 | * one can toggle power of serial, irda, dect circuits |
211 | * change the video driver and display status and | 213 | * change the video driver and display status and |
212 | * many more things. | 214 | * many more things. |
213 | * To not lose the current setting we read the current | 215 | * To not lose the current setting we read the current |
214 | * cs3 setting and toggle the necessary bits and then | 216 | * cs3 setting and toggle the necessary bits and then |
215 | * write it. | 217 | * write it. |
216 | */ | 218 | */ |
217 | static bool setCS3Bit( bool bitset, int bit ) { | 219 | static bool setCS3Bit( bool bitset, int bit ) { |
218 | QFile file( SIMPAD_BOARDCONTROL ); | 220 | QFile file( SIMPAD_BOARDCONTROL ); |
219 | if ( !file.open( IO_ReadOnly ) ) | 221 | if ( !file.open( IO_ReadOnly ) ) |
220 | return false; | 222 | return false; |
221 | 223 | ||
222 | unsigned int val = 0; | 224 | unsigned int val = 0; |
223 | bool ok = false; | 225 | bool ok = false; |
224 | QTextStream stream( &file ); | 226 | QTextStream stream( &file ); |
225 | 227 | ||
226 | /* | 228 | /* |
227 | * Use QFile and QTextStream for parsing to be more | 229 | * Use QFile and QTextStream for parsing to be more |
228 | * robust | 230 | * robust |
229 | */ | 231 | */ |
230 | while ( !stream.atEnd() ) { | 232 | while ( !stream.atEnd() ) { |
231 | QString line = stream.readLine(); | 233 | QString line = stream.readLine(); |
232 | if ( line.startsWith( "Chipselect3 : " ) ) { | 234 | if ( line.startsWith( "Chipselect3 : " ) ) { |
233 | val = line.mid( 14 ).toUInt( 0, 16 ); | 235 | val = line.mid( 14 ).toUInt( 0, 16 ); |
234 | ok = true; | 236 | ok = true; |
235 | break; | 237 | break; |
236 | } | 238 | } |
237 | } | 239 | } |
238 | 240 | ||
239 | if ( !ok ) | 241 | if ( !ok ) |
240 | return false; | 242 | return false; |
241 | 243 | ||
242 | file.close(); | 244 | file.close(); |
243 | 245 | ||
244 | /* | 246 | /* |
245 | * change the value | 247 | * change the value |
246 | */ | 248 | */ |
247 | val = bitset ? (val | bit) : (val & ~bit); | 249 | val = bitset ? (val | bit) : (val & ~bit); |
248 | 250 | ||
249 | /* | 251 | /* |
250 | * write it back | 252 | * write it back |
251 | */ | 253 | */ |
252 | int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); | 254 | int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); |
253 | if ( cs3_fd < 0 ) | 255 | if ( cs3_fd < 0 ) |
254 | return false; | 256 | return false; |
255 | 257 | ||
256 | char line[32]; | 258 | char line[32]; |
257 | ::snprintf(line, sizeof(line), "0x%04x\n", val); | 259 | ::snprintf(line, sizeof(line), "0x%04x\n", val); |
258 | ::write(cs3_fd, line, strlen(line)); | 260 | ::write(cs3_fd, line, strlen(line)); |
259 | ::close(cs3_fd); | 261 | ::close(cs3_fd); |
260 | 262 | ||
261 | return true; | 263 | return true; |
262 | } | 264 | } |
263 | 265 | ||
264 | 266 | ||
265 | QValueList <OLed> SIMpad::ledList() const | 267 | QValueList <OLed> SIMpad::ledList() const |
266 | { | 268 | { |
267 | QValueList <OLed> vl; | 269 | QValueList <OLed> vl; |
268 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 270 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
269 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 271 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
270 | return vl; | 272 | return vl; |
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp index 8f22514..f81e452 100644 --- a/libopie2/opiecore/device/odevice_yopy.cpp +++ b/libopie2/opiecore/device/odevice_yopy.cpp | |||
@@ -1,153 +1,155 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | =. | 4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This program is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Library General Public License for more | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: details. | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = Library General Public License along with | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | If not, write to the Free Software Foundation, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | Inc., 59 Temple Place - Suite 330, | 26 | If not, write to the Free Software Foundation, |
27 | Boston, MA 02111-1307, USA. | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | ||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_yopy.h" | 31 | #include "odevice_yopy.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | #include <opie2/oresource.h> | ||
45 | |||
44 | /* STD */ | 46 | /* STD */ |
45 | #include <fcntl.h> | 47 | #include <fcntl.h> |
46 | #include <math.h> | 48 | #include <math.h> |
47 | #include <stdlib.h> | 49 | #include <stdlib.h> |
48 | #include <signal.h> | 50 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 52 | #include <sys/time.h> |
51 | #include <unistd.h> | 53 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 54 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 55 | #include <linux/soundcard.h> |
54 | #endif | 56 | #endif |
55 | 57 | ||
56 | using namespace Opie::Core; | 58 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 59 | using namespace Opie::Core::Internal; |
58 | 60 | ||
59 | struct yopy_button yopy_buttons [] = { | 61 | struct yopy_button yopy_buttons [] = { |
60 | { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), | 62 | { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), |
61 | "devicebuttons/yopy_action", | 63 | "devicebuttons/yopy_action", |
62 | "datebook", "nextView()", | 64 | "datebook", "nextView()", |
63 | "today", "raise()" }, | 65 | "today", "raise()" }, |
64 | { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), | 66 | { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), |
65 | "devicebuttons/yopy_ok", | 67 | "devicebuttons/yopy_ok", |
66 | "addressbook", "raise()", | 68 | "addressbook", "raise()", |
67 | "addressbook", "beamBusinessCard()" }, | 69 | "addressbook", "beamBusinessCard()" }, |
68 | { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), | 70 | { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), |
69 | "devicebuttons/yopy_end", | 71 | "devicebuttons/yopy_end", |
70 | "QPE/Launcher", "home()", | 72 | "QPE/Launcher", "home()", |
71 | "buttonsettings", "raise()" }, | 73 | "buttonsettings", "raise()" }, |
72 | }; | 74 | }; |
73 | 75 | ||
74 | void Yopy::init(const QString&) | 76 | void Yopy::init(const QString&) |
75 | { | 77 | { |
76 | d->m_vendorstr = "G.Mate"; | 78 | d->m_vendorstr = "G.Mate"; |
77 | d->m_vendor = Vendor_GMate; | 79 | d->m_vendor = Vendor_GMate; |
78 | d->m_modelstr = "Yopy3700"; | 80 | d->m_modelstr = "Yopy3700"; |
79 | d->m_model = Model_Yopy_3700; | 81 | d->m_model = Model_Yopy_3700; |
80 | d->m_rotation = Rot0; | 82 | d->m_rotation = Rot0; |
81 | d->m_systemstr = "Linupy"; | 83 | d->m_systemstr = "Linupy"; |
82 | d->m_system = System_Linupy; | 84 | d->m_system = System_Linupy; |
83 | // Distribution detection code now in the base class | 85 | // Distribution detection code now in the base class |
84 | } | 86 | } |
85 | 87 | ||
86 | 88 | ||
87 | void Yopy::initButtons() | 89 | void Yopy::initButtons() |
88 | { | 90 | { |
89 | if ( d->m_buttons ) | 91 | if ( d->m_buttons ) |
90 | return ; | 92 | return ; |
91 | 93 | ||
92 | d->m_buttons = new QValueList <ODeviceButton>; | 94 | d->m_buttons = new QValueList <ODeviceButton>; |
93 | 95 | ||
94 | for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) | 96 | for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) |
95 | { | 97 | { |
96 | 98 | ||
97 | yopy_button *ib = yopy_buttons + i; | 99 | yopy_button *ib = yopy_buttons + i; |
98 | 100 | ||
99 | ODeviceButton b; | 101 | ODeviceButton b; |
100 | 102 | ||
101 | b. setKeycode ( ib->code ); | 103 | b. setKeycode ( ib->code ); |
102 | b. setUserText ( QObject::tr ( "Button", ib->utext ) ); | 104 | b. setUserText ( QObject::tr ( "Button", ib->utext ) ); |
103 | b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); | 105 | b. setPixmap ( OResource::loadPixmap ( ib->pix ) ); |
104 | b. setFactoryPresetPressedAction | 106 | b. setFactoryPresetPressedAction |
105 | ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); | 107 | ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); |
106 | b. setFactoryPresetHeldAction | 108 | b. setFactoryPresetHeldAction |
107 | ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); | 109 | ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); |
108 | 110 | ||
109 | d->m_buttons->append ( b ); | 111 | d->m_buttons->append ( b ); |
110 | } | 112 | } |
111 | reloadButtonMapping(); | 113 | reloadButtonMapping(); |
112 | } | 114 | } |
113 | 115 | ||
114 | 116 | ||
115 | bool Yopy::suspend() | 117 | bool Yopy::suspend() |
116 | { | 118 | { |
117 | /* Opie for Yopy does not implement its own power management at the | 119 | /* Opie for Yopy does not implement its own power management at the |
118 | moment. The public version runs parallel to X, and relies on the | 120 | moment. The public version runs parallel to X, and relies on the |
119 | existing power management features. */ | 121 | existing power management features. */ |
120 | return false; | 122 | return false; |
121 | } | 123 | } |
122 | 124 | ||
123 | 125 | ||
124 | bool Yopy::setDisplayBrightness( int bright ) | 126 | bool Yopy::setDisplayBrightness( int bright ) |
125 | { | 127 | { |
126 | /* The code here works, but is disabled as the current version runs | 128 | /* The code here works, but is disabled as the current version runs |
127 | parallel to X, and relies on the existing backlight demon. */ | 129 | parallel to X, and relies on the existing backlight demon. */ |
128 | #if 0 | 130 | #if 0 |
129 | if ( QFile::exists( "/proc/sys/pm/light" ) ) | 131 | if ( QFile::exists( "/proc/sys/pm/light" ) ) |
130 | { | 132 | { |
131 | int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); | 133 | int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); |
132 | if ( fd >= 0 ) | 134 | if ( fd >= 0 ) |
133 | { | 135 | { |
134 | if ( bright ) | 136 | if ( bright ) |
135 | ::write( fd, "1\n", 2 ); | 137 | ::write( fd, "1\n", 2 ); |
136 | else | 138 | else |
137 | ::write( fd, "0\n", 2 ); | 139 | ::write( fd, "0\n", 2 ); |
138 | ::close( fd ); | 140 | ::close( fd ); |
139 | return true; | 141 | return true; |
140 | } | 142 | } |
141 | } | 143 | } |
142 | #else | 144 | #else |
143 | Q_UNUSED( bright ) | 145 | Q_UNUSED( bright ) |
144 | #endif | 146 | #endif |
145 | return false; | 147 | return false; |
146 | } | 148 | } |
147 | 149 | ||
148 | 150 | ||
149 | int Yopy::displayBrightnessResolution() const | 151 | int Yopy::displayBrightnessResolution() const |
150 | { | 152 | { |
151 | return 2; | 153 | return 2; |
152 | } | 154 | } |
153 | 155 | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index e9b163a..1742100 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,137 +1,139 @@ | |||
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 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_zaurus.h" | 31 | #include "odevice_zaurus.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <opie2/oinputsystem.h> | 40 | #include <opie2/oinputsystem.h> |
41 | #include <opie2/oresource.h> | ||
42 | |||
40 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
41 | #include <qpe/resource.h> | ||
42 | #include <qpe/sound.h> | 44 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 45 | #include <qpe/qcopenvelope_qws.h> |
44 | 46 | ||
45 | /* STD */ | 47 | /* STD */ |
46 | #include <fcntl.h> | 48 | #include <fcntl.h> |
47 | #include <math.h> | 49 | #include <math.h> |
48 | #include <stdlib.h> | 50 | #include <stdlib.h> |
49 | #include <signal.h> | 51 | #include <signal.h> |
50 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> |
51 | #include <sys/time.h> | 53 | #include <sys/time.h> |
52 | #include <unistd.h> | 54 | #include <unistd.h> |
53 | #ifndef QT_NO_SOUND | 55 | #ifndef QT_NO_SOUND |
54 | #include <linux/soundcard.h> | 56 | #include <linux/soundcard.h> |
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | using namespace Opie::Core; | 59 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 60 | using namespace Opie::Core::Internal; |
59 | 61 | ||
60 | struct z_button z_buttons [] = { | 62 | struct z_button z_buttons [] = { |
61 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 63 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
62 | "devicebuttons/z_calendar", | 64 | "devicebuttons/z_calendar", |
63 | "datebook", "nextView()", | 65 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 66 | "today", "raise()" }, |
65 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 67 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
66 | "devicebuttons/z_contact", | 68 | "devicebuttons/z_contact", |
67 | "addressbook", "raise()", | 69 | "addressbook", "raise()", |
68 | "addressbook", "beamBusinessCard()" }, | 70 | "addressbook", "beamBusinessCard()" }, |
69 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 71 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
70 | "devicebuttons/z_home", | 72 | "devicebuttons/z_home", |
71 | "QPE/Launcher", "home()", | 73 | "QPE/Launcher", "home()", |
72 | "buttonsettings", "raise()" }, | 74 | "buttonsettings", "raise()" }, |
73 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 75 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
74 | "devicebuttons/z_menu", | 76 | "devicebuttons/z_menu", |
75 | "QPE/TaskBar", "toggleMenu()", | 77 | "QPE/TaskBar", "toggleMenu()", |
76 | "QPE/TaskBar", "toggleStartMenu()" }, | 78 | "QPE/TaskBar", "toggleStartMenu()" }, |
77 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 79 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
78 | "devicebuttons/z_mail", | 80 | "devicebuttons/z_mail", |
79 | "opiemail", "raise()", | 81 | "opiemail", "raise()", |
80 | "opiemail", "newMail()" }, | 82 | "opiemail", "newMail()" }, |
81 | }; | 83 | }; |
82 | 84 | ||
83 | struct z_button z_buttons_c700 [] = { | 85 | struct z_button z_buttons_c700 [] = { |
84 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 86 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
85 | "devicebuttons/z_calendar", | 87 | "devicebuttons/z_calendar", |
86 | "datebook", "nextView()", | 88 | "datebook", "nextView()", |
87 | "today", "raise()" }, | 89 | "today", "raise()" }, |
88 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 90 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
89 | "devicebuttons/z_contact", | 91 | "devicebuttons/z_contact", |
90 | "addressbook", "raise()", | 92 | "addressbook", "raise()", |
91 | "addressbook", "beamBusinessCard()" }, | 93 | "addressbook", "beamBusinessCard()" }, |
92 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 94 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
93 | "devicebuttons/z_home", | 95 | "devicebuttons/z_home", |
94 | "QPE/Launcher", "home()", | 96 | "QPE/Launcher", "home()", |
95 | "buttonsettings", "raise()" }, | 97 | "buttonsettings", "raise()" }, |
96 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 98 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
97 | "devicebuttons/z_menu", | 99 | "devicebuttons/z_menu", |
98 | "QPE/TaskBar", "toggleMenu()", | 100 | "QPE/TaskBar", "toggleMenu()", |
99 | "QPE/TaskBar", "toggleStartMenu()" }, | 101 | "QPE/TaskBar", "toggleStartMenu()" }, |
100 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 102 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
101 | "devicebuttons/z_mail", | 103 | "devicebuttons/z_mail", |
102 | "opiemail", "raise()", | 104 | "opiemail", "raise()", |
103 | "opiemail", "newMail()" }, | 105 | "opiemail", "newMail()" }, |
104 | 106 | ||
105 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), | 107 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), |
106 | "devicebuttons/z_hinge1", | 108 | "devicebuttons/z_hinge1", |
107 | "QPE/Rotation", "rotateDefault()",0}, | 109 | "QPE/Rotation", "rotateDefault()",0}, |
108 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), | 110 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
109 | "devicebuttons/z_hinge2", | 111 | "devicebuttons/z_hinge2", |
110 | "QPE/Rotation", "rotateDefault()",0}, | 112 | "QPE/Rotation", "rotateDefault()",0}, |
111 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 113 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
112 | "devicebuttons/z_hinge3", | 114 | "devicebuttons/z_hinge3", |
113 | "QPE/Rotation", "rotateDefault()",0}, | 115 | "QPE/Rotation", "rotateDefault()",0}, |
114 | }; | 116 | }; |
115 | 117 | ||
116 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 118 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
117 | // class up into individual classes. We would need three classes | 119 | // class up into individual classes. We would need three classes |
118 | // | 120 | // |
119 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 121 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
120 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 122 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
121 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000) | 123 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000) |
122 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 124 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
123 | 125 | ||
124 | void Zaurus::init(const QString& cpu_info) | 126 | void Zaurus::init(const QString& cpu_info) |
125 | { | 127 | { |
126 | // Set the time to wait until the system is really suspended | 128 | // Set the time to wait until the system is really suspended |
127 | // the delta between apm --suspend and sleeping | 129 | // the delta between apm --suspend and sleeping |
128 | setAPMTimeOut( 15000 ); | 130 | setAPMTimeOut( 15000 ); |
129 | 131 | ||
130 | // generic distribution code already scanned /etc/issue at that point - | 132 | // generic distribution code already scanned /etc/issue at that point - |
131 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 133 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
132 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 134 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
133 | { | 135 | { |
134 | d->m_vendorstr = "Sharp"; | 136 | d->m_vendorstr = "Sharp"; |
135 | d->m_vendor = Vendor_Sharp; | 137 | d->m_vendor = Vendor_Sharp; |
136 | d->m_systemstr = "Zaurus"; | 138 | d->m_systemstr = "Zaurus"; |
137 | d->m_system = System_Zaurus; | 139 | d->m_system = System_Zaurus; |
@@ -143,213 +145,213 @@ void Zaurus::init(const QString& cpu_info) | |||
143 | d->m_systemstr = "OpenZaurus"; | 145 | d->m_systemstr = "OpenZaurus"; |
144 | d->m_system = System_OpenZaurus; | 146 | d->m_system = System_OpenZaurus; |
145 | // sysver already gathered | 147 | // sysver already gathered |
146 | 148 | ||
147 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one | 149 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one |
148 | FILE *uname = popen("uname -r", "r"); | 150 | FILE *uname = popen("uname -r", "r"); |
149 | QFile f; | 151 | QFile f; |
150 | QString line; | 152 | QString line; |
151 | if ( f.open(IO_ReadOnly, uname) ) { | 153 | if ( f.open(IO_ReadOnly, uname) ) { |
152 | QTextStream ts ( &f ); | 154 | QTextStream ts ( &f ); |
153 | line = ts.readLine(); | 155 | line = ts.readLine(); |
154 | m_embedix = line.startsWith( "2.4." ); | 156 | m_embedix = line.startsWith( "2.4." ); |
155 | f.close(); | 157 | f.close(); |
156 | } | 158 | } |
157 | pclose(uname); | 159 | pclose(uname); |
158 | } | 160 | } |
159 | 161 | ||
160 | // check the Zaurus model | 162 | // check the Zaurus model |
161 | QString model; | 163 | QString model; |
162 | int loc = cpu_info.find( ":" ); | 164 | int loc = cpu_info.find( ":" ); |
163 | if ( loc != -1 ) | 165 | if ( loc != -1 ) |
164 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 166 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
165 | else | 167 | else |
166 | model = cpu_info; | 168 | model = cpu_info; |
167 | 169 | ||
168 | if ( model == "SHARP Corgi" ) { | 170 | if ( model == "SHARP Corgi" ) { |
169 | d->m_model = Model_Zaurus_SLC7x0; | 171 | d->m_model = Model_Zaurus_SLC7x0; |
170 | d->m_modelstr = "Zaurus SL-C700"; | 172 | d->m_modelstr = "Zaurus SL-C700"; |
171 | } else if ( model == "SHARP Shepherd" ) { | 173 | } else if ( model == "SHARP Shepherd" ) { |
172 | d->m_model = Model_Zaurus_SLC7x0; | 174 | d->m_model = Model_Zaurus_SLC7x0; |
173 | d->m_modelstr = "Zaurus SL-C750"; | 175 | d->m_modelstr = "Zaurus SL-C750"; |
174 | } else if ( model == "SHARP Husky" ) { | 176 | } else if ( model == "SHARP Husky" ) { |
175 | d->m_model = Model_Zaurus_SLC7x0; | 177 | d->m_model = Model_Zaurus_SLC7x0; |
176 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 178 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
177 | } else if ( model == "SHARP Boxer" ) { | 179 | } else if ( model == "SHARP Boxer" ) { |
178 | d->m_model = Model_Zaurus_SLC7x0; | 180 | d->m_model = Model_Zaurus_SLC7x0; |
179 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 181 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
180 | } else if ( model == "SHARP Poodle" ) { | 182 | } else if ( model == "SHARP Poodle" ) { |
181 | d->m_model = Model_Zaurus_SLB600; | 183 | d->m_model = Model_Zaurus_SLB600; |
182 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 184 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
183 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 185 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
184 | d->m_model = Model_Zaurus_SL5500; | 186 | d->m_model = Model_Zaurus_SL5500; |
185 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 187 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
186 | } else if ( model == "SHARP Tosa" ) { | 188 | } else if ( model == "SHARP Tosa" ) { |
187 | d->m_model = Model_Zaurus_SL6000; | 189 | d->m_model = Model_Zaurus_SL6000; |
188 | d->m_modelstr = "Zaurus SL-6000"; | 190 | d->m_modelstr = "Zaurus SL-6000"; |
189 | } else if ( model == "SHARP Spitz" ) { | 191 | } else if ( model == "SHARP Spitz" ) { |
190 | d->m_model = Model_Zaurus_SLC3000; | 192 | d->m_model = Model_Zaurus_SLC3000; |
191 | d->m_modelstr = "Zaurus SL-C3000"; | 193 | d->m_modelstr = "Zaurus SL-C3000"; |
192 | } else if ( model == "SHARP Akita" ) { | 194 | } else if ( model == "SHARP Akita" ) { |
193 | d->m_model = Model_Zaurus_SLC1000; | 195 | d->m_model = Model_Zaurus_SLC1000; |
194 | d->m_modelstr = "Zaurus SL-C1000"; | 196 | d->m_modelstr = "Zaurus SL-C1000"; |
195 | } else { | 197 | } else { |
196 | d->m_model = Model_Zaurus_SL5500; | 198 | d->m_model = Model_Zaurus_SL5500; |
197 | d->m_modelstr = "Unknown Zaurus"; | 199 | d->m_modelstr = "Unknown Zaurus"; |
198 | } | 200 | } |
199 | 201 | ||
200 | // set initial rotation | 202 | // set initial rotation |
201 | switch( d->m_model ) { | 203 | switch( d->m_model ) { |
202 | case Model_Zaurus_SL6000: // fallthrough | 204 | case Model_Zaurus_SL6000: // fallthrough |
203 | case Model_Zaurus_SLA300: | 205 | case Model_Zaurus_SLA300: |
204 | d->m_rotation = Rot0; | 206 | d->m_rotation = Rot0; |
205 | break; | 207 | break; |
206 | case Model_Zaurus_SLC3000: // fallthrough | 208 | case Model_Zaurus_SLC3000: // fallthrough |
207 | case Model_Zaurus_SLC1000: // fallthrough | 209 | case Model_Zaurus_SLC1000: // fallthrough |
208 | case Model_Zaurus_SLC7x0: | 210 | case Model_Zaurus_SLC7x0: |
209 | d->m_rotation = rotation(); | 211 | d->m_rotation = rotation(); |
210 | d->m_direction = direction(); | 212 | d->m_direction = direction(); |
211 | break; | 213 | break; |
212 | case Model_Zaurus_SLB600: // fallthrough | 214 | case Model_Zaurus_SLB600: // fallthrough |
213 | case Model_Zaurus_SL5000: // fallthrough | 215 | case Model_Zaurus_SL5000: // fallthrough |
214 | case Model_Zaurus_SL5500: // fallthrough | 216 | case Model_Zaurus_SL5500: // fallthrough |
215 | default: | 217 | default: |
216 | d->m_rotation = Rot270; | 218 | d->m_rotation = Rot270; |
217 | break; | 219 | break; |
218 | } | 220 | } |
219 | m_leds[0] = Led_Off; | 221 | m_leds[0] = Led_Off; |
220 | 222 | ||
221 | if ( m_embedix ) | 223 | if ( m_embedix ) |
222 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | 224 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); |
223 | else | 225 | else |
224 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 226 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
225 | } | 227 | } |
226 | 228 | ||
227 | void Zaurus::initButtons() | 229 | void Zaurus::initButtons() |
228 | { | 230 | { |
229 | if ( d->m_buttons ) | 231 | if ( d->m_buttons ) |
230 | return; | 232 | return; |
231 | 233 | ||
232 | 234 | ||
233 | d->m_buttons = new QValueList <ODeviceButton>; | 235 | d->m_buttons = new QValueList <ODeviceButton>; |
234 | 236 | ||
235 | struct z_button * pz_buttons; | 237 | struct z_button * pz_buttons; |
236 | int buttoncount; | 238 | int buttoncount; |
237 | switch ( d->m_model ) { | 239 | switch ( d->m_model ) { |
238 | case Model_Zaurus_SLC3000: // fallthrough | 240 | case Model_Zaurus_SLC3000: // fallthrough |
239 | case Model_Zaurus_SLC1000: // fallthrough | 241 | case Model_Zaurus_SLC1000: // fallthrough |
240 | case Model_Zaurus_SLC7x0: | 242 | case Model_Zaurus_SLC7x0: |
241 | if ( isQWS( ) ) { | 243 | if ( isQWS( ) ) { |
242 | addPreHandler(this); // hinge-sensor-handler | 244 | addPreHandler(this); // hinge-sensor-handler |
243 | } | 245 | } |
244 | pz_buttons = z_buttons_c700; | 246 | pz_buttons = z_buttons_c700; |
245 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 247 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
246 | break; | 248 | break; |
247 | default: | 249 | default: |
248 | pz_buttons = z_buttons; | 250 | pz_buttons = z_buttons; |
249 | buttoncount = ARRAY_SIZE(z_buttons); | 251 | buttoncount = ARRAY_SIZE(z_buttons); |
250 | break; | 252 | break; |
251 | } | 253 | } |
252 | 254 | ||
253 | for ( int i = 0; i < buttoncount; i++ ) { | 255 | for ( int i = 0; i < buttoncount; i++ ) { |
254 | struct z_button *zb = pz_buttons + i; | 256 | struct z_button *zb = pz_buttons + i; |
255 | ODeviceButton b; | 257 | ODeviceButton b; |
256 | 258 | ||
257 | b.setKeycode( zb->code ); | 259 | b.setKeycode( zb->code ); |
258 | b.setUserText( QObject::tr( "Button", zb->utext )); | 260 | b.setUserText( QObject::tr( "Button", zb->utext )); |
259 | b.setPixmap( Resource::loadPixmap( zb->pix )); | 261 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
260 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 262 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
261 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 263 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
262 | d->m_buttons->append( b ); | 264 | d->m_buttons->append( b ); |
263 | } | 265 | } |
264 | 266 | ||
265 | reloadButtonMapping(); | 267 | reloadButtonMapping(); |
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
269 | 271 | ||
270 | typedef struct sharp_led_status { | 272 | typedef struct sharp_led_status { |
271 | int which; /* select which LED status is wanted. */ | 273 | int which; /* select which LED status is wanted. */ |
272 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 274 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
273 | } sharp_led_status; | 275 | } sharp_led_status; |
274 | 276 | ||
275 | void Zaurus::buzzer( int sound ) | 277 | void Zaurus::buzzer( int sound ) |
276 | { | 278 | { |
277 | #ifndef QT_NO_SOUND | 279 | #ifndef QT_NO_SOUND |
278 | Sound *snd = 0; | 280 | Sound *snd = 0; |
279 | 281 | ||
280 | // All devices except SL5500 have a DSP device | 282 | // All devices except SL5500 have a DSP device |
281 | if ( d->m_model != Model_Zaurus_SL5000 | 283 | if ( d->m_model != Model_Zaurus_SL5000 |
282 | && d->m_model != Model_Zaurus_SL5500 ) { | 284 | && d->m_model != Model_Zaurus_SL5500 ) { |
283 | 285 | ||
284 | switch ( sound ){ | 286 | switch ( sound ){ |
285 | case SHARP_BUZ_TOUCHSOUND: { | 287 | case SHARP_BUZ_TOUCHSOUND: { |
286 | static Sound touch_sound("touchsound"); | 288 | static Sound touch_sound("touchsound"); |
287 | snd = &touch_sound; | 289 | snd = &touch_sound; |
288 | } | 290 | } |
289 | break; | 291 | break; |
290 | case SHARP_BUZ_KEYSOUND: { | 292 | case SHARP_BUZ_KEYSOUND: { |
291 | static Sound key_sound( "keysound" ); | 293 | static Sound key_sound( "keysound" ); |
292 | snd = &key_sound; | 294 | snd = &key_sound; |
293 | } | 295 | } |
294 | break; | 296 | break; |
295 | case SHARP_BUZ_SCHEDULE_ALARM: | 297 | case SHARP_BUZ_SCHEDULE_ALARM: |
296 | default: { | 298 | default: { |
297 | static Sound alarm_sound("alarm"); | 299 | static Sound alarm_sound("alarm"); |
298 | snd = &alarm_sound; | 300 | snd = &alarm_sound; |
299 | } | 301 | } |
300 | break; | 302 | break; |
301 | } | 303 | } |
302 | } | 304 | } |
303 | 305 | ||
304 | // If a soundname is defined, we expect that this device has | 306 | // If a soundname is defined, we expect that this device has |
305 | // sound capabilities.. Otherwise we expect to have the buzzer | 307 | // sound capabilities.. Otherwise we expect to have the buzzer |
306 | // device.. | 308 | // device.. |
307 | if ( snd && snd->isFinished() ){ | 309 | if ( snd && snd->isFinished() ){ |
308 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 310 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
309 | snd->play(); | 311 | snd->play(); |
310 | } else if( !snd ) { | 312 | } else if( !snd ) { |
311 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 313 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
312 | 314 | ||
313 | if ( fd >= 0 ) { | 315 | if ( fd >= 0 ) { |
314 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 316 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
315 | ::close ( fd ); | 317 | ::close ( fd ); |
316 | } | 318 | } |
317 | 319 | ||
318 | } | 320 | } |
319 | #endif | 321 | #endif |
320 | } | 322 | } |
321 | 323 | ||
322 | 324 | ||
323 | void Zaurus::playAlarmSound() | 325 | void Zaurus::playAlarmSound() |
324 | { | 326 | { |
325 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 327 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
326 | } | 328 | } |
327 | 329 | ||
328 | void Zaurus::playTouchSound() | 330 | void Zaurus::playTouchSound() |
329 | { | 331 | { |
330 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 332 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
331 | } | 333 | } |
332 | 334 | ||
333 | void Zaurus::playKeySound() | 335 | void Zaurus::playKeySound() |
334 | { | 336 | { |
335 | buzzer( SHARP_BUZ_KEYSOUND ); | 337 | buzzer( SHARP_BUZ_KEYSOUND ); |
336 | } | 338 | } |
337 | 339 | ||
338 | 340 | ||
339 | QValueList <OLed> Zaurus::ledList() const | 341 | QValueList <OLed> Zaurus::ledList() const |
340 | { | 342 | { |
341 | QValueList <OLed> vl; | 343 | QValueList <OLed> vl; |
342 | vl << Led_Mail; | 344 | vl << Led_Mail; |
343 | return vl; | 345 | return vl; |
344 | } | 346 | } |
345 | 347 | ||
346 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 348 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
347 | { | 349 | { |
348 | QValueList <OLedState> vl; | 350 | QValueList <OLedState> vl; |
349 | 351 | ||
350 | if ( l == Led_Mail ) | 352 | if ( l == Led_Mail ) |
351 | vl << Led_Off << Led_On << Led_BlinkSlow; | 353 | vl << Led_Off << Led_On << Led_BlinkSlow; |
352 | return vl; | 354 | return vl; |
353 | } | 355 | } |
354 | 356 | ||
355 | OLedState Zaurus::ledState( OLed which ) const | 357 | OLedState Zaurus::ledState( OLed which ) const |
@@ -396,231 +398,231 @@ bool Zaurus::setLedState( OLed which, OLedState st ) | |||
396 | 398 | ||
397 | int Zaurus::displayBrightnessResolution() const | 399 | int Zaurus::displayBrightnessResolution() const |
398 | { | 400 | { |
399 | int res = 1; | 401 | int res = 1; |
400 | if (m_embedix) | 402 | if (m_embedix) |
401 | { | 403 | { |
402 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 404 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
403 | if ( fd ) | 405 | if ( fd ) |
404 | { | 406 | { |
405 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 407 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
406 | ::close( fd ); | 408 | ::close( fd ); |
407 | return value ? value : res; | 409 | return value ? value : res; |
408 | } | 410 | } |
409 | } | 411 | } |
410 | else | 412 | else |
411 | { | 413 | { |
412 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); | 414 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); |
413 | if ( fd ) | 415 | if ( fd ) |
414 | { | 416 | { |
415 | char buf[100]; | 417 | char buf[100]; |
416 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 418 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
417 | ::close( fd ); | 419 | ::close( fd ); |
418 | } | 420 | } |
419 | } | 421 | } |
420 | return res; | 422 | return res; |
421 | } | 423 | } |
422 | 424 | ||
423 | bool Zaurus::setDisplayBrightness( int bright ) | 425 | bool Zaurus::setDisplayBrightness( int bright ) |
424 | { | 426 | { |
425 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 427 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
426 | bool res = false; | 428 | bool res = false; |
427 | 429 | ||
428 | if ( bright > 255 ) bright = 255; | 430 | if ( bright > 255 ) bright = 255; |
429 | if ( bright < 0 ) bright = 0; | 431 | if ( bright < 0 ) bright = 0; |
430 | 432 | ||
431 | int numberOfSteps = displayBrightnessResolution(); | 433 | int numberOfSteps = displayBrightnessResolution(); |
432 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 434 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
433 | 435 | ||
434 | if ( m_embedix ) | 436 | if ( m_embedix ) |
435 | { | 437 | { |
436 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 438 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
437 | if ( fd ) | 439 | if ( fd ) |
438 | { | 440 | { |
439 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 441 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
440 | ::close( fd ); | 442 | ::close( fd ); |
441 | } | 443 | } |
442 | } | 444 | } |
443 | else | 445 | else |
444 | { | 446 | { |
445 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); | 447 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); |
446 | if ( fd ) | 448 | if ( fd ) |
447 | { | 449 | { |
448 | char buf[100]; | 450 | char buf[100]; |
449 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 451 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
450 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 452 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
451 | ::close( fd ); | 453 | ::close( fd ); |
452 | } | 454 | } |
453 | } | 455 | } |
454 | return res; | 456 | return res; |
455 | } | 457 | } |
456 | 458 | ||
457 | bool Zaurus::setDisplayStatus( bool on ) | 459 | bool Zaurus::setDisplayStatus( bool on ) |
458 | { | 460 | { |
459 | bool res = false; | 461 | bool res = false; |
460 | if ( m_embedix ) | 462 | if ( m_embedix ) |
461 | { | 463 | { |
462 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 464 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
463 | if ( fd ) | 465 | if ( fd ) |
464 | { | 466 | { |
465 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 467 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
466 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 468 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
467 | ::close ( fd ); | 469 | ::close ( fd ); |
468 | } | 470 | } |
469 | } | 471 | } |
470 | else | 472 | else |
471 | { | 473 | { |
472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 474 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
473 | if ( fd ) | 475 | if ( fd ) |
474 | { | 476 | { |
475 | char buf[10]; | 477 | char buf[10]; |
476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 478 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
477 | buf[1] = '\0'; | 479 | buf[1] = '\0'; |
478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 480 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
479 | ::close( fd ); | 481 | ::close( fd ); |
480 | } | 482 | } |
481 | } | 483 | } |
482 | return res; | 484 | return res; |
483 | } | 485 | } |
484 | 486 | ||
485 | Transformation Zaurus::rotation() const | 487 | Transformation Zaurus::rotation() const |
486 | { | 488 | { |
487 | qDebug( "Zaurus::rotation()" ); | 489 | qDebug( "Zaurus::rotation()" ); |
488 | Transformation rot; | 490 | Transformation rot; |
489 | 491 | ||
490 | switch ( d->m_model ) { | 492 | switch ( d->m_model ) { |
491 | case Model_Zaurus_SLC3000: // fallthrough | 493 | case Model_Zaurus_SLC3000: // fallthrough |
492 | case Model_Zaurus_SLC1000: // fallthrough | 494 | case Model_Zaurus_SLC1000: // fallthrough |
493 | case Model_Zaurus_SLC7x0: | 495 | case Model_Zaurus_SLC7x0: |
494 | { | 496 | { |
495 | OHingeStatus hs = readHingeSensor(); | 497 | OHingeStatus hs = readHingeSensor(); |
496 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 498 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
497 | 499 | ||
498 | if ( m_embedix ) | 500 | if ( m_embedix ) |
499 | { | 501 | { |
500 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 502 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
501 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 503 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
502 | else rot = Rot270; | 504 | else rot = Rot270; |
503 | } | 505 | } |
504 | else | 506 | else |
505 | { | 507 | { |
506 | if ( hs == CASE_PORTRAIT ) rot = Rot90; | 508 | if ( hs == CASE_PORTRAIT ) rot = Rot90; |
507 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 509 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
508 | else rot = Rot0; | 510 | else rot = Rot0; |
509 | } | 511 | } |
510 | } | 512 | } |
511 | break; | 513 | break; |
512 | case Model_Zaurus_SL6000: | 514 | case Model_Zaurus_SL6000: |
513 | case Model_Zaurus_SLB600: | 515 | case Model_Zaurus_SLB600: |
514 | case Model_Zaurus_SLA300: | 516 | case Model_Zaurus_SLA300: |
515 | case Model_Zaurus_SL5500: | 517 | case Model_Zaurus_SL5500: |
516 | case Model_Zaurus_SL5000: | 518 | case Model_Zaurus_SL5000: |
517 | default: | 519 | default: |
518 | rot = d->m_rotation; | 520 | rot = d->m_rotation; |
519 | break; | 521 | break; |
520 | } | 522 | } |
521 | 523 | ||
522 | return rot; | 524 | return rot; |
523 | } | 525 | } |
524 | ODirection Zaurus::direction() const | 526 | ODirection Zaurus::direction() const |
525 | { | 527 | { |
526 | ODirection dir; | 528 | ODirection dir; |
527 | 529 | ||
528 | switch ( d->m_model ) { | 530 | switch ( d->m_model ) { |
529 | case Model_Zaurus_SLC3000: // fallthrough | 531 | case Model_Zaurus_SLC3000: // fallthrough |
530 | case Model_Zaurus_SLC1000: // fallthrough | 532 | case Model_Zaurus_SLC1000: // fallthrough |
531 | case Model_Zaurus_SLC7x0: { | 533 | case Model_Zaurus_SLC7x0: { |
532 | OHingeStatus hs = readHingeSensor(); | 534 | OHingeStatus hs = readHingeSensor(); |
533 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 535 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
534 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 536 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
535 | else dir = CW; | 537 | else dir = CW; |
536 | } | 538 | } |
537 | break; | 539 | break; |
538 | case Model_Zaurus_SL6000: | 540 | case Model_Zaurus_SL6000: |
539 | case Model_Zaurus_SLA300: | 541 | case Model_Zaurus_SLA300: |
540 | case Model_Zaurus_SLB600: | 542 | case Model_Zaurus_SLB600: |
541 | case Model_Zaurus_SL5500: | 543 | case Model_Zaurus_SL5500: |
542 | case Model_Zaurus_SL5000: | 544 | case Model_Zaurus_SL5000: |
543 | default: dir = d->m_direction; | 545 | default: dir = d->m_direction; |
544 | break; | 546 | break; |
545 | } | 547 | } |
546 | return dir; | 548 | return dir; |
547 | 549 | ||
548 | } | 550 | } |
549 | 551 | ||
550 | bool Zaurus::hasHingeSensor() const | 552 | bool Zaurus::hasHingeSensor() const |
551 | { | 553 | { |
552 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; | 554 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; |
553 | } | 555 | } |
554 | 556 | ||
555 | OHingeStatus Zaurus::readHingeSensor() const | 557 | OHingeStatus Zaurus::readHingeSensor() const |
556 | { | 558 | { |
557 | if (m_embedix) | 559 | if (m_embedix) |
558 | { | 560 | { |
559 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 561 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
560 | if (handle == -1) | 562 | if (handle == -1) |
561 | { | 563 | { |
562 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 564 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
563 | return CASE_UNKNOWN; | 565 | return CASE_UNKNOWN; |
564 | } | 566 | } |
565 | else | 567 | else |
566 | { | 568 | { |
567 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 569 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
568 | ::close (handle); | 570 | ::close (handle); |
569 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 571 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
570 | { | 572 | { |
571 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 573 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
572 | return static_cast<OHingeStatus>( retval ); | 574 | return static_cast<OHingeStatus>( retval ); |
573 | } | 575 | } |
574 | else | 576 | else |
575 | { | 577 | { |
576 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 578 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
577 | return CASE_UNKNOWN; | 579 | return CASE_UNKNOWN; |
578 | } | 580 | } |
579 | } | 581 | } |
580 | } | 582 | } |
581 | else | 583 | else |
582 | { | 584 | { |
583 | // corgi keyboard is event source 0 in OZ kernel 2.6 | 585 | // corgi keyboard is event source 0 in OZ kernel 2.6 |
584 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 586 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
585 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; | 587 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; |
586 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; | 588 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; |
587 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; | 589 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; |
588 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 590 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
589 | return CASE_UNKNOWN; | 591 | return CASE_UNKNOWN; |
590 | } | 592 | } |
591 | } | 593 | } |
592 | 594 | ||
593 | /* | 595 | /* |
594 | * Take code from iPAQ device. | 596 | * Take code from iPAQ device. |
595 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | 597 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. |
596 | * I hope that is ok - Alwin | 598 | * I hope that is ok - Alwin |
597 | */ | 599 | */ |
598 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 600 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
599 | { | 601 | { |
600 | int newkeycode = keycode; | 602 | int newkeycode = keycode; |
601 | 603 | ||
602 | if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false; | 604 | if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false; |
603 | 605 | ||
604 | /* map cursor keys depending on the hinge status */ | 606 | /* map cursor keys depending on the hinge status */ |
605 | switch ( keycode ) { | 607 | switch ( keycode ) { |
606 | // Rotate cursor keys | 608 | // Rotate cursor keys |
607 | case Key_Left : | 609 | case Key_Left : |
608 | case Key_Right: | 610 | case Key_Right: |
609 | case Key_Up : | 611 | case Key_Up : |
610 | case Key_Down : | 612 | case Key_Down : |
611 | { | 613 | { |
612 | if (rotation()==Rot90) { | 614 | if (rotation()==Rot90) { |
613 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 615 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
614 | } | 616 | } |
615 | } | 617 | } |
616 | break; | 618 | break; |
617 | 619 | ||
618 | } | 620 | } |
619 | if (newkeycode!=keycode) { | 621 | if (newkeycode!=keycode) { |
620 | if ( newkeycode != Key_unknown ) { | 622 | if ( newkeycode != Key_unknown ) { |
621 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 623 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
622 | } | 624 | } |
623 | return true; | 625 | return true; |
624 | } | 626 | } |
625 | return false; | 627 | return false; |
626 | } | 628 | } |