summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device
authorerik <erik>2007-01-29 21:53:48 (UTC)
committer erik <erik>2007-01-29 21:53:48 (UTC)
commit02ef45be75a3024df11365956e1cce6392d9103c (patch) (unidiff)
tree42fd5c909d67a473f57a607e01d32e01b3dd2511 /libopie2/opiecore/device
parentb2c306a99b8dc82c981390f02db859149fac8cf0 (diff)
downloadopie-02ef45be75a3024df11365956e1cce6392d9103c.zip
opie-02ef45be75a3024df11365956e1cce6392d9103c.tar.gz
opie-02ef45be75a3024df11365956e1cce6392d9103c.tar.bz2
Each file in this commit has an issue where the initial value of a variable
is assumed to be something but no initial value is given. This commit changes that by either assigning an initial value or removing the assumption on an initial value (usually the former).
Diffstat (limited to 'libopie2/opiecore/device') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_htc.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp
index c21e10d..4e5200b 100644
--- a/libopie2/opiecore/device/odevice_htc.cpp
+++ b/libopie2/opiecore/device/odevice_htc.cpp
@@ -375,106 +375,105 @@ int HTC::displayBrightnessResolution() const
375 } 375 }
376 376
377 return res; 377 return res;
378} 378}
379 379
380bool HTC::setDisplayBrightness( int bright ) 380bool HTC::setDisplayBrightness( int bright )
381{ 381{
382 382
383 //qDebug( "HTC::setDisplayBrightness( %d )", bright ); 383 //qDebug( "HTC::setDisplayBrightness( %d )", bright );
384 bool res = false; 384 bool res = false;
385 385
386 if ( bright > 255 ) bright = 255; 386 if ( bright > 255 ) bright = 255;
387 if ( bright < 0 ) bright = 0; 387 if ( bright < 0 ) bright = 0;
388 388
389 int numberOfSteps = displayBrightnessResolution(); 389 int numberOfSteps = displayBrightnessResolution();
390 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 390 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
391 391
392 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); 392 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
393 if ( fd ) 393 if ( fd )
394 { 394 {
395 char buf[100]; 395 char buf[100];
396 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 396 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
397 res = ( ::write( fd, &buf[0], len ) == 0 ); 397 res = ( ::write( fd, &buf[0], len ) == 0 );
398 ::close( fd ); 398 ::close( fd );
399 } 399 }
400 return res; 400 return res;
401} 401}
402 402
403bool HTC::setDisplayStatus( bool on ) 403bool HTC::setDisplayStatus( bool on )
404{ 404{
405 405
406 bool res = false; 406 bool res = false;
407 407
408 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); 408 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
409 if ( fd ) 409 if ( fd )
410 { 410 {
411 char buf[10]; 411 char buf[10];
412 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 412 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
413 buf[1] = '\0'; 413 buf[1] = '\0';
414 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 414 res = ( ::write( fd, &buf[0], 2 ) == 0 );
415 ::close( fd ); 415 ::close( fd );
416 } 416 }
417 return res; 417 return res;
418} 418}
419 419
420Transformation HTC::rotation() const 420Transformation HTC::rotation() const
421{ 421{
422 qDebug( "HTC::rotation()" ); 422 qDebug( "HTC::rotation()" );
423 Transformation rot; 423 Transformation rot = Rot270;
424 424
425 switch ( d->m_model ) { 425 switch ( d->m_model ) {
426 case Model_HTC_Universal: 426 case Model_HTC_Universal:
427 { 427 {
428 OHingeStatus hs = readHingeSensor(); 428 OHingeStatus hs = readHingeSensor();
429 qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); 429 qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs );
430 if ( hs == CASE_PORTRAIT ) rot = Rot0; 430 if ( hs == CASE_PORTRAIT ) rot = Rot0;
431 else if ( hs == CASE_UNKNOWN ) rot = Rot270; 431 else if ( hs == CASE_UNKNOWN ) rot = Rot270;
432 else rot = Rot270;
433 } 432 }
434 break; 433 break;
435 } 434 }
436 435
437 qDebug( "HTC::rotation() - returning '%d'", rot ); 436 qDebug( "HTC::rotation() - returning '%d'", rot );
438 return rot; 437 return rot;
439} 438}
440ODirection HTC::direction() const 439ODirection HTC::direction() const
441{ 440{
442 ODirection dir; 441 ODirection dir;
443 442
444 switch ( d->m_model ) { 443 switch ( d->m_model ) {
445 case Model_HTC_Universal: { 444 case Model_HTC_Universal: {
446 OHingeStatus hs = readHingeSensor(); 445 OHingeStatus hs = readHingeSensor();
447 if ( hs == CASE_PORTRAIT ) dir = CCW; 446 if ( hs == CASE_PORTRAIT ) dir = CCW;
448 else if ( hs == CASE_UNKNOWN ) dir = CCW; 447 else if ( hs == CASE_UNKNOWN ) dir = CCW;
449 else dir = CW; 448 else dir = CW;
450 } 449 }
451 break; 450 break;
452 default: dir = d->m_direction; 451 default: dir = d->m_direction;
453 break; 452 break;
454 } 453 }
455 return dir; 454 return dir;
456 455
457} 456}
458 457
459bool HTC::hasHingeSensor() const 458bool HTC::hasHingeSensor() const
460{ 459{
461 return d->m_model == Model_HTC_Universal; 460 return d->m_model == Model_HTC_Universal;
462} 461}
463 462
464OHingeStatus HTC::readHingeSensor() const 463OHingeStatus HTC::readHingeSensor() const
465{ 464{
466 /* 465 /*
467 * The HTC Universal keyboard is event source 1 in kernel 2.6. 466 * The HTC Universal keyboard is event source 1 in kernel 2.6.
468 * Hinge status is reported via Input System Switchs 0 and 1 like that: 467 * Hinge status is reported via Input System Switchs 0 and 1 like that:
469 * 468 *
470 * ------------------------- 469 * -------------------------
471 * | SW0 | SW1 | CASE | 470 * | SW0 | SW1 | CASE |
472 * |-----|-----|-----------| 471 * |-----|-----|-----------|
473 * | 0 0 Unknown | 472 * | 0 0 Unknown |
474 * | 1 0 Portrait | 473 * | 1 0 Portrait |
475 * | 0 1 Closed | 474 * | 0 1 Closed |
476 * | 1 1 Landscape | 475 * | 1 1 Landscape |
477 * ------------------------- 476 * -------------------------
478 */ 477 */
479 OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); 478 OInputDevice* keyboard = OInputSystem::instance()->device( "event1" );
480 bool switch0 = true; 479 bool switch0 = true;