summaryrefslogtreecommitdiff
path: root/libopie
authorsandman <sandman>2002-09-05 21:23:09 (UTC)
committer sandman <sandman>2002-09-05 21:23:09 (UTC)
commitbaea6aaf4f0c9672a4383470a9389bca1a20bdba (patch) (unidiff)
treedef42730d45a0aa47eeb4f637cf140633b8d2c7c /libopie
parent930e178bf07eb5685852f56a3ecb05b8b823f42c (diff)
downloadopie-baea6aaf4f0c9672a4383470a9389bca1a20bdba.zip
opie-baea6aaf4f0c9672a4383470a9389bca1a20bdba.tar.gz
opie-baea6aaf4f0c9672a4383470a9389bca1a20bdba.tar.bz2
- added a setPowerButtonHandler() for iPAQs and Zs
(-> disableAPM() in launcher can be removed) - another try to fix the OZ suspend code
Diffstat (limited to 'libopie') (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp68
-rw-r--r--libopie/odevice.h6
2 files changed, 70 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 2f40731..95fd6bd 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -61,2 +61,4 @@ protected:
61public: 61public:
62 virtual bool setPowerButtonHandler ( PowerButtonHandler h );
63
62 virtual void alarmSound ( ); 64 virtual void alarmSound ( );
@@ -73,2 +75,4 @@ protected:
73 public: 75 public:
76 virtual bool setPowerButtonHandler ( PowerButtonHandler h );
77
74 virtual void alarmSound ( ); 78 virtual void alarmSound ( );
@@ -133,2 +137,7 @@ ODevice::~ODevice ( )
133 137
138bool ODevice::setPowerButtonHandler ( ODevice::PowerButtonHandler )
139{
140 return false;
141}
142
134bool ODevice::suspend ( ) 143bool ODevice::suspend ( )
@@ -150,3 +159,3 @@ bool ODevice::suspend ( )
150 159
151 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending 160 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending
152 161
@@ -406,4 +415,20 @@ bool ODeviceIPAQ::setLed ( uint which, OLedState st )
406 415
416bool ODeviceIPAQ::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
417{
418 bool res = false;
419 int fd;
420
421 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
422 if ( ::write ( fd, p == KERNEL ? "0" : "1", 1 ) == 1 )
423 res = true;
424 else
425 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
426
427 ::close ( fd );
428 }
429 else
430 ::perror ( "/proc/sys/ts/suspend_button_mode" );
407 431
408//#endif 432 return res;
433}
409 434
@@ -413,3 +438,2 @@ bool ODeviceIPAQ::setLed ( uint which, OLedState st )
413 438
414//#if defined( QT_QWS_EBX ) // Zaurus
415 439
@@ -496,2 +520,8 @@ typedef struct sharp_led_status {
496 520
521// #include <asm/sharp_apm.h> // including kernel headers is evil ...
522
523#define APM_IOCGEVTSRC (( 2 ) | ( 'A'<<8 ) | ( 203 ) | ( sizeof(int) ))
524#define APM_IOCSEVTSRC (( 3 ) | ( 'A'<<8 ) | ( 204 ) | ( sizeof(int) ))
525#define APM_EVT_POWER_BUTTON (1 << 0)
526
497 527
@@ -562,2 +592,32 @@ bool ODeviceZaurus::setLed ( uint which, OLedState st )
562 592
563//#endif 593bool ODeviceZaurus::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
594{
595 bool res = false;
596 int fd;
597
598 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
599 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
600
601 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
602
603 if ( sources >= 0 ) {
604 if ( p == KERNEL )
605 sources |= APM_EVT_POWER_BUTTON;
606 else
607 sources &= ~APM_EVT_POWER_BUTTON;
608
609 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources & ~APM_EVT_POWER_BUTTON ) >= 0 ) // set new event sources
610 res = true;
611 else
612 perror ( "APM_IOCGEVTSRC" );
613 }
614 else
615 perror ( "APM_IOCGEVTSRC" );
616
617 ::close ( fd );
618 }
619 else
620 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
621
622 return res;
623}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 5009b91..ee01f0f 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -69,2 +69,8 @@ public:
69 // system 69 // system
70 enum PowerButtonHandler {
71 KERNEL,
72 OPIE
73 };
74
75 virtual bool setPowerButtonHandler ( PowerButtonHandler h );
70 virtual bool suspend ( ); 76 virtual bool suspend ( );