summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp112
-rw-r--r--libopie/odevice.h24
2 files changed, 107 insertions, 29 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c5a916b..c5342e1 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -76,4 +76,5 @@ public:
76 uint m_holdtime; 76 uint m_holdtime;
77 QStrList *m_cpu_frequencies; 77 QStrList *m_cpu_frequencies;
78
78}; 79};
79 80
@@ -141,6 +142,6 @@ public:
141 virtual bool setLedState ( OLed led, OLedState st ); 142 virtual bool setLedState ( OLed led, OLedState st );
142 143
143 virtual bool hasHingeSensor() const; 144 bool hasHingeSensor() const;
144 virtual OHingeStatus readHingeSensor(); 145 OHingeStatus readHingeSensor();
145 146
146 static bool isZaurus(); 147 static bool isZaurus();
@@ -148,6 +149,6 @@ public:
148 // Does this break BC? 149 // Does this break BC?
149 virtual bool suspend ( ); 150 virtual bool suspend ( );
150 virtual Transformation rotation ( ) const; 151 Transformation rotation ( ) const;
151 virtual ODirection direction ( ) const; 152 ODirection direction ( ) const;
152 153
153protected: 154protected:
@@ -156,4 +157,5 @@ protected:
156 OLedState m_leds [1]; 157 OLedState m_leds [1];
157 bool m_embedix; 158 bool m_embedix;
159 void virtual_hook( int id, void *data );
158}; 160};
159 161
@@ -445,5 +447,5 @@ ODevice *ODevice::inst ( )
445 static ODevice *dev = 0; 447 static ODevice *dev = 0;
446 448
447 if ( !dev ) { 449 if ( !dev ) {
448 if ( QFile::exists ( "/proc/hal/model" )) 450 if ( QFile::exists ( "/proc/hal/model" ))
449 dev = new iPAQ ( ); 451 dev = new iPAQ ( );
@@ -729,5 +731,8 @@ QString ODevice::systemVersionString ( ) const
729Transformation ODevice::rotation ( ) const 731Transformation ODevice::rotation ( ) const
730{ 732{
731 return d-> m_rotation; 733 VirtRotation rot;
734 ODevice* that =(ODevice* )this;
735 that->virtual_hook( VIRTUAL_ROTATION, &rot );
736 return rot.trans;
732} 737}
733 738
@@ -737,5 +742,8 @@ Transformation ODevice::rotation ( ) const
737ODirection ODevice::direction ( ) const 742ODirection ODevice::direction ( ) const
738{ 743{
739 return d-> m_direction; 744 VirtDirection dir;
745 ODevice* that =(ODevice* )this;
746 that->virtual_hook( VIRTUAL_DIRECTION, &dir );
747 return dir.direct;
740} 748}
741 749
@@ -847,5 +855,8 @@ int ODevice::lightSensorResolution ( ) const
847bool ODevice::hasHingeSensor ( ) const 855bool ODevice::hasHingeSensor ( ) const
848{ 856{
849 return false; 857 VirtHasHinge hing;
858 ODevice* that =(ODevice* )this;
859 that->virtual_hook( VIRTUAL_HAS_HINGE, &hing );
860 return hing.hasHinge;
850} 861}
851 862
@@ -855,5 +866,7 @@ bool ODevice::hasHingeSensor ( ) const
855OHingeStatus ODevice::readHingeSensor ( ) 866OHingeStatus ODevice::readHingeSensor ( )
856{ 867{
857 return CASE_UNKNOWN; 868 VirtHingeStatus hing;
869 virtual_hook( VIRTUAL_HINGE, &hing );
870 return hing.hingeStat;
858} 871}
859 872
@@ -1004,6 +1017,27 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
1004 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 1017 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
1005} 1018}
1006void ODevice::virtual_hook(int, void* ){ 1019void ODevice::virtual_hook(int id, void* data){
1007 1020 switch( id ) {
1021 case VIRTUAL_ROTATION:{
1022 VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
1023 rot->trans = d->m_rotation;
1024 break;
1025 }
1026 case VIRTUAL_DIRECTION:{
1027 VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
1028 dir->direct = d->m_direction;
1029 break;
1030 }
1031 case VIRTUAL_HAS_HINGE:{
1032 VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
1033 hin->hasHinge = false;
1034 break;
1035 }
1036 case VIRTUAL_HINGE:{
1037 VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
1038 hin->hingeStat = CASE_UNKNOWN;
1039 break;
1040 }
1041 }
1008} 1042}
1009 1043
@@ -1041,8 +1075,8 @@ void Yopy::init ( )
1041 d-> m_model = Model_Yopy_3700; 1075 d-> m_model = Model_Yopy_3700;
1042 d-> m_rotation = Rot0; 1076 d-> m_rotation = Rot0;
1043 1077
1044 d-> m_systemstr = "Linupy"; 1078 d-> m_systemstr = "Linupy";
1045 d-> m_system = System_Linupy; 1079 d-> m_system = System_Linupy;
1046 1080
1047 QFile f ( "/etc/issue" ); 1081 QFile f ( "/etc/issue" );
1048 if ( f. open ( IO_ReadOnly )) { 1082 if ( f. open ( IO_ReadOnly )) {
@@ -1064,5 +1098,5 @@ void Yopy::initButtons ( )
1064 1098
1065 yopy_button *ib = yopy_buttons + i; 1099 yopy_button *ib = yopy_buttons + i;
1066 1100
1067 ODeviceButton b; 1101 ODeviceButton b;
1068 1102
@@ -1078,7 +1112,7 @@ void Yopy::initButtons ( )
1078 } 1112 }
1079 reloadButtonMapping ( ); 1113 reloadButtonMapping ( );
1080 1114
1081 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1115 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1082 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1116 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1083 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1117 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1084} 1118}
@@ -1086,6 +1120,6 @@ void Yopy::initButtons ( )
1086bool Yopy::suspend() 1120bool Yopy::suspend()
1087{ 1121{
1088 /* Opie for Yopy does not implement its own power management at the 1122 /* Opie for Yopy does not implement its own power management at the
1089 moment. The public version runs parallel to X, and relies on the 1123 moment. The public version runs parallel to X, and relies on the
1090 existing power management features. */ 1124 existing power management features. */
1091 return false; 1125 return false;
@@ -1544,5 +1578,5 @@ bool Zaurus::isZaurus()
1544 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1578 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1545 return true; 1579 return true;
1546 } 1580 }
1547 1581
1548 // On non-embedix kernels, we have to look closer. 1582 // On non-embedix kernels, we have to look closer.
@@ -1822,5 +1856,5 @@ void Zaurus::buzzer ( int sound )
1822 1856
1823 Sound snd ( soundname ); 1857 Sound snd ( soundname );
1824 1858
1825 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1859 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1826 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1860 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
@@ -1849,7 +1883,7 @@ void Zaurus::buzzer ( int sound )
1849 ::close ( fd ); 1883 ::close ( fd );
1850 } 1884 }
1851 } else { 1885 } else {
1852 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1886 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1853 1887
1854 if ( fd >= 0 ) { 1888 if ( fd >= 0 ) {
1855 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1889 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
@@ -1857,5 +1891,5 @@ void Zaurus::buzzer ( int sound )
1857 } 1891 }
1858 1892
1859 } 1893 }
1860#endif 1894#endif
1861} 1895}
@@ -2067,7 +2101,7 @@ Transformation Zaurus::rotation ( ) const
2067 ::close (handle); 2101 ::close (handle);
2068 2102
2069 if (retval == 2 ) 2103 if (retval == 2 )
2070 rot = Rot0; 2104 rot = Rot0;
2071 else 2105 else
2072 rot = Rot270; 2106 rot = Rot270;
2073 } 2107 }
@@ -2154,4 +2188,32 @@ OHingeStatus Zaurus::readHingeSensor()
2154 2188
2155 2189
2190void Zaurus::virtual_hook( int id, void *data ) {
2191 switch( id ) {
2192 case VIRTUAL_ROTATION:{
2193 VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
2194 rot->trans = rotation();
2195 break;
2196 }
2197 case VIRTUAL_DIRECTION:{
2198 VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
2199 dir->direct = direction();
2200 break;
2201 }
2202 case VIRTUAL_HAS_HINGE:{
2203 VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
2204 hin->hasHinge = hasHingeSensor();
2205 break;
2206 }
2207 case VIRTUAL_HINGE:{
2208 VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
2209 hin->hingeStat = readHingeSensor();
2210 break;
2211 }
2212 default:
2213 ODevice::virtual_hook( id, data );
2214 break;
2215 }
2216}
2217
2156/************************************************** 2218/**************************************************
2157 * 2219 *
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 791d358..fc41079 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -195,6 +195,6 @@ public:
195 QString systemVersionString ( ) const; 195 QString systemVersionString ( ) const;
196 196
197 virtual Transformation rotation ( ) const; 197 /*virtual*/ Transformation rotation ( ) const;
198 virtual ODirection direction ( ) const; 198 /*virtual*/ ODirection direction ( ) const;
199 199
200// system 200// system
@@ -230,6 +230,6 @@ public:
230 virtual int lightSensorResolution ( ) const; 230 virtual int lightSensorResolution ( ) const;
231 231
232 virtual bool hasHingeSensor ( ) const; 232 /*virtual*/ bool hasHingeSensor ( ) const;
233 virtual OHingeStatus readHingeSensor ( ); 233 /*virtual*/ OHingeStatus readHingeSensor ( );
234 234
235 const QStrList &allowedCpuFrequencies() const; 235 const QStrList &allowedCpuFrequencies() const;
@@ -279,4 +279,20 @@ protected:
279 /* ugly virtual hook */ 279 /* ugly virtual hook */
280 virtual void virtual_hook( int id, void* data ); 280 virtual void virtual_hook( int id, void* data );
281
282protected:
283 enum { VIRTUAL_ROTATION = 0x200, VIRTUAL_DIRECTION,
284 VIRTUAL_HAS_HINGE, VIRTUAL_HINGE };
285 struct VirtRotation {
286 Transformation trans;
287 };
288 struct VirtDirection {
289 ODirection direct;
290 };
291 struct VirtHasHinge {
292 bool hasHinge;
293 };
294 struct VirtHingeStatus {
295 OHingeStatus hingeStat;
296 };
281}; 297};
282 298