summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp77
-rw-r--r--libopie2/opiecore/device/odevice_mypal.cpp17
2 files changed, 43 insertions, 51 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 00939bf..16ecc27 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,553 +1,542 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qtextstream.h> 36#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38 38
39/* OPIE */ 39/* OPIE */
40#include <qpe/config.h> 40#include <qpe/config.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#include <opie2/okeyfilter.h> 44#include <opie2/okeyfilter.h>
45#include <opie2/oresource.h> 45#include <opie2/oresource.h>
46 46
47/* STD */ 47/* STD */
48#include <fcntl.h> 48#include <fcntl.h>
49#include <math.h> 49#include <math.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <signal.h> 51#include <signal.h>
52#include <sys/ioctl.h> 52#include <sys/ioctl.h>
53#include <sys/time.h> 53#include <sys/time.h>
54#include <unistd.h> 54#include <unistd.h>
55#ifndef QT_NO_SOUND 55#ifndef QT_NO_SOUND
56#include <linux/soundcard.h> 56#include <linux/soundcard.h>
57#endif 57#endif
58 58
59 59
60using namespace Opie::Core; 60using namespace Opie::Core;
61using namespace Opie::Core::Internal; 61using namespace Opie::Core::Internal;
62 62
63/* KERNEL */ 63/* KERNEL */
64#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 64#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
65 65
66#define OD_IO(type,number) OD_IOC(0,type,number,0) 66#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)) 67#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)) 68#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)) 69#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
70 70
71typedef struct { 71typedef struct {
72 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 72 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
73 unsigned char TotalTime; /* Units of 5 seconds */ 73 unsigned char TotalTime; /* Units of 5 seconds */
74 unsigned char OnTime; /* units of 100m/s */ 74 unsigned char OnTime; /* units of 100m/s */
75 unsigned char OffTime; /* units of 100m/s */ 75 unsigned char OffTime; /* units of 100m/s */
76} LED_IN; 76} LED_IN;
77 77
78typedef struct { 78typedef struct {
79 unsigned char mode; 79 unsigned char mode;
80 unsigned char pwr; 80 unsigned char pwr;
81 unsigned char brightness; 81 unsigned char brightness;
82} FLITE_IN; 82} FLITE_IN;
83 83
84#define LED_ON OD_IOW( 'f', 5, LED_IN ) 84#define LED_ON OD_IOW( 'f', 5, LED_IN )
85#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 85#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
86 86
87#define Model_Keyboardless_2_6 (Model_iPAQ_H191x | Model_iPAQ_H22xx | Model_iPAQ_HX4700 | Model_iPAQ_H4xxx)
88
87struct i_button ipaq_buttons [] = { 89struct 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 | Model_iPAQ_H22xx | Model_iPAQ_HX4700 | Model_iPAQ_H4xxx, 90
91 // Common button map for all keyboardless devices with 2.6 kernel
92 { Model_Keyboardless_2_6,
89 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 93 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
90 "devicebuttons/ipaq_calendar", 94 "devicebuttons/ipaq_calendar",
91 "datebook", "nextView()", 95 "datebook", "nextView()",
92 "today", "raise()" }, 96 "today", "raise()" },
93 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x | Model_iPAQ_H22xx | Model_iPAQ_HX4700 | Model_iPAQ_H4xxx, 97 { Model_Keyboardless_2_6,
94 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 98 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
95 "devicebuttons/ipaq_contact", 99 "devicebuttons/ipaq_contact",
96 "addressbook", "raise()", 100 "addressbook", "raise()",
97 "addressbook", "beamBusinessCard()" }, 101 "addressbook", "beamBusinessCard()" },
98 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 102 { Model_Keyboardless_2_6,
99 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 103 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
100 "devicebuttons/ipaq_menu",
101 "QPE/TaskBar", "toggleMenu()",
102 "QPE/TaskBar", "toggleStartMenu()" },
103 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
104 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 | Model_iPAQ_H4xxx, 107 { Model_Keyboardless_2_6,
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, 112 { Model_Keyboardless_2_6,
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()" },
118 117
119 { Model_iPAQ_H191x | Model_iPAQ_H4xxx, 118 // Devices with 2.4 kernel
120 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"), 119 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
121 "devicebuttons/ipaq_mail", 120 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
122 "opiemail", "raise()", 121 "devicebuttons/ipaq_calendar",
123 "opiemail", "newMail()" }, 122 "datebook", "nextView()",
124 { Model_iPAQ_H191x | Model_iPAQ_H4xxx, 123 "today", "raise()" },
125 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"), 124 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
126 "devicebuttons/ipaq_record", 125 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
127 "QPE/VMemo", "toggleRecord()", 126 "devicebuttons/ipaq_contact",
128 "sound", "raise()" }, 127 "addressbook", "raise()",
129 128 "addressbook", "beamBusinessCard()" },
130 //h2200 has different button mapping 129 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
131 { Model_iPAQ_H22xx, 130 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
132 Qt::Key_NumLock, QT_TRANSLATE_NOOP("Button", "Mail Button"),
133 "devicebuttons/ipaq_mail",
134 "opiemail", "raise()",
135 "opiemail", "newMail()" },
136 { Model_iPAQ_H22xx,
137 Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("Button", "Menu Button"),
138 "devicebuttons/ipaq_menu", 131 "devicebuttons/ipaq_menu",
139 "QPE/TaskBar", "toggleMenu()", 132 "QPE/TaskBar", "toggleMenu()",
140 "QPE/TaskBar", "toggleStartMenu()" }, 133 "QPE/TaskBar", "toggleStartMenu()" },
141 // and hx4700 has different button mapping still 134 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
142 { Model_iPAQ_HX4700, 135 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
143 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
144 "devicebuttons/ipaq_mail", 136 "devicebuttons/ipaq_mail",
145 "opiemail", "raise()", 137 "opiemail", "raise()",
146 "opiemail", "newMail()" }, 138 "opiemail", "newMail()" },
147 { Model_iPAQ_HX4700, 139 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
148 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), 140 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
149 "devicebuttons/ipaq_record",
150 "QPE/VMemo", "toggleRecord()",
151 "sound", "raise()" },
152 { Model_iPAQ_HX4700,
153 Qt::Key_Home, QT_TRANSLATE_NOOP("Button", "Home Button"),
154 "devicebuttons/ipaq_home", 141 "devicebuttons/ipaq_home",
155 "QPE/Launcher", "home()", 142 "QPE/Launcher", "home()",
156 "buttonsettings", "raise()" }, 143 "buttonsettings", "raise()" },
144 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
145 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
146 "devicebuttons/ipaq_record",
147 "QPE/VMemo", "toggleRecord()",
148 "sound", "raise()" },
157 149
158}; 150};
159 151
160void iPAQ::init(const QString& model) 152void iPAQ::init(const QString& model)
161{ 153{
162 d->m_vendorstr = "HP"; 154 d->m_vendorstr = "HP";
163 d->m_vendor = Vendor_HP; 155 d->m_vendor = Vendor_HP;
164 156
165 d->m_modelstr = model.mid(model.findRev('H')); 157 d->m_modelstr = model.mid(model.findRev('H'));
166 158
167 if ( d->m_modelstr == "H3100" ) 159 if ( d->m_modelstr == "H3100" )
168 d->m_model = Model_iPAQ_H31xx; 160 d->m_model = Model_iPAQ_H31xx;
169 else if ( d->m_modelstr == "H3600" ) 161 else if ( d->m_modelstr == "H3600" )
170 d->m_model = Model_iPAQ_H36xx; 162 d->m_model = Model_iPAQ_H36xx;
171 else if ( d->m_modelstr == "H3700" ) 163 else if ( d->m_modelstr == "H3700" )
172 d->m_model = Model_iPAQ_H37xx; 164 d->m_model = Model_iPAQ_H37xx;
173 else if ( d->m_modelstr == "H3800" ) 165 else if ( d->m_modelstr == "H3800" )
174 d->m_model = Model_iPAQ_H38xx; 166 d->m_model = Model_iPAQ_H38xx;
175 else if ( d->m_modelstr == "H3900" ) 167 else if ( d->m_modelstr == "H3900" )
176 d->m_model = Model_iPAQ_H39xx; 168 d->m_model = Model_iPAQ_H39xx;
177 else if ( d->m_modelstr == "H5400" ) 169 else if ( d->m_modelstr == "H5400" )
178 d->m_model = Model_iPAQ_H5xxx; 170 d->m_model = Model_iPAQ_H5xxx;
179 else if ( d->m_modelstr == "H2200" ) 171 else if ( d->m_modelstr == "H2200" )
180 d->m_model = Model_iPAQ_H22xx; 172 d->m_model = Model_iPAQ_H22xx;
181 else if ( d->m_modelstr == "H1910" ) 173 else if ( d->m_modelstr == "H1910" )
182 d->m_model = Model_iPAQ_H191x; 174 d->m_model = Model_iPAQ_H191x;
183 else if ( d->m_modelstr == "H1940" ) 175 else if ( d->m_modelstr == "H1940" )
184 d->m_model = Model_iPAQ_H1940; 176 d->m_model = Model_iPAQ_H1940;
185 else if ( d->m_modelstr == "HX4700" ) 177 else if ( d->m_modelstr == "HX4700" )
186 d->m_model = Model_iPAQ_HX4700; 178 d->m_model = Model_iPAQ_HX4700;
187 else if ( d->m_modelstr == "H4000" ) 179 else if ( d->m_modelstr == "H4000" )
188 d->m_model = Model_iPAQ_H4xxx; 180 d->m_model = Model_iPAQ_H4xxx;
189 181
190 else 182 else
191 d->m_model = Model_Unknown; 183 d->m_model = Model_Unknown;
192 184
193 switch ( d->m_model ) { 185 switch ( d->m_model ) {
194 case Model_iPAQ_H31xx: 186 case Model_iPAQ_H31xx:
195 case Model_iPAQ_H38xx: 187 case Model_iPAQ_H38xx:
196 d->m_rotation = Rot90; 188 d->m_rotation = Rot90;
197 break; 189 break;
198 case Model_iPAQ_H5xxx: 190 case Model_iPAQ_H5xxx:
199 case Model_iPAQ_H22xx: 191 case Model_iPAQ_H22xx:
200 case Model_iPAQ_H191x: 192 case Model_iPAQ_H191x:
201 case Model_iPAQ_H1940: 193 case Model_iPAQ_H1940:
202 case Model_iPAQ_HX4700: 194 case Model_iPAQ_HX4700:
203 case Model_iPAQ_H4xxx: 195 case Model_iPAQ_H4xxx:
204 d->m_rotation = Rot0; 196 d->m_rotation = Rot0;
205 break; 197 break;
206 case Model_iPAQ_H36xx: 198 case Model_iPAQ_H36xx:
207 case Model_iPAQ_H37xx: 199 case Model_iPAQ_H37xx:
208 case Model_iPAQ_H39xx: 200 case Model_iPAQ_H39xx:
209 default: 201 default:
210 d->m_rotation = Rot270; 202 d->m_rotation = Rot270;
211 break; 203 break;
212 204
213 } 205 }
214 206
215 m_leds [0] = m_leds [1] = Led_Off; 207 m_leds [0] = m_leds [1] = Led_Off;
216 208
217 m_power_timer = 0; 209 m_power_timer = 0;
218 210
219} 211}
220 212
221void iPAQ::initButtons() 213void iPAQ::initButtons()
222{ 214{
223 if ( d->m_buttons ) 215 if ( d->m_buttons )
224 return; 216 return;
225 217
226 if ( isQWS( ) ) { 218 if ( isQWS( ) ) {
227 addPreHandler(this); 219 addPreHandler(this);
228 } 220 }
229 221
230 d->m_buttons = new QValueList <ODeviceButton>; 222 d->m_buttons = new QValueList <ODeviceButton>;
231 223
232 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 224 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
233 i_button *ib = ipaq_buttons + i; 225 i_button *ib = ipaq_buttons + i;
234 ODeviceButton b; 226 ODeviceButton b;
235 227
236 if (( ib->model & d->m_model ) == d->m_model ) { 228 if (( ib->model & d->m_model ) == d->m_model ) {
237 b. setKeycode ( ib->code ); 229 b. setKeycode ( ib->code );
238 b. setUserText ( QObject::tr ( "Button", ib->utext )); 230 b. setUserText ( QObject::tr ( "Button", ib->utext ));
239 b. setPixmap ( OResource::loadPixmap ( ib->pix )); 231 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
240 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
241 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 233 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
242 234
243 d->m_buttons->append ( b ); 235 d->m_buttons->append ( b );
244 } 236 }
245 } 237 }
246 reloadButtonMapping(); 238 reloadButtonMapping();
247} 239}
248 240
249QValueList <OLed> iPAQ::ledList() const 241QValueList <OLed> iPAQ::ledList() const
250{ 242{
251 QValueList <OLed> vl; 243 QValueList <OLed> vl;
252 vl << Led_Power; 244 vl << Led_Power;
253 245
254 if ( d->m_model == Model_iPAQ_H38xx ) 246 if ( d->m_model == Model_iPAQ_H38xx )
255 vl << Led_BlueTooth; 247 vl << Led_BlueTooth;
256 return vl; 248 return vl;
257} 249}
258 250
259QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 251QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
260{ 252{
261 QValueList <OLedState> vl; 253 QValueList <OLedState> vl;
262 254
263 if ( l == Led_Power ) 255 if ( l == Led_Power )
264 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 256 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
265 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 257 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
266 vl << Led_Off; // << Led_On << ??? 258 vl << Led_Off; // << Led_On << ???
267 259
268 return vl; 260 return vl;
269} 261}
270 262
271OLedState iPAQ::ledState ( OLed l ) const 263OLedState iPAQ::ledState ( OLed l ) const
272{ 264{
273 switch ( l ) { 265 switch ( l ) {
274 case Led_Power: 266 case Led_Power:
275 return m_leds [0]; 267 return m_leds [0];
276 case Led_BlueTooth: 268 case Led_BlueTooth:
277 return m_leds [1]; 269 return m_leds [1];
278 default: 270 default:
279 return Led_Off; 271 return Led_Off;
280 } 272 }
281} 273}
282 274
283bool iPAQ::setLedState ( OLed l, OLedState st ) 275bool iPAQ::setLedState ( OLed l, OLedState st )
284{ 276{
285 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 277 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
286 278
287 if ( l == Led_Power ) { 279 if ( l == Led_Power ) {
288 if ( fd >= 0 ) { 280 if ( fd >= 0 ) {
289 LED_IN leds; 281 LED_IN leds;
290 ::memset ( &leds, 0, sizeof( leds )); 282 ::memset ( &leds, 0, sizeof( leds ));
291 leds. TotalTime = 0; 283 leds. TotalTime = 0;
292 leds. OnTime = 0; 284 leds. OnTime = 0;
293 leds. OffTime = 1; 285 leds. OffTime = 1;
294 leds. OffOnBlink = 2; 286 leds. OffOnBlink = 2;
295 287
296 switch ( st ) { 288 switch ( st ) {
297 case Led_Off : leds. OffOnBlink = 0; break; 289 case Led_Off : leds. OffOnBlink = 0; break;
298 case Led_On : leds. OffOnBlink = 1; break; 290 case Led_On : leds. OffOnBlink = 1; break;
299 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 291 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
300 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 292 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
301 } 293 }
302 294
303 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 295 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
304 m_leds [0] = st; 296 m_leds [0] = st;
305 return true; 297 return true;
306 } 298 }
307 } 299 }
308 } 300 }
309 return false; 301 return false;
310} 302}
311 303
312 304
313bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 305bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
314{ 306{
315 int newkeycode = keycode; 307 int newkeycode = keycode;
316 308
317 switch ( keycode ) { 309 switch ( keycode ) {
318 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 310 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
319 case HardKey_Menu: { 311 case HardKey_Menu: {
320 if (( d->m_model == Model_iPAQ_H38xx ) || 312 if (( d->m_model == Model_iPAQ_H38xx ) ||
321 ( d->m_model == Model_iPAQ_H39xx ) || 313 ( d->m_model == Model_iPAQ_H39xx ) ||
322 ( d->m_model == Model_iPAQ_H5xxx)) { 314 ( d->m_model == Model_iPAQ_H5xxx)) {
323 newkeycode = HardKey_Mail; 315 newkeycode = HardKey_Mail;
324 } 316 }
325 break; 317 break;
326 } 318 }
327 319
328 // Rotate cursor keys 180 or 270 320 // Rotate cursor keys 180 or 270
329 case Key_Left : 321 case Key_Left :
330 case Key_Right: 322 case Key_Right:
331 case Key_Up : 323 case Key_Up :
332 case Key_Down : { 324 case Key_Down : {
333 if (( d->m_model == Model_iPAQ_H31xx ) || 325 if (( d->m_model == Model_iPAQ_H31xx ) ||
334 ( d->m_model == Model_iPAQ_H38xx )) { 326 ( d->m_model == Model_iPAQ_H38xx )) {
335 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 327 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
336 } 328 }
337 // Rotate the cursor keys by 270 329 // Rotate the cursor keys by 270
338 // keycode - Key_Left = position of the button starting from left clockwise 330 // keycode - Key_Left = position of the button starting from left clockwise
339 // add the rotation to it and modolo. No we've the original offset 331 // add the rotation to it and modolo. No we've the original offset
340 // add the offset to the Key_Left key 332 // add the offset to the Key_Left key
341 if (( d->m_model == Model_iPAQ_H5xxx ) || 333 if (( d->m_model == Model_iPAQ_H5xxx ) ||
342 ( d->m_model == Model_iPAQ_H191x ) || 334 ( d->m_model == Model_iPAQ_H191x ) ||
343 ( d->m_model == Model_iPAQ_H4xxx ) || 335 ( d->m_model == Model_iPAQ_H4xxx ) ||
344 ( d->m_model == Model_iPAQ_H1940 )) 336 ( d->m_model == Model_iPAQ_H1940 ))
345 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 337 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
346 break; 338 break;
347 } 339 }
348 340
349 // map Power Button short/long press to F6 for h191x
350 case Key_F6:
351 if ( d->m_model != Model_iPAQ_H191x && d->m_model != Model_iPAQ_H4xxx )
352 break;
353 // map Power Button short/long press to F34/F35 341 // map Power Button short/long press to F34/F35
342 case HardKey_Suspend: // Hope we don't have infinite recursion here
354 case Key_SysReq: { 343 case Key_SysReq: {
355 if ( isPress ) { 344 if ( isPress ) {
356 if ( m_power_timer ) 345 if ( m_power_timer )
357 killTimer ( m_power_timer ); 346 killTimer ( m_power_timer );
358 m_power_timer = startTimer ( 500 ); 347 m_power_timer = startTimer ( 500 );
359 } 348 }
360 else if ( m_power_timer ) { 349 else if ( m_power_timer ) {
361 killTimer ( m_power_timer ); 350 killTimer ( m_power_timer );
362 m_power_timer = 0; 351 m_power_timer = 0;
363 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 352 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
364 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 353 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
365 } 354 }
366 newkeycode = Key_unknown; 355 newkeycode = Key_unknown;
367 break; 356 break;
368 } 357 }
369 } 358 }
370 359
371 if ( newkeycode != keycode ) { 360 if ( newkeycode != keycode ) {
372 if ( newkeycode != Key_unknown ) 361 if ( newkeycode != Key_unknown )
373 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 362 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
374 return true; 363 return true;
375 } 364 }
376 else 365 else
377 return false; 366 return false;
378} 367}
379 368
380void iPAQ::timerEvent ( QTimerEvent * ) 369void iPAQ::timerEvent ( QTimerEvent * )
381{ 370{
382 killTimer ( m_power_timer ); 371 killTimer ( m_power_timer );
383 m_power_timer = 0; 372 m_power_timer = 0;
384 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 373 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
385 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 374 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
386} 375}
387 376
388 377
389void iPAQ::playAlarmSound() 378void iPAQ::playAlarmSound()
390{ 379{
391#ifndef QT_NO_SOUND 380#ifndef QT_NO_SOUND
392 static Sound snd ( "alarm" ); 381 static Sound snd ( "alarm" );
393 if(!snd.isFinished()) 382 if(!snd.isFinished())
394 return; 383 return;
395 384
396 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 385 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
397 snd. play(); 386 snd. play();
398#endif 387#endif
399} 388}
400 389
401bool iPAQ::setDisplayBrightness ( int bright ) 390bool iPAQ::setDisplayBrightness ( int bright )
402{ 391{
403 bool res = false; 392 bool res = false;
404 int fd; 393 int fd;
405 394
406 if ( bright > 255 ) 395 if ( bright > 255 )
407 bright = 255; 396 bright = 255;
408 if ( bright < 0 ) 397 if ( bright < 0 )
409 bright = 0; 398 bright = 0;
410 399
411 QString cmdline; 400 QString cmdline;
412 401
413 switch ( model()) { 402 switch ( model()) {
414 case Model_iPAQ_H191x: 403 case Model_iPAQ_H191x:
415 case Model_iPAQ_H4xxx: 404 case Model_iPAQ_H4xxx:
416 { 405 {
417 QDir sysClass( "/sys/class/backlight/pxafb/" ); 406 QDir sysClass( "/sys/class/backlight/pxafb/" );
418 sysClass.setFilter(QDir::Dirs); 407 sysClass.setFilter(QDir::Dirs);
419 int fd; 408 int fd;
420 if ( sysClass.exists() ) { 409 if ( sysClass.exists() ) {
421 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); 410 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
422 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 411 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
423 if ( fd ) { 412 if ( fd ) {
424 char buf[10]; 413 char buf[10];
425 buf[0] = bright ? 0 : 4; 414 buf[0] = bright ? 0 : 4;
426 buf[1] = '\0'; 415 buf[1] = '\0';
427 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 416 res = ( ::write( fd, &buf[0], 2 ) == 0 );
428 ::close( fd ); 417 ::close( fd );
429 } 418 }
430 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" ); 419 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
431 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 420 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
432 if ( fd ) { 421 if ( fd ) {
433 char buf[100]; 422 char buf[100];
434 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright ); 423 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
435 res = ( ::write( fd, &buf[0], len ) == 0 ); 424 res = ( ::write( fd, &buf[0], len ) == 0 );
436 ::close( fd ); 425 ::close( fd );
437 } 426 }
438 } 427 }
439 } 428 }
440 break; 429 break;
441 430
442 case Model_iPAQ_HX4700: 431 case Model_iPAQ_HX4700:
443 cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright ); 432 cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright );
444 // No Global::shellQuote as we gurantee it to be sane 433 // No Global::shellQuote as we gurantee it to be sane
445 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 434 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
446 break; 435 break;
447 436
448 437
449 default: 438 default:
450 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 439 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
451 FLITE_IN bl; 440 FLITE_IN bl;
452 bl. mode = 1; 441 bl. mode = 1;
453 bl. pwr = bright ? 1 : 0; 442 bl. pwr = bright ? 1 : 0;
454 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 443 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
455 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 444 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
456 ::close ( fd ); 445 ::close ( fd );
457 } 446 }
458 } 447 }
459 return res; 448 return res;
460} 449}
461 450
462int iPAQ::displayBrightnessResolution() const 451int iPAQ::displayBrightnessResolution() const
463{ 452{
464 switch ( model()) { 453 switch ( model()) {
465 case Model_iPAQ_H31xx: 454 case Model_iPAQ_H31xx:
466 case Model_iPAQ_H36xx: 455 case Model_iPAQ_H36xx:
467 case Model_iPAQ_H37xx: 456 case Model_iPAQ_H37xx:
468 return 128; // really 256, but >128 could damage the LCD 457 return 128; // really 256, but >128 could damage the LCD
469 458
470 case Model_iPAQ_H38xx: 459 case Model_iPAQ_H38xx:
471 case Model_iPAQ_H39xx: 460 case Model_iPAQ_H39xx:
472 return 64; 461 return 64;
473 case Model_iPAQ_H5xxx: 462 case Model_iPAQ_H5xxx:
474 case Model_iPAQ_HX4700: 463 case Model_iPAQ_HX4700:
475 case Model_iPAQ_H4xxx: 464 case Model_iPAQ_H4xxx:
476 return 255; 465 return 255;
477 case Model_iPAQ_H191x: 466 case Model_iPAQ_H191x:
478 return 7; 467 return 7;
479 case Model_iPAQ_H1940: 468 case Model_iPAQ_H1940:
480 return 44; 469 return 44;
481 default: 470 default:
482 return 2; 471 return 2;
483 } 472 }
484} 473}
485 474
486bool iPAQ::setDisplayStatus ( bool on ) 475bool iPAQ::setDisplayStatus ( bool on )
487{ 476{
488 bool res = false; 477 bool res = false;
489 478
490 QString cmdline; 479 QString cmdline;
491 480
492 if ( model() == Model_iPAQ_H191x ) { 481 if ( model() == Model_iPAQ_H191x ) {
493 QDir sysClass( "/sys/class/lcd/pxafb/" ); 482 QDir sysClass( "/sys/class/lcd/pxafb/" );
494 sysClass.setFilter(QDir::Dirs); 483 sysClass.setFilter(QDir::Dirs);
495 if ( sysClass.exists() ) { 484 if ( sysClass.exists() ) {
496 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" ); 485 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
497 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 486 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
498 if ( fd ) { 487 if ( fd ) {
499 char buf[10]; 488 char buf[10];
500 buf[0] = on ? 0 : 4; 489 buf[0] = on ? 0 : 4;
501 buf[1] = '\0'; 490 buf[1] = '\0';
502 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 491 res = ( ::write( fd, &buf[0], 2 ) == 0 );
503 ::close( fd ); 492 ::close( fd );
504 } 493 }
505 } 494 }
506 return res; 495 return res;
507 } else { 496 } else {
508 return OAbstractMobileDevice::setDisplayStatus(on); 497 return OAbstractMobileDevice::setDisplayStatus(on);
509 } 498 }
510 499
511 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 500 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
512 501
513 return res; 502 return res;
514} 503}
515 504
516bool iPAQ::hasLightSensor() const 505bool iPAQ::hasLightSensor() const
517{ 506{
518 switch (model()) { 507 switch (model()) {
519 case Model_iPAQ_H191x: 508 case Model_iPAQ_H191x:
520 case Model_iPAQ_H4xxx: 509 case Model_iPAQ_H4xxx:
521 return false; 510 return false;
522 default: 511 default:
523 return true; 512 return true;
524 } 513 }
525} 514}
526 515
527int iPAQ::readLightSensor() 516int iPAQ::readLightSensor()
528{ 517{
529 int fd; 518 int fd;
530 int val = -1; 519 int val = -1;
531 520
532 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 521 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
533 char buffer [8]; 522 char buffer [8];
534 523
535 if ( ::read ( fd, buffer, 5 ) == 5 ) { 524 if ( ::read ( fd, buffer, 5 ) == 5 ) {
536 char *endptr; 525 char *endptr;
537 526
538 buffer [4] = 0; 527 buffer [4] = 0;
539 val = ::strtol ( buffer + 2, &endptr, 16 ); 528 val = ::strtol ( buffer + 2, &endptr, 16 );
540 529
541 if ( *endptr != 0 ) 530 if ( *endptr != 0 )
542 val = -1; 531 val = -1;
543 } 532 }
544 ::close ( fd ); 533 ::close ( fd );
545 } 534 }
546 535
547 return val; 536 return val;
548} 537}
549 538
550int iPAQ::lightSensorResolution() const 539int iPAQ::lightSensorResolution() const
551{ 540{
552 return 256; 541 return 256;
553} 542}
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp
index 7eb8d1d..208be46 100644
--- a/libopie2/opiecore/device/odevice_mypal.cpp
+++ b/libopie2/opiecore/device/odevice_mypal.cpp
@@ -1,265 +1,268 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "odevice_mypal.h" 30#include "odevice_mypal.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qtextstream.h> 36#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38 38
39/* OPIE */ 39/* OPIE */
40#include <qpe/config.h> 40#include <qpe/config.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#include <opie2/okeyfilter.h> 44#include <opie2/okeyfilter.h>
45#include <opie2/oresource.h> 45#include <opie2/oresource.h>
46 46
47/* STD */ 47/* STD */
48#include <fcntl.h> 48#include <fcntl.h>
49#include <math.h> 49#include <math.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <signal.h> 51#include <signal.h>
52#include <sys/ioctl.h> 52#include <sys/ioctl.h>
53#include <sys/time.h> 53#include <sys/time.h>
54#include <unistd.h> 54#include <unistd.h>
55#ifndef QT_NO_SOUND 55#ifndef QT_NO_SOUND
56#include <linux/soundcard.h> 56#include <linux/soundcard.h>
57#endif 57#endif
58 58
59 59
60using namespace Opie::Core; 60using namespace Opie::Core;
61using namespace Opie::Core::Internal; 61using namespace Opie::Core::Internal;
62 62
63#define Model_Keyboardless_2_6 (Model_MyPal_716)
64
63struct m_button mypal_buttons [] = { 65struct m_button mypal_buttons [] = {
64 { Model_MyPal_716, 66 // Common button map for all keyboardless devices with 2.6 kernel
67 { Model_Keyboardless_2_6,
65 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 68 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
66 "devicebuttons/ipaq_calendar", 69 "devicebuttons/ipaq_calendar",
67 "datebook", "nextView()", 70 "datebook", "nextView()",
68 "today", "raise()" }, 71 "today", "raise()" },
69 { Model_MyPal_716, 72 { Model_Keyboardless_2_6,
70 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 73 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
71 "devicebuttons/ipaq_contact", 74 "devicebuttons/ipaq_contact",
72 "addressbook", "raise()", 75 "addressbook", "raise()",
73 "addressbook", "beamBusinessCard()" }, 76 "addressbook", "beamBusinessCard()" },
74 { Model_MyPal_716, 77 { Model_Keyboardless_2_6,
75 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"), 78 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
76 "devicebuttons/ipaq_mail", 79 "devicebuttons/ipaq_mail",
77 "opiemail", "raise()", 80 "opiemail", "raise()",
78 "opiemail", "newMail()" }, 81 "opiemail", "newMail()" },
79 { Model_MyPal_716, 82 { Model_Keyboardless_2_6,
80 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 83 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
81 "devicebuttons/ipaq_home", 84 "devicebuttons/ipaq_home",
82 "QPE/Launcher", "home()", 85 "QPE/Launcher", "home()",
83 "buttonsettings", "raise()" }, 86 "buttonsettings", "raise()" },
84 { Model_MyPal_716, 87 { Model_Keyboardless_2_6,
85 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"), 88 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
86 "devicebuttons/ipaq_record", 89 "devicebuttons/ipaq_record",
87 "QPE/VMemo", "toggleRecord()", 90 "QPE/VMemo", "toggleRecord()",
88 "sound", "raise()" }, 91 "sound", "raise()" },
89}; 92};
90 93
91void MyPal::init(const QString& model) 94void MyPal::init(const QString& model)
92{ 95{
93 d->m_vendorstr = "Asus"; 96 d->m_vendorstr = "Asus";
94 d->m_vendor = Vendor_Asus; 97 d->m_vendor = Vendor_Asus;
95 98
96 d->m_modelstr = model.mid(model.findRev('A')); 99 d->m_modelstr = model.mid(model.findRev('A'));
97 if ( d->m_modelstr == "A716" ) 100 if ( d->m_modelstr == "A716" )
98 d->m_model = Model_MyPal_716; 101 d->m_model = Model_MyPal_716;
99 else 102 else
100 d->m_model = Model_Unknown; 103 d->m_model = Model_Unknown;
101 104
102 d->m_rotation = Rot0; 105 d->m_rotation = Rot0;
103 106
104 m_power_timer = 0; 107 m_power_timer = 0;
105} 108}
106 109
107void MyPal::initButtons() 110void MyPal::initButtons()
108{ 111{
109 if ( d->m_buttons ) 112 if ( d->m_buttons )
110 return; 113 return;
111 114
112 if ( isQWS( ) ) { 115 if ( isQWS( ) ) {
113 addPreHandler(this); 116 addPreHandler(this);
114 } 117 }
115 118
116 d->m_buttons = new QValueList <ODeviceButton>; 119 d->m_buttons = new QValueList <ODeviceButton>;
117 120
118 for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) { 121 for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) {
119 m_button *mb = mypal_buttons + i; 122 m_button *mb = mypal_buttons + i;
120 ODeviceButton b; 123 ODeviceButton b;
121 124
122 if (( mb->model & d->m_model ) == d->m_model ) { 125 if (( mb->model & d->m_model ) == d->m_model ) {
123 b. setKeycode ( mb->code ); 126 b. setKeycode ( mb->code );
124 b. setUserText ( QObject::tr ( "Button", mb->utext )); 127 b. setUserText ( QObject::tr ( "Button", mb->utext ));
125 b. setPixmap ( OResource::loadPixmap ( mb->pix )); 128 b. setPixmap ( OResource::loadPixmap ( mb->pix ));
126 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction )); 129 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction ));
127 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction )); 130 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction ));
128 131
129 d->m_buttons->append ( b ); 132 d->m_buttons->append ( b );
130 } 133 }
131 } 134 }
132 reloadButtonMapping(); 135 reloadButtonMapping();
133} 136}
134 137
135bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 138bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
136{ 139{
137 int newkeycode = keycode; 140 int newkeycode = keycode;
138 141
139 switch ( keycode ) { 142 switch ( keycode ) {
140 case Key_Left : 143 case Key_Left :
141 case Key_Right: 144 case Key_Right:
142 case Key_Up : 145 case Key_Up :
143 case Key_Down : { 146 case Key_Down : {
144 // Rotate the cursor keys by 270 147 // Rotate the cursor keys by 270
145 // keycode - Key_Left = position of the button starting from left clockwise 148 // keycode - Key_Left = position of the button starting from left clockwise
146 // add the rotation to it and modolo. No we've the original offset 149 // add the rotation to it and modolo. No we've the original offset
147 // add the offset to the Key_Left key 150 // add the offset to the Key_Left key
148 if ( d->m_model == Model_MyPal_716 ) 151 if ( d->m_model == Model_MyPal_716 )
149 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 152 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
150 break; 153 break;
151 } 154 }
152 155
153 // map Power Button short/long press to F6 156 // map Power Button short/long press to F6
154 case Key_F6: { 157 case Key_F6: {
155 if ( isPress ) { 158 if ( isPress ) {
156 if ( m_power_timer ) 159 if ( m_power_timer )
157 killTimer ( m_power_timer ); 160 killTimer ( m_power_timer );
158 m_power_timer = startTimer ( 500 ); 161 m_power_timer = startTimer ( 500 );
159 } 162 }
160 else if ( m_power_timer ) { 163 else if ( m_power_timer ) {
161 killTimer ( m_power_timer ); 164 killTimer ( m_power_timer );
162 m_power_timer = 0; 165 m_power_timer = 0;
163 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 166 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
164 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 167 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
165 } 168 }
166 newkeycode = Key_unknown; 169 newkeycode = Key_unknown;
167 break; 170 break;
168 } 171 }
169 } 172 }
170 173
171 if ( newkeycode != keycode ) { 174 if ( newkeycode != keycode ) {
172 if ( newkeycode != Key_unknown ) 175 if ( newkeycode != Key_unknown )
173 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 176 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
174 return true; 177 return true;
175 } 178 }
176 else 179 else
177 return false; 180 return false;
178} 181}
179 182
180void MyPal::timerEvent ( QTimerEvent * ) 183void MyPal::timerEvent ( QTimerEvent * )
181{ 184{
182 killTimer ( m_power_timer ); 185 killTimer ( m_power_timer );
183 m_power_timer = 0; 186 m_power_timer = 0;
184 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 187 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
185 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 188 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
186} 189}
187 190
188 191
189void MyPal::playAlarmSound() 192void MyPal::playAlarmSound()
190{ 193{
191#ifndef QT_NO_SOUND 194#ifndef QT_NO_SOUND
192 static Sound snd ( "alarm" ); 195 static Sound snd ( "alarm" );
193 if(!snd.isFinished()) 196 if(!snd.isFinished())
194 return; 197 return;
195 198
196 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 199 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
197 snd. play(); 200 snd. play();
198#endif 201#endif
199} 202}
200 203
201bool MyPal::setDisplayBrightness ( int bright ) 204bool MyPal::setDisplayBrightness ( int bright )
202{ 205{
203 bool res = false; 206 bool res = false;
204 207
205 if ( bright > 255 ) 208 if ( bright > 255 )
206 bright = 255; 209 bright = 255;
207 if ( bright < 0 ) 210 if ( bright < 0 )
208 bright = 0; 211 bright = 0;
209 212
210 QDir sysClass( "/sys/class/backlight/pxafb/" ); 213 QDir sysClass( "/sys/class/backlight/pxafb/" );
211 sysClass.setFilter(QDir::Dirs); 214 sysClass.setFilter(QDir::Dirs);
212 int fd; 215 int fd;
213 if ( sysClass.exists() ) { 216 if ( sysClass.exists() ) {
214 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); 217 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
215 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 218 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
216 if ( fd ) { 219 if ( fd ) {
217 char buf[10]; 220 char buf[10];
218 buf[0] = bright ? 0 : 4; 221 buf[0] = bright ? 0 : 4;
219 buf[1] = '\0'; 222 buf[1] = '\0';
220 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 223 res = ( ::write( fd, &buf[0], 2 ) == 0 );
221 ::close( fd ); 224 ::close( fd );
222 } 225 }
223 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" ); 226 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
224 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 227 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
225 if ( fd ) { 228 if ( fd ) {
226 char buf[100]; 229 char buf[100];
227 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright ); 230 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
228 res = ( ::write( fd, &buf[0], len ) == 0 ); 231 res = ( ::write( fd, &buf[0], len ) == 0 );
229 ::close( fd ); 232 ::close( fd );
230 } 233 }
231 } 234 }
232 235
233 return res; 236 return res;
234} 237}
235 238
236int MyPal::displayBrightnessResolution() const 239int MyPal::displayBrightnessResolution() const
237{ 240{
238 switch ( model()) { 241 switch ( model()) {
239 case Model_MyPal_716: 242 case Model_MyPal_716:
240 return 7; 243 return 7;
241 default: 244 default:
242 return OAbstractMobileDevice::displayBrightnessResolution(); 245 return OAbstractMobileDevice::displayBrightnessResolution();
243 } 246 }
244} 247}
245 248
246bool MyPal::setDisplayStatus ( bool on ) 249bool MyPal::setDisplayStatus ( bool on )
247{ 250{
248 bool res = false; 251 bool res = false;
249 252
250 QDir sysClass( "/sys/class/lcd/" ); 253 QDir sysClass( "/sys/class/lcd/" );
251 sysClass.setFilter(QDir::Dirs); 254 sysClass.setFilter(QDir::Dirs);
252 if ( sysClass.exists() ) { 255 if ( sysClass.exists() ) {
253 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" ); 256 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
254 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 257 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
255 if ( fd ) { 258 if ( fd ) {
256 char buf[10]; 259 char buf[10];
257 buf[0] = on ? 0 : 4; 260 buf[0] = on ? 0 : 4;
258 buf[1] = '\0'; 261 buf[1] = '\0';
259 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 262 res = ( ::write( fd, &buf[0], 2 ) == 0 );
260 ::close( fd ); 263 ::close( fd );
261 } 264 }
262 } 265 }
263 266
264 return res; 267 return res;
265} 268}