Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 99 |
1 files changed, 34 insertions, 65 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 47682bb..127fee9 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,72 +1,72 @@ | |||
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"), |
@@ -138,98 +138,96 @@ void Zaurus::init(const QString& cpu_info) | |||
138 | FILE *uname = popen("uname -r", "r"); | 138 | FILE *uname = popen("uname -r", "r"); |
139 | QFile f; | 139 | QFile f; |
140 | QString line; | 140 | QString line; |
141 | if ( f.open(IO_ReadOnly, uname) ) { | 141 | if ( f.open(IO_ReadOnly, uname) ) { |
142 | QTextStream ts ( &f ); | 142 | QTextStream ts ( &f ); |
143 | line = ts. readLine(); | 143 | line = ts. readLine(); |
144 | int loc = line. find ( "embedix" ); | 144 | int loc = line. find ( "embedix" ); |
145 | if ( loc != -1 ) | 145 | if ( loc != -1 ) |
146 | m_embedix = true; | 146 | m_embedix = true; |
147 | else | 147 | else |
148 | m_embedix = false; | 148 | m_embedix = false; |
149 | f.close(); | 149 | f.close(); |
150 | } | 150 | } |
151 | pclose(uname); | 151 | pclose(uname); |
152 | } | 152 | } |
153 | 153 | ||
154 | // check the Zaurus model | 154 | // check the Zaurus model |
155 | QString model; | 155 | QString model; |
156 | int loc = cpu_info.find( ":" ); | 156 | int loc = cpu_info.find( ":" ); |
157 | if ( loc != -1 ) | 157 | if ( loc != -1 ) |
158 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 158 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
159 | else | 159 | else |
160 | model = cpu_info; | 160 | model = cpu_info; |
161 | 161 | ||
162 | if ( model == "SHARP Corgi" ) { | 162 | if ( model == "SHARP Corgi" ) { |
163 | d->m_model = Model_Zaurus_SLC7x0; | 163 | d->m_model = Model_Zaurus_SLC7x0; |
164 | d->m_modelstr = "Zaurus SL-C700"; | 164 | d->m_modelstr = "Zaurus SL-C700"; |
165 | } else if ( model == "SHARP Shepherd" ) { | 165 | } else if ( model == "SHARP Shepherd" ) { |
166 | d->m_model = Model_Zaurus_SLC7x0; | 166 | d->m_model = Model_Zaurus_SLC7x0; |
167 | d->m_modelstr = "Zaurus SL-C750"; | 167 | d->m_modelstr = "Zaurus SL-C750"; |
168 | } else if ( model == "SHARP Husky" ) { | 168 | } else if ( model == "SHARP Husky" ) { |
169 | d->m_model = Model_Zaurus_SLC7x0; | 169 | d->m_model = Model_Zaurus_SLC7x0; |
170 | d->m_modelstr = "Zaurus SL-C760"; | 170 | d->m_modelstr = "Zaurus SL-C760"; |
171 | } else if ( model == "SHARP Poodle" ) { | 171 | } else if ( model == "SHARP Poodle" ) { |
172 | d->m_model = Model_Zaurus_SLB600; | 172 | d->m_model = Model_Zaurus_SLB600; |
173 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 173 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
175 | d->m_model = Model_Zaurus_SL5500; | 175 | d->m_model = Model_Zaurus_SL5500; |
176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
177 | } else if ( model == "SHARP Tosa" ) { | 177 | } else if ( model == "SHARP Tosa" ) { |
178 | d->m_model = Model_Zaurus_SL6000; | 178 | d->m_model = Model_Zaurus_SL6000; |
179 | d->m_modelstr = "Zaurus SL-6000"; | 179 | d->m_modelstr = "Zaurus SL-6000"; |
180 | } else { | 180 | } else { |
181 | d->m_model = Model_Zaurus_SL5500; | 181 | d->m_model = Model_Zaurus_SL5500; |
182 | d->m_modelstr = "Unkown Zaurus"; | 182 | d->m_modelstr = "Unkown Zaurus"; |
183 | } | 183 | } |
184 | 184 | ||
185 | // set initial rotation | 185 | // set initial rotation |
186 | |||
187 | bool flipstate = false; | ||
188 | switch ( d->m_model ) { | 186 | switch ( d->m_model ) { |
189 | case Model_Zaurus_SL6000: | 187 | case Model_Zaurus_SL6000: |
190 | case Model_Zaurus_SLA300: | 188 | case Model_Zaurus_SLA300: |
191 | d->m_rotation = Rot0; | 189 | d->m_rotation = Rot0; |
192 | break; | 190 | break; |
193 | case Model_Zaurus_SLC7x0: | 191 | case Model_Zaurus_SLC7x0: |
194 | d->m_rotation = rotation(); | 192 | d->m_rotation = rotation(); |
195 | d->m_direction = direction(); | 193 | d->m_direction = direction(); |
196 | break; | 194 | break; |
197 | case Model_Zaurus_SLB600: | 195 | case Model_Zaurus_SLB600: |
198 | case Model_Zaurus_SL5500: | 196 | case Model_Zaurus_SL5500: |
199 | case Model_Zaurus_SL5000: | 197 | case Model_Zaurus_SL5000: |
200 | default: | 198 | default: |
201 | d->m_rotation = Rot270; | 199 | d->m_rotation = Rot270; |
202 | break; | 200 | break; |
203 | } | 201 | } |
204 | m_leds [0] = Led_Off; | 202 | m_leds [0] = Led_Off; |
205 | } | 203 | } |
206 | 204 | ||
207 | void Zaurus::initButtons() | 205 | void Zaurus::initButtons() |
208 | { | 206 | { |
209 | if ( d->m_buttons ) | 207 | if ( d->m_buttons ) |
210 | return; | 208 | return; |
211 | 209 | ||
212 | d->m_buttons = new QValueList <ODeviceButton>; | 210 | d->m_buttons = new QValueList <ODeviceButton>; |
213 | 211 | ||
214 | struct z_button * pz_buttons; | 212 | struct z_button * pz_buttons; |
215 | int buttoncount; | 213 | int buttoncount; |
216 | switch ( d->m_model ) { | 214 | switch ( d->m_model ) { |
217 | case Model_Zaurus_SLC7x0: | 215 | case Model_Zaurus_SLC7x0: |
218 | pz_buttons = z_buttons_c700; | 216 | pz_buttons = z_buttons_c700; |
219 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 217 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
220 | break; | 218 | break; |
221 | default: | 219 | default: |
222 | pz_buttons = z_buttons; | 220 | pz_buttons = z_buttons; |
223 | buttoncount = ARRAY_SIZE(z_buttons); | 221 | buttoncount = ARRAY_SIZE(z_buttons); |
224 | break; | 222 | break; |
225 | } | 223 | } |
226 | 224 | ||
227 | for ( int i = 0; i < buttoncount; i++ ) { | 225 | for ( int i = 0; i < buttoncount; i++ ) { |
228 | struct z_button *zb = pz_buttons + i; | 226 | struct z_button *zb = pz_buttons + i; |
229 | ODeviceButton b; | 227 | ODeviceButton b; |
230 | 228 | ||
231 | b. setKeycode ( zb->code ); | 229 | b. setKeycode ( zb->code ); |
232 | b. setUserText ( QObject::tr ( "Button", zb->utext )); | 230 | b. setUserText ( QObject::tr ( "Button", zb->utext )); |
233 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); | 231 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); |
234 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), | 232 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), |
235 | zb->fpressedaction )); | 233 | zb->fpressedaction )); |
@@ -273,154 +271,125 @@ void Zaurus::initButtons() | |||
273 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 271 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
274 | 272 | ||
275 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 273 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
276 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 274 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
277 | 275 | ||
278 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 276 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
279 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 277 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
280 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 278 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
281 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 279 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
282 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 280 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
283 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 281 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
284 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 282 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
285 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 283 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
286 | 284 | ||
287 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 285 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
288 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 286 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
289 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 287 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
290 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 288 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
291 | // | 289 | // |
292 | 290 | ||
293 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 291 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
294 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 292 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
295 | 293 | ||
296 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 294 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
297 | 295 | ||
298 | typedef struct sharp_led_status { | 296 | typedef struct sharp_led_status { |
299 | int which; /* select which LED status is wanted. */ | 297 | int which; /* select which LED status is wanted. */ |
300 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 298 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
301 | } sharp_led_status; | 299 | } sharp_led_status; |
302 | 300 | ||
303 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 301 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
304 | 302 | ||
305 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 303 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
306 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 304 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
307 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 305 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
308 | 306 | ||
309 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 307 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
310 | 308 | ||
311 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 309 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
312 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 310 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
313 | #define APM_EVT_POWER_BUTTON (1 << 0) | 311 | #define APM_EVT_POWER_BUTTON (1 << 0) |
314 | 312 | ||
315 | #define FL_IOCTL_STEP_CONTRAST 100 | 313 | #define FL_IOCTL_STEP_CONTRAST 100 |
316 | 314 | ||
317 | 315 | ||
318 | void Zaurus::buzzer ( int sound ) | 316 | void Zaurus::buzzer ( int sound ) |
319 | { | 317 | { |
320 | #ifndef QT_NO_SOUND | 318 | #ifndef QT_NO_SOUND |
321 | QString soundname; | 319 | Sound *snd = 0; |
322 | 320 | ||
323 | // Not all devices have real sound | 321 | // Not all devices have real sound |
324 | if ( d->m_model == Model_Zaurus_SLC7x0 | 322 | if ( d->m_model == Model_Zaurus_SLC7x0 |
325 | || d->m_model == Model_Zaurus_SLB600 ){ | 323 | || d->m_model == Model_Zaurus_SLB600 ){ |
326 | 324 | ||
327 | switch ( sound ){ | 325 | switch ( sound ){ |
328 | case SHARP_BUZ_SCHEDULE_ALARM: | ||
329 | soundname = "alarm"; | ||
330 | break; | ||
331 | case SHARP_BUZ_TOUCHSOUND: | 326 | case SHARP_BUZ_TOUCHSOUND: |
332 | soundname = "touchsound"; | 327 | static Sound touch_sound("touchsound"); |
328 | snd = &touch_sound; | ||
333 | break; | 329 | break; |
334 | case SHARP_BUZ_KEYSOUND: | 330 | case SHARP_BUZ_KEYSOUND: |
335 | soundname = "keysound"; | 331 | static Sound key_sound( "keysound" ); |
332 | snd = &key_sound; | ||
336 | break; | 333 | break; |
334 | case SHARP_BUZ_SCHEDULE_ALARM: | ||
337 | default: | 335 | default: |
338 | soundname = "alarm"; | 336 | static Sound alarm_sound("alarm"); |
339 | 337 | snd = &alarm_sound; | |
338 | break; | ||
340 | } | 339 | } |
341 | } | 340 | } |
342 | 341 | ||
343 | // If a soundname is defined, we expect that this device has | 342 | // If a soundname is defined, we expect that this device has |
344 | // sound capabilities.. Otherwise we expect to have the buzzer | 343 | // sound capabilities.. Otherwise we expect to have the buzzer |
345 | // device.. | 344 | // device.. |
346 | if ( !soundname.isEmpty() ){ | 345 | if ( snd ){ |
347 | int fd; | 346 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
348 | int vol; | 347 | snd-> play(); |
349 | bool vol_reset = false; | ||
350 | |||
351 | Sound snd ( soundname ); | ||
352 | |||
353 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | ||
354 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | ||
355 | Config cfg ( "qpe" ); | ||
356 | cfg. setGroup ( "Volume" ); | ||
357 | |||
358 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | ||
359 | if ( volalarm < 0 ) | ||
360 | volalarm = 0; | ||
361 | else if ( volalarm > 100 ) | ||
362 | volalarm = 100; | ||
363 | volalarm |= ( volalarm << 8 ); | ||
364 | |||
365 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | ||
366 | vol_reset = true; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | snd. play(); | ||
371 | while ( !snd. isFinished()) | ||
372 | qApp->processEvents(); | ||
373 | |||
374 | if ( fd >= 0 ) { | ||
375 | if ( vol_reset ) | ||
376 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | ||
377 | ::close ( fd ); | ||
378 | } | ||
379 | } else { | 348 | } else { |
380 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 349 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
381 | 350 | ||
382 | if ( fd >= 0 ) { | 351 | if ( fd >= 0 ) { |
383 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 352 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
384 | ::close ( fd ); | 353 | ::close ( fd ); |
385 | } | 354 | } |
386 | 355 | ||
387 | } | 356 | } |
388 | #endif | 357 | #endif |
389 | } | 358 | } |
390 | 359 | ||
391 | 360 | ||
392 | void Zaurus::playAlarmSound() | 361 | void Zaurus::playAlarmSound() |
393 | { | 362 | { |
394 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 363 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
395 | } | 364 | } |
396 | 365 | ||
397 | void Zaurus::playTouchSound() | 366 | void Zaurus::playTouchSound() |
398 | { | 367 | { |
399 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 368 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
400 | } | 369 | } |
401 | 370 | ||
402 | void Zaurus::playKeySound() | 371 | void Zaurus::playKeySound() |
403 | { | 372 | { |
404 | buzzer ( SHARP_BUZ_KEYSOUND ); | 373 | buzzer ( SHARP_BUZ_KEYSOUND ); |
405 | } | 374 | } |
406 | 375 | ||
407 | 376 | ||
408 | QValueList <OLed> Zaurus::ledList() const | 377 | QValueList <OLed> Zaurus::ledList() const |
409 | { | 378 | { |
410 | QValueList <OLed> vl; | 379 | QValueList <OLed> vl; |
411 | vl << Led_Mail; | 380 | vl << Led_Mail; |
412 | return vl; | 381 | return vl; |
413 | } | 382 | } |
414 | 383 | ||
415 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 384 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
416 | { | 385 | { |
417 | QValueList <OLedState> vl; | 386 | QValueList <OLedState> vl; |
418 | 387 | ||
419 | if ( l == Led_Mail ) | 388 | if ( l == Led_Mail ) |
420 | vl << Led_Off << Led_On << Led_BlinkSlow; | 389 | vl << Led_Off << Led_On << Led_BlinkSlow; |
421 | return vl; | 390 | return vl; |
422 | } | 391 | } |
423 | 392 | ||
424 | OLedState Zaurus::ledState ( OLed which ) const | 393 | OLedState Zaurus::ledState ( OLed which ) const |
425 | { | 394 | { |
426 | if ( which == Led_Mail ) | 395 | if ( which == Led_Mail ) |
@@ -469,97 +438,97 @@ bool Zaurus::setSoftSuspend ( bool soft ) | |||
469 | bool res = false; | 438 | bool res = false; |
470 | int fd; | 439 | int fd; |
471 | 440 | ||
472 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 441 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
473 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 442 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
474 | 443 | ||
475 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 444 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
476 | 445 | ||
477 | if ( sources >= 0 ) { | 446 | if ( sources >= 0 ) { |
478 | if ( soft ) | 447 | if ( soft ) |
479 | sources &= ~APM_EVT_POWER_BUTTON; | 448 | sources &= ~APM_EVT_POWER_BUTTON; |
480 | else | 449 | else |
481 | sources |= APM_EVT_POWER_BUTTON; | 450 | sources |= APM_EVT_POWER_BUTTON; |
482 | 451 | ||
483 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 452 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
484 | res = true; | 453 | res = true; |
485 | else | 454 | else |
486 | perror ( "APM_IOCGEVTSRC" ); | 455 | perror ( "APM_IOCGEVTSRC" ); |
487 | } | 456 | } |
488 | else | 457 | else |
489 | perror ( "APM_IOCGEVTSRC" ); | 458 | perror ( "APM_IOCGEVTSRC" ); |
490 | 459 | ||
491 | ::close ( fd ); | 460 | ::close ( fd ); |
492 | } | 461 | } |
493 | else | 462 | else |
494 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 463 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
495 | 464 | ||
496 | return res; | 465 | return res; |
497 | } | 466 | } |
498 | 467 | ||
499 | 468 | ||
500 | bool Zaurus::setDisplayBrightness ( int bright ) | 469 | bool Zaurus::setDisplayBrightness ( int bright ) |
501 | { | 470 | { |
502 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 471 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
503 | bool res = false; | 472 | bool res = false; |
504 | int fd; | 473 | int fd; |
505 | 474 | ||
506 | if ( bright > 255 ) bright = 255; | 475 | if ( bright > 255 ) bright = 255; |
507 | if ( bright < 0 ) bright = 0; | 476 | if ( bright < 0 ) bright = 0; |
508 | 477 | ||
509 | if ( m_embedix ) | 478 | if ( m_embedix ) |
510 | { | 479 | { |
511 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 480 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
512 | { | 481 | { |
513 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 482 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); |
514 | // special treatment for devices with the corgi backlight interface | 483 | // special treatment for devices with the corgi backlight interface |
515 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 484 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
516 | { | 485 | { |
517 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); | 486 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); |
518 | char writeCommand[100]; | 487 | char writeCommand[100]; |
519 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 488 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
520 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 489 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
521 | ::close ( fd ); | 490 | ::close ( fd ); |
522 | } | 491 | } |
523 | return res; | 492 | return res; |
524 | } | 493 | } |
525 | else | 494 | else |
526 | { | 495 | { |
527 | // standard treatment for devices with the dumb embedix frontlight interface | 496 | // standard treatment for devices with the dumb embedix frontlight interface |
528 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 497 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
529 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 498 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
530 | if ( bright && !bl ) | 499 | if ( bright && !bl ) |
531 | bl = 1; | 500 | bl = 1; |
532 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 501 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
533 | ::close ( fd ); | 502 | ::close ( fd ); |
534 | } | 503 | } |
535 | } | 504 | } |
536 | } | 505 | } |
537 | else | 506 | else |
538 | { | 507 | { |
539 | // special treatment for the OpenZaurus unified interface | 508 | // special treatment for the OpenZaurus unified interface |
540 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 509 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
541 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 510 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
542 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 511 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
543 | ::close ( fd ); | 512 | ::close ( fd ); |
544 | } | 513 | } |
545 | } | 514 | } |
546 | return res; | 515 | return res; |
547 | } | 516 | } |
548 | 517 | ||
549 | bool Zaurus::suspend() | 518 | bool Zaurus::suspend() |
550 | { | 519 | { |
551 | qDebug("ODevice::suspend"); | 520 | qDebug("ODevice::suspend"); |
552 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 521 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
553 | return false; | 522 | return false; |
554 | 523 | ||
555 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 524 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
556 | return false; | 525 | return false; |
557 | 526 | ||
558 | bool res = false; | 527 | bool res = false; |
559 | ODevice::sendSuspendmsg(); | 528 | ODevice::sendSuspendmsg(); |
560 | 529 | ||
561 | struct timeval tvs, tvn; | 530 | struct timeval tvs, tvn; |
562 | ::gettimeofday ( &tvs, 0 ); | 531 | ::gettimeofday ( &tvs, 0 ); |
563 | 532 | ||
564 | ::sync(); // flush fs caches | 533 | ::sync(); // flush fs caches |
565 | res = ( ::system ( "apm --suspend" ) == 0 ); | 534 | res = ( ::system ( "apm --suspend" ) == 0 ); |