Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index e9b163a..1742100 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,89 +1,91 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_zaurus.h" | 31 | #include "odevice_zaurus.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <opie2/oinputsystem.h> | 40 | #include <opie2/oinputsystem.h> |
41 | #include <opie2/oresource.h> | ||
42 | |||
40 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
41 | #include <qpe/resource.h> | ||
42 | #include <qpe/sound.h> | 44 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 45 | #include <qpe/qcopenvelope_qws.h> |
44 | 46 | ||
45 | /* STD */ | 47 | /* STD */ |
46 | #include <fcntl.h> | 48 | #include <fcntl.h> |
47 | #include <math.h> | 49 | #include <math.h> |
48 | #include <stdlib.h> | 50 | #include <stdlib.h> |
49 | #include <signal.h> | 51 | #include <signal.h> |
50 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> |
51 | #include <sys/time.h> | 53 | #include <sys/time.h> |
52 | #include <unistd.h> | 54 | #include <unistd.h> |
53 | #ifndef QT_NO_SOUND | 55 | #ifndef QT_NO_SOUND |
54 | #include <linux/soundcard.h> | 56 | #include <linux/soundcard.h> |
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | using namespace Opie::Core; | 59 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 60 | using namespace Opie::Core::Internal; |
59 | 61 | ||
60 | struct z_button z_buttons [] = { | 62 | struct z_button z_buttons [] = { |
61 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 63 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
62 | "devicebuttons/z_calendar", | 64 | "devicebuttons/z_calendar", |
63 | "datebook", "nextView()", | 65 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 66 | "today", "raise()" }, |
65 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 67 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
66 | "devicebuttons/z_contact", | 68 | "devicebuttons/z_contact", |
67 | "addressbook", "raise()", | 69 | "addressbook", "raise()", |
68 | "addressbook", "beamBusinessCard()" }, | 70 | "addressbook", "beamBusinessCard()" }, |
69 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 71 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
70 | "devicebuttons/z_home", | 72 | "devicebuttons/z_home", |
71 | "QPE/Launcher", "home()", | 73 | "QPE/Launcher", "home()", |
72 | "buttonsettings", "raise()" }, | 74 | "buttonsettings", "raise()" }, |
73 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 75 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
74 | "devicebuttons/z_menu", | 76 | "devicebuttons/z_menu", |
75 | "QPE/TaskBar", "toggleMenu()", | 77 | "QPE/TaskBar", "toggleMenu()", |
76 | "QPE/TaskBar", "toggleStartMenu()" }, | 78 | "QPE/TaskBar", "toggleStartMenu()" }, |
77 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 79 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
78 | "devicebuttons/z_mail", | 80 | "devicebuttons/z_mail", |
79 | "opiemail", "raise()", | 81 | "opiemail", "raise()", |
80 | "opiemail", "newMail()" }, | 82 | "opiemail", "newMail()" }, |
81 | }; | 83 | }; |
82 | 84 | ||
83 | struct z_button z_buttons_c700 [] = { | 85 | struct z_button z_buttons_c700 [] = { |
84 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 86 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
85 | "devicebuttons/z_calendar", | 87 | "devicebuttons/z_calendar", |
86 | "datebook", "nextView()", | 88 | "datebook", "nextView()", |
87 | "today", "raise()" }, | 89 | "today", "raise()" }, |
88 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 90 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
89 | "devicebuttons/z_contact", | 91 | "devicebuttons/z_contact", |
@@ -191,117 +193,117 @@ void Zaurus::init(const QString& cpu_info) | |||
191 | d->m_modelstr = "Zaurus SL-C3000"; | 193 | d->m_modelstr = "Zaurus SL-C3000"; |
192 | } else if ( model == "SHARP Akita" ) { | 194 | } else if ( model == "SHARP Akita" ) { |
193 | d->m_model = Model_Zaurus_SLC1000; | 195 | d->m_model = Model_Zaurus_SLC1000; |
194 | d->m_modelstr = "Zaurus SL-C1000"; | 196 | d->m_modelstr = "Zaurus SL-C1000"; |
195 | } else { | 197 | } else { |
196 | d->m_model = Model_Zaurus_SL5500; | 198 | d->m_model = Model_Zaurus_SL5500; |
197 | d->m_modelstr = "Unknown Zaurus"; | 199 | d->m_modelstr = "Unknown Zaurus"; |
198 | } | 200 | } |
199 | 201 | ||
200 | // set initial rotation | 202 | // set initial rotation |
201 | switch( d->m_model ) { | 203 | switch( d->m_model ) { |
202 | case Model_Zaurus_SL6000: // fallthrough | 204 | case Model_Zaurus_SL6000: // fallthrough |
203 | case Model_Zaurus_SLA300: | 205 | case Model_Zaurus_SLA300: |
204 | d->m_rotation = Rot0; | 206 | d->m_rotation = Rot0; |
205 | break; | 207 | break; |
206 | case Model_Zaurus_SLC3000: // fallthrough | 208 | case Model_Zaurus_SLC3000: // fallthrough |
207 | case Model_Zaurus_SLC1000: // fallthrough | 209 | case Model_Zaurus_SLC1000: // fallthrough |
208 | case Model_Zaurus_SLC7x0: | 210 | case Model_Zaurus_SLC7x0: |
209 | d->m_rotation = rotation(); | 211 | d->m_rotation = rotation(); |
210 | d->m_direction = direction(); | 212 | d->m_direction = direction(); |
211 | break; | 213 | break; |
212 | case Model_Zaurus_SLB600: // fallthrough | 214 | case Model_Zaurus_SLB600: // fallthrough |
213 | case Model_Zaurus_SL5000: // fallthrough | 215 | case Model_Zaurus_SL5000: // fallthrough |
214 | case Model_Zaurus_SL5500: // fallthrough | 216 | case Model_Zaurus_SL5500: // fallthrough |
215 | default: | 217 | default: |
216 | d->m_rotation = Rot270; | 218 | d->m_rotation = Rot270; |
217 | break; | 219 | break; |
218 | } | 220 | } |
219 | m_leds[0] = Led_Off; | 221 | m_leds[0] = Led_Off; |
220 | 222 | ||
221 | if ( m_embedix ) | 223 | if ( m_embedix ) |
222 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | 224 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); |
223 | else | 225 | else |
224 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 226 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
225 | } | 227 | } |
226 | 228 | ||
227 | void Zaurus::initButtons() | 229 | void Zaurus::initButtons() |
228 | { | 230 | { |
229 | if ( d->m_buttons ) | 231 | if ( d->m_buttons ) |
230 | return; | 232 | return; |
231 | 233 | ||
232 | 234 | ||
233 | d->m_buttons = new QValueList <ODeviceButton>; | 235 | d->m_buttons = new QValueList <ODeviceButton>; |
234 | 236 | ||
235 | struct z_button * pz_buttons; | 237 | struct z_button * pz_buttons; |
236 | int buttoncount; | 238 | int buttoncount; |
237 | switch ( d->m_model ) { | 239 | switch ( d->m_model ) { |
238 | case Model_Zaurus_SLC3000: // fallthrough | 240 | case Model_Zaurus_SLC3000: // fallthrough |
239 | case Model_Zaurus_SLC1000: // fallthrough | 241 | case Model_Zaurus_SLC1000: // fallthrough |
240 | case Model_Zaurus_SLC7x0: | 242 | case Model_Zaurus_SLC7x0: |
241 | if ( isQWS( ) ) { | 243 | if ( isQWS( ) ) { |
242 | addPreHandler(this); // hinge-sensor-handler | 244 | addPreHandler(this); // hinge-sensor-handler |
243 | } | 245 | } |
244 | pz_buttons = z_buttons_c700; | 246 | pz_buttons = z_buttons_c700; |
245 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 247 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
246 | break; | 248 | break; |
247 | default: | 249 | default: |
248 | pz_buttons = z_buttons; | 250 | pz_buttons = z_buttons; |
249 | buttoncount = ARRAY_SIZE(z_buttons); | 251 | buttoncount = ARRAY_SIZE(z_buttons); |
250 | break; | 252 | break; |
251 | } | 253 | } |
252 | 254 | ||
253 | for ( int i = 0; i < buttoncount; i++ ) { | 255 | for ( int i = 0; i < buttoncount; i++ ) { |
254 | struct z_button *zb = pz_buttons + i; | 256 | struct z_button *zb = pz_buttons + i; |
255 | ODeviceButton b; | 257 | ODeviceButton b; |
256 | 258 | ||
257 | b.setKeycode( zb->code ); | 259 | b.setKeycode( zb->code ); |
258 | b.setUserText( QObject::tr( "Button", zb->utext )); | 260 | b.setUserText( QObject::tr( "Button", zb->utext )); |
259 | b.setPixmap( Resource::loadPixmap( zb->pix )); | 261 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
260 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 262 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
261 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 263 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
262 | d->m_buttons->append( b ); | 264 | d->m_buttons->append( b ); |
263 | } | 265 | } |
264 | 266 | ||
265 | reloadButtonMapping(); | 267 | reloadButtonMapping(); |
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
269 | 271 | ||
270 | typedef struct sharp_led_status { | 272 | typedef struct sharp_led_status { |
271 | int which; /* select which LED status is wanted. */ | 273 | int which; /* select which LED status is wanted. */ |
272 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 274 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
273 | } sharp_led_status; | 275 | } sharp_led_status; |
274 | 276 | ||
275 | void Zaurus::buzzer( int sound ) | 277 | void Zaurus::buzzer( int sound ) |
276 | { | 278 | { |
277 | #ifndef QT_NO_SOUND | 279 | #ifndef QT_NO_SOUND |
278 | Sound *snd = 0; | 280 | Sound *snd = 0; |
279 | 281 | ||
280 | // All devices except SL5500 have a DSP device | 282 | // All devices except SL5500 have a DSP device |
281 | if ( d->m_model != Model_Zaurus_SL5000 | 283 | if ( d->m_model != Model_Zaurus_SL5000 |
282 | && d->m_model != Model_Zaurus_SL5500 ) { | 284 | && d->m_model != Model_Zaurus_SL5500 ) { |
283 | 285 | ||
284 | switch ( sound ){ | 286 | switch ( sound ){ |
285 | case SHARP_BUZ_TOUCHSOUND: { | 287 | case SHARP_BUZ_TOUCHSOUND: { |
286 | static Sound touch_sound("touchsound"); | 288 | static Sound touch_sound("touchsound"); |
287 | snd = &touch_sound; | 289 | snd = &touch_sound; |
288 | } | 290 | } |
289 | break; | 291 | break; |
290 | case SHARP_BUZ_KEYSOUND: { | 292 | case SHARP_BUZ_KEYSOUND: { |
291 | static Sound key_sound( "keysound" ); | 293 | static Sound key_sound( "keysound" ); |
292 | snd = &key_sound; | 294 | snd = &key_sound; |
293 | } | 295 | } |
294 | break; | 296 | break; |
295 | case SHARP_BUZ_SCHEDULE_ALARM: | 297 | case SHARP_BUZ_SCHEDULE_ALARM: |
296 | default: { | 298 | default: { |
297 | static Sound alarm_sound("alarm"); | 299 | static Sound alarm_sound("alarm"); |
298 | snd = &alarm_sound; | 300 | snd = &alarm_sound; |
299 | } | 301 | } |
300 | break; | 302 | break; |
301 | } | 303 | } |
302 | } | 304 | } |
303 | 305 | ||
304 | // If a soundname is defined, we expect that this device has | 306 | // If a soundname is defined, we expect that this device has |
305 | // sound capabilities.. Otherwise we expect to have the buzzer | 307 | // sound capabilities.. Otherwise we expect to have the buzzer |
306 | // device.. | 308 | // device.. |
307 | if ( snd && snd->isFinished() ){ | 309 | if ( snd && snd->isFinished() ){ |
@@ -444,135 +446,135 @@ bool Zaurus::setDisplayBrightness( int bright ) | |||
444 | { | 446 | { |
445 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); | 447 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); |
446 | if ( fd ) | 448 | if ( fd ) |
447 | { | 449 | { |
448 | char buf[100]; | 450 | char buf[100]; |
449 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 451 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
450 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 452 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
451 | ::close( fd ); | 453 | ::close( fd ); |
452 | } | 454 | } |
453 | } | 455 | } |
454 | return res; | 456 | return res; |
455 | } | 457 | } |
456 | 458 | ||
457 | bool Zaurus::setDisplayStatus( bool on ) | 459 | bool Zaurus::setDisplayStatus( bool on ) |
458 | { | 460 | { |
459 | bool res = false; | 461 | bool res = false; |
460 | if ( m_embedix ) | 462 | if ( m_embedix ) |
461 | { | 463 | { |
462 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 464 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
463 | if ( fd ) | 465 | if ( fd ) |
464 | { | 466 | { |
465 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 467 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
466 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 468 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
467 | ::close ( fd ); | 469 | ::close ( fd ); |
468 | } | 470 | } |
469 | } | 471 | } |
470 | else | 472 | else |
471 | { | 473 | { |
472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 474 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
473 | if ( fd ) | 475 | if ( fd ) |
474 | { | 476 | { |
475 | char buf[10]; | 477 | char buf[10]; |
476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 478 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
477 | buf[1] = '\0'; | 479 | buf[1] = '\0'; |
478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 480 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
479 | ::close( fd ); | 481 | ::close( fd ); |
480 | } | 482 | } |
481 | } | 483 | } |
482 | return res; | 484 | return res; |
483 | } | 485 | } |
484 | 486 | ||
485 | Transformation Zaurus::rotation() const | 487 | Transformation Zaurus::rotation() const |
486 | { | 488 | { |
487 | qDebug( "Zaurus::rotation()" ); | 489 | qDebug( "Zaurus::rotation()" ); |
488 | Transformation rot; | 490 | Transformation rot; |
489 | 491 | ||
490 | switch ( d->m_model ) { | 492 | switch ( d->m_model ) { |
491 | case Model_Zaurus_SLC3000: // fallthrough | 493 | case Model_Zaurus_SLC3000: // fallthrough |
492 | case Model_Zaurus_SLC1000: // fallthrough | 494 | case Model_Zaurus_SLC1000: // fallthrough |
493 | case Model_Zaurus_SLC7x0: | 495 | case Model_Zaurus_SLC7x0: |
494 | { | 496 | { |
495 | OHingeStatus hs = readHingeSensor(); | 497 | OHingeStatus hs = readHingeSensor(); |
496 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 498 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
497 | 499 | ||
498 | if ( m_embedix ) | 500 | if ( m_embedix ) |
499 | { | 501 | { |
500 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 502 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
501 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 503 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
502 | else rot = Rot270; | 504 | else rot = Rot270; |
503 | } | 505 | } |
504 | else | 506 | else |
505 | { | 507 | { |
506 | if ( hs == CASE_PORTRAIT ) rot = Rot90; | 508 | if ( hs == CASE_PORTRAIT ) rot = Rot90; |
507 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 509 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
508 | else rot = Rot0; | 510 | else rot = Rot0; |
509 | } | 511 | } |
510 | } | 512 | } |
511 | break; | 513 | break; |
512 | case Model_Zaurus_SL6000: | 514 | case Model_Zaurus_SL6000: |
513 | case Model_Zaurus_SLB600: | 515 | case Model_Zaurus_SLB600: |
514 | case Model_Zaurus_SLA300: | 516 | case Model_Zaurus_SLA300: |
515 | case Model_Zaurus_SL5500: | 517 | case Model_Zaurus_SL5500: |
516 | case Model_Zaurus_SL5000: | 518 | case Model_Zaurus_SL5000: |
517 | default: | 519 | default: |
518 | rot = d->m_rotation; | 520 | rot = d->m_rotation; |
519 | break; | 521 | break; |
520 | } | 522 | } |
521 | 523 | ||
522 | return rot; | 524 | return rot; |
523 | } | 525 | } |
524 | ODirection Zaurus::direction() const | 526 | ODirection Zaurus::direction() const |
525 | { | 527 | { |
526 | ODirection dir; | 528 | ODirection dir; |
527 | 529 | ||
528 | switch ( d->m_model ) { | 530 | switch ( d->m_model ) { |
529 | case Model_Zaurus_SLC3000: // fallthrough | 531 | case Model_Zaurus_SLC3000: // fallthrough |
530 | case Model_Zaurus_SLC1000: // fallthrough | 532 | case Model_Zaurus_SLC1000: // fallthrough |
531 | case Model_Zaurus_SLC7x0: { | 533 | case Model_Zaurus_SLC7x0: { |
532 | OHingeStatus hs = readHingeSensor(); | 534 | OHingeStatus hs = readHingeSensor(); |
533 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 535 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
534 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 536 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
535 | else dir = CW; | 537 | else dir = CW; |
536 | } | 538 | } |
537 | break; | 539 | break; |
538 | case Model_Zaurus_SL6000: | 540 | case Model_Zaurus_SL6000: |
539 | case Model_Zaurus_SLA300: | 541 | case Model_Zaurus_SLA300: |
540 | case Model_Zaurus_SLB600: | 542 | case Model_Zaurus_SLB600: |
541 | case Model_Zaurus_SL5500: | 543 | case Model_Zaurus_SL5500: |
542 | case Model_Zaurus_SL5000: | 544 | case Model_Zaurus_SL5000: |
543 | default: dir = d->m_direction; | 545 | default: dir = d->m_direction; |
544 | break; | 546 | break; |
545 | } | 547 | } |
546 | return dir; | 548 | return dir; |
547 | 549 | ||
548 | } | 550 | } |
549 | 551 | ||
550 | bool Zaurus::hasHingeSensor() const | 552 | bool Zaurus::hasHingeSensor() const |
551 | { | 553 | { |
552 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; | 554 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; |
553 | } | 555 | } |
554 | 556 | ||
555 | OHingeStatus Zaurus::readHingeSensor() const | 557 | OHingeStatus Zaurus::readHingeSensor() const |
556 | { | 558 | { |
557 | if (m_embedix) | 559 | if (m_embedix) |
558 | { | 560 | { |
559 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 561 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
560 | if (handle == -1) | 562 | if (handle == -1) |
561 | { | 563 | { |
562 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 564 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
563 | return CASE_UNKNOWN; | 565 | return CASE_UNKNOWN; |
564 | } | 566 | } |
565 | else | 567 | else |
566 | { | 568 | { |
567 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 569 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
568 | ::close (handle); | 570 | ::close (handle); |
569 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 571 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
570 | { | 572 | { |
571 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 573 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
572 | return static_cast<OHingeStatus>( retval ); | 574 | return static_cast<OHingeStatus>( retval ); |
573 | } | 575 | } |
574 | else | 576 | else |
575 | { | 577 | { |
576 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 578 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
577 | return CASE_UNKNOWN; | 579 | return CASE_UNKNOWN; |
578 | } | 580 | } |