summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_htc.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/device/odevice_htc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_htc.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp
index 44b33c0..7f82369 100644
--- a/libopie2/opiecore/device/odevice_htc.cpp
+++ b/libopie2/opiecore/device/odevice_htc.cpp
@@ -213,193 +213,195 @@ void HTC::init(const QString& cpu_info)
{
default:
d->m_qteDriver = "Transformed";
}
m_leds[0] = Led_Off;
qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr );
}
void HTC::initButtons()
{
qDebug( "HTC::initButtons()" );
if ( d->m_buttons )
return;
d->m_buttons = new QValueList <ODeviceButton>;
struct htc_button * phtc_buttons;
int buttoncount;
switch ( d->m_model )
{
case Model_HTC_Universal:
if ( isQWS( ) )
{
addPreHandler(this);
}
phtc_buttons = htc_buttons_universal;
buttoncount = ARRAY_SIZE(htc_buttons_universal);
break;
default:
phtc_buttons = htc_buttons;
buttoncount = ARRAY_SIZE(htc_buttons);
break;
}
for ( int i = 0; i < buttoncount; i++ ) {
struct htc_button *zb = phtc_buttons + i;
ODeviceButton b;
b.setKeycode( zb->code );
b.setUserText( QObject::tr( "Button", zb->utext ));
b.setPixmap( OResource::loadPixmap( zb->pix ));
b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
d->m_buttons->append( b );
}
reloadButtonMapping();
}
typedef struct sharp_led_status {
int which; /* select which LED status is wanted. */
int status; /* set new led status if you call SHARP_LED_SETSTATUS */
} sharp_led_status;
void HTC::buzzer( int sound )
{
#ifndef QT_NO_SOUND
Sound *snd = 0;
// All devices except SL5500 have a DSP device
if ( d->m_model == Model_HTC_Universal ) {
switch ( sound ){
case SHARP_BUZ_TOUCHSOUND: {
static Sound touch_sound("touchsound");
snd = &touch_sound;
}
break;
case SHARP_BUZ_KEYSOUND: {
static Sound key_sound( "keysound" );
snd = &key_sound;
}
break;
case SHARP_BUZ_SCHEDULE_ALARM:
default: {
static Sound alarm_sound("alarm");
snd = &alarm_sound;
}
break;
}
}
// If a soundname is defined, we expect that this device has
// sound capabilities.. Otherwise we expect to have the buzzer
// device..
if ( snd && snd->isFinished() ){
changeMixerForAlarm( 0, "/dev/mixer", snd );
snd->play();
} else if( !snd ) {
int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
if ( fd >= 0 ) {
- ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
+ if (::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ) == -1)
+ qWarning( "HTC::buzzer() - Couldn't make the buzzer buzz (%s)",
+ strerror( errno ) );
::close ( fd );
}
}
#endif
}
void HTC::playAlarmSound()
{
buzzer( SHARP_BUZ_SCHEDULE_ALARM );
}
void HTC::playTouchSound()
{
buzzer( SHARP_BUZ_TOUCHSOUND );
}
void HTC::playKeySound()
{
buzzer( SHARP_BUZ_KEYSOUND );
}
QValueList <OLed> HTC::ledList() const
{
QValueList <OLed> vl;
vl << Led_Mail;
return vl;
}
QValueList <OLedState> HTC::ledStateList( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Mail )
vl << Led_Off << Led_On << Led_BlinkSlow;
return vl;
}
OLedState HTC::ledState( OLed which ) const
{
if ( which == Led_Mail )
return m_leds [0];
else
return Led_Off;
}
bool HTC::setLedState( OLed, OLedState )
{
qDebug( "HTC::setLedState: ODevice handling not yet implemented" );
return false;
}
int HTC::displayBrightnessResolution() const
{
int res = 1;
int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
if ( fd )
{
char buf[100];
if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
::close( fd );
}
return res;
}
bool HTC::setDisplayBrightness( int bright )
{
//qDebug( "HTC::setDisplayBrightness( %d )", bright );
bool res = false;
if ( bright > 255 ) bright = 255;
if ( bright < 0 ) bright = 0;
int numberOfSteps = displayBrightnessResolution();
int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
if ( fd )
{
char buf[100];
int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
res = ( ::write( fd, &buf[0], len ) == 0 );
::close( fd );
}
return res;
}
bool HTC::setDisplayStatus( bool on )
{