summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_simpad.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_simpad.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp47
1 files changed, 9 insertions, 38 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index c6de614..2d0160d 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -217,153 +217,124 @@ QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
217 217
218OLedState SIMpad::ledState ( OLed l ) const 218OLedState SIMpad::ledState ( OLed l ) const
219{ 219{
220 switch ( l ) { 220 switch ( l ) {
221 case Led_Power: 221 case Led_Power:
222 return m_leds [0]; 222 return m_leds [0];
223 //case Led_Mail: 223 //case Led_Mail:
224 // return m_leds [1]; 224 // return m_leds [1];
225 default: 225 default:
226 return Led_Off; 226 return Led_Off;
227 } 227 }
228} 228}
229 229
230bool SIMpad::setLedState ( OLed l, OLedState st ) 230bool SIMpad::setLedState ( OLed l, OLedState st )
231{ 231{
232#if 0 232#if 0
233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
234 234
235 /*TODO Implement this like that: 235 /*TODO Implement this like that:
236 read from cs3 236 read from cs3
237 && with SIMPAD_LED2_ON 237 && with SIMPAD_LED2_ON
238 write to cs3 */ 238 write to cs3 */
239 m_leds [0] = st; 239 m_leds [0] = st;
240 return true; 240 return true;
241 } 241 // }
242 } 242// }
243 } 243#else
244 244 Q_UNUSED( l )
245 Q_UNUSED( st )
245#endif 246#endif
246 return false; 247 return false;
247} 248}
248 249
249 250
250bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 251bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ )
251{ 252{
252 //TODO 253 //TODO
253 return false; 254 return false;
254} 255}
255 256
256void SIMpad::timerEvent ( QTimerEvent * ) 257void SIMpad::timerEvent ( QTimerEvent * )
257{ 258{
258 killTimer ( m_power_timer ); 259 killTimer ( m_power_timer );
259 m_power_timer = 0; 260 m_power_timer = 0;
260 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 262 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
262} 263}
263 264
264 265
265void SIMpad::playAlarmSound() 266void SIMpad::playAlarmSound()
266{ 267{
267#ifndef QT_NO_SOUND 268#ifndef QT_NO_SOUND
268 static Sound snd ( "alarm" ); 269 static Sound snd ( "alarm" );
269 int fd;
270 int vol;
271 bool vol_reset = false;
272
273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
275 Config cfg ( "qpe" );
276 cfg. setGroup ( "Volume" );
277
278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
279 if ( volalarm < 0 )
280 volalarm = 0;
281 else if ( volalarm > 100 )
282 volalarm = 100;
283 volalarm |= ( volalarm << 8 );
284
285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
286 vol_reset = true;
287 }
288 }
289 270
271 /* save as the Sound is static! */
272 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
290 snd. play(); 273 snd. play();
291 while ( !snd. isFinished())
292 qApp->processEvents();
293
294 if ( fd >= 0 ) {
295 if ( vol_reset )
296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
297 ::close ( fd );
298 }
299#endif 274#endif
300} 275}
301 276
302 277
303bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 278bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
304{ 279{
305 qDebug( "ODevice for SIMpad: suspend()" ); 280 qDebug( "ODevice for SIMpad: suspend()" );
306 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 281 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
307 return false; 282 return false;
308 283
309 /* 284 /*
310 * we need to save the screen content 285 * we need to save the screen content
311 * then go to suspend using ODevice::suspend 286 * then go to suspend using ODevice::suspend
312 * and finally restore the screen content 287 * and finally restore the screen content
313 */ 288 */
314 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); 289 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
315 bool res = ODevice::suspend(); 290 bool res = ODevice::suspend();
316 291
317 /* 292 /*
318 * restore 293 * restore
319 */ 294 */
320 if ( res ) 295 if ( res )
321 ::system( "cat /tmp/.buffer > /dev/fb/0" ); 296 ::system( "cat /tmp/.buffer > /dev/fb/0" );
322 297
323 return res; 298 return res;
324} 299}
325 300
326 301
327bool SIMpad::setSoftSuspend ( bool soft ) 302bool SIMpad::setSoftSuspend ( bool soft )
328{ 303{
329 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 304 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
330 return false; 305 return false;
331} 306}
332 307
333 308
334bool SIMpad::setDisplayStatus ( bool on ) 309bool SIMpad::setDisplayStatus ( bool on )
335{ 310{
336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 311 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
337 312
338 bool res = false;
339 int fd;
340 313
341 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 314 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
342 315
343 res = ( ::system( (const char*) cmdline ) == 0 ); 316 return ( ::system( (const char*) cmdline ) == 0 );
344
345 return res;
346} 317}
347 318
348 319
349bool SIMpad::setDisplayBrightness ( int bright ) 320bool SIMpad::setDisplayBrightness ( int bright )
350{ 321{
351 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 322 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
352 bool res = false; 323 bool res = false;
353 int fd; 324 int fd;
354 325
355 if ( bright > 255 ) 326 if ( bright > 255 )
356 bright = 255; 327 bright = 255;
357 if ( bright < 1 ) 328 if ( bright < 1 )
358 bright = 0; 329 bright = 0;
359 330
360 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 331 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
361 int value = 255 - bright; 332 int value = 255 - bright;
362 const int mask = SIMPAD_BACKLIGHT_MASK; 333 const int mask = SIMPAD_BACKLIGHT_MASK;
363 value = value << 8; 334 value = value << 8;
364 value += mask; 335 value += mask;
365 char writeCommand[100]; 336 char writeCommand[100];
366 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); 337 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value );
367 res = ( ::write ( fd, writeCommand, count ) != -1 ); 338 res = ( ::write ( fd, writeCommand, count ) != -1 );
368 ::close ( fd ); 339 ::close ( fd );
369 } 340 }