-rw-r--r-- | libopie/odevice.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 057c344..bf64676 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -245,150 +245,152 @@ void ODeviceIPAQ::init ( ) | |||
245 | d-> m_model = OMODEL_iPAQ_H37xx; | 245 | d-> m_model = OMODEL_iPAQ_H37xx; |
246 | else if ( d-> m_modelstr == "H3800" ) | 246 | else if ( d-> m_modelstr == "H3800" ) |
247 | d-> m_model = OMODEL_iPAQ_H38xx; | 247 | d-> m_model = OMODEL_iPAQ_H38xx; |
248 | else | 248 | else |
249 | d-> m_model = OMODEL_Unknown; | 249 | d-> m_model = OMODEL_Unknown; |
250 | 250 | ||
251 | f. close ( ); | 251 | f. close ( ); |
252 | } | 252 | } |
253 | 253 | ||
254 | f. setName ( "/etc/familiar-version" ); | 254 | f. setName ( "/etc/familiar-version" ); |
255 | if ( f. open ( IO_ReadOnly )) { | 255 | if ( f. open ( IO_ReadOnly )) { |
256 | d-> m_systemstr = "Familiar"; | 256 | d-> m_systemstr = "Familiar"; |
257 | d-> m_system = OSYSTEM_Familiar; | 257 | d-> m_system = OSYSTEM_Familiar; |
258 | 258 | ||
259 | QTextStream ts ( &f ); | 259 | QTextStream ts ( &f ); |
260 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 260 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
261 | 261 | ||
262 | f. close ( ); | 262 | f. close ( ); |
263 | } | 263 | } |
264 | 264 | ||
265 | d-> m_leds [0] = OLED_Off; | 265 | d-> m_leds [0] = OLED_Off; |
266 | } | 266 | } |
267 | 267 | ||
268 | #include <unistd.h> | 268 | #include <unistd.h> |
269 | #include <fcntl.h> | 269 | #include <fcntl.h> |
270 | #include <sys/ioctl.h> | 270 | #include <sys/ioctl.h> |
271 | #include <signal.h> | 271 | #include <signal.h> |
272 | #include <sys/time.h> | 272 | #include <sys/time.h> |
273 | #include <linux/soundcard.h> | 273 | #include <linux/soundcard.h> |
274 | #include <qapplication.h> | 274 | #include <qapplication.h> |
275 | #include <qpe/config.h> | 275 | #include <qpe/config.h> |
276 | 276 | ||
277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
278 | 278 | ||
279 | typedef struct h3600_ts_led { | 279 | typedef struct h3600_ts_led { |
280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
281 | unsigned char TotalTime; /* Units of 5 seconds */ | 281 | unsigned char TotalTime; /* Units of 5 seconds */ |
282 | unsigned char OnTime; /* units of 100m/s */ | 282 | unsigned char OnTime; /* units of 100m/s */ |
283 | unsigned char OffTime; /* units of 100m/s */ | 283 | unsigned char OffTime; /* units of 100m/s */ |
284 | } LED_IN; | 284 | } LED_IN; |
285 | 285 | ||
286 | 286 | ||
287 | // #define IOC_H3600_TS_MAGIC 'f' | 287 | // #define IOC_H3600_TS_MAGIC 'f' |
288 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) | 288 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) |
289 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( | 289 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( |
290 | 290 | ||
291 | 291 | ||
292 | //#include <linux/apm_bios.h> | 292 | //#include <linux/apm_bios.h> |
293 | 293 | ||
294 | //#define APM_IOC_SUSPEND _IO('A',2) | 294 | //#define APM_IOC_SUSPEND _IO('A',2) |
295 | 295 | ||
296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) | 296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) |
297 | 297 | ||
298 | 298 | ||
299 | void ODeviceIPAQ::tstp_sighandler ( int ) | 299 | void ODeviceIPAQ::tstp_sighandler ( int ) |
300 | { | 300 | { |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | bool ODeviceIPAQ::suspend ( ) | 304 | bool ODeviceIPAQ::suspend ( ) |
305 | { | 305 | { |
306 | int fd; | 306 | int fd; |
307 | bool res = false; | 307 | bool res = false; |
308 | 308 | ||
309 | if (( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) { | 309 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
310 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | ||
310 | struct timeval tvs, tvn; | 311 | struct timeval tvs, tvn; |
311 | 312 | ||
312 | ::signal ( SIGTSTP, tstp_sighandler ); | 313 | ::signal ( SIGTSTP, tstp_sighandler ); |
313 | ::gettimeofday ( &tvs, 0 ); | 314 | ::gettimeofday ( &tvs, 0 ); |
314 | 315 | ||
315 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); | 316 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); |
316 | ::close ( fd ); | 317 | ::close ( fd ); |
317 | 318 | ||
318 | if ( res ) { | 319 | if ( res ) { |
319 | ::kill ( -::getpid ( ), SIGTSTP ); | 320 | ::kill ( -::getpid ( ), SIGTSTP ); |
320 | 321 | ||
321 | do { | 322 | do { |
322 | ::usleep ( 200 * 1000 ); | 323 | ::usleep ( 200 * 1000 ); |
323 | ::gettimeofday ( &tvn, 0 ); | 324 | ::gettimeofday ( &tvn, 0 ); |
324 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 325 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
325 | 326 | ||
326 | ::kill ( -::getpid ( ), SIGCONT ); | 327 | ::kill ( -::getpid ( ), SIGCONT ); |
327 | } | 328 | } |
328 | 329 | ||
329 | ::signal ( SIGTSTP, SIG_DFL ); | 330 | ::signal ( SIGTSTP, SIG_DFL ); |
330 | } | 331 | } |
332 | |||
331 | return res; | 333 | return res; |
332 | } | 334 | } |
333 | 335 | ||
334 | 336 | ||
335 | void ODeviceIPAQ::alarmSound ( ) | 337 | void ODeviceIPAQ::alarmSound ( ) |
336 | { | 338 | { |
337 | #if defined( QT_QWS_IPAQ ) // IPAQ | 339 | #if defined( QT_QWS_IPAQ ) // IPAQ |
338 | #ifndef QT_NO_SOUND | 340 | #ifndef QT_NO_SOUND |
339 | static Sound snd ( "alarm" ); | 341 | static Sound snd ( "alarm" ); |
340 | int fd; | 342 | int fd; |
341 | int vol; | 343 | int vol; |
342 | bool vol_reset = false; | 344 | bool vol_reset = false; |
343 | 345 | ||
344 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 346 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
345 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 347 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
346 | 348 | ||
347 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 349 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
348 | Config cfg ( "qpe" ); | 350 | Config cfg ( "qpe" ); |
349 | cfg. setGroup ( "Volume" ); | 351 | cfg. setGroup ( "Volume" ); |
350 | 352 | ||
351 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 353 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
352 | if ( volalarm < 0 ) | 354 | if ( volalarm < 0 ) |
353 | volalarm = 0; | 355 | volalarm = 0; |
354 | else if ( volalarm > 100 ) | 356 | else if ( volalarm > 100 ) |
355 | volalarm = 100; | 357 | volalarm = 100; |
356 | volalarm |= ( volalarm << 8 ); | 358 | volalarm |= ( volalarm << 8 ); |
357 | 359 | ||
358 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 360 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
359 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 361 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
360 | vol_reset = true; | 362 | vol_reset = true; |
361 | } | 363 | } |
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
365 | snd. play ( ); | 367 | snd. play ( ); |
366 | while ( !snd. isFinished ( )) | 368 | while ( !snd. isFinished ( )) |
367 | qApp-> processEvents ( ); | 369 | qApp-> processEvents ( ); |
368 | 370 | ||
369 | if ( fd >= 0 ) { | 371 | if ( fd >= 0 ) { |
370 | if ( vol_reset ) | 372 | if ( vol_reset ) |
371 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 373 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
372 | ::close ( fd ); | 374 | ::close ( fd ); |
373 | } | 375 | } |
374 | #endif | 376 | #endif |
375 | #endif | 377 | #endif |
376 | } | 378 | } |
377 | 379 | ||
378 | uint ODeviceIPAQ::hasLeds ( ) const | 380 | uint ODeviceIPAQ::hasLeds ( ) const |
379 | { | 381 | { |
380 | return 1; | 382 | return 1; |
381 | } | 383 | } |
382 | 384 | ||
383 | OLedState ODeviceIPAQ::led ( uint which ) const | 385 | OLedState ODeviceIPAQ::led ( uint which ) const |
384 | { | 386 | { |
385 | if ( which == 0 ) | 387 | if ( which == 0 ) |
386 | return d-> m_leds [0]; | 388 | return d-> m_leds [0]; |
387 | else | 389 | else |
388 | return OLED_Off; | 390 | return OLED_Off; |
389 | } | 391 | } |
390 | 392 | ||
391 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) | 393 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) |
392 | { | 394 | { |
393 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); | 395 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); |
394 | 396 | ||