summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_htc.cpp
Unidiff
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)
213 { 213 {
214 default: 214 default:
215 d->m_qteDriver = "Transformed"; 215 d->m_qteDriver = "Transformed";
216 } 216 }
217 217
218 m_leds[0] = Led_Off; 218 m_leds[0] = Led_Off;
219 219
220 qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); 220 qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr );
221} 221}
222 222
223void HTC::initButtons() 223void HTC::initButtons()
224{ 224{
225 qDebug( "HTC::initButtons()" ); 225 qDebug( "HTC::initButtons()" );
226 if ( d->m_buttons ) 226 if ( d->m_buttons )
227 return; 227 return;
228 228
229 d->m_buttons = new QValueList <ODeviceButton>; 229 d->m_buttons = new QValueList <ODeviceButton>;
230 230
231 struct htc_button * phtc_buttons; 231 struct htc_button * phtc_buttons;
232 int buttoncount; 232 int buttoncount;
233 switch ( d->m_model ) 233 switch ( d->m_model )
234 { 234 {
235 case Model_HTC_Universal: 235 case Model_HTC_Universal:
236 if ( isQWS( ) ) 236 if ( isQWS( ) )
237 { 237 {
238 addPreHandler(this); 238 addPreHandler(this);
239 } 239 }
240 phtc_buttons = htc_buttons_universal; 240 phtc_buttons = htc_buttons_universal;
241 buttoncount = ARRAY_SIZE(htc_buttons_universal); 241 buttoncount = ARRAY_SIZE(htc_buttons_universal);
242 break; 242 break;
243 default: 243 default:
244 phtc_buttons = htc_buttons; 244 phtc_buttons = htc_buttons;
245 buttoncount = ARRAY_SIZE(htc_buttons); 245 buttoncount = ARRAY_SIZE(htc_buttons);
246 break; 246 break;
247 } 247 }
248 248
249 for ( int i = 0; i < buttoncount; i++ ) { 249 for ( int i = 0; i < buttoncount; i++ ) {
250 struct htc_button *zb = phtc_buttons + i; 250 struct htc_button *zb = phtc_buttons + i;
251 ODeviceButton b; 251 ODeviceButton b;
252 252
253 b.setKeycode( zb->code ); 253 b.setKeycode( zb->code );
254 b.setUserText( QObject::tr( "Button", zb->utext )); 254 b.setUserText( QObject::tr( "Button", zb->utext ));
255 b.setPixmap( OResource::loadPixmap( zb->pix )); 255 b.setPixmap( OResource::loadPixmap( zb->pix ));
256 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 256 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
257 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 257 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
258 d->m_buttons->append( b ); 258 d->m_buttons->append( b );
259 } 259 }
260 260
261 reloadButtonMapping(); 261 reloadButtonMapping();
262} 262}
263 263
264 264
265 265
266typedef struct sharp_led_status { 266typedef struct sharp_led_status {
267 int which; /* select which LED status is wanted. */ 267 int which; /* select which LED status is wanted. */
268 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 268 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
269} sharp_led_status; 269} sharp_led_status;
270 270
271void HTC::buzzer( int sound ) 271void HTC::buzzer( int sound )
272{ 272{
273#ifndef QT_NO_SOUND 273#ifndef QT_NO_SOUND
274 Sound *snd = 0; 274 Sound *snd = 0;
275 275
276 // All devices except SL5500 have a DSP device 276 // All devices except SL5500 have a DSP device
277 if ( d->m_model == Model_HTC_Universal ) { 277 if ( d->m_model == Model_HTC_Universal ) {
278 278
279 switch ( sound ){ 279 switch ( sound ){
280 case SHARP_BUZ_TOUCHSOUND: { 280 case SHARP_BUZ_TOUCHSOUND: {
281 static Sound touch_sound("touchsound"); 281 static Sound touch_sound("touchsound");
282 snd = &touch_sound; 282 snd = &touch_sound;
283 } 283 }
284 break; 284 break;
285 case SHARP_BUZ_KEYSOUND: { 285 case SHARP_BUZ_KEYSOUND: {
286 static Sound key_sound( "keysound" ); 286 static Sound key_sound( "keysound" );
287 snd = &key_sound; 287 snd = &key_sound;
288 } 288 }
289 break; 289 break;
290 case SHARP_BUZ_SCHEDULE_ALARM: 290 case SHARP_BUZ_SCHEDULE_ALARM:
291 default: { 291 default: {
292 static Sound alarm_sound("alarm"); 292 static Sound alarm_sound("alarm");
293 snd = &alarm_sound; 293 snd = &alarm_sound;
294 } 294 }
295 break; 295 break;
296 } 296 }
297 } 297 }
298 298
299 // If a soundname is defined, we expect that this device has 299 // If a soundname is defined, we expect that this device has
300 // sound capabilities.. Otherwise we expect to have the buzzer 300 // sound capabilities.. Otherwise we expect to have the buzzer
301 // device.. 301 // device..
302 if ( snd && snd->isFinished() ){ 302 if ( snd && snd->isFinished() ){
303 changeMixerForAlarm( 0, "/dev/mixer", snd ); 303 changeMixerForAlarm( 0, "/dev/mixer", snd );
304 snd->play(); 304 snd->play();
305 } else if( !snd ) { 305 } else if( !snd ) {
306 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 306 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
307 307
308 if ( fd >= 0 ) { 308 if ( fd >= 0 ) {
309 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 309 if (::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ) == -1)
310 qWarning( "HTC::buzzer() - Couldn't make the buzzer buzz (%s)",
311 strerror( errno ) );
310 ::close ( fd ); 312 ::close ( fd );
311 } 313 }
312 314
313 } 315 }
314#endif 316#endif
315} 317}
316 318
317 319
318void HTC::playAlarmSound() 320void HTC::playAlarmSound()
319{ 321{
320 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 322 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
321} 323}
322 324
323void HTC::playTouchSound() 325void HTC::playTouchSound()
324{ 326{
325 buzzer( SHARP_BUZ_TOUCHSOUND ); 327 buzzer( SHARP_BUZ_TOUCHSOUND );
326} 328}
327 329
328void HTC::playKeySound() 330void HTC::playKeySound()
329{ 331{
330 buzzer( SHARP_BUZ_KEYSOUND ); 332 buzzer( SHARP_BUZ_KEYSOUND );
331} 333}
332 334
333 335
334QValueList <OLed> HTC::ledList() const 336QValueList <OLed> HTC::ledList() const
335{ 337{
336 QValueList <OLed> vl; 338 QValueList <OLed> vl;
337 vl << Led_Mail; 339 vl << Led_Mail;
338 return vl; 340 return vl;
339} 341}
340 342
341QValueList <OLedState> HTC::ledStateList( OLed l ) const 343QValueList <OLedState> HTC::ledStateList( OLed l ) const
342{ 344{
343 QValueList <OLedState> vl; 345 QValueList <OLedState> vl;
344 346
345 if ( l == Led_Mail ) 347 if ( l == Led_Mail )
346 vl << Led_Off << Led_On << Led_BlinkSlow; 348 vl << Led_Off << Led_On << Led_BlinkSlow;
347 return vl; 349 return vl;
348} 350}
349 351
350OLedState HTC::ledState( OLed which ) const 352OLedState HTC::ledState( OLed which ) const
351{ 353{
352 if ( which == Led_Mail ) 354 if ( which == Led_Mail )
353 return m_leds [0]; 355 return m_leds [0];
354 else 356 else
355 return Led_Off; 357 return Led_Off;
356} 358}
357 359
358bool HTC::setLedState( OLed, OLedState ) 360bool HTC::setLedState( OLed, OLedState )
359{ 361{
360 qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); 362 qDebug( "HTC::setLedState: ODevice handling not yet implemented" );
361 return false; 363 return false;
362} 364}
363 365
364int HTC::displayBrightnessResolution() const 366int HTC::displayBrightnessResolution() const
365{ 367{
366 int res = 1; 368 int res = 1;
367 369
368 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); 370 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
369 371
370 if ( fd ) 372 if ( fd )
371 { 373 {
372 char buf[100]; 374 char buf[100];
373 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 375 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
374 ::close( fd ); 376 ::close( fd );
375 } 377 }
376 378
377 return res; 379 return res;
378} 380}
379 381
380bool HTC::setDisplayBrightness( int bright ) 382bool HTC::setDisplayBrightness( int bright )
381{ 383{
382 384
383 //qDebug( "HTC::setDisplayBrightness( %d )", bright ); 385 //qDebug( "HTC::setDisplayBrightness( %d )", bright );
384 bool res = false; 386 bool res = false;
385 387
386 if ( bright > 255 ) bright = 255; 388 if ( bright > 255 ) bright = 255;
387 if ( bright < 0 ) bright = 0; 389 if ( bright < 0 ) bright = 0;
388 390
389 int numberOfSteps = displayBrightnessResolution(); 391 int numberOfSteps = displayBrightnessResolution();
390 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 392 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
391 393
392 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); 394 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
393 if ( fd ) 395 if ( fd )
394 { 396 {
395 char buf[100]; 397 char buf[100];
396 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 398 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
397 res = ( ::write( fd, &buf[0], len ) == 0 ); 399 res = ( ::write( fd, &buf[0], len ) == 0 );
398 ::close( fd ); 400 ::close( fd );
399 } 401 }
400 return res; 402 return res;
401} 403}
402 404
403bool HTC::setDisplayStatus( bool on ) 405bool HTC::setDisplayStatus( bool on )
404{ 406{
405 407