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,447 +1,458 @@
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>
53#include <sys/time.h> 52#include <sys/time.h>
54#include <unistd.h> 53#include <unistd.h>
55#ifndef QT_NO_SOUND 54#ifndef QT_NO_SOUND
56#include <linux/soundcard.h> 55#include <linux/soundcard.h>
57#endif 56#endif
58 57
59 58
60using namespace Opie::Core; 59using namespace Opie::Core;
61using namespace Opie::Core::Internal; 60using namespace Opie::Core::Internal;
62 61
63/* KERNEL */ 62/* KERNEL */
64#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 63#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
65 64
66#define OD_IO(type,number) OD_IOC(0,type,number,0) 65#define OD_IO(type,number) OD_IOC(0,type,number,0)
67#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 66#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
68#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 67#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
69#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 68#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
70 69
71typedef struct { 70typedef struct {
72 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 71 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
73 unsigned char TotalTime; /* Units of 5 seconds */ 72 unsigned char TotalTime; /* Units of 5 seconds */
74 unsigned char OnTime; /* units of 100m/s */ 73 unsigned char OnTime; /* units of 100m/s */
75 unsigned char OffTime; /* units of 100m/s */ 74 unsigned char OffTime; /* units of 100m/s */
76} LED_IN; 75} LED_IN;
77 76
78typedef struct { 77typedef 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" )
142 d->m_model = Model_iPAQ_H191x; 153 d->m_model = Model_iPAQ_H191x;
143 else 154 else
144 d->m_model = Model_Unknown; 155 d->m_model = Model_Unknown;
145 156
146 switch ( d->m_model ) { 157 switch ( d->m_model ) {
147 case Model_iPAQ_H31xx: 158 case Model_iPAQ_H31xx:
148 case Model_iPAQ_H38xx: 159 case Model_iPAQ_H38xx:
149 d->m_rotation = Rot90; 160 d->m_rotation = Rot90;
150 break; 161 break;
151 case Model_iPAQ_H5xxx: 162 case Model_iPAQ_H5xxx:
152 case Model_iPAQ_H22xx: 163 case Model_iPAQ_H22xx:
153 case Model_iPAQ_H191x: 164 case Model_iPAQ_H191x:
154 d->m_rotation = Rot0; 165 d->m_rotation = Rot0;
155 break; 166 break;
156 case Model_iPAQ_H36xx: 167 case Model_iPAQ_H36xx:
157 case Model_iPAQ_H37xx: 168 case Model_iPAQ_H37xx:
158 case Model_iPAQ_H39xx: 169 case Model_iPAQ_H39xx:
159 default: 170 default:
160 d->m_rotation = Rot270; 171 d->m_rotation = Rot270;
161 break; 172 break;
162 173
163 } 174 }
164 175
165 m_leds [0] = m_leds [1] = Led_Off; 176 m_leds [0] = m_leds [1] = Led_Off;
166 177
167 m_power_timer = 0; 178 m_power_timer = 0;
168 179
169} 180}
170 181
171void iPAQ::initButtons() 182void iPAQ::initButtons()
172{ 183{
173 if ( d->m_buttons ) 184 if ( d->m_buttons )
174 return; 185 return;
175 186
176 if ( isQWS( ) ) { 187 if ( isQWS( ) ) {
177 addPreHandler(this); 188 addPreHandler(this);
178 } 189 }
179 190
180 d->m_buttons = new QValueList <ODeviceButton>; 191 d->m_buttons = new QValueList <ODeviceButton>;
181 192
182 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 193 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
183 i_button *ib = ipaq_buttons + i; 194 i_button *ib = ipaq_buttons + i;
184 ODeviceButton b; 195 ODeviceButton b;
185 196
186 if (( ib->model & d->m_model ) == d->m_model ) { 197 if (( ib->model & d->m_model ) == d->m_model ) {
187 b. setKeycode ( ib->code ); 198 b. setKeycode ( ib->code );
188 b. setUserText ( QObject::tr ( "Button", ib->utext )); 199 b. setUserText ( QObject::tr ( "Button", ib->utext ));
189 b. setPixmap ( OResource::loadPixmap ( ib->pix )); 200 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
190 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 201 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
191 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 202 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
192 203
193 d->m_buttons->append ( b ); 204 d->m_buttons->append ( b );
194 } 205 }
195 } 206 }
196 reloadButtonMapping(); 207 reloadButtonMapping();
197} 208}
198 209
199QValueList <OLed> iPAQ::ledList() const 210QValueList <OLed> iPAQ::ledList() const
200{ 211{
201 QValueList <OLed> vl; 212 QValueList <OLed> vl;
202 vl << Led_Power; 213 vl << Led_Power;
203 214
204 if ( d->m_model == Model_iPAQ_H38xx ) 215 if ( d->m_model == Model_iPAQ_H38xx )
205 vl << Led_BlueTooth; 216 vl << Led_BlueTooth;
206 return vl; 217 return vl;
207} 218}
208 219
209QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 220QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
210{ 221{
211 QValueList <OLedState> vl; 222 QValueList <OLedState> vl;
212 223
213 if ( l == Led_Power ) 224 if ( l == Led_Power )
214 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 225 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
215 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 226 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
216 vl << Led_Off; // << Led_On << ??? 227 vl << Led_Off; // << Led_On << ???
217 228
218 return vl; 229 return vl;
219} 230}
220 231
221OLedState iPAQ::ledState ( OLed l ) const 232OLedState iPAQ::ledState ( OLed l ) const
222{ 233{
223 switch ( l ) { 234 switch ( l ) {
224 case Led_Power: 235 case Led_Power:
225 return m_leds [0]; 236 return m_leds [0];
226 case Led_BlueTooth: 237 case Led_BlueTooth:
227 return m_leds [1]; 238 return m_leds [1];
228 default: 239 default:
229 return Led_Off; 240 return Led_Off;
230 } 241 }
231} 242}
232 243
233bool iPAQ::setLedState ( OLed l, OLedState st ) 244bool iPAQ::setLedState ( OLed l, OLedState st )
234{ 245{
235 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 246 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
236 247
237 if ( l == Led_Power ) { 248 if ( l == Led_Power ) {
238 if ( fd >= 0 ) { 249 if ( fd >= 0 ) {
239 LED_IN leds; 250 LED_IN leds;
240 ::memset ( &leds, 0, sizeof( leds )); 251 ::memset ( &leds, 0, sizeof( leds ));
241 leds. TotalTime = 0; 252 leds. TotalTime = 0;
242 leds. OnTime = 0; 253 leds. OnTime = 0;
243 leds. OffTime = 1; 254 leds. OffTime = 1;
244 leds. OffOnBlink = 2; 255 leds. OffOnBlink = 2;
245 256
246 switch ( st ) { 257 switch ( st ) {
247 case Led_Off : leds. OffOnBlink = 0; break; 258 case Led_Off : leds. OffOnBlink = 0; break;
248 case Led_On : leds. OffOnBlink = 1; break; 259 case Led_On : leds. OffOnBlink = 1; break;
249 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 260 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
250 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 261 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
251 } 262 }
252 263
253 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 264 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
254 m_leds [0] = st; 265 m_leds [0] = st;
255 return true; 266 return true;
256 } 267 }
257 } 268 }
258 } 269 }
259 return false; 270 return false;
260} 271}
261 272
262 273
263bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 274bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
264{ 275{
265 int newkeycode = keycode; 276 int newkeycode = keycode;
266 277
267 switch ( keycode ) { 278 switch ( keycode ) {
268 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 279 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
269 case HardKey_Menu: { 280 case HardKey_Menu: {
270 if (( d->m_model == Model_iPAQ_H38xx ) || 281 if (( d->m_model == Model_iPAQ_H38xx ) ||
271 ( d->m_model == Model_iPAQ_H39xx ) || 282 ( d->m_model == Model_iPAQ_H39xx ) ||
272 ( d->m_model == Model_iPAQ_H5xxx)) { 283 ( d->m_model == Model_iPAQ_H5xxx)) {
273 newkeycode = HardKey_Mail; 284 newkeycode = HardKey_Mail;
274 } 285 }
275 break; 286 break;
276 } 287 }
277 288
278 // Rotate cursor keys 180 or 270 289 // Rotate cursor keys 180 or 270
279 case Key_Left : 290 case Key_Left :
280 case Key_Right: 291 case Key_Right:
281 case Key_Up : 292 case Key_Up :
282 case Key_Down : { 293 case Key_Down : {
283 if (( d->m_model == Model_iPAQ_H31xx ) || 294 if (( d->m_model == Model_iPAQ_H31xx ) ||
284 ( d->m_model == Model_iPAQ_H38xx )) { 295 ( d->m_model == Model_iPAQ_H38xx )) {
285 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 296 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
286 } 297 }
287 // Rotate the cursor keys by 270 298 // Rotate the cursor keys by 270
288 // keycode - Key_Left = position of the button starting from left clockwise 299 // keycode - Key_Left = position of the button starting from left clockwise
289 // add the rotation to it and modolo. No we've the original offset 300 // add the rotation to it and modolo. No we've the original offset
290 // add the offset to the Key_Left key 301 // add the offset to the Key_Left key
291 if (( d->m_model == Model_iPAQ_H5xxx ) || 302 if (( d->m_model == Model_iPAQ_H5xxx ) ||
292 ( d->m_model == Model_iPAQ_H191x )) 303 ( d->m_model == Model_iPAQ_H191x ))
293 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 304 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
294 break; 305 break;
295 } 306 }
296 307
297 // map Power Button short/long press to F34/F35 308 // map Power Button short/long press to F34/F35
298 case Key_SysReq: { 309 case Key_SysReq: {
299 if ( isPress ) { 310 if ( isPress ) {
300 if ( m_power_timer ) 311 if ( m_power_timer )
301 killTimer ( m_power_timer ); 312 killTimer ( m_power_timer );
302 m_power_timer = startTimer ( 500 ); 313 m_power_timer = startTimer ( 500 );
303 } 314 }
304 else if ( m_power_timer ) { 315 else if ( m_power_timer ) {
305 killTimer ( m_power_timer ); 316 killTimer ( m_power_timer );
306 m_power_timer = 0; 317 m_power_timer = 0;
307 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 318 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
308 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 319 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
309 } 320 }
310 newkeycode = Key_unknown; 321 newkeycode = Key_unknown;
311 break; 322 break;
312 } 323 }
313 } 324 }
314 325
315 if ( newkeycode != keycode ) { 326 if ( newkeycode != keycode ) {
316 if ( newkeycode != Key_unknown ) 327 if ( newkeycode != Key_unknown )
317 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 328 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
318 return true; 329 return true;
319 } 330 }
320 else 331 else
321 return false; 332 return false;
322} 333}
323 334
324void iPAQ::timerEvent ( QTimerEvent * ) 335void iPAQ::timerEvent ( QTimerEvent * )
325{ 336{
326 killTimer ( m_power_timer ); 337 killTimer ( m_power_timer );
327 m_power_timer = 0; 338 m_power_timer = 0;
328 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 339 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
329 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 340 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
330} 341}
331 342
332 343
333void iPAQ::playAlarmSound() 344void iPAQ::playAlarmSound()
334{ 345{
335#ifndef QT_NO_SOUND 346#ifndef QT_NO_SOUND
336 static Sound snd ( "alarm" ); 347 static Sound snd ( "alarm" );
337 if(!snd.isFinished()) 348 if(!snd.isFinished())
338 return; 349 return;
339 350
340 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 351 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
341 snd. play(); 352 snd. play();
342#endif 353#endif
343} 354}
344 355
345bool iPAQ::setDisplayBrightness ( int bright ) 356bool iPAQ::setDisplayBrightness ( int bright )
346{ 357{
347 bool res = false; 358 bool res = false;
348 int fd; 359 int fd;
349 360
350 if ( bright > 255 ) 361 if ( bright > 255 )
351 bright = 255; 362 bright = 255;
352 if ( bright < 0 ) 363 if ( bright < 0 )
353 bright = 0; 364 bright = 0;
354 365
355 QString cmdline; 366 QString cmdline;
356 367
357 switch ( model()) { 368 switch ( model()) {
358 case Model_iPAQ_H191x: 369 case Model_iPAQ_H191x:
359 if ( !bright ) 370 if ( !bright )
360 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); 371 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
361 else 372 else
362 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); 373 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
363 // No Global::shellQuote as we gurantee it to be sane 374 // No Global::shellQuote as we gurantee it to be sane
364 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 375 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
365 break; 376 break;
366 default: 377 default:
367 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 378 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
368 FLITE_IN bl; 379 FLITE_IN bl;
369 bl. mode = 1; 380 bl. mode = 1;
370 bl. pwr = bright ? 1 : 0; 381 bl. pwr = bright ? 1 : 0;
371 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 382 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
372 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 383 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
373 ::close ( fd ); 384 ::close ( fd );
374 } 385 }
375 } 386 }
376 return res; 387 return res;
377} 388}
378 389
379int iPAQ::displayBrightnessResolution() const 390int iPAQ::displayBrightnessResolution() const
380{ 391{
381 switch ( model()) { 392 switch ( model()) {
382 case Model_iPAQ_H31xx: 393 case Model_iPAQ_H31xx:
383 case Model_iPAQ_H36xx: 394 case Model_iPAQ_H36xx:
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;
433 val = ::strtol ( buffer + 2, &endptr, 16 ); 444 val = ::strtol ( buffer + 2, &endptr, 16 );
434 445
435 if ( *endptr != 0 ) 446 if ( *endptr != 0 )
436 val = -1; 447 val = -1;
437 } 448 }
438 ::close ( fd ); 449 ::close ( fd );
439 } 450 }
440 451
441 return val; 452 return val;
442} 453}
443 454
444int iPAQ::lightSensorResolution() const 455int iPAQ::lightSensorResolution() const
445{ 456{
446 return 256; 457 return 256;
447} 458}