summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp63
1 files changed, 37 insertions, 26 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 309e1e4..3cc6cec 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,52 +1,51 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 Copyright (C)2002, 2003, 2004 The Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l. 4 .=l.
7           .>+-= 5           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; version 2 of the License.
13     ._= =}       : or (at your option) any later version. 11     ._= =}       :
14    .%`+i>       _;_. 12    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 19++=   -.     .`     .: details.
22:     =  ...= . :.=- 20 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27
29*/ 28*/
30 29
31#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
32 31
33/* QT */ 32/* QT */
34#include <qapplication.h> 33#include <qapplication.h>
35#include <qfile.h> 34#include <qfile.h>
36#include <qtextstream.h> 35#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
38 37
39/* OPIE */ 38/* OPIE */
40#include <qpe/config.h> 39#include <qpe/config.h>
41#include <qpe/sound.h> 40#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
43 42
44#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
45#include <opie2/oresource.h> 44#include <opie2/oresource.h>
46 45
47/* STD */ 46/* STD */
48#include <fcntl.h> 47#include <fcntl.h>
49#include <math.h> 48#include <math.h>
50#include <stdlib.h> 49#include <stdlib.h>
51#include <signal.h> 50#include <signal.h>
52#include <sys/ioctl.h> 51#include <sys/ioctl.h>
@@ -79,63 +78,75 @@ typedef struct {
79 unsigned char mode; 78 unsigned char mode;
80 unsigned char pwr; 79 unsigned char pwr;
81 unsigned char brightness; 80 unsigned char brightness;
82} FLITE_IN; 81} FLITE_IN;
83 82
84#define LED_ON OD_IOW( 'f', 5, LED_IN ) 83#define LED_ON OD_IOW( 'f', 5, LED_IN )
85#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 84#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
86 85
87struct i_button ipaq_buttons [] = { 86struct i_button ipaq_buttons [] = {
88 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 87 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x,
89 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 88 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
90 "devicebuttons/ipaq_calendar", 89 "devicebuttons/ipaq_calendar",
91 "datebook", "nextView()", 90 "datebook", "nextView()",
92 "today", "raise()" }, 91 "today", "raise()" },
93 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 92 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x,
94 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 93 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
95 "devicebuttons/ipaq_contact", 94 "devicebuttons/ipaq_contact",
96 "addressbook", "raise()", 95 "addressbook", "raise()",
97 "addressbook", "beamBusinessCard()" }, 96 "addressbook", "beamBusinessCard()" },
98 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 97 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
99 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 98 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
100 "devicebuttons/ipaq_menu", 99 "devicebuttons/ipaq_menu",
101 "QPE/TaskBar", "toggleMenu()", 100 "QPE/TaskBar", "toggleMenu()",
102 "QPE/TaskBar", "toggleStartMenu()" }, 101 "QPE/TaskBar", "toggleStartMenu()" },
103 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 102 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
104 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 103 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
105 "devicebuttons/ipaq_mail", 104 "devicebuttons/ipaq_mail",
106 "opiemail", "raise()", 105 "opiemail", "raise()",
107 "opiemail", "newMail()" }, 106 "opiemail", "newMail()" },
108 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 107 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x,
109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
110 "devicebuttons/ipaq_home", 109 "devicebuttons/ipaq_home",
111 "QPE/Launcher", "home()", 110 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 111 "buttonsettings", "raise()" },
113 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 112 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
114 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 113 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
115 "devicebuttons/ipaq_record", 114 "devicebuttons/ipaq_record",
116 "QPE/VMemo", "toggleRecord()", 115 "QPE/VMemo", "toggleRecord()",
117 "sound", "raise()" }, 116 "sound", "raise()" },
117
118 { Model_iPAQ_H191x,
119 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"),
120 "devicebuttons/ipaq_mail",
121 "opiemail", "raise()",
122 "opiemail", "newMail()" },
123 { Model_iPAQ_H191x,
124 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"),
125 "devicebuttons/ipaq_record",
126 "QPE/VMemo", "toggleRecord()",
127 "sound", "raise()" },
128
118}; 129};
119 130
120void iPAQ::init(const QString& model) 131void iPAQ::init(const QString& model)
121{ 132{
122 d->m_vendorstr = "HP"; 133 d->m_vendorstr = "HP";
123 d->m_vendor = Vendor_HP; 134 d->m_vendor = Vendor_HP;
124 135
125 d->m_modelstr = model.mid(model.findRev('H')); 136 d->m_modelstr = model.mid(model.findRev('H'));
126 137
127 if ( d->m_modelstr == "H3100" ) 138 if ( d->m_modelstr == "H3100" )
128 d->m_model = Model_iPAQ_H31xx; 139 d->m_model = Model_iPAQ_H31xx;
129 else if ( d->m_modelstr == "H3600" ) 140 else if ( d->m_modelstr == "H3600" )
130 d->m_model = Model_iPAQ_H36xx; 141 d->m_model = Model_iPAQ_H36xx;
131 else if ( d->m_modelstr == "H3700" ) 142 else if ( d->m_modelstr == "H3700" )
132 d->m_model = Model_iPAQ_H37xx; 143 d->m_model = Model_iPAQ_H37xx;
133 else if ( d->m_modelstr == "H3800" ) 144 else if ( d->m_modelstr == "H3800" )
134 d->m_model = Model_iPAQ_H38xx; 145 d->m_model = Model_iPAQ_H38xx;
135 else if ( d->m_modelstr == "H3900" ) 146 else if ( d->m_modelstr == "H3900" )
136 d->m_model = Model_iPAQ_H39xx; 147 d->m_model = Model_iPAQ_H39xx;
137 else if ( d->m_modelstr == "H5400" ) 148 else if ( d->m_modelstr == "H5400" )
138 d->m_model = Model_iPAQ_H5xxx; 149 d->m_model = Model_iPAQ_H5xxx;
139 else if ( d->m_modelstr == "H2200" ) 150 else if ( d->m_modelstr == "H2200" )
140 d->m_model = Model_iPAQ_H22xx; 151 d->m_model = Model_iPAQ_H22xx;
141 else if ( d->m_modelstr == "H1910" ) 152 else if ( d->m_modelstr == "H1910" )
@@ -384,49 +395,49 @@ int iPAQ::displayBrightnessResolution() const
384 case Model_iPAQ_H37xx: 395 case Model_iPAQ_H37xx:
385 return 128; // really 256, but >128 could damage the LCD 396 return 128; // really 256, but >128 could damage the LCD
386 397
387 case Model_iPAQ_H38xx: 398 case Model_iPAQ_H38xx:
388 case Model_iPAQ_H39xx: 399 case Model_iPAQ_H39xx:
389 return 64; 400 return 64;
390 case Model_iPAQ_H5xxx: 401 case Model_iPAQ_H5xxx:
391 return 255; 402 return 255;
392 case Model_iPAQ_H191x: 403 case Model_iPAQ_H191x:
393 return 183; 404 return 183;
394 default: 405 default:
395 return 2; 406 return 2;
396 } 407 }
397} 408}
398 409
399bool iPAQ::setDisplayStatus ( bool on ) 410bool iPAQ::setDisplayStatus ( bool on )
400{ 411{
401 bool res = false; 412 bool res = false;
402 413
403 QString cmdline; 414 QString cmdline;
404 415
405 if ( model() == Model_iPAQ_H191x ) { 416 if ( model() == Model_iPAQ_H191x ) {
406 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 417 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
407 } else { 418 } else {
408 res = OAbstractMobileDevice::setDisplayStatus(on); 419 return OAbstractMobileDevice::setDisplayStatus(on);
409 } 420 }
410 421
411 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 422 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
412 423
413 return res; 424 return res;
414} 425}
415 426
416bool iPAQ::hasLightSensor() const 427bool iPAQ::hasLightSensor() const
417{ 428{
418 return true; 429 return true;
419} 430}
420 431
421int iPAQ::readLightSensor() 432int iPAQ::readLightSensor()
422{ 433{
423 int fd; 434 int fd;
424 int val = -1; 435 int val = -1;
425 436
426 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 437 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
427 char buffer [8]; 438 char buffer [8];
428 439
429 if ( ::read ( fd, buffer, 5 ) == 5 ) { 440 if ( ::read ( fd, buffer, 5 ) == 5 ) {
430 char *endptr; 441 char *endptr;
431 442
432 buffer [4] = 0; 443 buffer [4] = 0;