summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_zaurus.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp54
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,65 +1,67 @@
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
57using namespace Opie::Core; 59using namespace Opie::Core;
58using namespace Opie::Core::Internal; 60using namespace Opie::Core::Internal;
59 61
60struct z_button z_buttons [] = { 62struct 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"),
@@ -215,69 +217,69 @@ void Zaurus::init(const QString& cpu_info)
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
227void Zaurus::initButtons() 229void 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
270typedef struct sharp_led_status { 272typedef 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
275void Zaurus::buzzer( int sound ) 277void 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
@@ -468,87 +470,87 @@ bool Zaurus::setDisplayStatus( bool on )
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
485Transformation Zaurus::rotation() const 487Transformation 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}
524ODirection Zaurus::direction() const 526ODirection 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
550bool Zaurus::hasHingeSensor() const 552bool 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