-rw-r--r-- | libopie/odevice.cpp | 82 | ||||
-rw-r--r-- | libopie/odevice.h | 24 |
2 files changed, 92 insertions, 14 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index c5a916b..c5342e1 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -72,12 +72,13 @@ public: | |||
72 | Transformation m_rotation; | 72 | Transformation m_rotation; |
73 | ODirection m_direction; | 73 | ODirection m_direction; |
74 | 74 | ||
75 | QValueList <ODeviceButton> *m_buttons; | 75 | QValueList <ODeviceButton> *m_buttons; |
76 | uint m_holdtime; | 76 | uint m_holdtime; |
77 | QStrList *m_cpu_frequencies; | 77 | QStrList *m_cpu_frequencies; |
78 | |||
78 | }; | 79 | }; |
79 | 80 | ||
80 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 81 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
81 | protected: | 82 | protected: |
82 | virtual void init ( ); | 83 | virtual void init ( ); |
83 | virtual void initButtons ( ); | 84 | virtual void initButtons ( ); |
@@ -137,27 +138,28 @@ public: | |||
137 | 138 | ||
138 | virtual QValueList <OLed> ledList ( ) const; | 139 | virtual QValueList <OLed> ledList ( ) const; |
139 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 140 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
140 | virtual OLedState ledState ( OLed led ) const; | 141 | virtual OLedState ledState ( OLed led ) const; |
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(); |
147 | 148 | ||
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 | ||
153 | protected: | 154 | protected: |
154 | virtual void buzzer ( int snd ); | 155 | virtual void buzzer ( int snd ); |
155 | 156 | ||
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 | ||
160 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 162 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
161 | protected: | 163 | protected: |
162 | virtual void init ( ); | 164 | virtual void init ( ); |
163 | virtual void initButtons ( ); | 165 | virtual void initButtons ( ); |
@@ -725,21 +727,27 @@ QString ODevice::systemVersionString ( ) const | |||
725 | 727 | ||
726 | /** | 728 | /** |
727 | * @return the current Transformation | 729 | * @return the current Transformation |
728 | */ | 730 | */ |
729 | Transformation ODevice::rotation ( ) const | 731 | Transformation 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 | ||
734 | /** | 739 | /** |
735 | * @return the current rotation direction | 740 | * @return the current rotation direction |
736 | */ | 741 | */ |
737 | ODirection ODevice::direction ( ) const | 742 | ODirection 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 | ||
742 | /** | 750 | /** |
743 | * This plays an alarmSound | 751 | * This plays an alarmSound |
744 | */ | 752 | */ |
745 | void ODevice::alarmSound ( ) | 753 | void ODevice::alarmSound ( ) |
@@ -843,21 +851,26 @@ int ODevice::lightSensorResolution ( ) const | |||
843 | 851 | ||
844 | /** | 852 | /** |
845 | * @return if the device has a hinge sensor | 853 | * @return if the device has a hinge sensor |
846 | */ | 854 | */ |
847 | bool ODevice::hasHingeSensor ( ) const | 855 | bool 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 | ||
852 | /** | 863 | /** |
853 | * @return a value from the hinge sensor | 864 | * @return a value from the hinge sensor |
854 | */ | 865 | */ |
855 | OHingeStatus ODevice::readHingeSensor ( ) | 866 | OHingeStatus 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 | ||
860 | /** | 873 | /** |
861 | * @return a list with CPU frequencies supported by the hardware | 874 | * @return a list with CPU frequencies supported by the hardware |
862 | */ | 875 | */ |
863 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 876 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
@@ -1000,14 +1013,35 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
1000 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 1013 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
1001 | 1014 | ||
1002 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 1015 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
1003 | 1016 | ||
1004 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 1017 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
1005 | } | 1018 | } |
1006 | void ODevice::virtual_hook(int, void* ){ | 1019 | void 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 | ||
1010 | /************************************************** | 1044 | /************************************************** |
1011 | * | 1045 | * |
1012 | * Yopy 3500/3700 | 1046 | * Yopy 3500/3700 |
1013 | * | 1047 | * |
@@ -2150,12 +2184,40 @@ OHingeStatus Zaurus::readHingeSensor() | |||
2150 | return CASE_UNKNOWN; | 2184 | return CASE_UNKNOWN; |
2151 | } | 2185 | } |
2152 | } | 2186 | } |
2153 | } | 2187 | } |
2154 | 2188 | ||
2155 | 2189 | ||
2190 | void 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 | * |
2158 | * SIMpad | 2220 | * SIMpad |
2159 | * | 2221 | * |
2160 | **************************************************/ | 2222 | **************************************************/ |
2161 | 2223 | ||
diff --git a/libopie/odevice.h b/libopie/odevice.h index 791d358..fc41079 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -191,14 +191,14 @@ public: | |||
191 | 191 | ||
192 | QString systemString ( ) const; | 192 | QString systemString ( ) const; |
193 | OSystem system ( ) const; | 193 | OSystem system ( ) const; |
194 | 194 | ||
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 |
201 | 201 | ||
202 | virtual bool setSoftSuspend ( bool on ); | 202 | virtual bool setSoftSuspend ( bool on ); |
203 | virtual bool suspend ( ); | 203 | virtual bool suspend ( ); |
204 | 204 | ||
@@ -226,14 +226,14 @@ public: | |||
226 | virtual bool setLedState ( OLed led, OLedState st ); | 226 | virtual bool setLedState ( OLed led, OLedState st ); |
227 | 227 | ||
228 | virtual bool hasLightSensor ( ) const; | 228 | virtual bool hasLightSensor ( ) const; |
229 | virtual int readLightSensor ( ); | 229 | virtual int readLightSensor ( ); |
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; |
236 | bool setCurrentCpuFrequency(uint index); | 236 | bool setCurrentCpuFrequency(uint index); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * Returns the available buttons on this device. The number and location | 239 | * Returns the available buttons on this device. The number and location |
@@ -275,12 +275,28 @@ private slots: | |||
275 | void systemMessage ( const QCString &, const QByteArray & ); | 275 | void systemMessage ( const QCString &, const QByteArray & ); |
276 | 276 | ||
277 | protected: | 277 | protected: |
278 | void reloadButtonMapping ( ); | 278 | void reloadButtonMapping ( ); |
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 | |||
282 | protected: | ||
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 | ||
283 | } | 299 | } |
284 | 300 | ||
285 | #endif | 301 | #endif |
286 | 302 | ||