summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
Unidiff
Diffstat (limited to 'libopie2/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.h1
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp47
2 files changed, 42 insertions, 6 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index c2fa411..a8362cd 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -50,48 +50,49 @@ namespace Opie{
50namespace Core{ 50namespace Core{
51 51
52class ODeviceData; 52class ODeviceData;
53/** 53/**
54 * The available devices 54 * The available devices
55 */ 55 */
56enum OModel { 56enum OModel {
57 Model_Unknown, // = 0 57 Model_Unknown, // = 0
58 58
59 Model_Series_Mask = 0xffff0000, 59 Model_Series_Mask = 0xffff0000,
60 60
61 Model_iPAQ = ( 1 << 16 ), 61 Model_iPAQ = ( 1 << 16 ),
62 62
63 Model_iPAQ_All = ( Model_iPAQ | 0xffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffff ),
64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ),
65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ),
66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ),
67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ),
68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ),
69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ),
70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ),
71 Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), 71 Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ),
72 Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), 72 Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ),
73 Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ), 73 Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ),
74 Model_iPAQ_H4xxx = ( Model_iPAQ | 0x000b ),
74 Model_Jornada = ( 6 << 16 ), 75 Model_Jornada = ( 6 << 16 ),
75 Model_Jornada_56x = ( Model_Jornada | 0x0001 ), 76 Model_Jornada_56x = ( Model_Jornada | 0x0001 ),
76 Model_Jornada_720 = ( Model_Jornada | 0x0002 ), 77 Model_Jornada_720 = ( Model_Jornada | 0x0002 ),
77 Model_Jornada_820 = ( Model_Jornada | 0x0003 ), 78 Model_Jornada_820 = ( Model_Jornada | 0x0003 ),
78 79
79 Model_Zaurus = ( 2 << 16 ), 80 Model_Zaurus = ( 2 << 16 ),
80 81
81 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), 82 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ),
82 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), 83 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ),
83 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), 84 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ),
84 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), 85 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ),
85 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), 86 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ),
86 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ), 87 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ),
87 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ), 88 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ),
88 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ), 89 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ),
89 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ), 90 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ),
90 91
91 Model_SIMpad = ( 3 << 16 ), 92 Model_SIMpad = ( 3 << 16 ),
92 93
93 Model_SIMpad_All = ( Model_SIMpad | 0xffff ), 94 Model_SIMpad_All = ( Model_SIMpad | 0xffff ),
94 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), 95 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ),
95 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), 96 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ),
96 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), 97 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ),
97 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), 98 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ),
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 63b60a7..00939bf 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -64,133 +64,164 @@ using namespace Opie::Core::Internal;
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
87struct i_button ipaq_buttons [] = { 87struct 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, 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,
89 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 89 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
90 "devicebuttons/ipaq_calendar", 90 "devicebuttons/ipaq_calendar",
91 "datebook", "nextView()", 91 "datebook", "nextView()",
92 "today", "raise()" }, 92 "today", "raise()" },
93 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 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,
94 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 94 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
95 "devicebuttons/ipaq_contact", 95 "devicebuttons/ipaq_contact",
96 "addressbook", "raise()", 96 "addressbook", "raise()",
97 "addressbook", "beamBusinessCard()" }, 97 "addressbook", "beamBusinessCard()" },
98 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 98 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
99 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 99 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
100 "devicebuttons/ipaq_menu", 100 "devicebuttons/ipaq_menu",
101 "QPE/TaskBar", "toggleMenu()", 101 "QPE/TaskBar", "toggleMenu()",
102 "QPE/TaskBar", "toggleStartMenu()" }, 102 "QPE/TaskBar", "toggleStartMenu()" },
103 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 103 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
104 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 104 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
105 "devicebuttons/ipaq_mail", 105 "devicebuttons/ipaq_mail",
106 "opiemail", "raise()", 106 "opiemail", "raise()",
107 "opiemail", "newMail()" }, 107 "opiemail", "newMail()" },
108 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, 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,
109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
110 "devicebuttons/ipaq_home", 110 "devicebuttons/ipaq_home",
111 "QPE/Launcher", "home()", 111 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 112 "buttonsettings", "raise()" },
113 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 113 { 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"), 114 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
115 "devicebuttons/ipaq_record", 115 "devicebuttons/ipaq_record",
116 "QPE/VMemo", "toggleRecord()", 116 "QPE/VMemo", "toggleRecord()",
117 "sound", "raise()" }, 117 "sound", "raise()" },
118 118
119 { Model_iPAQ_H191x, 119 { Model_iPAQ_H191x | Model_iPAQ_H4xxx,
120 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"), 120 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"),
121 "devicebuttons/ipaq_mail", 121 "devicebuttons/ipaq_mail",
122 "opiemail", "raise()", 122 "opiemail", "raise()",
123 "opiemail", "newMail()" }, 123 "opiemail", "newMail()" },
124 { Model_iPAQ_H191x, 124 { Model_iPAQ_H191x | Model_iPAQ_H4xxx,
125 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"), 125 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"),
126 "devicebuttons/ipaq_record", 126 "devicebuttons/ipaq_record",
127 "QPE/VMemo", "toggleRecord()", 127 "QPE/VMemo", "toggleRecord()",
128 "sound", "raise()" }, 128 "sound", "raise()" },
129 129
130 //h2200 has different button mapping
131 { Model_iPAQ_H22xx,
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",
139 "QPE/TaskBar", "toggleMenu()",
140 "QPE/TaskBar", "toggleStartMenu()" },
141 // and hx4700 has different button mapping still
142 { Model_iPAQ_HX4700,
143 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
144 "devicebuttons/ipaq_mail",
145 "opiemail", "raise()",
146 "opiemail", "newMail()" },
147 { Model_iPAQ_HX4700,
148 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record 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",
155 "QPE/Launcher", "home()",
156 "buttonsettings", "raise()" },
157
130}; 158};
131 159
132void iPAQ::init(const QString& model) 160void iPAQ::init(const QString& model)
133{ 161{
134 d->m_vendorstr = "HP"; 162 d->m_vendorstr = "HP";
135 d->m_vendor = Vendor_HP; 163 d->m_vendor = Vendor_HP;
136 164
137 d->m_modelstr = model.mid(model.findRev('H')); 165 d->m_modelstr = model.mid(model.findRev('H'));
138 166
139 if ( d->m_modelstr == "H3100" ) 167 if ( d->m_modelstr == "H3100" )
140 d->m_model = Model_iPAQ_H31xx; 168 d->m_model = Model_iPAQ_H31xx;
141 else if ( d->m_modelstr == "H3600" ) 169 else if ( d->m_modelstr == "H3600" )
142 d->m_model = Model_iPAQ_H36xx; 170 d->m_model = Model_iPAQ_H36xx;
143 else if ( d->m_modelstr == "H3700" ) 171 else if ( d->m_modelstr == "H3700" )
144 d->m_model = Model_iPAQ_H37xx; 172 d->m_model = Model_iPAQ_H37xx;
145 else if ( d->m_modelstr == "H3800" ) 173 else if ( d->m_modelstr == "H3800" )
146 d->m_model = Model_iPAQ_H38xx; 174 d->m_model = Model_iPAQ_H38xx;
147 else if ( d->m_modelstr == "H3900" ) 175 else if ( d->m_modelstr == "H3900" )
148 d->m_model = Model_iPAQ_H39xx; 176 d->m_model = Model_iPAQ_H39xx;
149 else if ( d->m_modelstr == "H5400" ) 177 else if ( d->m_modelstr == "H5400" )
150 d->m_model = Model_iPAQ_H5xxx; 178 d->m_model = Model_iPAQ_H5xxx;
151 else if ( d->m_modelstr == "H2200" ) 179 else if ( d->m_modelstr == "H2200" )
152 d->m_model = Model_iPAQ_H22xx; 180 d->m_model = Model_iPAQ_H22xx;
153 else if ( d->m_modelstr == "H1910" ) 181 else if ( d->m_modelstr == "H1910" )
154 d->m_model = Model_iPAQ_H191x; 182 d->m_model = Model_iPAQ_H191x;
155 else if ( d->m_modelstr == "H1940" ) 183 else if ( d->m_modelstr == "H1940" )
156 d->m_model = Model_iPAQ_H1940; 184 d->m_model = Model_iPAQ_H1940;
157 else if ( d->m_modelstr == "HX4700" ) 185 else if ( d->m_modelstr == "HX4700" )
158 d->m_model = Model_iPAQ_HX4700; 186 d->m_model = Model_iPAQ_HX4700;
187 else if ( d->m_modelstr == "H4000" )
188 d->m_model = Model_iPAQ_H4xxx;
159 189
160 else 190 else
161 d->m_model = Model_Unknown; 191 d->m_model = Model_Unknown;
162 192
163 switch ( d->m_model ) { 193 switch ( d->m_model ) {
164 case Model_iPAQ_H31xx: 194 case Model_iPAQ_H31xx:
165 case Model_iPAQ_H38xx: 195 case Model_iPAQ_H38xx:
166 d->m_rotation = Rot90; 196 d->m_rotation = Rot90;
167 break; 197 break;
168 case Model_iPAQ_H5xxx: 198 case Model_iPAQ_H5xxx:
169 case Model_iPAQ_H22xx: 199 case Model_iPAQ_H22xx:
170 case Model_iPAQ_H191x: 200 case Model_iPAQ_H191x:
171 case Model_iPAQ_H1940: 201 case Model_iPAQ_H1940:
172 case Model_iPAQ_HX4700: 202 case Model_iPAQ_HX4700:
203 case Model_iPAQ_H4xxx:
173 d->m_rotation = Rot0; 204 d->m_rotation = Rot0;
174 break; 205 break;
175 case Model_iPAQ_H36xx: 206 case Model_iPAQ_H36xx:
176 case Model_iPAQ_H37xx: 207 case Model_iPAQ_H37xx:
177 case Model_iPAQ_H39xx: 208 case Model_iPAQ_H39xx:
178 default: 209 default:
179 d->m_rotation = Rot270; 210 d->m_rotation = Rot270;
180 break; 211 break;
181 212
182 } 213 }
183 214
184 m_leds [0] = m_leds [1] = Led_Off; 215 m_leds [0] = m_leds [1] = Led_Off;
185 216
186 m_power_timer = 0; 217 m_power_timer = 0;
187 218
188} 219}
189 220
190void iPAQ::initButtons() 221void iPAQ::initButtons()
191{ 222{
192 if ( d->m_buttons ) 223 if ( d->m_buttons )
193 return; 224 return;
194 225
195 if ( isQWS( ) ) { 226 if ( isQWS( ) ) {
196 addPreHandler(this); 227 addPreHandler(this);
@@ -288,56 +319,57 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b
288 case HardKey_Menu: { 319 case HardKey_Menu: {
289 if (( d->m_model == Model_iPAQ_H38xx ) || 320 if (( d->m_model == Model_iPAQ_H38xx ) ||
290 ( d->m_model == Model_iPAQ_H39xx ) || 321 ( d->m_model == Model_iPAQ_H39xx ) ||
291 ( d->m_model == Model_iPAQ_H5xxx)) { 322 ( d->m_model == Model_iPAQ_H5xxx)) {
292 newkeycode = HardKey_Mail; 323 newkeycode = HardKey_Mail;
293 } 324 }
294 break; 325 break;
295 } 326 }
296 327
297 // Rotate cursor keys 180 or 270 328 // Rotate cursor keys 180 or 270
298 case Key_Left : 329 case Key_Left :
299 case Key_Right: 330 case Key_Right:
300 case Key_Up : 331 case Key_Up :
301 case Key_Down : { 332 case Key_Down : {
302 if (( d->m_model == Model_iPAQ_H31xx ) || 333 if (( d->m_model == Model_iPAQ_H31xx ) ||
303 ( d->m_model == Model_iPAQ_H38xx )) { 334 ( d->m_model == Model_iPAQ_H38xx )) {
304 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 335 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
305 } 336 }
306 // Rotate the cursor keys by 270 337 // Rotate the cursor keys by 270
307 // keycode - Key_Left = position of the button starting from left clockwise 338 // keycode - Key_Left = position of the button starting from left clockwise
308 // add the rotation to it and modolo. No we've the original offset 339 // add the rotation to it and modolo. No we've the original offset
309 // add the offset to the Key_Left key 340 // add the offset to the Key_Left key
310 if (( d->m_model == Model_iPAQ_H5xxx ) || 341 if (( d->m_model == Model_iPAQ_H5xxx ) ||
311 ( d->m_model == Model_iPAQ_H191x ) || 342 ( d->m_model == Model_iPAQ_H191x ) ||
343 ( d->m_model == Model_iPAQ_H4xxx ) ||
312 ( d->m_model == Model_iPAQ_H1940 )) 344 ( d->m_model == Model_iPAQ_H1940 ))
313 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 345 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
314 break; 346 break;
315 } 347 }
316 348
317 // map Power Button short/long press to F6 for h191x 349 // map Power Button short/long press to F6 for h191x
318 case Key_F6: 350 case Key_F6:
319 if ( d->m_model != Model_iPAQ_H191x ) 351 if ( d->m_model != Model_iPAQ_H191x && d->m_model != Model_iPAQ_H4xxx )
320 break; 352 break;
321 // map Power Button short/long press to F34/F35 353 // map Power Button short/long press to F34/F35
322 case Key_SysReq: { 354 case Key_SysReq: {
323 if ( isPress ) { 355 if ( isPress ) {
324 if ( m_power_timer ) 356 if ( m_power_timer )
325 killTimer ( m_power_timer ); 357 killTimer ( m_power_timer );
326 m_power_timer = startTimer ( 500 ); 358 m_power_timer = startTimer ( 500 );
327 } 359 }
328 else if ( m_power_timer ) { 360 else if ( m_power_timer ) {
329 killTimer ( m_power_timer ); 361 killTimer ( m_power_timer );
330 m_power_timer = 0; 362 m_power_timer = 0;
331 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 363 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
332 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 364 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
333 } 365 }
334 newkeycode = Key_unknown; 366 newkeycode = Key_unknown;
335 break; 367 break;
336 } 368 }
337 } 369 }
338 370
339 if ( newkeycode != keycode ) { 371 if ( newkeycode != keycode ) {
340 if ( newkeycode != Key_unknown ) 372 if ( newkeycode != Key_unknown )
341 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 373 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
342 return true; 374 return true;
343 } 375 }
@@ -359,48 +391,49 @@ void iPAQ::playAlarmSound()
359#ifndef QT_NO_SOUND 391#ifndef QT_NO_SOUND
360 static Sound snd ( "alarm" ); 392 static Sound snd ( "alarm" );
361 if(!snd.isFinished()) 393 if(!snd.isFinished())
362 return; 394 return;
363 395
364 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 396 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
365 snd. play(); 397 snd. play();
366#endif 398#endif
367} 399}
368 400
369bool iPAQ::setDisplayBrightness ( int bright ) 401bool iPAQ::setDisplayBrightness ( int bright )
370{ 402{
371 bool res = false; 403 bool res = false;
372 int fd; 404 int fd;
373 405
374 if ( bright > 255 ) 406 if ( bright > 255 )
375 bright = 255; 407 bright = 255;
376 if ( bright < 0 ) 408 if ( bright < 0 )
377 bright = 0; 409 bright = 0;
378 410
379 QString cmdline; 411 QString cmdline;
380 412
381 switch ( model()) { 413 switch ( model()) {
382 case Model_iPAQ_H191x: 414 case Model_iPAQ_H191x:
415 case Model_iPAQ_H4xxx:
383 { 416 {
384 QDir sysClass( "/sys/class/backlight/pxafb/" ); 417 QDir sysClass( "/sys/class/backlight/pxafb/" );
385 sysClass.setFilter(QDir::Dirs); 418 sysClass.setFilter(QDir::Dirs);
386 int fd; 419 int fd;
387 if ( sysClass.exists() ) { 420 if ( sysClass.exists() ) {
388 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); 421 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
389 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 422 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
390 if ( fd ) { 423 if ( fd ) {
391 char buf[10]; 424 char buf[10];
392 buf[0] = bright ? 0 : 4; 425 buf[0] = bright ? 0 : 4;
393 buf[1] = '\0'; 426 buf[1] = '\0';
394 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 427 res = ( ::write( fd, &buf[0], 2 ) == 0 );
395 ::close( fd ); 428 ::close( fd );
396 } 429 }
397 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" ); 430 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
398 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 431 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
399 if ( fd ) { 432 if ( fd ) {
400 char buf[100]; 433 char buf[100];
401 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright ); 434 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
402 res = ( ::write( fd, &buf[0], len ) == 0 ); 435 res = ( ::write( fd, &buf[0], len ) == 0 );
403 ::close( fd ); 436 ::close( fd );
404 } 437 }
405 } 438 }
406 } 439 }
@@ -418,92 +451,94 @@ bool iPAQ::setDisplayBrightness ( int bright )
418 FLITE_IN bl; 451 FLITE_IN bl;
419 bl. mode = 1; 452 bl. mode = 1;
420 bl. pwr = bright ? 1 : 0; 453 bl. pwr = bright ? 1 : 0;
421 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 454 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
422 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 455 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
423 ::close ( fd ); 456 ::close ( fd );
424 } 457 }
425 } 458 }
426 return res; 459 return res;
427} 460}
428 461
429int iPAQ::displayBrightnessResolution() const 462int iPAQ::displayBrightnessResolution() const
430{ 463{
431 switch ( model()) { 464 switch ( model()) {
432 case Model_iPAQ_H31xx: 465 case Model_iPAQ_H31xx:
433 case Model_iPAQ_H36xx: 466 case Model_iPAQ_H36xx:
434 case Model_iPAQ_H37xx: 467 case Model_iPAQ_H37xx:
435 return 128; // really 256, but >128 could damage the LCD 468 return 128; // really 256, but >128 could damage the LCD
436 469
437 case Model_iPAQ_H38xx: 470 case Model_iPAQ_H38xx:
438 case Model_iPAQ_H39xx: 471 case Model_iPAQ_H39xx:
439 return 64; 472 return 64;
440 case Model_iPAQ_H5xxx: 473 case Model_iPAQ_H5xxx:
441 case Model_iPAQ_HX4700: 474 case Model_iPAQ_HX4700:
475 case Model_iPAQ_H4xxx:
442 return 255; 476 return 255;
443 case Model_iPAQ_H191x: 477 case Model_iPAQ_H191x:
444 return 7; 478 return 7;
445 case Model_iPAQ_H1940: 479 case Model_iPAQ_H1940:
446 return 44; 480 return 44;
447 default: 481 default:
448 return 2; 482 return 2;
449 } 483 }
450} 484}
451 485
452bool iPAQ::setDisplayStatus ( bool on ) 486bool iPAQ::setDisplayStatus ( bool on )
453{ 487{
454 bool res = false; 488 bool res = false;
455 489
456 QString cmdline; 490 QString cmdline;
457 491
458 if ( model() == Model_iPAQ_H191x ) { 492 if ( model() == Model_iPAQ_H191x ) {
459 QDir sysClass( "/sys/class/lcd/pxafb/" ); 493 QDir sysClass( "/sys/class/lcd/pxafb/" );
460 sysClass.setFilter(QDir::Dirs); 494 sysClass.setFilter(QDir::Dirs);
461 if ( sysClass.exists() ) { 495 if ( sysClass.exists() ) {
462 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" ); 496 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
463 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 497 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
464 if ( fd ) { 498 if ( fd ) {
465 char buf[10]; 499 char buf[10];
466 buf[0] = on ? 0 : 4; 500 buf[0] = on ? 0 : 4;
467 buf[1] = '\0'; 501 buf[1] = '\0';
468 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 502 res = ( ::write( fd, &buf[0], 2 ) == 0 );
469 ::close( fd ); 503 ::close( fd );
470 } 504 }
471 } 505 }
472 return res; 506 return res;
473 } else { 507 } else {
474 return OAbstractMobileDevice::setDisplayStatus(on); 508 return OAbstractMobileDevice::setDisplayStatus(on);
475 } 509 }
476 510
477 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 511 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
478 512
479 return res; 513 return res;
480} 514}
481 515
482bool iPAQ::hasLightSensor() const 516bool iPAQ::hasLightSensor() const
483{ 517{
484 switch (model()) { 518 switch (model()) {
485 case Model_iPAQ_H191x: 519 case Model_iPAQ_H191x:
520 case Model_iPAQ_H4xxx:
486 return false; 521 return false;
487 default: 522 default:
488 return true; 523 return true;
489 } 524 }
490} 525}
491 526
492int iPAQ::readLightSensor() 527int iPAQ::readLightSensor()
493{ 528{
494 int fd; 529 int fd;
495 int val = -1; 530 int val = -1;
496 531
497 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 532 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
498 char buffer [8]; 533 char buffer [8];
499 534
500 if ( ::read ( fd, buffer, 5 ) == 5 ) { 535 if ( ::read ( fd, buffer, 5 ) == 5 ) {
501 char *endptr; 536 char *endptr;
502 537
503 buffer [4] = 0; 538 buffer [4] = 0;
504 val = ::strtol ( buffer + 2, &endptr, 16 ); 539 val = ::strtol ( buffer + 2, &endptr, 16 );
505 540
506 if ( *endptr != 0 ) 541 if ( *endptr != 0 )
507 val = -1; 542 val = -1;
508 } 543 }
509 ::close ( fd ); 544 ::close ( fd );