-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 65 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 64 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 25 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 19 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.cpp | 12 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 65 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.cpp | 11 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 69 |
8 files changed, 141 insertions, 189 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index cef7f63..5b73e59 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,666 +1,687 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_ipaq.h" | 30 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | 31 | #include "odevice_jornada.h" |
32 | #include "odevice_ramses.h" | 32 | #include "odevice_ramses.h" |
33 | #include "odevice_simpad.h" | 33 | #include "odevice_simpad.h" |
34 | #include "odevice_yopy.h" | 34 | #include "odevice_yopy.h" |
35 | #include "odevice_zaurus.h" | 35 | #include "odevice_zaurus.h" |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | 42 | ||
43 | /* OPIE */ | 43 | /* OPIE */ |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
48 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <math.h> | 51 | #include <math.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | #include <signal.h> | 53 | #include <signal.h> |
54 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
55 | #include <sys/time.h> | 55 | #include <sys/time.h> |
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #ifndef QT_NO_SOUND | 57 | #ifndef QT_NO_SOUND |
58 | #include <linux/soundcard.h> | 58 | #include <linux/soundcard.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
62 | 62 | ||
63 | using namespace Opie::Core; | 63 | using namespace Opie::Core; |
64 | 64 | ||
65 | struct default_button default_buttons [] = { | 65 | struct default_button default_buttons [] = { |
66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
67 | "devicebuttons/z_calendar", | 67 | "devicebuttons/z_calendar", |
68 | "datebook", "nextView()", | 68 | "datebook", "nextView()", |
69 | "today", "raise()" }, | 69 | "today", "raise()" }, |
70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
71 | "devicebuttons/z_contact", | 71 | "devicebuttons/z_contact", |
72 | "addressbook", "raise()", | 72 | "addressbook", "raise()", |
73 | "addressbook", "beamBusinessCard()" }, | 73 | "addressbook", "beamBusinessCard()" }, |
74 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 74 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
75 | "devicebuttons/z_home", | 75 | "devicebuttons/z_home", |
76 | "QPE/Launcher", "home()", | 76 | "QPE/Launcher", "home()", |
77 | "buttonsettings", "raise()" }, | 77 | "buttonsettings", "raise()" }, |
78 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 78 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
79 | "devicebuttons/z_menu", | 79 | "devicebuttons/z_menu", |
80 | "QPE/TaskBar", "toggleMenu()", | 80 | "QPE/TaskBar", "toggleMenu()", |
81 | "QPE/TaskBar", "toggleStartMenu()" }, | 81 | "QPE/TaskBar", "toggleStartMenu()" }, |
82 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 82 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
83 | "devicebuttons/z_mail", | 83 | "devicebuttons/z_mail", |
84 | "opiemail", "raise()", | 84 | "opiemail", "raise()", |
85 | "opiemail", "newMail()" }, | 85 | "opiemail", "newMail()" }, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | ODevice *ODevice::inst() | 88 | ODevice *ODevice::inst() |
89 | { | 89 | { |
90 | static ODevice *dev = 0; | 90 | static ODevice *dev = 0; |
91 | 91 | ||
92 | // rewrite this to only use /proc/cpuinfo or so | 92 | // rewrite this to only use /proc/cpuinfo or so |
93 | QString cpu_info; | 93 | QString cpu_info; |
94 | 94 | ||
95 | if ( !dev ) | 95 | if ( !dev ) |
96 | { | 96 | { |
97 | QFile f( PATH_PROC_CPUINFO ); | 97 | QFile f( PATH_PROC_CPUINFO ); |
98 | if ( f.open( IO_ReadOnly ) ) | 98 | if ( f.open( IO_ReadOnly ) ) |
99 | { | 99 | { |
100 | QTextStream s( &f ); | 100 | QTextStream s( &f ); |
101 | while ( !s.atEnd() ) | 101 | while ( !s.atEnd() ) |
102 | { | 102 | { |
103 | QString line; | 103 | QString line; |
104 | line = s.readLine(); | 104 | line = s.readLine(); |
105 | if ( line.startsWith( "Hardware" ) ) | 105 | if ( line.startsWith( "Hardware" ) ) |
106 | { | 106 | { |
107 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 107 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
108 | cpu_info = line; | 108 | cpu_info = line; |
109 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 109 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
110 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 110 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
111 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 111 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
112 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 112 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
113 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 113 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
114 | else qWarning( "ODevice() - unknown hardware - using default." ); | 114 | else qWarning( "ODevice() - unknown hardware - using default." ); |
115 | break; | 115 | break; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | else | 119 | else |
120 | { | 120 | { |
121 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 121 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
122 | } | 122 | } |
123 | if ( !dev ) dev = new ODevice(); | 123 | if ( !dev ) dev = new ODevice(); |
124 | dev->init(cpu_info); | 124 | dev->init(cpu_info); |
125 | } | 125 | } |
126 | return dev; | 126 | return dev; |
127 | } | 127 | } |
128 | 128 | ||
129 | ODevice::ODevice() | 129 | ODevice::ODevice() |
130 | { | 130 | { |
131 | d = new ODeviceData; | 131 | d = new ODeviceData; |
132 | 132 | ||
133 | d->m_modelstr = "Unknown"; | 133 | d->m_modelstr = "Unknown"; |
134 | d->m_model = Model_Unknown; | 134 | d->m_model = Model_Unknown; |
135 | d->m_vendorstr = "Unknown"; | 135 | d->m_vendorstr = "Unknown"; |
136 | d->m_vendor = Vendor_Unknown; | 136 | d->m_vendor = Vendor_Unknown; |
137 | d->m_systemstr = "Unknown"; | 137 | d->m_systemstr = "Unknown"; |
138 | d->m_system = System_Unknown; | 138 | d->m_system = System_Unknown; |
139 | d->m_sysverstr = "0.0"; | 139 | d->m_sysverstr = "0.0"; |
140 | d->m_rotation = Rot0; | 140 | d->m_rotation = Rot0; |
141 | d->m_direction = CW; | 141 | d->m_direction = CW; |
142 | 142 | ||
143 | d->m_holdtime = 1000; // 1000ms | 143 | d->m_holdtime = 1000; // 1000ms |
144 | d->m_buttons = 0; | 144 | d->m_buttons = 0; |
145 | d->m_cpu_frequencies = new QStrList; | 145 | d->m_cpu_frequencies = new QStrList; |
146 | |||
147 | // New distribution detection code first checks for legacy distributions, | ||
148 | // identified by /etc/familiar-version or /etc/oz_version. | ||
149 | // Then check for OpenEmbedded and lastly, read /etc/issue | ||
150 | |||
151 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | ||
152 | { | ||
153 | if ( QFile::exists( distributions[i].sysvfile ) ) | ||
154 | { | ||
155 | d->m_systemstr = distributions[i].sysstr; | ||
156 | d->m_system = distributions[i].system; | ||
157 | d->m_sysverstr = "<Unknown>"; | ||
158 | QFile f( distributions[i].sysvfile ); | ||
159 | if ( f.open( IO_ReadOnly ) ) | ||
160 | { | ||
161 | QTextStream ts( &f ); | ||
162 | d->m_sysverstr = ts.readLine(); | ||
163 | } | ||
164 | break; | ||
165 | } | ||
166 | } | ||
146 | } | 167 | } |
147 | 168 | ||
148 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 169 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
149 | { | 170 | { |
150 | if ( msg == "deviceButtonMappingChanged()" ) { | 171 | if ( msg == "deviceButtonMappingChanged()" ) { |
151 | reloadButtonMapping(); | 172 | reloadButtonMapping(); |
152 | } | 173 | } |
153 | } | 174 | } |
154 | 175 | ||
155 | void ODevice::init(const QString&) | 176 | void ODevice::init(const QString&) |
156 | { | 177 | { |
157 | } | 178 | } |
158 | 179 | ||
159 | /** | 180 | /** |
160 | * This method initialises the button mapping | 181 | * This method initialises the button mapping |
161 | */ | 182 | */ |
162 | void ODevice::initButtons() | 183 | void ODevice::initButtons() |
163 | { | 184 | { |
164 | if ( d->m_buttons ) | 185 | if ( d->m_buttons ) |
165 | return; | 186 | return; |
166 | 187 | ||
167 | qDebug ( "init Buttons" ); | 188 | qDebug ( "init Buttons" ); |
168 | d->m_buttons = new QValueList <ODeviceButton>; | 189 | d->m_buttons = new QValueList <ODeviceButton>; |
169 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 190 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
170 | default_button *db = default_buttons + i; | 191 | default_button *db = default_buttons + i; |
171 | ODeviceButton b; | 192 | ODeviceButton b; |
172 | b. setKeycode ( db->code ); | 193 | b. setKeycode ( db->code ); |
173 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 194 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
174 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 195 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
175 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 196 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
176 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 197 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
177 | d->m_buttons->append ( b ); | 198 | d->m_buttons->append ( b ); |
178 | } | 199 | } |
179 | 200 | ||
180 | reloadButtonMapping(); | 201 | reloadButtonMapping(); |
181 | 202 | ||
182 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 203 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
183 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 204 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
184 | } | 205 | } |
185 | 206 | ||
186 | ODevice::~ODevice() | 207 | ODevice::~ODevice() |
187 | { | 208 | { |
188 | // we leak m_devicebuttons and m_cpu_frequency | 209 | // we leak m_devicebuttons and m_cpu_frequency |
189 | // but it's a singleton and it is not so importantant | 210 | // but it's a singleton and it is not so importantant |
190 | // -zecke | 211 | // -zecke |
191 | delete d; | 212 | delete d; |
192 | } | 213 | } |
193 | 214 | ||
194 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 215 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
195 | { | 216 | { |
196 | return false; | 217 | return false; |
197 | } | 218 | } |
198 | 219 | ||
199 | //#include <linux/apm_bios.h> | 220 | //#include <linux/apm_bios.h> |
200 | 221 | ||
201 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 222 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
202 | 223 | ||
203 | /** | 224 | /** |
204 | * This method will try to suspend the device | 225 | * This method will try to suspend the device |
205 | * It only works if the user is the QWS Server and the apm application | 226 | * It only works if the user is the QWS Server and the apm application |
206 | * is installed. | 227 | * is installed. |
207 | * It tries to suspend and then waits some time cause some distributions | 228 | * It tries to suspend and then waits some time cause some distributions |
208 | * do have asynchronus apm implementations. | 229 | * do have asynchronus apm implementations. |
209 | * This method will either fail and return false or it'll suspend the | 230 | * This method will either fail and return false or it'll suspend the |
210 | * device and return once the device got woken up | 231 | * device and return once the device got woken up |
211 | * | 232 | * |
212 | * @return if the device got suspended | 233 | * @return if the device got suspended |
213 | */ | 234 | */ |
214 | bool ODevice::suspend() | 235 | bool ODevice::suspend() |
215 | { | 236 | { |
216 | qDebug("ODevice::suspend"); | 237 | qDebug("ODevice::suspend"); |
217 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 238 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
218 | return false; | 239 | return false; |
219 | 240 | ||
220 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 241 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
221 | return false; | 242 | return false; |
222 | 243 | ||
223 | bool res = false; | 244 | bool res = false; |
224 | ODevice::sendSuspendmsg(); | 245 | ODevice::sendSuspendmsg(); |
225 | 246 | ||
226 | struct timeval tvs, tvn; | 247 | struct timeval tvs, tvn; |
227 | ::gettimeofday ( &tvs, 0 ); | 248 | ::gettimeofday ( &tvs, 0 ); |
228 | 249 | ||
229 | ::sync(); // flush fs caches | 250 | ::sync(); // flush fs caches |
230 | res = ( ::system ( "apm --suspend" ) == 0 ); | 251 | res = ( ::system ( "apm --suspend" ) == 0 ); |
231 | 252 | ||
232 | // This is needed because the iPAQ apm implementation is asynchronous and we | 253 | // This is needed because the iPAQ apm implementation is asynchronous and we |
233 | // can not be sure when exactly the device is really suspended | 254 | // can not be sure when exactly the device is really suspended |
234 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 255 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
235 | 256 | ||
236 | if ( res ) { | 257 | if ( res ) { |
237 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 258 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
238 | ::usleep ( 200 * 1000 ); | 259 | ::usleep ( 200 * 1000 ); |
239 | ::gettimeofday ( &tvn, 0 ); | 260 | ::gettimeofday ( &tvn, 0 ); |
240 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 261 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
241 | } | 262 | } |
242 | 263 | ||
243 | return res; | 264 | return res; |
244 | } | 265 | } |
245 | 266 | ||
246 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 267 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
247 | 268 | ||
248 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 269 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
249 | 270 | ||
250 | /* VESA Blanking Levels */ | 271 | /* VESA Blanking Levels */ |
251 | #define VESA_NO_BLANKING 0 | 272 | #define VESA_NO_BLANKING 0 |
252 | #define VESA_VSYNC_SUSPEND 1 | 273 | #define VESA_VSYNC_SUSPEND 1 |
253 | #define VESA_HSYNC_SUSPEND 2 | 274 | #define VESA_HSYNC_SUSPEND 2 |
254 | #define VESA_POWERDOWN 3 | 275 | #define VESA_POWERDOWN 3 |
255 | 276 | ||
256 | /** | 277 | /** |
257 | * This sets the display on or off | 278 | * This sets the display on or off |
258 | */ | 279 | */ |
259 | bool ODevice::setDisplayStatus ( bool on ) | 280 | bool ODevice::setDisplayStatus ( bool on ) |
260 | { | 281 | { |
261 | qDebug("ODevice::setDisplayStatus(%d)", on); | 282 | qDebug("ODevice::setDisplayStatus(%d)", on); |
262 | 283 | ||
263 | if ( d->m_model == Model_Unknown ) | 284 | if ( d->m_model == Model_Unknown ) |
264 | return false; | 285 | return false; |
265 | 286 | ||
266 | bool res = false; | 287 | bool res = false; |
267 | int fd; | 288 | int fd; |
268 | 289 | ||
269 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 290 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
270 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 291 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
271 | ::close ( fd ); | 292 | ::close ( fd ); |
272 | } | 293 | } |
273 | return res; | 294 | return res; |
274 | } | 295 | } |
275 | 296 | ||
276 | /** | 297 | /** |
277 | * This sets the display brightness | 298 | * This sets the display brightness |
278 | * | 299 | * |
279 | * @param p The brightness to be set on a scale from 0 to 255 | 300 | * @param p The brightness to be set on a scale from 0 to 255 |
280 | * @return success or failure | 301 | * @return success or failure |
281 | */ | 302 | */ |
282 | bool ODevice::setDisplayBrightness ( int p) | 303 | bool ODevice::setDisplayBrightness ( int p) |
283 | { | 304 | { |
284 | Q_UNUSED( p ) | 305 | Q_UNUSED( p ) |
285 | return false; | 306 | return false; |
286 | } | 307 | } |
287 | 308 | ||
288 | /** | 309 | /** |
289 | * @return returns the number of steppings on the brightness slider | 310 | * @return returns the number of steppings on the brightness slider |
290 | * in the Light-'n-Power settings. | 311 | * in the Light-'n-Power settings. |
291 | */ | 312 | */ |
292 | int ODevice::displayBrightnessResolution() const | 313 | int ODevice::displayBrightnessResolution() const |
293 | { | 314 | { |
294 | return 16; | 315 | return 16; |
295 | } | 316 | } |
296 | 317 | ||
297 | /** | 318 | /** |
298 | * This sets the display contrast | 319 | * This sets the display contrast |
299 | * @param p The contrast to be set on a scale from 0 to 255 | 320 | * @param p The contrast to be set on a scale from 0 to 255 |
300 | * @return success or failure | 321 | * @return success or failure |
301 | */ | 322 | */ |
302 | bool ODevice::setDisplayContrast ( int p) | 323 | bool ODevice::setDisplayContrast ( int p) |
303 | { | 324 | { |
304 | Q_UNUSED( p ) | 325 | Q_UNUSED( p ) |
305 | return false; | 326 | return false; |
306 | } | 327 | } |
307 | 328 | ||
308 | /** | 329 | /** |
309 | * @return return the max value for the brightness settings slider | 330 | * @return return the max value for the brightness settings slider |
310 | * or 0 if the device doesn't support setting of a contrast | 331 | * or 0 if the device doesn't support setting of a contrast |
311 | */ | 332 | */ |
312 | int ODevice::displayContrastResolution() const | 333 | int ODevice::displayContrastResolution() const |
313 | { | 334 | { |
314 | return 0; | 335 | return 0; |
315 | } | 336 | } |
316 | 337 | ||
317 | /** | 338 | /** |
318 | * This returns the vendor as string | 339 | * This returns the vendor as string |
319 | * @return Vendor as QString | 340 | * @return Vendor as QString |
320 | */ | 341 | */ |
321 | QString ODevice::vendorString() const | 342 | QString ODevice::vendorString() const |
322 | { | 343 | { |
323 | return d->m_vendorstr; | 344 | return d->m_vendorstr; |
324 | } | 345 | } |
325 | 346 | ||
326 | /** | 347 | /** |
327 | * This returns the vendor as one of the values of OVendor | 348 | * This returns the vendor as one of the values of OVendor |
328 | * @return OVendor | 349 | * @return OVendor |
329 | */ | 350 | */ |
330 | OVendor ODevice::vendor() const | 351 | OVendor ODevice::vendor() const |
331 | { | 352 | { |
332 | return d->m_vendor; | 353 | return d->m_vendor; |
333 | } | 354 | } |
334 | 355 | ||
335 | /** | 356 | /** |
336 | * This returns the model as a string | 357 | * This returns the model as a string |
337 | * @return A string representing the model | 358 | * @return A string representing the model |
338 | */ | 359 | */ |
339 | QString ODevice::modelString() const | 360 | QString ODevice::modelString() const |
340 | { | 361 | { |
341 | return d->m_modelstr; | 362 | return d->m_modelstr; |
342 | } | 363 | } |
343 | 364 | ||
344 | /** | 365 | /** |
345 | * This does return the OModel used | 366 | * This does return the OModel used |
346 | */ | 367 | */ |
347 | OModel ODevice::model() const | 368 | OModel ODevice::model() const |
348 | { | 369 | { |
349 | return d->m_model; | 370 | return d->m_model; |
350 | } | 371 | } |
351 | 372 | ||
352 | /** | 373 | /** |
353 | * This does return the systen name | 374 | * This does return the systen name |
354 | */ | 375 | */ |
355 | QString ODevice::systemString() const | 376 | QString ODevice::systemString() const |
356 | { | 377 | { |
357 | return d->m_systemstr; | 378 | return d->m_systemstr; |
358 | } | 379 | } |
359 | 380 | ||
360 | /** | 381 | /** |
361 | * Return System as OSystem value | 382 | * Return System as OSystem value |
362 | */ | 383 | */ |
363 | OSystem ODevice::system() const | 384 | OSystem ODevice::system() const |
364 | { | 385 | { |
365 | return d->m_system; | 386 | return d->m_system; |
366 | } | 387 | } |
367 | 388 | ||
368 | /** | 389 | /** |
369 | * @return the version string of the base system | 390 | * @return the version string of the base system |
370 | */ | 391 | */ |
371 | QString ODevice::systemVersionString() const | 392 | QString ODevice::systemVersionString() const |
372 | { | 393 | { |
373 | return d->m_sysverstr; | 394 | return d->m_sysverstr; |
374 | } | 395 | } |
375 | 396 | ||
376 | /** | 397 | /** |
377 | * @return the current Transformation | 398 | * @return the current Transformation |
378 | */ | 399 | */ |
379 | Transformation ODevice::rotation() const | 400 | Transformation ODevice::rotation() const |
380 | { | 401 | { |
381 | return d->m_rotation; | 402 | return d->m_rotation; |
382 | } | 403 | } |
383 | 404 | ||
384 | /** | 405 | /** |
385 | * @return the current rotation direction | 406 | * @return the current rotation direction |
386 | */ | 407 | */ |
387 | ODirection ODevice::direction() const | 408 | ODirection ODevice::direction() const |
388 | { | 409 | { |
389 | return d->m_direction; | 410 | return d->m_direction; |
390 | } | 411 | } |
391 | 412 | ||
392 | /** | 413 | /** |
393 | * This plays an alarm sound | 414 | * This plays an alarm sound |
394 | */ | 415 | */ |
395 | void ODevice::playAlarmSound() | 416 | void ODevice::playAlarmSound() |
396 | { | 417 | { |
397 | #ifndef QT_NO_SOUND | 418 | #ifndef QT_NO_SOUND |
398 | static Sound snd ( "alarm" ); | 419 | static Sound snd ( "alarm" ); |
399 | 420 | ||
400 | if ( snd. isFinished()) | 421 | if ( snd. isFinished()) |
401 | snd. play(); | 422 | snd. play(); |
402 | #endif | 423 | #endif |
403 | } | 424 | } |
404 | 425 | ||
405 | /** | 426 | /** |
406 | * This plays a key sound | 427 | * This plays a key sound |
407 | */ | 428 | */ |
408 | void ODevice::playKeySound() | 429 | void ODevice::playKeySound() |
409 | { | 430 | { |
410 | #ifndef QT_NO_SOUND | 431 | #ifndef QT_NO_SOUND |
411 | static Sound snd ( "keysound" ); | 432 | static Sound snd ( "keysound" ); |
412 | 433 | ||
413 | if ( snd. isFinished()) | 434 | if ( snd. isFinished()) |
414 | snd. play(); | 435 | snd. play(); |
415 | #endif | 436 | #endif |
416 | } | 437 | } |
417 | 438 | ||
418 | /** | 439 | /** |
419 | * This plays a touch sound | 440 | * This plays a touch sound |
420 | */ | 441 | */ |
421 | void ODevice::playTouchSound() | 442 | void ODevice::playTouchSound() |
422 | { | 443 | { |
423 | #ifndef QT_NO_SOUND | 444 | #ifndef QT_NO_SOUND |
424 | static Sound snd ( "touchsound" ); | 445 | static Sound snd ( "touchsound" ); |
425 | 446 | ||
426 | if ( snd. isFinished()) | 447 | if ( snd. isFinished()) |
427 | snd. play(); | 448 | snd. play(); |
428 | #endif | 449 | #endif |
429 | } | 450 | } |
430 | 451 | ||
431 | /** | 452 | /** |
432 | * This method will return a list of leds | 453 | * This method will return a list of leds |
433 | * available on this device | 454 | * available on this device |
434 | * @return a list of LEDs. | 455 | * @return a list of LEDs. |
435 | */ | 456 | */ |
436 | QValueList <OLed> ODevice::ledList() const | 457 | QValueList <OLed> ODevice::ledList() const |
437 | { | 458 | { |
438 | return QValueList <OLed>(); | 459 | return QValueList <OLed>(); |
439 | } | 460 | } |
440 | 461 | ||
441 | /** | 462 | /** |
442 | * This does return the state of the LEDs | 463 | * This does return the state of the LEDs |
443 | */ | 464 | */ |
444 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 465 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
445 | { | 466 | { |
446 | return QValueList <OLedState>(); | 467 | return QValueList <OLedState>(); |
447 | } | 468 | } |
448 | 469 | ||
449 | /** | 470 | /** |
450 | * @return the state for a given OLed | 471 | * @return the state for a given OLed |
451 | */ | 472 | */ |
452 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 473 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
453 | { | 474 | { |
454 | return Led_Off; | 475 | return Led_Off; |
455 | } | 476 | } |
456 | 477 | ||
457 | /** | 478 | /** |
458 | * Set the state for a LED | 479 | * Set the state for a LED |
459 | * @param which Which OLed to use | 480 | * @param which Which OLed to use |
460 | * @param st The state to set | 481 | * @param st The state to set |
461 | * @return success or failure | 482 | * @return success or failure |
462 | */ | 483 | */ |
463 | bool ODevice::setLedState ( OLed which, OLedState st ) | 484 | bool ODevice::setLedState ( OLed which, OLedState st ) |
464 | { | 485 | { |
465 | Q_UNUSED( which ) | 486 | Q_UNUSED( which ) |
466 | Q_UNUSED( st ) | 487 | Q_UNUSED( st ) |
467 | return false; | 488 | return false; |
468 | } | 489 | } |
469 | 490 | ||
470 | /** | 491 | /** |
471 | * @return if the device has a light sensor | 492 | * @return if the device has a light sensor |
472 | */ | 493 | */ |
473 | bool ODevice::hasLightSensor() const | 494 | bool ODevice::hasLightSensor() const |
474 | { | 495 | { |
475 | return false; | 496 | return false; |
476 | } | 497 | } |
477 | 498 | ||
478 | /** | 499 | /** |
479 | * @return a value from the light sensor | 500 | * @return a value from the light sensor |
480 | */ | 501 | */ |
481 | int ODevice::readLightSensor() | 502 | int ODevice::readLightSensor() |
482 | { | 503 | { |
483 | return -1; | 504 | return -1; |
484 | } | 505 | } |
485 | 506 | ||
486 | /** | 507 | /** |
487 | * @return the light sensor resolution | 508 | * @return the light sensor resolution |
488 | */ | 509 | */ |
489 | int ODevice::lightSensorResolution() const | 510 | int ODevice::lightSensorResolution() const |
490 | { | 511 | { |
491 | return 0; | 512 | return 0; |
492 | } | 513 | } |
493 | 514 | ||
494 | /** | 515 | /** |
495 | * @return if the device has a hinge sensor | 516 | * @return if the device has a hinge sensor |
496 | */ | 517 | */ |
497 | bool ODevice::hasHingeSensor() const | 518 | bool ODevice::hasHingeSensor() const |
498 | { | 519 | { |
499 | return false; | 520 | return false; |
500 | } | 521 | } |
501 | 522 | ||
502 | /** | 523 | /** |
503 | * @return a value from the hinge sensor | 524 | * @return a value from the hinge sensor |
504 | */ | 525 | */ |
505 | OHingeStatus ODevice::readHingeSensor() | 526 | OHingeStatus ODevice::readHingeSensor() |
506 | { | 527 | { |
507 | return CASE_UNKNOWN; | 528 | return CASE_UNKNOWN; |
508 | } | 529 | } |
509 | 530 | ||
510 | /** | 531 | /** |
511 | * @return a list with CPU frequencies supported by the hardware | 532 | * @return a list with CPU frequencies supported by the hardware |
512 | */ | 533 | */ |
513 | const QStrList &ODevice::allowedCpuFrequencies() const | 534 | const QStrList &ODevice::allowedCpuFrequencies() const |
514 | { | 535 | { |
515 | return *d->m_cpu_frequencies; | 536 | return *d->m_cpu_frequencies; |
516 | } | 537 | } |
517 | 538 | ||
518 | 539 | ||
519 | /** | 540 | /** |
520 | * Set desired CPU frequency | 541 | * Set desired CPU frequency |
521 | * | 542 | * |
522 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 543 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
523 | */ | 544 | */ |
524 | bool ODevice::setCurrentCpuFrequency(uint index) | 545 | bool ODevice::setCurrentCpuFrequency(uint index) |
525 | { | 546 | { |
526 | if (index >= d->m_cpu_frequencies->count()) | 547 | if (index >= d->m_cpu_frequencies->count()) |
527 | return false; | 548 | return false; |
528 | 549 | ||
529 | char *freq = d->m_cpu_frequencies->at(index); | 550 | char *freq = d->m_cpu_frequencies->at(index); |
530 | qWarning("set freq to %s", freq); | 551 | qWarning("set freq to %s", freq); |
531 | 552 | ||
532 | int fd; | 553 | int fd; |
533 | 554 | ||
534 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 555 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
535 | char writeCommand[50]; | 556 | char writeCommand[50]; |
536 | const int count = sprintf(writeCommand, "%s\n", freq); | 557 | const int count = sprintf(writeCommand, "%s\n", freq); |
537 | int res = (::write(fd, writeCommand, count) != -1); | 558 | int res = (::write(fd, writeCommand, count) != -1); |
538 | ::close(fd); | 559 | ::close(fd); |
539 | return res; | 560 | return res; |
540 | } | 561 | } |
541 | 562 | ||
542 | return false; | 563 | return false; |
543 | } | 564 | } |
544 | 565 | ||
545 | 566 | ||
546 | /** | 567 | /** |
547 | * @return a list of hardware buttons | 568 | * @return a list of hardware buttons |
548 | */ | 569 | */ |
549 | const QValueList <ODeviceButton> &ODevice::buttons() | 570 | const QValueList <ODeviceButton> &ODevice::buttons() |
550 | { | 571 | { |
551 | initButtons(); | 572 | initButtons(); |
552 | 573 | ||
553 | return *d->m_buttons; | 574 | return *d->m_buttons; |
554 | } | 575 | } |
555 | 576 | ||
556 | /** | 577 | /** |
557 | * @return The amount of time that would count as a hold | 578 | * @return The amount of time that would count as a hold |
558 | */ | 579 | */ |
559 | uint ODevice::buttonHoldTime() const | 580 | uint ODevice::buttonHoldTime() const |
560 | { | 581 | { |
561 | return d->m_holdtime; | 582 | return d->m_holdtime; |
562 | } | 583 | } |
563 | 584 | ||
564 | /** | 585 | /** |
565 | * This method return a ODeviceButton for a key code | 586 | * This method return a ODeviceButton for a key code |
566 | * or 0 if no special hardware button is available for the device | 587 | * or 0 if no special hardware button is available for the device |
567 | * | 588 | * |
568 | * @return The devicebutton or 0l | 589 | * @return The devicebutton or 0l |
569 | * @see ODeviceButton | 590 | * @see ODeviceButton |
570 | */ | 591 | */ |
571 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 592 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
572 | { | 593 | { |
573 | initButtons(); | 594 | initButtons(); |
574 | 595 | ||
575 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 596 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
576 | if ( (*it). keycode() == code ) | 597 | if ( (*it). keycode() == code ) |
577 | return &(*it); | 598 | return &(*it); |
578 | } | 599 | } |
579 | return 0; | 600 | return 0; |
580 | } | 601 | } |
581 | 602 | ||
582 | void ODevice::reloadButtonMapping() | 603 | void ODevice::reloadButtonMapping() |
583 | { | 604 | { |
584 | initButtons(); | 605 | initButtons(); |
585 | 606 | ||
586 | Config cfg ( "ButtonSettings" ); | 607 | Config cfg ( "ButtonSettings" ); |
587 | 608 | ||
588 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 609 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
589 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 610 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
590 | QString group = "Button" + QString::number ( i ); | 611 | QString group = "Button" + QString::number ( i ); |
591 | 612 | ||
592 | QCString pch, hch; | 613 | QCString pch, hch; |
593 | QCString pm, hm; | 614 | QCString pm, hm; |
594 | QByteArray pdata, hdata; | 615 | QByteArray pdata, hdata; |
595 | 616 | ||
596 | if ( cfg. hasGroup ( group )) { | 617 | if ( cfg. hasGroup ( group )) { |
597 | cfg. setGroup ( group ); | 618 | cfg. setGroup ( group ); |
598 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 619 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
599 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 620 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
600 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 621 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
601 | 622 | ||
602 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 623 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
603 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 624 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
604 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 625 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
605 | } | 626 | } |
606 | 627 | ||
607 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 628 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
608 | 629 | ||
609 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 630 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
610 | } | 631 | } |
611 | } | 632 | } |
612 | 633 | ||
613 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 634 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
614 | { | 635 | { |
615 | initButtons(); | 636 | initButtons(); |
616 | 637 | ||
617 | QString mb_chan; | 638 | QString mb_chan; |
618 | 639 | ||
619 | if ( button >= (int) d->m_buttons->count()) | 640 | if ( button >= (int) d->m_buttons->count()) |
620 | return; | 641 | return; |
621 | 642 | ||
622 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 643 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
623 | b. setPressedAction ( action ); | 644 | b. setPressedAction ( action ); |
624 | 645 | ||
625 | mb_chan=b. pressedAction(). channel(); | 646 | mb_chan=b. pressedAction(). channel(); |
626 | 647 | ||
627 | Config buttonFile ( "ButtonSettings" ); | 648 | Config buttonFile ( "ButtonSettings" ); |
628 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 649 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
629 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 650 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
630 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 651 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
631 | 652 | ||
632 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 653 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
633 | 654 | ||
634 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 655 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
635 | } | 656 | } |
636 | 657 | ||
637 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 658 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
638 | { | 659 | { |
639 | initButtons(); | 660 | initButtons(); |
640 | 661 | ||
641 | if ( button >= (int) d->m_buttons->count()) | 662 | if ( button >= (int) d->m_buttons->count()) |
642 | return; | 663 | return; |
643 | 664 | ||
644 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 665 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
645 | b. setHeldAction ( action ); | 666 | b. setHeldAction ( action ); |
646 | 667 | ||
647 | Config buttonFile ( "ButtonSettings" ); | 668 | Config buttonFile ( "ButtonSettings" ); |
648 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 669 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
649 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 670 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
650 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 671 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
651 | 672 | ||
652 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 673 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
653 | 674 | ||
654 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 675 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
655 | } | 676 | } |
656 | void ODevice::virtual_hook(int, void* ){ | 677 | void ODevice::virtual_hook(int, void* ){ |
657 | 678 | ||
658 | } | 679 | } |
659 | 680 | ||
660 | void ODevice::sendSuspendmsg() | 681 | void ODevice::sendSuspendmsg() |
661 | { | 682 | { |
662 | if ( isQWS() ) | 683 | if ( isQWS() ) |
663 | return; | 684 | return; |
664 | 685 | ||
665 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 686 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
666 | } | 687 | } |
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index aaebde3..474d792 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -1,351 +1,373 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_H_ | 30 | #ifndef ODEVICE_H_ |
31 | #define ODEVICE_H_ | 31 | #define ODEVICE_H_ |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odevicebutton.h> | 34 | #include <opie2/odevicebutton.h> |
35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qnamespace.h> | 38 | #include <qnamespace.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qstrlist.h> | 41 | #include <qstrlist.h> |
42 | 42 | ||
43 | namespace Opie{ | 43 | namespace Opie{ |
44 | namespace Core{ | 44 | namespace Core{ |
45 | 45 | ||
46 | class ODeviceData; | 46 | class ODeviceData; |
47 | /** | 47 | /** |
48 | * The available devices | 48 | * The available devices |
49 | */ | 49 | */ |
50 | enum OModel { | 50 | enum OModel { |
51 | Model_Unknown, // = 0 | 51 | Model_Unknown, // = 0 |
52 | 52 | ||
53 | Model_Series_Mask = 0xff000000, | 53 | Model_Series_Mask = 0xff000000, |
54 | 54 | ||
55 | Model_iPAQ = ( 1 << 24 ), | 55 | Model_iPAQ = ( 1 << 24 ), |
56 | 56 | ||
57 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 57 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
58 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 58 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
59 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 59 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
60 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 60 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
61 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 61 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
62 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 62 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
63 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), | 63 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), |
64 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), | 64 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), |
65 | 65 | ||
66 | Model_Jornada = ( 6 << 24 ), | 66 | Model_Jornada = ( 6 << 24 ), |
67 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | 67 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), |
68 | 68 | ||
69 | Model_Zaurus = ( 2 << 24 ), | 69 | Model_Zaurus = ( 2 << 24 ), |
70 | 70 | ||
71 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 71 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
72 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 72 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
73 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 73 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
74 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 74 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
75 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | 75 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), |
76 | 76 | ||
77 | Model_SIMpad = ( 3 << 24 ), | 77 | Model_SIMpad = ( 3 << 24 ), |
78 | 78 | ||
79 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 79 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
80 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 80 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
81 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 81 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
82 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 82 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
83 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 83 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
84 | 84 | ||
85 | Model_Ramses = ( 4 << 24 ), | 85 | Model_Ramses = ( 4 << 24 ), |
86 | 86 | ||
87 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 87 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
88 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 88 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
89 | 89 | ||
90 | Model_Yopy = ( 5 << 24 ), | 90 | Model_Yopy = ( 5 << 24 ), |
91 | 91 | ||
92 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | 92 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), |
93 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | 93 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), |
94 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | 94 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), |
95 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | 95 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), |
96 | 96 | ||
97 | Model_Beagle = ( 6 << 24 ), | ||
98 | |||
99 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), | ||
100 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), | ||
101 | |||
97 | }; | 102 | }; |
98 | 103 | ||
99 | /** | 104 | /** |
100 | * The vendor of the device | 105 | * The vendor of the device |
101 | */ | 106 | */ |
102 | enum OVendor { | 107 | enum OVendor { |
103 | Vendor_Unknown, | 108 | Vendor_Unknown, |
104 | 109 | ||
105 | Vendor_HP, | 110 | Vendor_HP, |
106 | Vendor_Sharp, | 111 | Vendor_Sharp, |
107 | Vendor_SIEMENS, | 112 | Vendor_SIEMENS, |
108 | Vendor_MundN, | 113 | Vendor_MundN, |
109 | Vendor_GMate, | 114 | Vendor_GMate, |
115 | Vendor_MasterIA, | ||
110 | }; | 116 | }; |
111 | 117 | ||
112 | /** | 118 | /** |
113 | * The System used | 119 | * The System used |
114 | */ | 120 | */ |
115 | enum OSystem { | 121 | enum OSystem { |
116 | System_Unknown, | 122 | System_Unknown, |
117 | 123 | ||
118 | System_Familiar, | 124 | System_Familiar, |
119 | System_Zaurus, | 125 | System_Zaurus, |
120 | System_OpenZaurus, | 126 | System_OpenZaurus, |
121 | System_Linupy, | 127 | System_Linupy, |
128 | System_OpenEmbedded, | ||
129 | }; | ||
130 | |||
131 | typedef struct { | ||
132 | OSystem system; | ||
133 | char* sysstr; | ||
134 | char* sysvfile; | ||
135 | } ODistribution; | ||
136 | |||
137 | static ODistribution distributions[] = | ||
138 | { | ||
139 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | ||
140 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | ||
141 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | ||
142 | { System_Unknown, "Linux", "/etc/issue" }, | ||
143 | |||
122 | }; | 144 | }; |
123 | 145 | ||
124 | enum OLedState { | 146 | enum OLedState { |
125 | Led_Off, | 147 | Led_Off, |
126 | Led_On, | 148 | Led_On, |
127 | Led_BlinkSlow, | 149 | Led_BlinkSlow, |
128 | Led_BlinkFast | 150 | Led_BlinkFast |
129 | }; | 151 | }; |
130 | 152 | ||
131 | enum OLed { | 153 | enum OLed { |
132 | Led_Mail, | 154 | Led_Mail, |
133 | Led_Power, | 155 | Led_Power, |
134 | Led_BlueTooth | 156 | Led_BlueTooth |
135 | }; | 157 | }; |
136 | 158 | ||
137 | enum OHardKey { | 159 | enum OHardKey { |
138 | HardKey_Datebook = Qt::Key_F9, | 160 | HardKey_Datebook = Qt::Key_F9, |
139 | HardKey_Contacts = Qt::Key_F10, | 161 | HardKey_Contacts = Qt::Key_F10, |
140 | HardKey_Menu = Qt::Key_F11, | 162 | HardKey_Menu = Qt::Key_F11, |
141 | HardKey_Home = Qt::Key_F12, | 163 | HardKey_Home = Qt::Key_F12, |
142 | HardKey_Mail = Qt::Key_F13, | 164 | HardKey_Mail = Qt::Key_F13, |
143 | HardKey_Record = Qt::Key_F24, | 165 | HardKey_Record = Qt::Key_F24, |
144 | HardKey_Suspend = Qt::Key_F34, | 166 | HardKey_Suspend = Qt::Key_F34, |
145 | HardKey_Backlight = Qt::Key_F35, | 167 | HardKey_Backlight = Qt::Key_F35, |
146 | HardKey_Action = Qt::Key_F10, | 168 | HardKey_Action = Qt::Key_F10, |
147 | HardKey_OK = Qt::Key_F11, | 169 | HardKey_OK = Qt::Key_F11, |
148 | HardKey_End = Qt::Key_F12, | 170 | HardKey_End = Qt::Key_F12, |
149 | }; | 171 | }; |
150 | 172 | ||
151 | enum ODirection { | 173 | enum ODirection { |
152 | CW = 0, | 174 | CW = 0, |
153 | CCW = 1, | 175 | CCW = 1, |
154 | Flip = 2, | 176 | Flip = 2, |
155 | }; | 177 | }; |
156 | 178 | ||
157 | enum OHingeStatus { | 179 | enum OHingeStatus { |
158 | CASE_CLOSED = 3, | 180 | CASE_CLOSED = 3, |
159 | CASE_PORTRAIT = 2, | 181 | CASE_PORTRAIT = 2, |
160 | CASE_LANDSCAPE = 0, | 182 | CASE_LANDSCAPE = 0, |
161 | CASE_UNKNOWN = 1, | 183 | CASE_UNKNOWN = 1, |
162 | }; | 184 | }; |
163 | 185 | ||
164 | /* default button for qvfb or such | 186 | /* default button for qvfb or such |
165 | * see odevice.cpp for details. | 187 | * see odevice.cpp for details. |
166 | * hint: manage a user defined button for qvfb? | 188 | * hint: manage a user defined button for qvfb? |
167 | * alwin | 189 | * alwin |
168 | */ | 190 | */ |
169 | struct default_button { | 191 | struct default_button { |
170 | Qt::Key code; | 192 | Qt::Key code; |
171 | char *utext; | 193 | char *utext; |
172 | char *pix; | 194 | char *pix; |
173 | char *fpressedservice; | 195 | char *fpressedservice; |
174 | char *fpressedaction; | 196 | char *fpressedaction; |
175 | char *fheldservice; | 197 | char *fheldservice; |
176 | char *fheldaction; | 198 | char *fheldaction; |
177 | }; | 199 | }; |
178 | 200 | ||
179 | /** | 201 | /** |
180 | * A singleton which gives informations about device specefic option | 202 | * A singleton which gives informations about device specefic option |
181 | * like the Hardware used, LEDs, the Base Distribution and | 203 | * like the Hardware used, LEDs, the Base Distribution and |
182 | * hardware key mappings. | 204 | * hardware key mappings. |
183 | * | 205 | * |
184 | * @short A small class for device specefic options | 206 | * @short A small class for device specefic options |
185 | * @see QObject | 207 | * @see QObject |
186 | * @author Robert Griebl | 208 | * @author Robert Griebl |
187 | * @version 1.0 | 209 | * @version 1.0 |
188 | */ | 210 | */ |
189 | class ODevice : public QObject | 211 | class ODevice : public QObject |
190 | { | 212 | { |
191 | Q_OBJECT | 213 | Q_OBJECT |
192 | 214 | ||
193 | private: | 215 | private: |
194 | /* disable copy */ | 216 | /* disable copy */ |
195 | ODevice ( const ODevice & ); | 217 | ODevice ( const ODevice & ); |
196 | 218 | ||
197 | protected: | 219 | protected: |
198 | ODevice(); | 220 | ODevice(); |
199 | virtual void init(const QString&); | 221 | virtual void init(const QString&); |
200 | virtual void initButtons(); | 222 | virtual void initButtons(); |
201 | static void sendSuspendmsg(); | 223 | static void sendSuspendmsg(); |
202 | 224 | ||
203 | ODeviceData *d; | 225 | ODeviceData *d; |
204 | 226 | ||
205 | public: | 227 | public: |
206 | // sandman do we want to allow destructions? -zecke? | 228 | // sandman do we want to allow destructions? -zecke? |
207 | virtual ~ODevice(); | 229 | virtual ~ODevice(); |
208 | 230 | ||
209 | static ODevice *inst(); | 231 | static ODevice *inst(); |
210 | 232 | ||
211 | // information | 233 | // information |
212 | 234 | ||
213 | QString modelString() const; | 235 | QString modelString() const; |
214 | OModel model() const; | 236 | OModel model() const; |
215 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | 237 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } |
216 | 238 | ||
217 | QString vendorString() const; | 239 | QString vendorString() const; |
218 | OVendor vendor() const; | 240 | OVendor vendor() const; |
219 | 241 | ||
220 | QString systemString() const; | 242 | QString systemString() const; |
221 | OSystem system() const; | 243 | OSystem system() const; |
222 | 244 | ||
223 | QString systemVersionString() const; | 245 | QString systemVersionString() const; |
224 | 246 | ||
225 | virtual Transformation rotation() const; | 247 | virtual Transformation rotation() const; |
226 | virtual ODirection direction() const; | 248 | virtual ODirection direction() const; |
227 | 249 | ||
228 | // system | 250 | // system |
229 | 251 | ||
230 | virtual bool setSoftSuspend ( bool on ); | 252 | virtual bool setSoftSuspend ( bool on ); |
231 | virtual bool suspend(); | 253 | virtual bool suspend(); |
232 | 254 | ||
233 | virtual bool setDisplayStatus ( bool on ); | 255 | virtual bool setDisplayStatus ( bool on ); |
234 | virtual bool setDisplayBrightness ( int brightness ); | 256 | virtual bool setDisplayBrightness ( int brightness ); |
235 | virtual int displayBrightnessResolution() const; | 257 | virtual int displayBrightnessResolution() const; |
236 | virtual bool setDisplayContrast ( int contrast ); | 258 | virtual bool setDisplayContrast ( int contrast ); |
237 | virtual int displayContrastResolution() const; | 259 | virtual int displayContrastResolution() const; |
238 | 260 | ||
239 | // don't add new virtual methods, use this: | 261 | // don't add new virtual methods, use this: |
240 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | 262 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; |
241 | // and in your subclass do do overwrite | 263 | // and in your subclass do do overwrite |
242 | //protected virtual int virtual_hook(int, void *) | 264 | //protected virtual int virtual_hook(int, void *) |
243 | // which is defined below | 265 | // which is defined below |
244 | 266 | ||
245 | // input / output | 267 | // input / output |
246 | virtual void playAlarmSound(); | 268 | virtual void playAlarmSound(); |
247 | virtual void playKeySound(); | 269 | virtual void playKeySound(); |
248 | virtual void playTouchSound(); | 270 | virtual void playTouchSound(); |
249 | 271 | ||
250 | virtual QValueList <OLed> ledList() const; | 272 | virtual QValueList <OLed> ledList() const; |
251 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 273 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
252 | virtual OLedState ledState ( OLed led ) const; | 274 | virtual OLedState ledState ( OLed led ) const; |
253 | virtual bool setLedState ( OLed led, OLedState st ); | 275 | virtual bool setLedState ( OLed led, OLedState st ); |
254 | 276 | ||
255 | virtual bool hasLightSensor() const; | 277 | virtual bool hasLightSensor() const; |
256 | virtual int readLightSensor(); | 278 | virtual int readLightSensor(); |
257 | virtual int lightSensorResolution() const; | 279 | virtual int lightSensorResolution() const; |
258 | 280 | ||
259 | virtual bool hasHingeSensor() const; | 281 | virtual bool hasHingeSensor() const; |
260 | virtual OHingeStatus readHingeSensor(); | 282 | virtual OHingeStatus readHingeSensor(); |
261 | 283 | ||
262 | const QStrList &allowedCpuFrequencies() const; | 284 | const QStrList &allowedCpuFrequencies() const; |
263 | bool setCurrentCpuFrequency(uint index); | 285 | bool setCurrentCpuFrequency(uint index); |
264 | 286 | ||
265 | /** | 287 | /** |
266 | * Returns the available buttons on this device. The number and location | 288 | * Returns the available buttons on this device. The number and location |
267 | * of buttons will vary depending on the device. Button numbers will be assigned | 289 | * of buttons will vary depending on the device. Button numbers will be assigned |
268 | * by the device manufacturer and will be from most preferred button to least preffered | 290 | * by the device manufacturer and will be from most preferred button to least preffered |
269 | * button. Note that this list only contains "user mappable" buttons. | 291 | * button. Note that this list only contains "user mappable" buttons. |
270 | * | 292 | * |
271 | * @todo Make method const and take care of calling initButtons or make that const too | 293 | * @todo Make method const and take care of calling initButtons or make that const too |
272 | * | 294 | * |
273 | */ | 295 | */ |
274 | const QValueList<ODeviceButton> &buttons(); | 296 | const QValueList<ODeviceButton> &buttons(); |
275 | 297 | ||
276 | /** | 298 | /** |
277 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 299 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
278 | * returns 0L | 300 | * returns 0L |
279 | */ | 301 | */ |
280 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 302 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
281 | 303 | ||
282 | /** | 304 | /** |
283 | * Reassigns the pressed action for \a button. To return to the factory | 305 | * Reassigns the pressed action for \a button. To return to the factory |
284 | * default pass an empty string as \a qcopMessage. | 306 | * default pass an empty string as \a qcopMessage. |
285 | */ | 307 | */ |
286 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 308 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
287 | 309 | ||
288 | /** | 310 | /** |
289 | * Reassigns the held action for \a button. To return to the factory | 311 | * Reassigns the held action for \a button. To return to the factory |
290 | * default pass an empty string as \a qcopMessage. | 312 | * default pass an empty string as \a qcopMessage. |
291 | */ | 313 | */ |
292 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 314 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
293 | 315 | ||
294 | /** | 316 | /** |
295 | * How long (in ms) you have to press a button for a "hold" action | 317 | * How long (in ms) you have to press a button for a "hold" action |
296 | */ | 318 | */ |
297 | uint buttonHoldTime() const; | 319 | uint buttonHoldTime() const; |
298 | 320 | ||
299 | signals: | 321 | signals: |
300 | void buttonMappingChanged(); | 322 | void buttonMappingChanged(); |
301 | 323 | ||
302 | private slots: | 324 | private slots: |
303 | void systemMessage ( const QCString &, const QByteArray & ); | 325 | void systemMessage ( const QCString &, const QByteArray & ); |
304 | 326 | ||
305 | protected: | 327 | protected: |
306 | void reloadButtonMapping(); | 328 | void reloadButtonMapping(); |
307 | /* ugly virtual hook */ | 329 | /* ugly virtual hook */ |
308 | virtual void virtual_hook( int id, void* data ); | 330 | virtual void virtual_hook( int id, void* data ); |
309 | }; | 331 | }; |
310 | 332 | ||
311 | class ODeviceData { | 333 | class ODeviceData { |
312 | 334 | ||
313 | public: | 335 | public: |
314 | QString m_vendorstr; | 336 | QString m_vendorstr; |
315 | OVendor m_vendor; | 337 | OVendor m_vendor; |
316 | 338 | ||
317 | QString m_modelstr; | 339 | QString m_modelstr; |
318 | OModel m_model; | 340 | OModel m_model; |
319 | 341 | ||
320 | QString m_systemstr; | 342 | QString m_systemstr; |
321 | OSystem m_system; | 343 | OSystem m_system; |
322 | 344 | ||
323 | QString m_sysverstr; | 345 | QString m_sysverstr; |
324 | 346 | ||
325 | Transformation m_rotation; | 347 | Transformation m_rotation; |
326 | ODirection m_direction; | 348 | ODirection m_direction; |
327 | 349 | ||
328 | QValueList <ODeviceButton> *m_buttons; | 350 | QValueList <ODeviceButton> *m_buttons; |
329 | uint m_holdtime; | 351 | uint m_holdtime; |
330 | QStrList *m_cpu_frequencies; | 352 | QStrList *m_cpu_frequencies; |
331 | }; | 353 | }; |
332 | 354 | ||
333 | } | 355 | } |
334 | } | 356 | } |
335 | 357 | ||
336 | static inline bool isQWS() | 358 | static inline bool isQWS() |
337 | { | 359 | { |
338 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 360 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
339 | } | 361 | } |
340 | 362 | ||
341 | static QCString makeChannel ( const char *str ) | 363 | static QCString makeChannel ( const char *str ) |
342 | { | 364 | { |
343 | if ( str && !::strchr ( str, '/' )) | 365 | if ( str && !::strchr ( str, '/' )) |
344 | return QCString ( "QPE/Application/" ) + str; | 366 | return QCString ( "QPE/Application/" ) + str; |
345 | else | 367 | else |
346 | return str; | 368 | return str; |
347 | } | 369 | } |
348 | 370 | ||
349 | 371 | ||
350 | #endif | 372 | #endif |
351 | 373 | ||
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index efe35e7..16c0538 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -1,483 +1,458 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_ipaq.h" | 30 | #include "odevice_ipaq.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.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 | 56 | ||
57 | using namespace Opie::Core; | 57 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 58 | using namespace Opie::Core::Internal; |
59 | 59 | ||
60 | /* KERNEL */ | 60 | /* KERNEL */ |
61 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 61 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
62 | 62 | ||
63 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 63 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
64 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 64 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
65 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 65 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
66 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 66 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
67 | 67 | ||
68 | typedef struct { | 68 | typedef struct { |
69 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 69 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
70 | unsigned char TotalTime; /* Units of 5 seconds */ | 70 | unsigned char TotalTime; /* Units of 5 seconds */ |
71 | unsigned char OnTime; /* units of 100m/s */ | 71 | unsigned char OnTime; /* units of 100m/s */ |
72 | unsigned char OffTime; /* units of 100m/s */ | 72 | unsigned char OffTime; /* units of 100m/s */ |
73 | } LED_IN; | 73 | } LED_IN; |
74 | 74 | ||
75 | typedef struct { | 75 | typedef struct { |
76 | unsigned char mode; | 76 | unsigned char mode; |
77 | unsigned char pwr; | 77 | unsigned char pwr; |
78 | unsigned char brightness; | 78 | unsigned char brightness; |
79 | } FLITE_IN; | 79 | } FLITE_IN; |
80 | 80 | ||
81 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 81 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
82 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 82 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
83 | 83 | ||
84 | struct i_button ipaq_buttons [] = { | 84 | struct i_button ipaq_buttons [] = { |
85 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 85 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
86 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 86 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
87 | "devicebuttons/ipaq_calendar", | 87 | "devicebuttons/ipaq_calendar", |
88 | "datebook", "nextView()", | 88 | "datebook", "nextView()", |
89 | "today", "raise()" }, | 89 | "today", "raise()" }, |
90 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 90 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
91 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 91 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
92 | "devicebuttons/ipaq_contact", | 92 | "devicebuttons/ipaq_contact", |
93 | "addressbook", "raise()", | 93 | "addressbook", "raise()", |
94 | "addressbook", "beamBusinessCard()" }, | 94 | "addressbook", "beamBusinessCard()" }, |
95 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 95 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
96 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 96 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
97 | "devicebuttons/ipaq_menu", | 97 | "devicebuttons/ipaq_menu", |
98 | "QPE/TaskBar", "toggleMenu()", | 98 | "QPE/TaskBar", "toggleMenu()", |
99 | "QPE/TaskBar", "toggleStartMenu()" }, | 99 | "QPE/TaskBar", "toggleStartMenu()" }, |
100 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 100 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
101 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 101 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
102 | "devicebuttons/ipaq_mail", | 102 | "devicebuttons/ipaq_mail", |
103 | "opiemail", "raise()", | 103 | "opiemail", "raise()", |
104 | "opiemail", "newMail()" }, | 104 | "opiemail", "newMail()" }, |
105 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 105 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
106 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 106 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
107 | "devicebuttons/ipaq_home", | 107 | "devicebuttons/ipaq_home", |
108 | "QPE/Launcher", "home()", | 108 | "QPE/Launcher", "home()", |
109 | "buttonsettings", "raise()" }, | 109 | "buttonsettings", "raise()" }, |
110 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 110 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
111 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 111 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
112 | "devicebuttons/ipaq_record", | 112 | "devicebuttons/ipaq_record", |
113 | "QPE/VMemo", "toggleRecord()", | 113 | "QPE/VMemo", "toggleRecord()", |
114 | "sound", "raise()" }, | 114 | "sound", "raise()" }, |
115 | }; | 115 | }; |
116 | 116 | ||
117 | void iPAQ::init(const QString& model) | 117 | void iPAQ::init(const QString& model) |
118 | { | 118 | { |
119 | d->m_vendorstr = "HP"; | 119 | d->m_vendorstr = "HP"; |
120 | d->m_vendor = Vendor_HP; | 120 | d->m_vendor = Vendor_HP; |
121 | 121 | ||
122 | d->m_modelstr = model.mid(model.findRev('H')); | 122 | d->m_modelstr = model.mid(model.findRev('H')); |
123 | 123 | ||
124 | if ( d->m_modelstr == "H3100" ) | 124 | if ( d->m_modelstr == "H3100" ) |
125 | d->m_model = Model_iPAQ_H31xx; | 125 | d->m_model = Model_iPAQ_H31xx; |
126 | else if ( d->m_modelstr == "H3600" ) | 126 | else if ( d->m_modelstr == "H3600" ) |
127 | d->m_model = Model_iPAQ_H36xx; | 127 | d->m_model = Model_iPAQ_H36xx; |
128 | else if ( d->m_modelstr == "H3700" ) | 128 | else if ( d->m_modelstr == "H3700" ) |
129 | d->m_model = Model_iPAQ_H37xx; | 129 | d->m_model = Model_iPAQ_H37xx; |
130 | else if ( d->m_modelstr == "H3800" ) | 130 | else if ( d->m_modelstr == "H3800" ) |
131 | d->m_model = Model_iPAQ_H38xx; | 131 | d->m_model = Model_iPAQ_H38xx; |
132 | else if ( d->m_modelstr == "H3900" ) | 132 | else if ( d->m_modelstr == "H3900" ) |
133 | d->m_model = Model_iPAQ_H39xx; | 133 | d->m_model = Model_iPAQ_H39xx; |
134 | else if ( d->m_modelstr == "H5400" ) | 134 | else if ( d->m_modelstr == "H5400" ) |
135 | d->m_model = Model_iPAQ_H5xxx; | 135 | d->m_model = Model_iPAQ_H5xxx; |
136 | else if ( d->m_modelstr == "H2200" ) | 136 | else if ( d->m_modelstr == "H2200" ) |
137 | d->m_model = Model_iPAQ_H22xx; | 137 | d->m_model = Model_iPAQ_H22xx; |
138 | else | 138 | else |
139 | d->m_model = Model_Unknown; | 139 | d->m_model = Model_Unknown; |
140 | 140 | ||
141 | |||
142 | |||
143 | switch ( d->m_model ) { | 141 | switch ( d->m_model ) { |
144 | case Model_iPAQ_H31xx: | 142 | case Model_iPAQ_H31xx: |
145 | case Model_iPAQ_H38xx: | 143 | case Model_iPAQ_H38xx: |
146 | d->m_rotation = Rot90; | 144 | d->m_rotation = Rot90; |
147 | break; | 145 | break; |
148 | case Model_iPAQ_H5xxx: | 146 | case Model_iPAQ_H5xxx: |
149 | case Model_iPAQ_H22xx: | 147 | case Model_iPAQ_H22xx: |
150 | d->m_rotation = Rot0; | 148 | d->m_rotation = Rot0; |
151 | break; | 149 | break; |
152 | case Model_iPAQ_H36xx: | 150 | case Model_iPAQ_H36xx: |
153 | case Model_iPAQ_H37xx: | 151 | case Model_iPAQ_H37xx: |
154 | case Model_iPAQ_H39xx: | 152 | case Model_iPAQ_H39xx: |
155 | default: | 153 | default: |
156 | d->m_rotation = Rot270; | 154 | d->m_rotation = Rot270; |
157 | break; | 155 | break; |
158 | 156 | ||
159 | } | 157 | } |
160 | 158 | ||
161 | QFile f( "/etc/familiar-version" ); | ||
162 | if ( f. open ( IO_ReadOnly )) { | ||
163 | d->m_systemstr = "Familiar"; | ||
164 | d->m_system = System_Familiar; | ||
165 | |||
166 | QTextStream ts ( &f ); | ||
167 | d->m_sysverstr = ts. readLine(). mid ( 10 ); | ||
168 | |||
169 | f. close(); | ||
170 | } else { | ||
171 | f. setName ( "/etc/oz_version" ); | ||
172 | |||
173 | if ( f. open ( IO_ReadOnly )) { | ||
174 | d->m_systemstr = "OpenEmbedded/iPaq"; | ||
175 | d->m_system = System_Familiar; | ||
176 | |||
177 | QTextStream ts ( &f ); | ||
178 | ts.setDevice ( &f ); | ||
179 | d->m_sysverstr = ts. readLine(); | ||
180 | f. close(); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | m_leds [0] = m_leds [1] = Led_Off; | 159 | m_leds [0] = m_leds [1] = Led_Off; |
185 | 160 | ||
186 | m_power_timer = 0; | 161 | m_power_timer = 0; |
187 | 162 | ||
188 | } | 163 | } |
189 | 164 | ||
190 | void iPAQ::initButtons() | 165 | void iPAQ::initButtons() |
191 | { | 166 | { |
192 | if ( d->m_buttons ) | 167 | if ( d->m_buttons ) |
193 | return; | 168 | return; |
194 | 169 | ||
195 | if ( isQWS( ) ) | 170 | if ( isQWS( ) ) |
196 | QWSServer::setKeyboardFilter ( this ); | 171 | QWSServer::setKeyboardFilter ( this ); |
197 | 172 | ||
198 | d->m_buttons = new QValueList <ODeviceButton>; | 173 | d->m_buttons = new QValueList <ODeviceButton>; |
199 | 174 | ||
200 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 175 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
201 | i_button *ib = ipaq_buttons + i; | 176 | i_button *ib = ipaq_buttons + i; |
202 | ODeviceButton b; | 177 | ODeviceButton b; |
203 | 178 | ||
204 | if (( ib->model & d->m_model ) == d->m_model ) { | 179 | if (( ib->model & d->m_model ) == d->m_model ) { |
205 | b. setKeycode ( ib->code ); | 180 | b. setKeycode ( ib->code ); |
206 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 181 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
207 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 182 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); |
208 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 183 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
209 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 184 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
210 | 185 | ||
211 | d->m_buttons->append ( b ); | 186 | d->m_buttons->append ( b ); |
212 | } | 187 | } |
213 | } | 188 | } |
214 | reloadButtonMapping(); | 189 | reloadButtonMapping(); |
215 | 190 | ||
216 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 191 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
217 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 192 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
218 | } | 193 | } |
219 | 194 | ||
220 | QValueList <OLed> iPAQ::ledList() const | 195 | QValueList <OLed> iPAQ::ledList() const |
221 | { | 196 | { |
222 | QValueList <OLed> vl; | 197 | QValueList <OLed> vl; |
223 | vl << Led_Power; | 198 | vl << Led_Power; |
224 | 199 | ||
225 | if ( d->m_model == Model_iPAQ_H38xx ) | 200 | if ( d->m_model == Model_iPAQ_H38xx ) |
226 | vl << Led_BlueTooth; | 201 | vl << Led_BlueTooth; |
227 | return vl; | 202 | return vl; |
228 | } | 203 | } |
229 | 204 | ||
230 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 205 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
231 | { | 206 | { |
232 | QValueList <OLedState> vl; | 207 | QValueList <OLedState> vl; |
233 | 208 | ||
234 | if ( l == Led_Power ) | 209 | if ( l == Led_Power ) |
235 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 210 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
236 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) | 211 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) |
237 | vl << Led_Off; // << Led_On << ??? | 212 | vl << Led_Off; // << Led_On << ??? |
238 | 213 | ||
239 | return vl; | 214 | return vl; |
240 | } | 215 | } |
241 | 216 | ||
242 | OLedState iPAQ::ledState ( OLed l ) const | 217 | OLedState iPAQ::ledState ( OLed l ) const |
243 | { | 218 | { |
244 | switch ( l ) { | 219 | switch ( l ) { |
245 | case Led_Power: | 220 | case Led_Power: |
246 | return m_leds [0]; | 221 | return m_leds [0]; |
247 | case Led_BlueTooth: | 222 | case Led_BlueTooth: |
248 | return m_leds [1]; | 223 | return m_leds [1]; |
249 | default: | 224 | default: |
250 | return Led_Off; | 225 | return Led_Off; |
251 | } | 226 | } |
252 | } | 227 | } |
253 | 228 | ||
254 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 229 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
255 | { | 230 | { |
256 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 231 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
257 | 232 | ||
258 | if ( l == Led_Power ) { | 233 | if ( l == Led_Power ) { |
259 | if ( fd >= 0 ) { | 234 | if ( fd >= 0 ) { |
260 | LED_IN leds; | 235 | LED_IN leds; |
261 | ::memset ( &leds, 0, sizeof( leds )); | 236 | ::memset ( &leds, 0, sizeof( leds )); |
262 | leds. TotalTime = 0; | 237 | leds. TotalTime = 0; |
263 | leds. OnTime = 0; | 238 | leds. OnTime = 0; |
264 | leds. OffTime = 1; | 239 | leds. OffTime = 1; |
265 | leds. OffOnBlink = 2; | 240 | leds. OffOnBlink = 2; |
266 | 241 | ||
267 | switch ( st ) { | 242 | switch ( st ) { |
268 | case Led_Off : leds. OffOnBlink = 0; break; | 243 | case Led_Off : leds. OffOnBlink = 0; break; |
269 | case Led_On : leds. OffOnBlink = 1; break; | 244 | case Led_On : leds. OffOnBlink = 1; break; |
270 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 245 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
271 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 246 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
272 | } | 247 | } |
273 | 248 | ||
274 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 249 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
275 | m_leds [0] = st; | 250 | m_leds [0] = st; |
276 | return true; | 251 | return true; |
277 | } | 252 | } |
278 | } | 253 | } |
279 | } | 254 | } |
280 | return false; | 255 | return false; |
281 | } | 256 | } |
282 | 257 | ||
283 | 258 | ||
284 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 259 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
285 | { | 260 | { |
286 | int newkeycode = keycode; | 261 | int newkeycode = keycode; |
287 | 262 | ||
288 | switch ( keycode ) { | 263 | switch ( keycode ) { |
289 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 264 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
290 | case HardKey_Menu: { | 265 | case HardKey_Menu: { |
291 | if (( d->m_model == Model_iPAQ_H38xx ) || | 266 | if (( d->m_model == Model_iPAQ_H38xx ) || |
292 | ( d->m_model == Model_iPAQ_H39xx ) || | 267 | ( d->m_model == Model_iPAQ_H39xx ) || |
293 | ( d->m_model == Model_iPAQ_H5xxx)) { | 268 | ( d->m_model == Model_iPAQ_H5xxx)) { |
294 | newkeycode = HardKey_Mail; | 269 | newkeycode = HardKey_Mail; |
295 | } | 270 | } |
296 | break; | 271 | break; |
297 | } | 272 | } |
298 | 273 | ||
299 | // Rotate cursor keys 180° or 270° | 274 | // Rotate cursor keys 180° or 270° |
300 | case Key_Left : | 275 | case Key_Left : |
301 | case Key_Right: | 276 | case Key_Right: |
302 | case Key_Up : | 277 | case Key_Up : |
303 | case Key_Down : { | 278 | case Key_Down : { |
304 | if (( d->m_model == Model_iPAQ_H31xx ) || | 279 | if (( d->m_model == Model_iPAQ_H31xx ) || |
305 | ( d->m_model == Model_iPAQ_H38xx )) { | 280 | ( d->m_model == Model_iPAQ_H38xx )) { |
306 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 281 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
307 | } | 282 | } |
308 | // Rotate the cursor keys by 270° | 283 | // Rotate the cursor keys by 270° |
309 | // keycode - Key_Left = position of the button starting from left clockwise | 284 | // keycode - Key_Left = position of the button starting from left clockwise |
310 | // add the rotation to it and modolo. No we've the original offset | 285 | // add the rotation to it and modolo. No we've the original offset |
311 | // add the offset to the Key_Left key | 286 | // add the offset to the Key_Left key |
312 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 287 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
313 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 288 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
314 | break; | 289 | break; |
315 | } | 290 | } |
316 | 291 | ||
317 | // map Power Button short/long press to F34/F35 | 292 | // map Power Button short/long press to F34/F35 |
318 | case Key_SysReq: { | 293 | case Key_SysReq: { |
319 | if ( isPress ) { | 294 | if ( isPress ) { |
320 | if ( m_power_timer ) | 295 | if ( m_power_timer ) |
321 | killTimer ( m_power_timer ); | 296 | killTimer ( m_power_timer ); |
322 | m_power_timer = startTimer ( 500 ); | 297 | m_power_timer = startTimer ( 500 ); |
323 | } | 298 | } |
324 | else if ( m_power_timer ) { | 299 | else if ( m_power_timer ) { |
325 | killTimer ( m_power_timer ); | 300 | killTimer ( m_power_timer ); |
326 | m_power_timer = 0; | 301 | m_power_timer = 0; |
327 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 302 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
328 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 303 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
329 | } | 304 | } |
330 | newkeycode = Key_unknown; | 305 | newkeycode = Key_unknown; |
331 | break; | 306 | break; |
332 | } | 307 | } |
333 | } | 308 | } |
334 | 309 | ||
335 | if ( newkeycode != keycode ) { | 310 | if ( newkeycode != keycode ) { |
336 | if ( newkeycode != Key_unknown ) | 311 | if ( newkeycode != Key_unknown ) |
337 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 312 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
338 | return true; | 313 | return true; |
339 | } | 314 | } |
340 | else | 315 | else |
341 | return false; | 316 | return false; |
342 | } | 317 | } |
343 | 318 | ||
344 | void iPAQ::timerEvent ( QTimerEvent * ) | 319 | void iPAQ::timerEvent ( QTimerEvent * ) |
345 | { | 320 | { |
346 | killTimer ( m_power_timer ); | 321 | killTimer ( m_power_timer ); |
347 | m_power_timer = 0; | 322 | m_power_timer = 0; |
348 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 323 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
349 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 324 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
350 | } | 325 | } |
351 | 326 | ||
352 | 327 | ||
353 | void iPAQ::playAlarmSound() | 328 | void iPAQ::playAlarmSound() |
354 | { | 329 | { |
355 | #ifndef QT_NO_SOUND | 330 | #ifndef QT_NO_SOUND |
356 | static Sound snd ( "alarm" ); | 331 | static Sound snd ( "alarm" ); |
357 | int fd; | 332 | int fd; |
358 | int vol; | 333 | int vol; |
359 | bool vol_reset = false; | 334 | bool vol_reset = false; |
360 | 335 | ||
361 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 336 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
362 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 337 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
363 | Config cfg ( "qpe" ); | 338 | Config cfg ( "qpe" ); |
364 | cfg. setGroup ( "Volume" ); | 339 | cfg. setGroup ( "Volume" ); |
365 | 340 | ||
366 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 341 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
367 | if ( volalarm < 0 ) | 342 | if ( volalarm < 0 ) |
368 | volalarm = 0; | 343 | volalarm = 0; |
369 | else if ( volalarm > 100 ) | 344 | else if ( volalarm > 100 ) |
370 | volalarm = 100; | 345 | volalarm = 100; |
371 | volalarm |= ( volalarm << 8 ); | 346 | volalarm |= ( volalarm << 8 ); |
372 | 347 | ||
373 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 348 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
374 | vol_reset = true; | 349 | vol_reset = true; |
375 | } | 350 | } |
376 | } | 351 | } |
377 | 352 | ||
378 | snd. play(); | 353 | snd. play(); |
379 | while ( !snd. isFinished()) | 354 | while ( !snd. isFinished()) |
380 | qApp->processEvents(); | 355 | qApp->processEvents(); |
381 | 356 | ||
382 | if ( fd >= 0 ) { | 357 | if ( fd >= 0 ) { |
383 | if ( vol_reset ) | 358 | if ( vol_reset ) |
384 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 359 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
385 | ::close ( fd ); | 360 | ::close ( fd ); |
386 | } | 361 | } |
387 | #endif | 362 | #endif |
388 | } | 363 | } |
389 | 364 | ||
390 | 365 | ||
391 | bool iPAQ::setSoftSuspend ( bool soft ) | 366 | bool iPAQ::setSoftSuspend ( bool soft ) |
392 | { | 367 | { |
393 | bool res = false; | 368 | bool res = false; |
394 | int fd; | 369 | int fd; |
395 | 370 | ||
396 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 371 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
397 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 372 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
398 | res = true; | 373 | res = true; |
399 | else | 374 | else |
400 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 375 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
401 | 376 | ||
402 | ::close ( fd ); | 377 | ::close ( fd ); |
403 | } | 378 | } |
404 | else | 379 | else |
405 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 380 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
406 | 381 | ||
407 | return res; | 382 | return res; |
408 | } | 383 | } |
409 | 384 | ||
410 | 385 | ||
411 | bool iPAQ::setDisplayBrightness ( int bright ) | 386 | bool iPAQ::setDisplayBrightness ( int bright ) |
412 | { | 387 | { |
413 | bool res = false; | 388 | bool res = false; |
414 | int fd; | 389 | int fd; |
415 | 390 | ||
416 | if ( bright > 255 ) | 391 | if ( bright > 255 ) |
417 | bright = 255; | 392 | bright = 255; |
418 | if ( bright < 0 ) | 393 | if ( bright < 0 ) |
419 | bright = 0; | 394 | bright = 0; |
420 | 395 | ||
421 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 396 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
422 | FLITE_IN bl; | 397 | FLITE_IN bl; |
423 | bl. mode = 1; | 398 | bl. mode = 1; |
424 | bl. pwr = bright ? 1 : 0; | 399 | bl. pwr = bright ? 1 : 0; |
425 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 400 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
426 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 401 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
427 | ::close ( fd ); | 402 | ::close ( fd ); |
428 | } | 403 | } |
429 | return res; | 404 | return res; |
430 | } | 405 | } |
431 | 406 | ||
432 | int iPAQ::displayBrightnessResolution() const | 407 | int iPAQ::displayBrightnessResolution() const |
433 | { | 408 | { |
434 | switch ( model()) { | 409 | switch ( model()) { |
435 | case Model_iPAQ_H31xx: | 410 | case Model_iPAQ_H31xx: |
436 | case Model_iPAQ_H36xx: | 411 | case Model_iPAQ_H36xx: |
437 | case Model_iPAQ_H37xx: | 412 | case Model_iPAQ_H37xx: |
438 | return 128; // really 256, but >128 could damage the LCD | 413 | return 128; // really 256, but >128 could damage the LCD |
439 | 414 | ||
440 | case Model_iPAQ_H38xx: | 415 | case Model_iPAQ_H38xx: |
441 | case Model_iPAQ_H39xx: | 416 | case Model_iPAQ_H39xx: |
442 | return 64; | 417 | return 64; |
443 | case Model_iPAQ_H5xxx: | 418 | case Model_iPAQ_H5xxx: |
444 | return 255; | 419 | return 255; |
445 | 420 | ||
446 | default: | 421 | default: |
447 | return 2; | 422 | return 2; |
448 | } | 423 | } |
449 | } | 424 | } |
450 | 425 | ||
451 | 426 | ||
452 | bool iPAQ::hasLightSensor() const | 427 | bool iPAQ::hasLightSensor() const |
453 | { | 428 | { |
454 | return true; | 429 | return true; |
455 | } | 430 | } |
456 | 431 | ||
457 | int iPAQ::readLightSensor() | 432 | int iPAQ::readLightSensor() |
458 | { | 433 | { |
459 | int fd; | 434 | int fd; |
460 | int val = -1; | 435 | int val = -1; |
461 | 436 | ||
462 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 437 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
463 | char buffer [8]; | 438 | char buffer [8]; |
464 | 439 | ||
465 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 440 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
466 | char *endptr; | 441 | char *endptr; |
467 | 442 | ||
468 | buffer [4] = 0; | 443 | buffer [4] = 0; |
469 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 444 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
470 | 445 | ||
471 | if ( *endptr != 0 ) | 446 | if ( *endptr != 0 ) |
472 | val = -1; | 447 | val = -1; |
473 | } | 448 | } |
474 | ::close ( fd ); | 449 | ::close ( fd ); |
475 | } | 450 | } |
476 | 451 | ||
477 | return val; | 452 | return val; |
478 | } | 453 | } |
479 | 454 | ||
480 | int iPAQ::lightSensorResolution() const | 455 | int iPAQ::lightSensorResolution() const |
481 | { | 456 | { |
482 | return 256; | 457 | return 256; |
483 | } | 458 | } |
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index 1f69326..5d32901 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,219 +1,208 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_jornada.h" | 30 | #include "odevice_jornada.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.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 | /* KERNEL */ | 56 | /* KERNEL */ |
57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
58 | 58 | ||
59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 59 | #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)) | 60 | #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)) | 61 | #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)) | 62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
63 | 63 | ||
64 | typedef struct { | 64 | typedef struct { |
65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
66 | unsigned char TotalTime; /* Units of 5 seconds */ | 66 | unsigned char TotalTime; /* Units of 5 seconds */ |
67 | unsigned char OnTime; /* units of 100m/s */ | 67 | unsigned char OnTime; /* units of 100m/s */ |
68 | unsigned char OffTime; /* units of 100m/s */ | 68 | unsigned char OffTime; /* units of 100m/s */ |
69 | } LED_IN; | 69 | } LED_IN; |
70 | 70 | ||
71 | typedef struct { | 71 | typedef struct { |
72 | unsigned char mode; | 72 | unsigned char mode; |
73 | unsigned char pwr; | 73 | unsigned char pwr; |
74 | unsigned char brightness; | 74 | unsigned char brightness; |
75 | } FLITE_IN; | 75 | } FLITE_IN; |
76 | 76 | ||
77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
79 | 79 | ||
80 | using namespace Opie::Core; | 80 | using namespace Opie::Core; |
81 | using namespace Opie::Core::Internal; | 81 | using namespace Opie::Core::Internal; |
82 | 82 | ||
83 | struct j_button jornada56x_buttons [] = { | 83 | struct j_button jornada56x_buttons [] = { |
84 | { Model_Jornada_56x, | 84 | { Model_Jornada_56x, |
85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
86 | "devicebuttons/jornada56x_calendar", | 86 | "devicebuttons/jornada56x_calendar", |
87 | "datebook", "nextView()", | 87 | "datebook", "nextView()", |
88 | "today", "raise()" }, | 88 | "today", "raise()" }, |
89 | { Model_Jornada_56x, | 89 | { Model_Jornada_56x, |
90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
91 | "devicebuttons/jornada56x_contact", | 91 | "devicebuttons/jornada56x_contact", |
92 | "addressbook", "raise()", | 92 | "addressbook", "raise()", |
93 | "addressbook", "beamBusinessCard()" }, | 93 | "addressbook", "beamBusinessCard()" }, |
94 | { Model_Jornada_56x, | 94 | { Model_Jornada_56x, |
95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | 95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), |
96 | "devicebuttons/jornada56x_todo", | 96 | "devicebuttons/jornada56x_todo", |
97 | "todolist", "raise()", | 97 | "todolist", "raise()", |
98 | "todolist", "create()" }, | 98 | "todolist", "create()" }, |
99 | { Model_Jornada_56x, | 99 | { Model_Jornada_56x, |
100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), | 100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), |
101 | "devicebuttons/jornada56x_home", | 101 | "devicebuttons/jornada56x_home", |
102 | "QPE/Launcher", "home()", | 102 | "QPE/Launcher", "home()", |
103 | "buttonsettings", "raise()" }, | 103 | "buttonsettings", "raise()" }, |
104 | { Model_Jornada_56x, | 104 | { Model_Jornada_56x, |
105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), | 105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), |
106 | "devicebuttons/jornada56x_record", | 106 | "devicebuttons/jornada56x_record", |
107 | "QPE/VMemo", "toggleRecord()", | 107 | "QPE/VMemo", "toggleRecord()", |
108 | "sound", "raise()" }, | 108 | "sound", "raise()" }, |
109 | }; | 109 | }; |
110 | 110 | ||
111 | void Jornada::init(const QString&) | 111 | void Jornada::init(const QString&) |
112 | { | 112 | { |
113 | d->m_vendorstr = "HP"; | 113 | d->m_vendorstr = "HP"; |
114 | d->m_vendor = Vendor_HP; | 114 | d->m_vendor = Vendor_HP; |
115 | d->m_modelstr = "Jornada 56x"; | 115 | d->m_modelstr = "Jornada 56x"; |
116 | d->m_model = Model_Jornada_56x; | 116 | d->m_model = Model_Jornada_56x; |
117 | d->m_systemstr = "Familiar"; | ||
118 | d->m_system = System_Familiar; | ||
119 | d->m_rotation = Rot0; | 117 | d->m_rotation = Rot0; |
120 | 118 | //Distribution detecting code is now in base class | |
121 | QFile f ( "/etc/familiar-version" ); | ||
122 | f.setName ( "/etc/familiar-version" ); | ||
123 | if ( f.open ( IO_ReadOnly )) { | ||
124 | |||
125 | QTextStream ts ( &f ); | ||
126 | d->m_sysverstr = ts.readLine().mid( 10 ); | ||
127 | |||
128 | f. close(); | ||
129 | } | ||
130 | } | 119 | } |
131 | 120 | ||
132 | void Jornada::initButtons() | 121 | void Jornada::initButtons() |
133 | { | 122 | { |
134 | if ( d->m_buttons ) | 123 | if ( d->m_buttons ) |
135 | return; | 124 | return; |
136 | 125 | ||
137 | d->m_buttons = new QValueList <ODeviceButton>; | 126 | d->m_buttons = new QValueList <ODeviceButton>; |
138 | 127 | ||
139 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { | 128 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { |
140 | j_button *ib = jornada56x_buttons + i; | 129 | j_button *ib = jornada56x_buttons + i; |
141 | ODeviceButton b; | 130 | ODeviceButton b; |
142 | 131 | ||
143 | if (( ib->model & d->m_model ) == d->m_model ) { | 132 | if (( ib->model & d->m_model ) == d->m_model ) { |
144 | b. setKeycode ( ib->code ); | 133 | b. setKeycode ( ib->code ); |
145 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 134 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
146 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 135 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); |
147 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 136 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
148 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 137 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
149 | 138 | ||
150 | d->m_buttons->append ( b ); | 139 | d->m_buttons->append ( b ); |
151 | } | 140 | } |
152 | } | 141 | } |
153 | reloadButtonMapping(); | 142 | reloadButtonMapping(); |
154 | 143 | ||
155 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 144 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
156 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 145 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
157 | } | 146 | } |
158 | 147 | ||
159 | int Jornada::displayBrightnessResolution() const | 148 | int Jornada::displayBrightnessResolution() const |
160 | { | 149 | { |
161 | return 255; | 150 | return 255; |
162 | } | 151 | } |
163 | 152 | ||
164 | 153 | ||
165 | bool Jornada::setDisplayBrightness( int bright ) | 154 | bool Jornada::setDisplayBrightness( int bright ) |
166 | { | 155 | { |
167 | bool res = false; | 156 | bool res = false; |
168 | 157 | ||
169 | if ( bright > 255 ) | 158 | if ( bright > 255 ) |
170 | bright = 255; | 159 | bright = 255; |
171 | if ( bright < 0 ) | 160 | if ( bright < 0 ) |
172 | bright = 0; | 161 | bright = 0; |
173 | 162 | ||
174 | QString cmdline; | 163 | QString cmdline; |
175 | 164 | ||
176 | int value = 255 - bright; | 165 | int value = 255 - bright; |
177 | if ( !bright ) | 166 | if ( !bright ) |
178 | cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); | 167 | cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); |
179 | else | 168 | else |
180 | cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value ); | 169 | cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value ); |
181 | 170 | ||
182 | res = ( ::system( (const char*) cmdline ) == 0 ); | 171 | res = ( ::system( (const char*) cmdline ) == 0 ); |
183 | 172 | ||
184 | return res; | 173 | return res; |
185 | } | 174 | } |
186 | 175 | ||
187 | 176 | ||
188 | bool Jornada::suspend( ) | 177 | bool Jornada::suspend( ) |
189 | { | 178 | { |
190 | qDebug("ODevice::suspend"); | 179 | qDebug("ODevice::suspend"); |
191 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 180 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
192 | return false; | 181 | return false; |
193 | 182 | ||
194 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 183 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
195 | return false; | 184 | return false; |
196 | 185 | ||
197 | bool res = false; | 186 | bool res = false; |
198 | ODevice::sendSuspendmsg(); | 187 | ODevice::sendSuspendmsg(); |
199 | 188 | ||
200 | struct timeval tvs; | 189 | struct timeval tvs; |
201 | ::gettimeofday ( &tvs, 0 ); | 190 | ::gettimeofday ( &tvs, 0 ); |
202 | 191 | ||
203 | ::sync(); // flush fs caches | 192 | ::sync(); // flush fs caches |
204 | res = ( ::system ( "apm --suspend" ) == 0 ); | 193 | res = ( ::system ( "apm --suspend" ) == 0 ); |
205 | 194 | ||
206 | return res; | 195 | return res; |
207 | } | 196 | } |
208 | 197 | ||
209 | bool Jornada::setDisplayStatus ( bool on ) | 198 | bool Jornada::setDisplayStatus ( bool on ) |
210 | { | 199 | { |
211 | bool res = false; | 200 | bool res = false; |
212 | 201 | ||
213 | QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "0" : "4", on? "0" : "4" ); | 202 | QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "0" : "4", on? "0" : "4" ); |
214 | 203 | ||
215 | res = ( ::system( (const char*) cmdline ) == 0 ); | 204 | res = ( ::system( (const char*) cmdline ) == 0 ); |
216 | 205 | ||
217 | return res; | 206 | return res; |
218 | } | 207 | } |
219 | 208 | ||
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp index 32467f1..7db2af1 100644 --- a/libopie2/opiecore/device/odevice_ramses.cpp +++ b/libopie2/opiecore/device/odevice_ramses.cpp | |||
@@ -1,274 +1,264 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_ramses.h" | 30 | #include "odevice_ramses.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.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 | struct r_button ramses_buttons [] = { | 59 | struct r_button ramses_buttons [] = { |
60 | { Model_Ramses_MNCI, | 60 | { Model_Ramses_MNCI, |
61 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 61 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
62 | "devicebuttons/z_menu", | 62 | "devicebuttons/z_menu", |
63 | "QPE/TaskBar", "toggleMenu()", | 63 | "QPE/TaskBar", "toggleMenu()", |
64 | "QPE/TaskBar", "toggleStartMenu()" }, | 64 | "QPE/TaskBar", "toggleStartMenu()" }, |
65 | { Model_Ramses_MNCI, | 65 | { Model_Ramses_MNCI, |
66 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 66 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
67 | "devicebuttons/ipaq_home", | 67 | "devicebuttons/ipaq_home", |
68 | "QPE/Launcher", "home()", | 68 | "QPE/Launcher", "home()", |
69 | "buttonsettings", "raise()" }, | 69 | "buttonsettings", "raise()" }, |
70 | }; | 70 | }; |
71 | 71 | ||
72 | void Ramses::init(const QString&) | 72 | void Ramses::init(const QString&) |
73 | { | 73 | { |
74 | d->m_vendorstr = "M und N"; | 74 | d->m_vendorstr = "M und N"; |
75 | d->m_vendor = Vendor_MundN; | 75 | d->m_vendor = Vendor_MundN; |
76 | 76 | ||
77 | QFile f("/proc/sys/board/ramses"); | 77 | QFile f("/proc/sys/board/ramses"); |
78 | 78 | ||
79 | d->m_modelstr = "Ramses"; | 79 | d->m_modelstr = "Ramses"; |
80 | d->m_model = Model_Ramses_MNCI; | 80 | d->m_model = Model_Ramses_MNCI; |
81 | 81 | ||
82 | d->m_rotation = Rot0; | 82 | d->m_rotation = Rot0; |
83 | d->m_holdtime = 1000; | 83 | d->m_holdtime = 1000; |
84 | 84 | ||
85 | f.setName("/etc/oz_version"); | 85 | // Distribution detection code now in the base class |
86 | |||
87 | if (f.open(IO_ReadOnly)) { | ||
88 | d->m_systemstr = "OpenEmbedded/Ramses"; | ||
89 | d->m_system = System_OpenZaurus; | ||
90 | |||
91 | QTextStream ts(&f); | ||
92 | ts.setDevice(&f); | ||
93 | d->m_sysverstr = ts.readLine(); | ||
94 | f.close(); | ||
95 | } | ||
96 | 86 | ||
97 | m_power_timer = 0; | 87 | m_power_timer = 0; |
98 | 88 | ||
99 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 89 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
100 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 90 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
101 | #define OC(x...) x | 91 | #define OC(x...) x |
102 | #else | 92 | #else |
103 | #define OC(x...) | 93 | #define OC(x...) |
104 | #endif | 94 | #endif |
105 | 95 | ||
106 | // This table is true for a Intel XScale PXA 255 | 96 | // This table is true for a Intel XScale PXA 255 |
107 | 97 | ||
108 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 98 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
109 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 99 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
110 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 100 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
111 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 101 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
112 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 102 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
113 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 103 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
114 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 104 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
115 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 105 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
116 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 106 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
117 | 107 | ||
118 | } | 108 | } |
119 | 109 | ||
120 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 110 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
121 | { | 111 | { |
122 | Q_UNUSED( keycode ); | 112 | Q_UNUSED( keycode ); |
123 | Q_UNUSED( modifiers ); | 113 | Q_UNUSED( modifiers ); |
124 | Q_UNUSED( isPress ); | 114 | Q_UNUSED( isPress ); |
125 | Q_UNUSED( autoRepeat ); | 115 | Q_UNUSED( autoRepeat ); |
126 | return false; | 116 | return false; |
127 | } | 117 | } |
128 | 118 | ||
129 | void Ramses::timerEvent(QTimerEvent *) | 119 | void Ramses::timerEvent(QTimerEvent *) |
130 | { | 120 | { |
131 | killTimer(m_power_timer); | 121 | killTimer(m_power_timer); |
132 | m_power_timer = 0; | 122 | m_power_timer = 0; |
133 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 123 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
134 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 124 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
135 | } | 125 | } |
136 | 126 | ||
137 | 127 | ||
138 | bool Ramses::setSoftSuspend(bool soft) | 128 | bool Ramses::setSoftSuspend(bool soft) |
139 | { | 129 | { |
140 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 130 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
141 | #if 0 | 131 | #if 0 |
142 | bool res = false; | 132 | bool res = false; |
143 | int fd; | 133 | int fd; |
144 | 134 | ||
145 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 135 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
146 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 136 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
147 | 137 | ||
148 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 138 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
149 | 139 | ||
150 | if (sources >= 0) { | 140 | if (sources >= 0) { |
151 | if (soft) | 141 | if (soft) |
152 | sources &= ~APM_EVT_POWER_BUTTON; | 142 | sources &= ~APM_EVT_POWER_BUTTON; |
153 | else | 143 | else |
154 | sources |= APM_EVT_POWER_BUTTON; | 144 | sources |= APM_EVT_POWER_BUTTON; |
155 | 145 | ||
156 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 146 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
157 | res = true; | 147 | res = true; |
158 | else | 148 | else |
159 | perror("APM_IOCGEVTSRC"); | 149 | perror("APM_IOCGEVTSRC"); |
160 | } | 150 | } |
161 | else | 151 | else |
162 | perror("APM_IOCGEVTSRC"); | 152 | perror("APM_IOCGEVTSRC"); |
163 | 153 | ||
164 | ::close(fd); | 154 | ::close(fd); |
165 | } | 155 | } |
166 | else | 156 | else |
167 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 157 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
168 | 158 | ||
169 | return res; | 159 | return res; |
170 | #else | 160 | #else |
171 | return true; | 161 | return true; |
172 | #endif | 162 | #endif |
173 | } | 163 | } |
174 | 164 | ||
175 | bool Ramses::suspend() | 165 | bool Ramses::suspend() |
176 | { | 166 | { |
177 | qDebug("Ramses::suspend"); | 167 | qDebug("Ramses::suspend"); |
178 | return false; | 168 | return false; |
179 | } | 169 | } |
180 | 170 | ||
181 | /** | 171 | /** |
182 | * This sets the display on or off | 172 | * This sets the display on or off |
183 | */ | 173 | */ |
184 | bool Ramses::setDisplayStatus(bool on) | 174 | bool Ramses::setDisplayStatus(bool on) |
185 | { | 175 | { |
186 | qDebug("Ramses::setDisplayStatus(%d)", on); | 176 | qDebug("Ramses::setDisplayStatus(%d)", on); |
187 | #if 0 | 177 | #if 0 |
188 | bool res = false; | 178 | bool res = false; |
189 | int fd; | 179 | int fd; |
190 | 180 | ||
191 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 181 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
192 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 182 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
193 | ::close(fd); | 183 | ::close(fd); |
194 | } | 184 | } |
195 | return res; | 185 | return res; |
196 | #else | 186 | #else |
197 | return true; | 187 | return true; |
198 | #endif | 188 | #endif |
199 | } | 189 | } |
200 | 190 | ||
201 | 191 | ||
202 | /* | 192 | /* |
203 | * We get something between 0..255 into us | 193 | * We get something between 0..255 into us |
204 | */ | 194 | */ |
205 | bool Ramses::setDisplayBrightness(int bright) | 195 | bool Ramses::setDisplayBrightness(int bright) |
206 | { | 196 | { |
207 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 197 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
208 | bool res = false; | 198 | bool res = false; |
209 | int fd; | 199 | int fd; |
210 | 200 | ||
211 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 201 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
212 | 202 | ||
213 | if (bright > 255 ) | 203 | if (bright > 255 ) |
214 | bright = 255; | 204 | bright = 255; |
215 | if (bright < 0) | 205 | if (bright < 0) |
216 | bright = 0; | 206 | bright = 0; |
217 | 207 | ||
218 | // Turn backlight completely off | 208 | // Turn backlight completely off |
219 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 209 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
220 | char writeCommand[10]; | 210 | char writeCommand[10]; |
221 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 211 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
222 | res = (::write(fd, writeCommand, count) != -1); | 212 | res = (::write(fd, writeCommand, count) != -1); |
223 | ::close(fd); | 213 | ::close(fd); |
224 | } | 214 | } |
225 | 215 | ||
226 | // scale backlight brightness to hardware | 216 | // scale backlight brightness to hardware |
227 | bright = 500-(bright * 500 / 255); | 217 | bright = 500-(bright * 500 / 255); |
228 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 218 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
229 | qDebug(" %d ->pwm1", bright); | 219 | qDebug(" %d ->pwm1", bright); |
230 | char writeCommand[100]; | 220 | char writeCommand[100]; |
231 | const int count = sprintf(writeCommand, "%d\n", bright); | 221 | const int count = sprintf(writeCommand, "%d\n", bright); |
232 | res = (::write(fd, writeCommand, count) != -1); | 222 | res = (::write(fd, writeCommand, count) != -1); |
233 | ::close(fd); | 223 | ::close(fd); |
234 | } | 224 | } |
235 | return res; | 225 | return res; |
236 | } | 226 | } |
237 | 227 | ||
238 | 228 | ||
239 | int Ramses::displayBrightnessResolution() const | 229 | int Ramses::displayBrightnessResolution() const |
240 | { | 230 | { |
241 | return 32; | 231 | return 32; |
242 | } | 232 | } |
243 | 233 | ||
244 | bool Ramses::setDisplayContrast(int contr) | 234 | bool Ramses::setDisplayContrast(int contr) |
245 | { | 235 | { |
246 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 236 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
247 | bool res = false; | 237 | bool res = false; |
248 | int fd; | 238 | int fd; |
249 | 239 | ||
250 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 240 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
251 | 241 | ||
252 | if (contr > 255 ) | 242 | if (contr > 255 ) |
253 | contr = 255; | 243 | contr = 255; |
254 | if (contr < 0) | 244 | if (contr < 0) |
255 | contr = 0; | 245 | contr = 0; |
256 | contr = 90 - (contr * 20 / 255); | 246 | contr = 90 - (contr * 20 / 255); |
257 | 247 | ||
258 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 248 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
259 | qDebug(" %d ->pwm0", contr); | 249 | qDebug(" %d ->pwm0", contr); |
260 | char writeCommand[100]; | 250 | char writeCommand[100]; |
261 | const int count = sprintf(writeCommand, "%d\n", contr); | 251 | const int count = sprintf(writeCommand, "%d\n", contr); |
262 | res = (::write(fd, writeCommand, count) != -1); | 252 | res = (::write(fd, writeCommand, count) != -1); |
263 | res = true; | 253 | res = true; |
264 | ::close(fd); | 254 | ::close(fd); |
265 | } | 255 | } |
266 | return res; | 256 | return res; |
267 | } | 257 | } |
268 | 258 | ||
269 | 259 | ||
270 | int Ramses::displayContrastResolution() const | 260 | int Ramses::displayContrastResolution() const |
271 | { | 261 | { |
272 | return 20; | 262 | return 20; |
273 | } | 263 | } |
274 | 264 | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 6630763..6d4624b 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,393 +1,372 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_simpad.h" | 30 | #include "odevice_simpad.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.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 | struct s_button simpad_buttons [] = { | 59 | struct s_button simpad_buttons [] = { |
60 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 60 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
61 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 61 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
62 | "devicebuttons/simpad_lower_up", | 62 | "devicebuttons/simpad_lower_up", |
63 | "datebook", "nextView()", | 63 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 64 | "today", "raise()" }, |
65 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 65 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
66 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 66 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
67 | "devicebuttons/simpad_lower_down", | 67 | "devicebuttons/simpad_lower_down", |
68 | "addressbook", "raise()", | 68 | "addressbook", "raise()", |
69 | "addressbook", "beamBusinessCard()" }, | 69 | "addressbook", "beamBusinessCard()" }, |
70 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 70 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
71 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 71 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
72 | "devicebuttons/simpad_lower_right", | 72 | "devicebuttons/simpad_lower_right", |
73 | "QPE/TaskBar", "toggleMenu()", | 73 | "QPE/TaskBar", "toggleMenu()", |
74 | "QPE/TaskBar", "toggleStartMenu()" }, | 74 | "QPE/TaskBar", "toggleStartMenu()" }, |
75 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 75 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
76 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 76 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
77 | "devicebuttons/simpad_lower_left", | 77 | "devicebuttons/simpad_lower_left", |
78 | "opiemail", "raise()", | 78 | "opiemail", "raise()", |
79 | "opiemail", "newMail()" }, | 79 | "opiemail", "newMail()" }, |
80 | 80 | ||
81 | { 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, |
82 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 82 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
83 | "devicebuttons/simpad_upper_up", | 83 | "devicebuttons/simpad_upper_up", |
84 | "QPE/Launcher", "home()", | 84 | "QPE/Launcher", "home()", |
85 | "buttonsettings", "raise()" }, | 85 | "buttonsettings", "raise()" }, |
86 | { 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, |
87 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 87 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
88 | "devicebuttons/simpad_upper_down", | 88 | "devicebuttons/simpad_upper_down", |
89 | "addressbook", "raise()", | 89 | "addressbook", "raise()", |
90 | "addressbook", "beamBusinessCard()" }, | 90 | "addressbook", "beamBusinessCard()" }, |
91 | { 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, |
92 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 92 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
93 | "devicebuttons/simpad_upper_right", | 93 | "devicebuttons/simpad_upper_right", |
94 | "QPE/TaskBar", "toggleMenu()", | 94 | "QPE/TaskBar", "toggleMenu()", |
95 | "QPE/TaskBar", "toggleStartMenu()" }, | 95 | "QPE/TaskBar", "toggleStartMenu()" }, |
96 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 96 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
97 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 97 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
98 | "devicebuttons/simpad_upper_left", | 98 | "devicebuttons/simpad_upper_left", |
99 | "QPE/Rotation", "flip()", | 99 | "QPE/Rotation", "flip()", |
100 | "QPE/Rotation", "flip()" }, | 100 | "QPE/Rotation", "flip()" }, |
101 | /* | 101 | /* |
102 | { 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, |
103 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 103 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
104 | "devicebuttons/simpad_lower_upper", | 104 | "devicebuttons/simpad_lower_upper", |
105 | "QPE/Launcher", "home()", | 105 | "QPE/Launcher", "home()", |
106 | "buttonsettings", "raise()" }, | 106 | "buttonsettings", "raise()" }, |
107 | { 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, |
108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
109 | "devicebuttons/simpad_upper_lower", | 109 | "devicebuttons/simpad_upper_lower", |
110 | "QPE/Launcher", "home()", | 110 | "QPE/Launcher", "home()", |
111 | "buttonsettings", "raise()" }, | 111 | "buttonsettings", "raise()" }, |
112 | */ | 112 | */ |
113 | }; | 113 | }; |
114 | 114 | ||
115 | void SIMpad::init(const QString&) | 115 | void SIMpad::init(const QString&) |
116 | { | 116 | { |
117 | d->m_vendorstr = "SIEMENS"; | 117 | d->m_vendorstr = "SIEMENS"; |
118 | d->m_vendor = Vendor_SIEMENS; | 118 | d->m_vendor = Vendor_SIEMENS; |
119 | 119 | ||
120 | QFile f ( "/proc/hal/model" ); | 120 | QFile f ( "/proc/hal/model" ); |
121 | 121 | ||
122 | //TODO Implement model checking | 122 | //TODO Implement model checking |
123 | //FIXME For now we assume an SL4 | 123 | //FIXME For now we assume an SL4 |
124 | 124 | ||
125 | d->m_modelstr = "SL4"; | 125 | d->m_modelstr = "SL4"; |
126 | d->m_model = Model_SIMpad_SL4; | 126 | d->m_model = Model_SIMpad_SL4; |
127 | 127 | ||
128 | switch ( d->m_model ) { | 128 | switch ( d->m_model ) { |
129 | default: | 129 | default: |
130 | d->m_rotation = Rot0; | 130 | d->m_rotation = Rot0; |
131 | d->m_direction = CCW; | 131 | d->m_direction = CCW; |
132 | d->m_holdtime = 1000; // 1000ms | 132 | d->m_holdtime = 1000; // 1000ms |
133 | 133 | ||
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | 136 | ||
137 | f. setName ( "/etc/familiar-version" ); | 137 | //Distribution detecting code is now in base class |
138 | if ( f. open ( IO_ReadOnly )) { | ||
139 | d->m_systemstr = "Familiar"; | ||
140 | d->m_system = System_Familiar; | ||
141 | |||
142 | QTextStream ts ( &f ); | ||
143 | d->m_sysverstr = ts. readLine(). mid ( 10 ); | ||
144 | |||
145 | f. close(); | ||
146 | } else { | ||
147 | f. setName ( "/etc/oz_version" ); | ||
148 | |||
149 | if ( f. open ( IO_ReadOnly )) { | ||
150 | d->m_systemstr = "OpenEmbedded/SIMpad"; | ||
151 | d->m_system = System_OpenZaurus; | ||
152 | |||
153 | QTextStream ts ( &f ); | ||
154 | ts.setDevice ( &f ); | ||
155 | d->m_sysverstr = ts. readLine(); | ||
156 | f. close(); | ||
157 | } | ||
158 | } | ||
159 | 138 | ||
160 | m_leds [0] = m_leds [1] = Led_Off; | 139 | m_leds [0] = m_leds [1] = Led_Off; |
161 | 140 | ||
162 | m_power_timer = 0; | 141 | m_power_timer = 0; |
163 | 142 | ||
164 | } | 143 | } |
165 | 144 | ||
166 | void SIMpad::initButtons() | 145 | void SIMpad::initButtons() |
167 | { | 146 | { |
168 | if ( d->m_buttons ) | 147 | if ( d->m_buttons ) |
169 | return; | 148 | return; |
170 | 149 | ||
171 | if ( isQWS( ) ) | 150 | if ( isQWS( ) ) |
172 | QWSServer::setKeyboardFilter ( this ); | 151 | QWSServer::setKeyboardFilter ( this ); |
173 | 152 | ||
174 | d->m_buttons = new QValueList <ODeviceButton>; | 153 | d->m_buttons = new QValueList <ODeviceButton>; |
175 | 154 | ||
176 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 155 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
177 | s_button *sb = simpad_buttons + i; | 156 | s_button *sb = simpad_buttons + i; |
178 | ODeviceButton b; | 157 | ODeviceButton b; |
179 | 158 | ||
180 | if (( sb->model & d->m_model ) == d->m_model ) { | 159 | if (( sb->model & d->m_model ) == d->m_model ) { |
181 | b. setKeycode ( sb->code ); | 160 | b. setKeycode ( sb->code ); |
182 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 161 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
183 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 162 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); |
184 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 163 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
185 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 164 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
186 | 165 | ||
187 | d->m_buttons->append ( b ); | 166 | d->m_buttons->append ( b ); |
188 | } | 167 | } |
189 | } | 168 | } |
190 | reloadButtonMapping(); | 169 | reloadButtonMapping(); |
191 | 170 | ||
192 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 171 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
193 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 172 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
194 | } | 173 | } |
195 | 174 | ||
196 | // SIMpad boardcontrol register CS3 | 175 | // SIMpad boardcontrol register CS3 |
197 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 176 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
198 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 177 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
199 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 178 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
200 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 179 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
201 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 180 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
202 | #define SIMPAD_DISPLAY_ON 0x0010 | 181 | #define SIMPAD_DISPLAY_ON 0x0010 |
203 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 182 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
204 | #define SIMPAD_MQ_RESET 0x0040 | 183 | #define SIMPAD_MQ_RESET 0x0040 |
205 | #define SIMPAD_PCMCIA_RESET 0x0080 | 184 | #define SIMPAD_PCMCIA_RESET 0x0080 |
206 | #define SIMPAD_DECT_POWER_ON 0x0100 | 185 | #define SIMPAD_DECT_POWER_ON 0x0100 |
207 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 186 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
208 | #define SIMPAD_RS232_ON 0x0400 | 187 | #define SIMPAD_RS232_ON 0x0400 |
209 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 188 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
210 | #define SIMPAD_LED2_ON 0x1000 | 189 | #define SIMPAD_LED2_ON 0x1000 |
211 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 190 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
212 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 191 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
213 | #define SIMPAD_RESET_SIMCARD 0x8000 | 192 | #define SIMPAD_RESET_SIMCARD 0x8000 |
214 | 193 | ||
215 | //SIMpad touchscreen backlight strength control | 194 | //SIMpad touchscreen backlight strength control |
216 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 195 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
217 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 196 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
218 | 197 | ||
219 | QValueList <OLed> SIMpad::ledList() const | 198 | QValueList <OLed> SIMpad::ledList() const |
220 | { | 199 | { |
221 | QValueList <OLed> vl; | 200 | QValueList <OLed> vl; |
222 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 201 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
223 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 202 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
224 | return vl; | 203 | return vl; |
225 | } | 204 | } |
226 | 205 | ||
227 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 206 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
228 | { | 207 | { |
229 | QValueList <OLedState> vl; | 208 | QValueList <OLedState> vl; |
230 | 209 | ||
231 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 210 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
232 | vl << Led_Off << Led_On; | 211 | vl << Led_Off << Led_On; |
233 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 212 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
234 | //vl << Led_Off; | 213 | //vl << Led_Off; |
235 | return vl; | 214 | return vl; |
236 | } | 215 | } |
237 | 216 | ||
238 | OLedState SIMpad::ledState ( OLed l ) const | 217 | OLedState SIMpad::ledState ( OLed l ) const |
239 | { | 218 | { |
240 | switch ( l ) { | 219 | switch ( l ) { |
241 | case Led_Power: | 220 | case Led_Power: |
242 | return m_leds [0]; | 221 | return m_leds [0]; |
243 | //case Led_Mail: | 222 | //case Led_Mail: |
244 | //return m_leds [1]; | 223 | //return m_leds [1]; |
245 | default: | 224 | default: |
246 | return Led_Off; | 225 | return Led_Off; |
247 | } | 226 | } |
248 | } | 227 | } |
249 | 228 | ||
250 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 229 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
251 | { | 230 | { |
252 | #if 0 | 231 | #if 0 |
253 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 232 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
254 | 233 | ||
255 | /*TODO Implement this like that: | 234 | /*TODO Implement this like that: |
256 | read from cs3 | 235 | read from cs3 |
257 | && with SIMPAD_LED2_ON | 236 | && with SIMPAD_LED2_ON |
258 | write to cs3 */ | 237 | write to cs3 */ |
259 | m_leds [0] = st; | 238 | m_leds [0] = st; |
260 | return true; | 239 | return true; |
261 | } | 240 | } |
262 | } | 241 | } |
263 | } | 242 | } |
264 | 243 | ||
265 | #endif | 244 | #endif |
266 | return false; | 245 | return false; |
267 | } | 246 | } |
268 | 247 | ||
269 | 248 | ||
270 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 249 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
271 | { | 250 | { |
272 | //TODO | 251 | //TODO |
273 | return false; | 252 | return false; |
274 | } | 253 | } |
275 | 254 | ||
276 | void SIMpad::timerEvent ( QTimerEvent * ) | 255 | void SIMpad::timerEvent ( QTimerEvent * ) |
277 | { | 256 | { |
278 | killTimer ( m_power_timer ); | 257 | killTimer ( m_power_timer ); |
279 | m_power_timer = 0; | 258 | m_power_timer = 0; |
280 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 259 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
281 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 260 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
282 | } | 261 | } |
283 | 262 | ||
284 | 263 | ||
285 | void SIMpad::playAlarmSound() | 264 | void SIMpad::playAlarmSound() |
286 | { | 265 | { |
287 | #ifndef QT_NO_SOUND | 266 | #ifndef QT_NO_SOUND |
288 | static Sound snd ( "alarm" ); | 267 | static Sound snd ( "alarm" ); |
289 | int fd; | 268 | int fd; |
290 | int vol; | 269 | int vol; |
291 | bool vol_reset = false; | 270 | bool vol_reset = false; |
292 | 271 | ||
293 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 272 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
294 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 273 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
295 | Config cfg ( "qpe" ); | 274 | Config cfg ( "qpe" ); |
296 | cfg. setGroup ( "Volume" ); | 275 | cfg. setGroup ( "Volume" ); |
297 | 276 | ||
298 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 277 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
299 | if ( volalarm < 0 ) | 278 | if ( volalarm < 0 ) |
300 | volalarm = 0; | 279 | volalarm = 0; |
301 | else if ( volalarm > 100 ) | 280 | else if ( volalarm > 100 ) |
302 | volalarm = 100; | 281 | volalarm = 100; |
303 | volalarm |= ( volalarm << 8 ); | 282 | volalarm |= ( volalarm << 8 ); |
304 | 283 | ||
305 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 284 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
306 | vol_reset = true; | 285 | vol_reset = true; |
307 | } | 286 | } |
308 | } | 287 | } |
309 | 288 | ||
310 | snd. play(); | 289 | snd. play(); |
311 | while ( !snd. isFinished()) | 290 | while ( !snd. isFinished()) |
312 | qApp->processEvents(); | 291 | qApp->processEvents(); |
313 | 292 | ||
314 | if ( fd >= 0 ) { | 293 | if ( fd >= 0 ) { |
315 | if ( vol_reset ) | 294 | if ( vol_reset ) |
316 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 295 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
317 | ::close ( fd ); | 296 | ::close ( fd ); |
318 | } | 297 | } |
319 | #endif | 298 | #endif |
320 | } | 299 | } |
321 | 300 | ||
322 | 301 | ||
323 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 302 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
324 | { | 303 | { |
325 | qDebug( "ODevice for SIMpad: suspend()" ); | 304 | qDebug( "ODevice for SIMpad: suspend()" ); |
326 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 305 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
327 | return false; | 306 | return false; |
328 | 307 | ||
329 | bool res = false; | 308 | bool res = false; |
330 | ODevice::sendSuspendmsg(); | 309 | ODevice::sendSuspendmsg(); |
331 | 310 | ||
332 | struct timeval tvs, tvn; | 311 | struct timeval tvs, tvn; |
333 | ::gettimeofday ( &tvs, 0 ); | 312 | ::gettimeofday ( &tvs, 0 ); |
334 | 313 | ||
335 | ::sync(); // flush fs caches | 314 | ::sync(); // flush fs caches |
336 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 315 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
337 | 316 | ||
338 | return res; | 317 | return res; |
339 | } | 318 | } |
340 | 319 | ||
341 | 320 | ||
342 | bool SIMpad::setSoftSuspend ( bool soft ) | 321 | bool SIMpad::setSoftSuspend ( bool soft ) |
343 | { | 322 | { |
344 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 323 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
345 | return false; | 324 | return false; |
346 | } | 325 | } |
347 | 326 | ||
348 | 327 | ||
349 | bool SIMpad::setDisplayStatus ( bool on ) | 328 | bool SIMpad::setDisplayStatus ( bool on ) |
350 | { | 329 | { |
351 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 330 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
352 | 331 | ||
353 | bool res = false; | 332 | bool res = false; |
354 | int fd; | 333 | int fd; |
355 | 334 | ||
356 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 335 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
357 | 336 | ||
358 | res = ( ::system( (const char*) cmdline ) == 0 ); | 337 | res = ( ::system( (const char*) cmdline ) == 0 ); |
359 | 338 | ||
360 | return res; | 339 | return res; |
361 | } | 340 | } |
362 | 341 | ||
363 | 342 | ||
364 | bool SIMpad::setDisplayBrightness ( int bright ) | 343 | bool SIMpad::setDisplayBrightness ( int bright ) |
365 | { | 344 | { |
366 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 345 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
367 | bool res = false; | 346 | bool res = false; |
368 | int fd; | 347 | int fd; |
369 | 348 | ||
370 | if ( bright > 255 ) | 349 | if ( bright > 255 ) |
371 | bright = 255; | 350 | bright = 255; |
372 | if ( bright < 1 ) | 351 | if ( bright < 1 ) |
373 | bright = 0; | 352 | bright = 0; |
374 | 353 | ||
375 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 354 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
376 | int value = 255 - bright; | 355 | int value = 255 - bright; |
377 | const int mask = SIMPAD_BACKLIGHT_MASK; | 356 | const int mask = SIMPAD_BACKLIGHT_MASK; |
378 | value = value << 8; | 357 | value = value << 8; |
379 | value += mask; | 358 | value += mask; |
380 | char writeCommand[100]; | 359 | char writeCommand[100]; |
381 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 360 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
382 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 361 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
383 | ::close ( fd ); | 362 | ::close ( fd ); |
384 | } | 363 | } |
385 | return res; | 364 | return res; |
386 | } | 365 | } |
387 | 366 | ||
388 | 367 | ||
389 | int SIMpad::displayBrightnessResolution() const | 368 | int SIMpad::displayBrightnessResolution() const |
390 | { | 369 | { |
391 | return 255; // All SIMpad models share the same display | 370 | return 255; // All SIMpad models share the same display |
392 | } | 371 | } |
393 | 372 | ||
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp index 493ed25..223aa76 100644 --- a/libopie2/opiecore/device/odevice_yopy.cpp +++ b/libopie2/opiecore/device/odevice_yopy.cpp | |||
@@ -1,164 +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 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_yopy.h" | 30 | #include "odevice_yopy.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.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 | struct yopy_button yopy_buttons [] = { | 59 | struct yopy_button yopy_buttons [] = { |
60 | { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), | 60 | { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), |
61 | "devicebuttons/yopy_action", | 61 | "devicebuttons/yopy_action", |
62 | "datebook", "nextView()", | 62 | "datebook", "nextView()", |
63 | "today", "raise()" }, | 63 | "today", "raise()" }, |
64 | { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), | 64 | { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), |
65 | "devicebuttons/yopy_ok", | 65 | "devicebuttons/yopy_ok", |
66 | "addressbook", "raise()", | 66 | "addressbook", "raise()", |
67 | "addressbook", "beamBusinessCard()" }, | 67 | "addressbook", "beamBusinessCard()" }, |
68 | { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), | 68 | { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), |
69 | "devicebuttons/yopy_end", | 69 | "devicebuttons/yopy_end", |
70 | "QPE/Launcher", "home()", | 70 | "QPE/Launcher", "home()", |
71 | "buttonsettings", "raise()" }, | 71 | "buttonsettings", "raise()" }, |
72 | }; | 72 | }; |
73 | 73 | ||
74 | void Yopy::init(const QString&) | 74 | void Yopy::init(const QString&) |
75 | { | 75 | { |
76 | d->m_vendorstr = "G.Mate"; | 76 | d->m_vendorstr = "G.Mate"; |
77 | d->m_vendor = Vendor_GMate; | 77 | d->m_vendor = Vendor_GMate; |
78 | d->m_modelstr = "Yopy3700"; | 78 | d->m_modelstr = "Yopy3700"; |
79 | d->m_model = Model_Yopy_3700; | 79 | d->m_model = Model_Yopy_3700; |
80 | d->m_rotation = Rot0; | 80 | d->m_rotation = Rot0; |
81 | |||
82 | d->m_systemstr = "Linupy"; | 81 | d->m_systemstr = "Linupy"; |
83 | d->m_system = System_Linupy; | 82 | d->m_system = System_Linupy; |
84 | 83 | // Distribution detection code now in the base class | |
85 | QFile f ( "/etc/issue" ); | ||
86 | if ( f. open ( IO_ReadOnly ) ) | ||
87 | { | ||
88 | QTextStream ts ( &f ); | ||
89 | ts.readLine(); | ||
90 | d->m_sysverstr = ts. readLine(); | ||
91 | f. close(); | ||
92 | } | ||
93 | } | 84 | } |
94 | 85 | ||
95 | 86 | ||
96 | void Yopy::initButtons() | 87 | void Yopy::initButtons() |
97 | { | 88 | { |
98 | if ( d->m_buttons ) | 89 | if ( d->m_buttons ) |
99 | return ; | 90 | return ; |
100 | 91 | ||
101 | d->m_buttons = new QValueList <ODeviceButton>; | 92 | d->m_buttons = new QValueList <ODeviceButton>; |
102 | 93 | ||
103 | for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) | 94 | for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) |
104 | { | 95 | { |
105 | 96 | ||
106 | yopy_button *ib = yopy_buttons + i; | 97 | yopy_button *ib = yopy_buttons + i; |
107 | 98 | ||
108 | ODeviceButton b; | 99 | ODeviceButton b; |
109 | 100 | ||
110 | b. setKeycode ( ib->code ); | 101 | b. setKeycode ( ib->code ); |
111 | b. setUserText ( QObject::tr ( "Button", ib->utext ) ); | 102 | b. setUserText ( QObject::tr ( "Button", ib->utext ) ); |
112 | b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); | 103 | b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); |
113 | b. setFactoryPresetPressedAction | 104 | b. setFactoryPresetPressedAction |
114 | ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); | 105 | ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); |
115 | b. setFactoryPresetHeldAction | 106 | b. setFactoryPresetHeldAction |
116 | ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); | 107 | ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); |
117 | 108 | ||
118 | d->m_buttons->append ( b ); | 109 | d->m_buttons->append ( b ); |
119 | } | 110 | } |
120 | reloadButtonMapping(); | 111 | reloadButtonMapping(); |
121 | 112 | ||
122 | QCopChannel *sysch = new QCopChannel( "QPE/System", this ); | 113 | QCopChannel *sysch = new QCopChannel( "QPE/System", this ); |
123 | connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ), | 114 | connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ), |
124 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 115 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
125 | } | 116 | } |
126 | 117 | ||
127 | 118 | ||
128 | bool Yopy::suspend() | 119 | bool Yopy::suspend() |
129 | { | 120 | { |
130 | /* Opie for Yopy does not implement its own power management at the | 121 | /* Opie for Yopy does not implement its own power management at the |
131 | moment. The public version runs parallel to X, and relies on the | 122 | moment. The public version runs parallel to X, and relies on the |
132 | existing power management features. */ | 123 | existing power management features. */ |
133 | return false; | 124 | return false; |
134 | } | 125 | } |
135 | 126 | ||
136 | 127 | ||
137 | bool Yopy::setDisplayBrightness( int bright ) | 128 | bool Yopy::setDisplayBrightness( int bright ) |
138 | { | 129 | { |
139 | /* The code here works, but is disabled as the current version runs | 130 | /* The code here works, but is disabled as the current version runs |
140 | parallel to X, and relies on the existing backlight demon. */ | 131 | parallel to X, and relies on the existing backlight demon. */ |
141 | #if 0 | 132 | #if 0 |
142 | if ( QFile::exists( "/proc/sys/pm/light" ) ) | 133 | if ( QFile::exists( "/proc/sys/pm/light" ) ) |
143 | { | 134 | { |
144 | int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); | 135 | int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); |
145 | if ( fd >= 0 ) | 136 | if ( fd >= 0 ) |
146 | { | 137 | { |
147 | if ( bright ) | 138 | if ( bright ) |
148 | ::write( fd, "1\n", 2 ); | 139 | ::write( fd, "1\n", 2 ); |
149 | else | 140 | else |
150 | ::write( fd, "0\n", 2 ); | 141 | ::write( fd, "0\n", 2 ); |
151 | ::close( fd ); | 142 | ::close( fd ); |
152 | return true; | 143 | return true; |
153 | } | 144 | } |
154 | } | 145 | } |
155 | #endif | 146 | #endif |
156 | return false; | 147 | return false; |
157 | } | 148 | } |
158 | 149 | ||
159 | 150 | ||
160 | int Yopy::displayBrightnessResolution() const | 151 | int Yopy::displayBrightnessResolution() const |
161 | { | 152 | { |
162 | return 2; | 153 | return 2; |
163 | } | 154 | } |
164 | 155 | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index e8b813e..6ac3157 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,693 +1,678 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.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 | struct z_button z_buttons [] = { | 59 | struct z_button z_buttons [] = { |
60 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 60 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
61 | "devicebuttons/z_calendar", | 61 | "devicebuttons/z_calendar", |
62 | "datebook", "nextView()", | 62 | "datebook", "nextView()", |
63 | "today", "raise()" }, | 63 | "today", "raise()" }, |
64 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 64 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
65 | "devicebuttons/z_contact", | 65 | "devicebuttons/z_contact", |
66 | "addressbook", "raise()", | 66 | "addressbook", "raise()", |
67 | "addressbook", "beamBusinessCard()" }, | 67 | "addressbook", "beamBusinessCard()" }, |
68 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 68 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
69 | "devicebuttons/z_home", | 69 | "devicebuttons/z_home", |
70 | "QPE/Launcher", "home()", | 70 | "QPE/Launcher", "home()", |
71 | "buttonsettings", "raise()" }, | 71 | "buttonsettings", "raise()" }, |
72 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 72 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
73 | "devicebuttons/z_menu", | 73 | "devicebuttons/z_menu", |
74 | "QPE/TaskBar", "toggleMenu()", | 74 | "QPE/TaskBar", "toggleMenu()", |
75 | "QPE/TaskBar", "toggleStartMenu()" }, | 75 | "QPE/TaskBar", "toggleStartMenu()" }, |
76 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 76 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
77 | "devicebuttons/z_mail", | 77 | "devicebuttons/z_mail", |
78 | "opiemail", "raise()", | 78 | "opiemail", "raise()", |
79 | "opiemail", "newMail()" }, | 79 | "opiemail", "newMail()" }, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct z_button z_buttons_c700 [] = { | 82 | struct z_button z_buttons_c700 [] = { |
83 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 83 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
84 | "devicebuttons/z_calendar", | 84 | "devicebuttons/z_calendar", |
85 | "datebook", "nextView()", | 85 | "datebook", "nextView()", |
86 | "today", "raise()" }, | 86 | "today", "raise()" }, |
87 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 87 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
88 | "devicebuttons/z_contact", | 88 | "devicebuttons/z_contact", |
89 | "addressbook", "raise()", | 89 | "addressbook", "raise()", |
90 | "addressbook", "beamBusinessCard()" }, | 90 | "addressbook", "beamBusinessCard()" }, |
91 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 91 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
92 | "devicebuttons/z_home", | 92 | "devicebuttons/z_home", |
93 | "QPE/Launcher", "home()", | 93 | "QPE/Launcher", "home()", |
94 | "buttonsettings", "raise()" }, | 94 | "buttonsettings", "raise()" }, |
95 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 95 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
96 | "devicebuttons/z_menu", | 96 | "devicebuttons/z_menu", |
97 | "QPE/TaskBar", "toggleMenu()", | 97 | "QPE/TaskBar", "toggleMenu()", |
98 | "QPE/TaskBar", "toggleStartMenu()" }, | 98 | "QPE/TaskBar", "toggleStartMenu()" }, |
99 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 99 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
100 | "devicebuttons/z_hinge", | 100 | "devicebuttons/z_hinge", |
101 | "QPE/Rotation", "rotateDefault()", | 101 | "QPE/Rotation", "rotateDefault()", |
102 | "QPE/Dummy", "doNothing()" }, | 102 | "QPE/Dummy", "doNothing()" }, |
103 | }; | 103 | }; |
104 | 104 | ||
105 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 105 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
106 | // class up into individual classes. We need three classes | 106 | // class up into individual classes. We need three classes |
107 | // | 107 | // |
108 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 108 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
109 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 109 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
110 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 110 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
111 | // | 111 | // |
112 | // Only question right now is: Do we really need to do it? Because as soon | 112 | // Only question right now is: Do we really need to do it? Because as soon |
113 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 113 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
114 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 114 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
115 | // | 115 | // |
116 | // Comments? - mickeyl. | 116 | // Comments? - mickeyl. |
117 | 117 | ||
118 | void Zaurus::init(const QString&) | 118 | void Zaurus::init(const QString& cpu_info) |
119 | { | 119 | { |
120 | d->m_vendorstr = "Sharp"; | 120 | // generic distribution code already scanned /etc/issue at that point - |
121 | d->m_vendor = Vendor_Sharp; | 121 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
122 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 122 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
123 | 123 | { | |
124 | // QFile f ( "/proc/filesystems" ); | 124 | d->m_vendorstr = "Sharp"; |
125 | QString model; | 125 | d->m_vendor = Vendor_Sharp; |
126 | 126 | d->m_systemstr = "Zaurus"; | |
127 | // It isn't a good idea to check the system configuration to | 127 | d->m_system = System_Zaurus; |
128 | // detect the distribution ! | 128 | m_embedix = true; |
129 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 129 | } |
130 | // because it uses a jffs2 filesystem.. | 130 | else |
131 | // (eilers) | 131 | { |
132 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { | ||
133 | QFile f ("/etc/oz_version"); | ||
134 | if ( f.exists() ){ | ||
135 | d->m_vendorstr = "OpenZaurus Team"; | 132 | d->m_vendorstr = "OpenZaurus Team"; |
136 | d->m_systemstr = "OpenZaurus"; | 133 | d->m_systemstr = "OpenZaurus"; |
137 | d->m_system = System_OpenZaurus; | 134 | d->m_system = System_OpenZaurus; |
135 | // sysver already gathered | ||
138 | 136 | ||
139 | if ( f. open ( IO_ReadOnly )) { | 137 | // Openzaurus sometimes uses the embedix kernel, check if this is one |
140 | QTextStream ts ( &f ); | ||
141 | d->m_sysverstr = ts. readLine();//. mid ( 10 ); | ||
142 | f. close(); | ||
143 | } | ||
144 | |||
145 | // Openzaurus sometimes uses the embedix kernel! | ||
146 | // => Check whether this is an embedix kernel | ||
147 | FILE *uname = popen("uname -r", "r"); | 138 | FILE *uname = popen("uname -r", "r"); |
139 | QFile f; | ||
148 | QString line; | 140 | QString line; |
149 | if ( f.open(IO_ReadOnly, uname) ) { | 141 | if ( f.open(IO_ReadOnly, uname) ) { |
150 | QTextStream ts ( &f ); | 142 | QTextStream ts ( &f ); |
151 | line = ts. readLine(); | 143 | line = ts. readLine(); |
152 | int loc = line. find ( "embedix" ); | 144 | int loc = line. find ( "embedix" ); |
153 | if ( loc != -1 ) | 145 | if ( loc != -1 ) |
154 | m_embedix = true; | 146 | m_embedix = true; |
155 | else | 147 | else |
156 | m_embedix = false; | 148 | m_embedix = false; |
157 | f. close(); | 149 | f.close(); |
158 | } | 150 | } |
159 | pclose(uname); | 151 | pclose(uname); |
160 | } | 152 | } |
161 | else { | ||
162 | d->m_systemstr = "Zaurus"; | ||
163 | d->m_system = System_Zaurus; | ||
164 | } | ||
165 | 153 | ||
166 | f. setName ( "/proc/cpuinfo" ); | 154 | // check the Zaurus model |
167 | if ( f. open ( IO_ReadOnly ) ) { | 155 | QString model; |
168 | QTextStream ts ( &f ); | 156 | int loc = cpu_info.find( ":" ); |
169 | QString line; | 157 | if ( loc != -1 ) |
170 | while( line = ts. readLine() ) { | 158 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
171 | if ( line. left ( 8 ) == "Hardware" ) | 159 | else |
172 | break; | 160 | model = cpu_info; |
173 | } | ||
174 | int loc = line. find ( ":" ); | ||
175 | if ( loc != -1 ) | ||
176 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | ||
177 | } | ||
178 | 161 | ||
179 | if ( model == "SHARP Corgi" ) { | 162 | if ( model == "SHARP Corgi" ) { |
180 | d->m_model = Model_Zaurus_SLC7x0; | 163 | d->m_model = Model_Zaurus_SLC7x0; |
181 | d->m_modelstr = "Zaurus SL-C700"; | 164 | d->m_modelstr = "Zaurus SL-C700"; |
182 | } else if ( model == "SHARP Shepherd" ) { | 165 | } else if ( model == "SHARP Shepherd" ) { |
183 | d->m_model = Model_Zaurus_SLC7x0; | 166 | d->m_model = Model_Zaurus_SLC7x0; |
184 | d->m_modelstr = "Zaurus SL-C750"; | 167 | d->m_modelstr = "Zaurus SL-C750"; |
185 | } else if ( model == "SHARP Husky" ) { | 168 | } else if ( model == "SHARP Husky" ) { |
186 | d->m_model = Model_Zaurus_SLC7x0; | 169 | d->m_model = Model_Zaurus_SLC7x0; |
187 | d->m_modelstr = "Zaurus SL-C760"; | 170 | d->m_modelstr = "Zaurus SL-C760"; |
188 | } else if ( model == "SHARP Poodle" ) { | 171 | } else if ( model == "SHARP Poodle" ) { |
189 | d->m_model = Model_Zaurus_SLB600; | 172 | d->m_model = Model_Zaurus_SLB600; |
190 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 173 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
191 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
192 | d->m_model = Model_Zaurus_SL5500; | 175 | d->m_model = Model_Zaurus_SL5500; |
193 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
194 | } else { | 177 | } else { |
195 | d->m_model = Model_Zaurus_SL5500; | 178 | d->m_model = Model_Zaurus_SL5500; |
196 | d->m_modelstr = "Zaurus (Model unknown)"; | 179 | d->m_modelstr = "Unkown Zaurus"; |
197 | } | 180 | } |
198 | 181 | ||
182 | // set initial rotation | ||
183 | |||
199 | bool flipstate = false; | 184 | bool flipstate = false; |
200 | switch ( d->m_model ) { | 185 | switch ( d->m_model ) { |
201 | case Model_Zaurus_SLA300: | 186 | case Model_Zaurus_SLA300: |
202 | d->m_rotation = Rot0; | 187 | d->m_rotation = Rot0; |
203 | break; | 188 | break; |
204 | case Model_Zaurus_SLC7x0: | 189 | case Model_Zaurus_SLC7x0: |
205 | d->m_rotation = rotation(); | 190 | d->m_rotation = rotation(); |
206 | d->m_direction = direction(); | 191 | d->m_direction = direction(); |
207 | break; | 192 | break; |
208 | case Model_Zaurus_SLB600: | 193 | case Model_Zaurus_SLB600: |
209 | case Model_Zaurus_SL5500: | 194 | case Model_Zaurus_SL5500: |
210 | case Model_Zaurus_SL5000: | 195 | case Model_Zaurus_SL5000: |
211 | default: | 196 | default: |
212 | d->m_rotation = Rot270; | 197 | d->m_rotation = Rot270; |
213 | break; | 198 | break; |
214 | } | 199 | } |
215 | m_leds [0] = Led_Off; | 200 | m_leds [0] = Led_Off; |
216 | } | 201 | } |
217 | 202 | ||
218 | void Zaurus::initButtons() | 203 | void Zaurus::initButtons() |
219 | { | 204 | { |
220 | if ( d->m_buttons ) | 205 | if ( d->m_buttons ) |
221 | return; | 206 | return; |
222 | 207 | ||
223 | d->m_buttons = new QValueList <ODeviceButton>; | 208 | d->m_buttons = new QValueList <ODeviceButton>; |
224 | 209 | ||
225 | struct z_button * pz_buttons; | 210 | struct z_button * pz_buttons; |
226 | int buttoncount; | 211 | int buttoncount; |
227 | switch ( d->m_model ) { | 212 | switch ( d->m_model ) { |
228 | case Model_Zaurus_SLC7x0: | 213 | case Model_Zaurus_SLC7x0: |
229 | pz_buttons = z_buttons_c700; | 214 | pz_buttons = z_buttons_c700; |
230 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 215 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
231 | break; | 216 | break; |
232 | default: | 217 | default: |
233 | pz_buttons = z_buttons; | 218 | pz_buttons = z_buttons; |
234 | buttoncount = ARRAY_SIZE(z_buttons); | 219 | buttoncount = ARRAY_SIZE(z_buttons); |
235 | break; | 220 | break; |
236 | } | 221 | } |
237 | 222 | ||
238 | for ( int i = 0; i < buttoncount; i++ ) { | 223 | for ( int i = 0; i < buttoncount; i++ ) { |
239 | struct z_button *zb = pz_buttons + i; | 224 | struct z_button *zb = pz_buttons + i; |
240 | ODeviceButton b; | 225 | ODeviceButton b; |
241 | 226 | ||
242 | b. setKeycode ( zb->code ); | 227 | b. setKeycode ( zb->code ); |
243 | b. setUserText ( QObject::tr ( "Button", zb->utext )); | 228 | b. setUserText ( QObject::tr ( "Button", zb->utext )); |
244 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); | 229 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); |
245 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), | 230 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), |
246 | zb->fpressedaction )); | 231 | zb->fpressedaction )); |
247 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), | 232 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), |
248 | zb->fheldaction )); | 233 | zb->fheldaction )); |
249 | 234 | ||
250 | d->m_buttons->append ( b ); | 235 | d->m_buttons->append ( b ); |
251 | } | 236 | } |
252 | 237 | ||
253 | reloadButtonMapping(); | 238 | reloadButtonMapping(); |
254 | 239 | ||
255 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 240 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
256 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), | 241 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), |
257 | this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 242 | this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
258 | } | 243 | } |
259 | 244 | ||
260 | #include <unistd.h> | 245 | #include <unistd.h> |
261 | #include <fcntl.h> | 246 | #include <fcntl.h> |
262 | #include <sys/ioctl.h> | 247 | #include <sys/ioctl.h> |
263 | 248 | ||
264 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 249 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
265 | 250 | ||
266 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 251 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
267 | 252 | ||
268 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 253 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
269 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 254 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
270 | 255 | ||
271 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 256 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
272 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 257 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
273 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 258 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
274 | 259 | ||
275 | /* --- for SHARP_BUZZER device --- */ | 260 | /* --- for SHARP_BUZZER device --- */ |
276 | 261 | ||
277 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 262 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
278 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 263 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
279 | 264 | ||
280 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 265 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
281 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 266 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
282 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 267 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
283 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 268 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
284 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 269 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
285 | 270 | ||
286 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 271 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
287 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 272 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
288 | 273 | ||
289 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 274 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
290 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 275 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
291 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 276 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
292 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 277 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
293 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 278 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
294 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 279 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
295 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 280 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
296 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 281 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
297 | 282 | ||
298 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 283 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
299 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 284 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
300 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 285 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
301 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 286 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
302 | // | 287 | // |
303 | 288 | ||
304 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 289 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
305 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 290 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
306 | 291 | ||
307 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 292 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
308 | 293 | ||
309 | typedef struct sharp_led_status { | 294 | typedef struct sharp_led_status { |
310 | int which; /* select which LED status is wanted. */ | 295 | int which; /* select which LED status is wanted. */ |
311 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 296 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
312 | } sharp_led_status; | 297 | } sharp_led_status; |
313 | 298 | ||
314 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 299 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
315 | 300 | ||
316 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 301 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
317 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 302 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
318 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 303 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
319 | 304 | ||
320 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 305 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
321 | 306 | ||
322 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 307 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
323 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 308 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
324 | #define APM_EVT_POWER_BUTTON (1 << 0) | 309 | #define APM_EVT_POWER_BUTTON (1 << 0) |
325 | 310 | ||
326 | #define FL_IOCTL_STEP_CONTRAST 100 | 311 | #define FL_IOCTL_STEP_CONTRAST 100 |
327 | 312 | ||
328 | 313 | ||
329 | void Zaurus::buzzer ( int sound ) | 314 | void Zaurus::buzzer ( int sound ) |
330 | { | 315 | { |
331 | #ifndef QT_NO_SOUND | 316 | #ifndef QT_NO_SOUND |
332 | QString soundname; | 317 | QString soundname; |
333 | 318 | ||
334 | // Not all devices have real sound | 319 | // Not all devices have real sound |
335 | if ( d->m_model == Model_Zaurus_SLC7x0 | 320 | if ( d->m_model == Model_Zaurus_SLC7x0 |
336 | || d->m_model == Model_Zaurus_SLB600 ){ | 321 | || d->m_model == Model_Zaurus_SLB600 ){ |
337 | 322 | ||
338 | switch ( sound ){ | 323 | switch ( sound ){ |
339 | case SHARP_BUZ_SCHEDULE_ALARM: | 324 | case SHARP_BUZ_SCHEDULE_ALARM: |
340 | soundname = "alarm"; | 325 | soundname = "alarm"; |
341 | break; | 326 | break; |
342 | case SHARP_BUZ_TOUCHSOUND: | 327 | case SHARP_BUZ_TOUCHSOUND: |
343 | soundname = "touchsound"; | 328 | soundname = "touchsound"; |
344 | break; | 329 | break; |
345 | case SHARP_BUZ_KEYSOUND: | 330 | case SHARP_BUZ_KEYSOUND: |
346 | soundname = "keysound"; | 331 | soundname = "keysound"; |
347 | break; | 332 | break; |
348 | default: | 333 | default: |
349 | soundname = "alarm"; | 334 | soundname = "alarm"; |
350 | 335 | ||
351 | } | 336 | } |
352 | } | 337 | } |
353 | 338 | ||
354 | // If a soundname is defined, we expect that this device has | 339 | // If a soundname is defined, we expect that this device has |
355 | // sound capabilities.. Otherwise we expect to have the buzzer | 340 | // sound capabilities.. Otherwise we expect to have the buzzer |
356 | // device.. | 341 | // device.. |
357 | if ( !soundname.isEmpty() ){ | 342 | if ( !soundname.isEmpty() ){ |
358 | int fd; | 343 | int fd; |
359 | int vol; | 344 | int vol; |
360 | bool vol_reset = false; | 345 | bool vol_reset = false; |
361 | 346 | ||
362 | Sound snd ( soundname ); | 347 | Sound snd ( soundname ); |
363 | 348 | ||
364 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 349 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
365 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 350 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
366 | Config cfg ( "qpe" ); | 351 | Config cfg ( "qpe" ); |
367 | cfg. setGroup ( "Volume" ); | 352 | cfg. setGroup ( "Volume" ); |
368 | 353 | ||
369 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 354 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
370 | if ( volalarm < 0 ) | 355 | if ( volalarm < 0 ) |
371 | volalarm = 0; | 356 | volalarm = 0; |
372 | else if ( volalarm > 100 ) | 357 | else if ( volalarm > 100 ) |
373 | volalarm = 100; | 358 | volalarm = 100; |
374 | volalarm |= ( volalarm << 8 ); | 359 | volalarm |= ( volalarm << 8 ); |
375 | 360 | ||
376 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 361 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
377 | vol_reset = true; | 362 | vol_reset = true; |
378 | } | 363 | } |
379 | } | 364 | } |
380 | 365 | ||
381 | snd. play(); | 366 | snd. play(); |
382 | while ( !snd. isFinished()) | 367 | while ( !snd. isFinished()) |
383 | qApp->processEvents(); | 368 | qApp->processEvents(); |
384 | 369 | ||
385 | if ( fd >= 0 ) { | 370 | if ( fd >= 0 ) { |
386 | if ( vol_reset ) | 371 | if ( vol_reset ) |
387 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 372 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
388 | ::close ( fd ); | 373 | ::close ( fd ); |
389 | } | 374 | } |
390 | } else { | 375 | } else { |
391 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 376 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
392 | 377 | ||
393 | if ( fd >= 0 ) { | 378 | if ( fd >= 0 ) { |
394 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 379 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
395 | ::close ( fd ); | 380 | ::close ( fd ); |
396 | } | 381 | } |
397 | 382 | ||
398 | } | 383 | } |
399 | #endif | 384 | #endif |
400 | } | 385 | } |
401 | 386 | ||
402 | 387 | ||
403 | void Zaurus::playAlarmSound() | 388 | void Zaurus::playAlarmSound() |
404 | { | 389 | { |
405 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 390 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
406 | } | 391 | } |
407 | 392 | ||
408 | void Zaurus::playTouchSound() | 393 | void Zaurus::playTouchSound() |
409 | { | 394 | { |
410 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 395 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
411 | } | 396 | } |
412 | 397 | ||
413 | void Zaurus::playKeySound() | 398 | void Zaurus::playKeySound() |
414 | { | 399 | { |
415 | buzzer ( SHARP_BUZ_KEYSOUND ); | 400 | buzzer ( SHARP_BUZ_KEYSOUND ); |
416 | } | 401 | } |
417 | 402 | ||
418 | 403 | ||
419 | QValueList <OLed> Zaurus::ledList() const | 404 | QValueList <OLed> Zaurus::ledList() const |
420 | { | 405 | { |
421 | QValueList <OLed> vl; | 406 | QValueList <OLed> vl; |
422 | vl << Led_Mail; | 407 | vl << Led_Mail; |
423 | return vl; | 408 | return vl; |
424 | } | 409 | } |
425 | 410 | ||
426 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 411 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
427 | { | 412 | { |
428 | QValueList <OLedState> vl; | 413 | QValueList <OLedState> vl; |
429 | 414 | ||
430 | if ( l == Led_Mail ) | 415 | if ( l == Led_Mail ) |
431 | vl << Led_Off << Led_On << Led_BlinkSlow; | 416 | vl << Led_Off << Led_On << Led_BlinkSlow; |
432 | return vl; | 417 | return vl; |
433 | } | 418 | } |
434 | 419 | ||
435 | OLedState Zaurus::ledState ( OLed which ) const | 420 | OLedState Zaurus::ledState ( OLed which ) const |
436 | { | 421 | { |
437 | if ( which == Led_Mail ) | 422 | if ( which == Led_Mail ) |
438 | return m_leds [0]; | 423 | return m_leds [0]; |
439 | else | 424 | else |
440 | return Led_Off; | 425 | return Led_Off; |
441 | } | 426 | } |
442 | 427 | ||
443 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 428 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
444 | { | 429 | { |
445 | if (!m_embedix) // Currently not supported on non_embedix kernels | 430 | if (!m_embedix) // Currently not supported on non_embedix kernels |
446 | return false; | 431 | return false; |
447 | 432 | ||
448 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 433 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
449 | 434 | ||
450 | if ( which == Led_Mail ) { | 435 | if ( which == Led_Mail ) { |
451 | if ( fd >= 0 ) { | 436 | if ( fd >= 0 ) { |
452 | struct sharp_led_status leds; | 437 | struct sharp_led_status leds; |
453 | ::memset ( &leds, 0, sizeof( leds )); | 438 | ::memset ( &leds, 0, sizeof( leds )); |
454 | leds. which = SHARP_LED_MAIL_EXISTS; | 439 | leds. which = SHARP_LED_MAIL_EXISTS; |
455 | bool ok = true; | 440 | bool ok = true; |
456 | 441 | ||
457 | switch ( st ) { | 442 | switch ( st ) { |
458 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 443 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
459 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 444 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
460 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 445 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
461 | default : ok = false; | 446 | default : ok = false; |
462 | } | 447 | } |
463 | 448 | ||
464 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 449 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
465 | m_leds [0] = st; | 450 | m_leds [0] = st; |
466 | return true; | 451 | return true; |
467 | } | 452 | } |
468 | } | 453 | } |
469 | } | 454 | } |
470 | return false; | 455 | return false; |
471 | } | 456 | } |
472 | 457 | ||
473 | bool Zaurus::setSoftSuspend ( bool soft ) | 458 | bool Zaurus::setSoftSuspend ( bool soft ) |
474 | { | 459 | { |
475 | if (!m_embedix) { | 460 | if (!m_embedix) { |
476 | /* non-Embedix kernels dont have kernel autosuspend */ | 461 | /* non-Embedix kernels dont have kernel autosuspend */ |
477 | return ODevice::setSoftSuspend( soft ); | 462 | return ODevice::setSoftSuspend( soft ); |
478 | } | 463 | } |
479 | 464 | ||
480 | bool res = false; | 465 | bool res = false; |
481 | int fd; | 466 | int fd; |
482 | 467 | ||
483 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 468 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
484 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 469 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
485 | 470 | ||
486 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 471 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
487 | 472 | ||
488 | if ( sources >= 0 ) { | 473 | if ( sources >= 0 ) { |
489 | if ( soft ) | 474 | if ( soft ) |
490 | sources &= ~APM_EVT_POWER_BUTTON; | 475 | sources &= ~APM_EVT_POWER_BUTTON; |
491 | else | 476 | else |
492 | sources |= APM_EVT_POWER_BUTTON; | 477 | sources |= APM_EVT_POWER_BUTTON; |
493 | 478 | ||
494 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 479 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
495 | res = true; | 480 | res = true; |
496 | else | 481 | else |
497 | perror ( "APM_IOCGEVTSRC" ); | 482 | perror ( "APM_IOCGEVTSRC" ); |
498 | } | 483 | } |
499 | else | 484 | else |
500 | perror ( "APM_IOCGEVTSRC" ); | 485 | perror ( "APM_IOCGEVTSRC" ); |
501 | 486 | ||
502 | ::close ( fd ); | 487 | ::close ( fd ); |
503 | } | 488 | } |
504 | else | 489 | else |
505 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 490 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
506 | 491 | ||
507 | return res; | 492 | return res; |
508 | } | 493 | } |
509 | 494 | ||
510 | 495 | ||
511 | bool Zaurus::setDisplayBrightness ( int bright ) | 496 | bool Zaurus::setDisplayBrightness ( int bright ) |
512 | { | 497 | { |
513 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 498 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
514 | bool res = false; | 499 | bool res = false; |
515 | int fd; | 500 | int fd; |
516 | 501 | ||
517 | if ( bright > 255 ) bright = 255; | 502 | if ( bright > 255 ) bright = 255; |
518 | if ( bright < 0 ) bright = 0; | 503 | if ( bright < 0 ) bright = 0; |
519 | 504 | ||
520 | if ( m_embedix ) | 505 | if ( m_embedix ) |
521 | { | 506 | { |
522 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 507 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
523 | { | 508 | { |
524 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 509 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); |
525 | // special treatment for devices with the corgi backlight interface | 510 | // special treatment for devices with the corgi backlight interface |
526 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 511 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
527 | { | 512 | { |
528 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); | 513 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); |
529 | char writeCommand[100]; | 514 | char writeCommand[100]; |
530 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 515 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
531 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 516 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
532 | ::close ( fd ); | 517 | ::close ( fd ); |
533 | } | 518 | } |
534 | return res; | 519 | return res; |
535 | } | 520 | } |
536 | else | 521 | else |
537 | { | 522 | { |
538 | // standard treatment for devices with the dumb embedix frontlight interface | 523 | // standard treatment for devices with the dumb embedix frontlight interface |
539 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 524 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
540 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 525 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
541 | if ( bright && !bl ) | 526 | if ( bright && !bl ) |
542 | bl = 1; | 527 | bl = 1; |
543 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 528 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
544 | ::close ( fd ); | 529 | ::close ( fd ); |
545 | } | 530 | } |
546 | } | 531 | } |
547 | } | 532 | } |
548 | else | 533 | else |
549 | { | 534 | { |
550 | // special treatment for the OpenZaurus unified interface | 535 | // special treatment for the OpenZaurus unified interface |
551 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 536 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
552 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 537 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
553 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 538 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
554 | ::close ( fd ); | 539 | ::close ( fd ); |
555 | } | 540 | } |
556 | } | 541 | } |
557 | return res; | 542 | return res; |
558 | } | 543 | } |
559 | 544 | ||
560 | bool Zaurus::suspend() | 545 | bool Zaurus::suspend() |
561 | { | 546 | { |
562 | qDebug("ODevice::suspend"); | 547 | qDebug("ODevice::suspend"); |
563 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 548 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
564 | return false; | 549 | return false; |
565 | 550 | ||
566 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 551 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
567 | return false; | 552 | return false; |
568 | 553 | ||
569 | bool res = false; | 554 | bool res = false; |
570 | ODevice::sendSuspendmsg(); | 555 | ODevice::sendSuspendmsg(); |
571 | 556 | ||
572 | struct timeval tvs, tvn; | 557 | struct timeval tvs, tvn; |
573 | ::gettimeofday ( &tvs, 0 ); | 558 | ::gettimeofday ( &tvs, 0 ); |
574 | 559 | ||
575 | ::sync(); // flush fs caches | 560 | ::sync(); // flush fs caches |
576 | res = ( ::system ( "apm --suspend" ) == 0 ); | 561 | res = ( ::system ( "apm --suspend" ) == 0 ); |
577 | 562 | ||
578 | // This is needed because the iPAQ apm implementation is asynchronous and we | 563 | // This is needed because the iPAQ apm implementation is asynchronous and we |
579 | // can not be sure when exactly the device is really suspended | 564 | // can not be sure when exactly the device is really suspended |
580 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 565 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
581 | 566 | ||
582 | if ( res ) { | 567 | if ( res ) { |
583 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 568 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
584 | ::usleep ( 200 * 1000 ); | 569 | ::usleep ( 200 * 1000 ); |
585 | ::gettimeofday ( &tvn, 0 ); | 570 | ::gettimeofday ( &tvn, 0 ); |
586 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 571 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
587 | } | 572 | } |
588 | 573 | ||
589 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 574 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
590 | return res; | 575 | return res; |
591 | } | 576 | } |
592 | 577 | ||
593 | 578 | ||
594 | Transformation Zaurus::rotation() const | 579 | Transformation Zaurus::rotation() const |
595 | { | 580 | { |
596 | Transformation rot; | 581 | Transformation rot; |
597 | int handle = 0; | 582 | int handle = 0; |
598 | int retval = 0; | 583 | int retval = 0; |
599 | 584 | ||
600 | switch ( d->m_model ) { | 585 | switch ( d->m_model ) { |
601 | case Model_Zaurus_SLC7x0: | 586 | case Model_Zaurus_SLC7x0: |
602 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 587 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
603 | if (handle == -1) { | 588 | if (handle == -1) { |
604 | return Rot270; | 589 | return Rot270; |
605 | } else { | 590 | } else { |
606 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 591 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
607 | ::close (handle); | 592 | ::close (handle); |
608 | 593 | ||
609 | if (retval == 2 ) | 594 | if (retval == 2 ) |
610 | rot = Rot0; | 595 | rot = Rot0; |
611 | else | 596 | else |
612 | rot = Rot270; | 597 | rot = Rot270; |
613 | } | 598 | } |
614 | break; | 599 | break; |
615 | case Model_Zaurus_SLA300: | 600 | case Model_Zaurus_SLA300: |
616 | case Model_Zaurus_SLB600: | 601 | case Model_Zaurus_SLB600: |
617 | case Model_Zaurus_SL5500: | 602 | case Model_Zaurus_SL5500: |
618 | case Model_Zaurus_SL5000: | 603 | case Model_Zaurus_SL5000: |
619 | default: | 604 | default: |
620 | rot = d->m_rotation; | 605 | rot = d->m_rotation; |
621 | break; | 606 | break; |
622 | } | 607 | } |
623 | 608 | ||
624 | return rot; | 609 | return rot; |
625 | } | 610 | } |
626 | ODirection Zaurus::direction() const | 611 | ODirection Zaurus::direction() const |
627 | { | 612 | { |
628 | ODirection dir; | 613 | ODirection dir; |
629 | int handle = 0; | 614 | int handle = 0; |
630 | int retval = 0; | 615 | int retval = 0; |
631 | switch ( d->m_model ) { | 616 | switch ( d->m_model ) { |
632 | case Model_Zaurus_SLC7x0: | 617 | case Model_Zaurus_SLC7x0: |
633 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 618 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
634 | if (handle == -1) { | 619 | if (handle == -1) { |
635 | dir = CW; | 620 | dir = CW; |
636 | } else { | 621 | } else { |
637 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 622 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
638 | ::close (handle); | 623 | ::close (handle); |
639 | if (retval == 2 ) | 624 | if (retval == 2 ) |
640 | dir = CCW; | 625 | dir = CCW; |
641 | else | 626 | else |
642 | dir = CW; | 627 | dir = CW; |
643 | } | 628 | } |
644 | break; | 629 | break; |
645 | case Model_Zaurus_SLA300: | 630 | case Model_Zaurus_SLA300: |
646 | case Model_Zaurus_SLB600: | 631 | case Model_Zaurus_SLB600: |
647 | case Model_Zaurus_SL5500: | 632 | case Model_Zaurus_SL5500: |
648 | case Model_Zaurus_SL5000: | 633 | case Model_Zaurus_SL5000: |
649 | default: | 634 | default: |
650 | dir = d->m_direction; | 635 | dir = d->m_direction; |
651 | break; | 636 | break; |
652 | } | 637 | } |
653 | return dir; | 638 | return dir; |
654 | 639 | ||
655 | } | 640 | } |
656 | 641 | ||
657 | int Zaurus::displayBrightnessResolution() const | 642 | int Zaurus::displayBrightnessResolution() const |
658 | { | 643 | { |
659 | if (m_embedix) | 644 | if (m_embedix) |
660 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; | 645 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; |
661 | else | 646 | else |
662 | return 256; | 647 | return 256; |
663 | } | 648 | } |
664 | 649 | ||
665 | bool Zaurus::hasHingeSensor() const | 650 | bool Zaurus::hasHingeSensor() const |
666 | { | 651 | { |
667 | return d->m_model == Model_Zaurus_SLC7x0; | 652 | return d->m_model == Model_Zaurus_SLC7x0; |
668 | } | 653 | } |
669 | 654 | ||
670 | OHingeStatus Zaurus::readHingeSensor() | 655 | OHingeStatus Zaurus::readHingeSensor() |
671 | { | 656 | { |
672 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 657 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
673 | if (handle == -1) | 658 | if (handle == -1) |
674 | { | 659 | { |
675 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 660 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
676 | return CASE_UNKNOWN; | 661 | return CASE_UNKNOWN; |
677 | } | 662 | } |
678 | else | 663 | else |
679 | { | 664 | { |
680 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 665 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
681 | ::close (handle); | 666 | ::close (handle); |
682 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 667 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
683 | { | 668 | { |
684 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 669 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
685 | return static_cast<OHingeStatus>( retval ); | 670 | return static_cast<OHingeStatus>( retval ); |
686 | } | 671 | } |
687 | else | 672 | else |
688 | { | 673 | { |
689 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 674 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
690 | return CASE_UNKNOWN; | 675 | return CASE_UNKNOWN; |
691 | } | 676 | } |
692 | } | 677 | } |
693 | } | 678 | } |