-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 02b685a..6dc1295 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -256,146 +256,142 @@ QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | |||
256 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 256 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
257 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) | 257 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) |
258 | vl << Led_Off; // << Led_On << ??? | 258 | vl << Led_Off; // << Led_On << ??? |
259 | 259 | ||
260 | return vl; | 260 | return vl; |
261 | } | 261 | } |
262 | 262 | ||
263 | OLedState iPAQ::ledState ( OLed l ) const | 263 | OLedState iPAQ::ledState ( OLed l ) const |
264 | { | 264 | { |
265 | switch ( l ) { | 265 | switch ( l ) { |
266 | case Led_Power: | 266 | case Led_Power: |
267 | return m_leds [0]; | 267 | return m_leds [0]; |
268 | case Led_BlueTooth: | 268 | case Led_BlueTooth: |
269 | return m_leds [1]; | 269 | return m_leds [1]; |
270 | default: | 270 | default: |
271 | return Led_Off; | 271 | return Led_Off; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 275 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
276 | { | 276 | { |
277 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 277 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
278 | 278 | ||
279 | if ( l == Led_Power ) { | 279 | if ( l == Led_Power ) { |
280 | if ( fd >= 0 ) { | 280 | if ( fd >= 0 ) { |
281 | LED_IN leds; | 281 | LED_IN leds; |
282 | ::memset ( &leds, 0, sizeof( leds )); | 282 | ::memset ( &leds, 0, sizeof( leds )); |
283 | leds. TotalTime = 0; | 283 | leds. TotalTime = 0; |
284 | leds. OnTime = 0; | 284 | leds. OnTime = 0; |
285 | leds. OffTime = 1; | 285 | leds. OffTime = 1; |
286 | leds. OffOnBlink = 2; | 286 | leds. OffOnBlink = 2; |
287 | 287 | ||
288 | switch ( st ) { | 288 | switch ( st ) { |
289 | case Led_Off : leds. OffOnBlink = 0; break; | 289 | case Led_Off : leds. OffOnBlink = 0; break; |
290 | case Led_On : leds. OffOnBlink = 1; break; | 290 | case Led_On : leds. OffOnBlink = 1; break; |
291 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 291 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
292 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 292 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
293 | } | 293 | } |
294 | 294 | ||
295 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 295 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
296 | m_leds [0] = st; | 296 | m_leds [0] = st; |
297 | return true; | 297 | return true; |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | return false; | 301 | return false; |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 305 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
306 | { | 306 | { |
307 | int newkeycode = keycode; | 307 | int newkeycode = keycode; |
308 | 308 | ||
309 | switch ( keycode ) { | 309 | switch ( keycode ) { |
310 | // 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 |
311 | case HardKey_Menu: { | 311 | case HardKey_Menu: { |
312 | if (( d->m_model == Model_iPAQ_H38xx ) || | 312 | if (( d->m_model == Model_iPAQ_H38xx ) || |
313 | ( d->m_model == Model_iPAQ_H39xx ) || | 313 | ( d->m_model == Model_iPAQ_H39xx ) || |
314 | ( d->m_model == Model_iPAQ_H5xxx)) { | 314 | ( d->m_model == Model_iPAQ_H5xxx)) { |
315 | newkeycode = HardKey_Mail; | 315 | newkeycode = HardKey_Mail; |
316 | } | 316 | } |
317 | break; | 317 | break; |
318 | } | 318 | } |
319 | 319 | ||
320 | // Rotate cursor keys 180 or 270 | 320 | // QT has strange screen coordinate system, so depending |
321 | // on native device screen orientation, we need to rotate cursor keys | ||
321 | case Key_Left : | 322 | case Key_Left : |
322 | case Key_Right: | 323 | case Key_Right: |
323 | case Key_Up : | 324 | case Key_Up : |
324 | case Key_Down : { | 325 | case Key_Down : { |
325 | if (( d->m_model == Model_iPAQ_H31xx ) || | 326 | int quarters; |
326 | ( d->m_model == Model_iPAQ_H38xx )) { | 327 | switch (d->m_rotation) { |
327 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 328 | case Rot0: quarters = 3/*270deg*/; break; |
329 | case Rot90: quarters = 2/*270deg*/; break; | ||
330 | case Rot180: quarters = 1/*270deg*/; break; | ||
331 | case Rot270: quarters = 0/*270deg*/; break; | ||
328 | } | 332 | } |
329 | // Rotate the cursor keys by 270 | 333 | newkeycode = Key_Left + ( keycode - Key_Left + quarters ) % 4; |
330 | // keycode - Key_Left = position of the button starting from left clockwise | ||
331 | // add the rotation to it and modolo. No we've the original offset | ||
332 | // add the offset to the Key_Left key | ||
333 | if (( d->m_model == Model_iPAQ_H5xxx ) || | ||
334 | ( d->m_model == Model_iPAQ_H191x ) || | ||
335 | ( d->m_model == Model_iPAQ_H4xxx ) || | ||
336 | ( d->m_model == Model_iPAQ_H1940 )) | ||
337 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | ||
338 | break; | 334 | break; |
339 | } | 335 | } |
340 | 336 | ||
341 | // map Power Button short/long press to F34/F35 | 337 | // map Power Button short/long press to F34/F35 |
342 | case HardKey_Suspend: // Hope we don't have infinite recursion here | 338 | case HardKey_Suspend: // Hope we don't have infinite recursion here |
343 | case Key_SysReq: { | 339 | case Key_SysReq: { |
344 | if ( isPress ) { | 340 | if ( isPress ) { |
345 | if ( m_power_timer ) | 341 | if ( m_power_timer ) |
346 | killTimer ( m_power_timer ); | 342 | killTimer ( m_power_timer ); |
347 | m_power_timer = startTimer ( 500 ); | 343 | m_power_timer = startTimer ( 500 ); |
348 | } | 344 | } |
349 | else if ( m_power_timer ) { | 345 | else if ( m_power_timer ) { |
350 | killTimer ( m_power_timer ); | 346 | killTimer ( m_power_timer ); |
351 | m_power_timer = 0; | 347 | m_power_timer = 0; |
352 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 348 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
353 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 349 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
354 | } | 350 | } |
355 | newkeycode = Key_unknown; | 351 | newkeycode = Key_unknown; |
356 | break; | 352 | break; |
357 | } | 353 | } |
358 | } | 354 | } |
359 | 355 | ||
360 | if ( newkeycode != keycode ) { | 356 | if ( newkeycode != keycode ) { |
361 | if ( newkeycode != Key_unknown ) | 357 | if ( newkeycode != Key_unknown ) |
362 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 358 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
363 | return true; | 359 | return true; |
364 | } | 360 | } |
365 | else | 361 | else |
366 | return false; | 362 | return false; |
367 | } | 363 | } |
368 | 364 | ||
369 | void iPAQ::timerEvent ( QTimerEvent * ) | 365 | void iPAQ::timerEvent ( QTimerEvent * ) |
370 | { | 366 | { |
371 | killTimer ( m_power_timer ); | 367 | killTimer ( m_power_timer ); |
372 | m_power_timer = 0; | 368 | m_power_timer = 0; |
373 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 369 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
374 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 370 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
375 | } | 371 | } |
376 | 372 | ||
377 | 373 | ||
378 | void iPAQ::playAlarmSound() | 374 | void iPAQ::playAlarmSound() |
379 | { | 375 | { |
380 | #ifndef QT_NO_SOUND | 376 | #ifndef QT_NO_SOUND |
381 | static Sound snd ( "alarm" ); | 377 | static Sound snd ( "alarm" ); |
382 | if(!snd.isFinished()) | 378 | if(!snd.isFinished()) |
383 | return; | 379 | return; |
384 | 380 | ||
385 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 381 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
386 | snd. play(); | 382 | snd. play(); |
387 | #endif | 383 | #endif |
388 | } | 384 | } |
389 | 385 | ||
390 | bool iPAQ::setDisplayBrightness ( int bright ) | 386 | bool iPAQ::setDisplayBrightness ( int bright ) |
391 | { | 387 | { |
392 | bool res = false; | 388 | bool res = false; |
393 | int fd; | 389 | int fd; |
394 | 390 | ||
395 | if ( bright > 255 ) | 391 | if ( bright > 255 ) |
396 | bright = 255; | 392 | bright = 255; |
397 | if ( bright < 0 ) | 393 | if ( bright < 0 ) |
398 | bright = 0; | 394 | bright = 0; |
399 | 395 | ||
400 | QDir sysClass( "/sys/class/backlight/" ); | 396 | QDir sysClass( "/sys/class/backlight/" ); |
401 | sysClass.setFilter(QDir::Dirs); | 397 | sysClass.setFilter(QDir::Dirs); |