author | zecke <zecke> | 2004-02-19 20:29:53 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-19 20:29:53 (UTC) |
commit | f6f89c9fad356f91f1ad63402757335f7fb4fed2 (patch) (unidiff) | |
tree | 9646358fb1b6bdec12fa29971936cbe63ad8f06b /libopie | |
parent | c2eb77f6b8933b02bd8bd59ec7325da0bfc956cb (diff) | |
download | opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.zip opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.tar.gz opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.tar.bz2 |
Restore binary compatibility and make use of the virtual_hook
Yeah it is ugly... but will work for libopie...
Now onto libopie2! development
-rw-r--r-- | libopie/odevice.cpp | 112 | ||||
-rw-r--r-- | libopie/odevice.h | 24 |
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 | |||
@@ -62,32 +62,33 @@ public: | |||
62 | OVendor m_vendor; | 62 | OVendor m_vendor; |
63 | 63 | ||
64 | QString m_modelstr; | 64 | QString m_modelstr; |
65 | OModel m_model; | 65 | OModel m_model; |
66 | 66 | ||
67 | QString m_systemstr; | 67 | QString m_systemstr; |
68 | OSystem m_system; | 68 | OSystem m_system; |
69 | 69 | ||
70 | QString m_sysverstr; | 70 | QString m_sysverstr; |
71 | 71 | ||
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 ( ); |
84 | 85 | ||
85 | public: | 86 | public: |
86 | virtual bool setSoftSuspend ( bool soft ); | 87 | virtual bool setSoftSuspend ( bool soft ); |
87 | 88 | ||
88 | virtual bool setDisplayBrightness ( int b ); | 89 | virtual bool setDisplayBrightness ( int b ); |
89 | virtual int displayBrightnessResolution ( ) const; | 90 | virtual int displayBrightnessResolution ( ) const; |
90 | 91 | ||
91 | virtual void alarmSound ( ); | 92 | virtual void alarmSound ( ); |
92 | 93 | ||
93 | virtual QValueList <OLed> ledList ( ) const; | 94 | virtual QValueList <OLed> ledList ( ) const; |
@@ -127,47 +128,48 @@ protected: | |||
127 | 128 | ||
128 | public: | 129 | public: |
129 | virtual bool setSoftSuspend ( bool soft ); | 130 | virtual bool setSoftSuspend ( bool soft ); |
130 | 131 | ||
131 | virtual bool setDisplayBrightness ( int b ); | 132 | virtual bool setDisplayBrightness ( int b ); |
132 | virtual int displayBrightnessResolution ( ) const; | 133 | virtual int displayBrightnessResolution ( ) const; |
133 | 134 | ||
134 | virtual void alarmSound ( ); | 135 | virtual void alarmSound ( ); |
135 | virtual void keySound ( ); | 136 | virtual void keySound ( ); |
136 | virtual void touchSound ( ); | 137 | virtual void touchSound ( ); |
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 ( ); |
164 | 166 | ||
165 | public: | 167 | public: |
166 | virtual bool setSoftSuspend ( bool soft ); | 168 | virtual bool setSoftSuspend ( bool soft ); |
167 | virtual bool suspend(); | 169 | virtual bool suspend(); |
168 | 170 | ||
169 | virtual bool setDisplayStatus( bool on ); | 171 | virtual bool setDisplayStatus( bool on ); |
170 | virtual bool setDisplayBrightness ( int b ); | 172 | virtual bool setDisplayBrightness ( int b ); |
171 | virtual int displayBrightnessResolution ( ) const; | 173 | virtual int displayBrightnessResolution ( ) const; |
172 | 174 | ||
173 | virtual void alarmSound ( ); | 175 | virtual void alarmSound ( ); |
@@ -431,33 +433,33 @@ static QCString makeChannel ( const char *str ) | |||
431 | { | 433 | { |
432 | if ( str && !::strchr ( str, '/' )) | 434 | if ( str && !::strchr ( str, '/' )) |
433 | return QCString ( "QPE/Application/" ) + str; | 435 | return QCString ( "QPE/Application/" ) + str; |
434 | else | 436 | else |
435 | return str; | 437 | return str; |
436 | } | 438 | } |
437 | 439 | ||
438 | static inline bool isQWS() | 440 | static inline bool isQWS() |
439 | { | 441 | { |
440 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 442 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
441 | } | 443 | } |
442 | 444 | ||
443 | ODevice *ODevice::inst ( ) | 445 | ODevice *ODevice::inst ( ) |
444 | { | 446 | { |
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 ( ); |
450 | else if ( Zaurus::isZaurus() ) | 452 | else if ( Zaurus::isZaurus() ) |
451 | dev = new Zaurus ( ); | 453 | dev = new Zaurus ( ); |
452 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 454 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
453 | dev = new SIMpad ( ); | 455 | dev = new SIMpad ( ); |
454 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 456 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
455 | dev = new Ramses ( ); | 457 | dev = new Ramses ( ); |
456 | else if ( Yopy::isYopy() ) | 458 | else if ( Yopy::isYopy() ) |
457 | dev = new Yopy ( ); | 459 | dev = new Yopy ( ); |
458 | else if ( Jornada::isJornada() ) | 460 | else if ( Jornada::isJornada() ) |
459 | dev = new Jornada ( ); | 461 | dev = new Jornada ( ); |
460 | else | 462 | else |
461 | dev = new ODevice ( ); | 463 | dev = new ODevice ( ); |
462 | dev-> init ( ); | 464 | dev-> init ( ); |
463 | } | 465 | } |
@@ -715,41 +717,47 @@ OSystem ODevice::system ( ) const | |||
715 | return d-> m_system; | 717 | return d-> m_system; |
716 | } | 718 | } |
717 | 719 | ||
718 | /** | 720 | /** |
719 | * @return the version string of the base system | 721 | * @return the version string of the base system |
720 | */ | 722 | */ |
721 | QString ODevice::systemVersionString ( ) const | 723 | QString ODevice::systemVersionString ( ) const |
722 | { | 724 | { |
723 | return d-> m_sysverstr; | 725 | return d-> m_sysverstr; |
724 | } | 726 | } |
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 ( ) |
746 | { | 754 | { |
747 | #ifndef QT_NO_SOUND | 755 | #ifndef QT_NO_SOUND |
748 | static Sound snd ( "alarm" ); | 756 | static Sound snd ( "alarm" ); |
749 | 757 | ||
750 | if ( snd. isFinished ( )) | 758 | if ( snd. isFinished ( )) |
751 | snd. play ( ); | 759 | snd. play ( ); |
752 | #endif | 760 | #endif |
753 | } | 761 | } |
754 | 762 | ||
755 | /** | 763 | /** |
@@ -833,41 +841,46 @@ int ODevice::readLightSensor ( ) | |||
833 | return -1; | 841 | return -1; |
834 | } | 842 | } |
835 | 843 | ||
836 | /** | 844 | /** |
837 | * @return the light sensor resolution | 845 | * @return the light sensor resolution |
838 | */ | 846 | */ |
839 | int ODevice::lightSensorResolution ( ) const | 847 | int ODevice::lightSensorResolution ( ) const |
840 | { | 848 | { |
841 | return 0; | 849 | return 0; |
842 | } | 850 | } |
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 |
864 | { | 877 | { |
865 | return *d->m_cpu_frequencies; | 878 | return *d->m_cpu_frequencies; |
866 | } | 879 | } |
867 | 880 | ||
868 | 881 | ||
869 | /** | 882 | /** |
870 | * Set desired CPU frequency | 883 | * Set desired CPU frequency |
871 | * | 884 | * |
872 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 885 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
873 | */ | 886 | */ |
@@ -990,34 +1003,55 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
990 | 1003 | ||
991 | if ( button >= (int) d-> m_buttons-> count ( )) | 1004 | if ( button >= (int) d-> m_buttons-> count ( )) |
992 | return; | 1005 | return; |
993 | 1006 | ||
994 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 1007 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
995 | b. setHeldAction ( action ); | 1008 | b. setHeldAction ( action ); |
996 | 1009 | ||
997 | Config buttonFile ( "ButtonSettings" ); | 1010 | Config buttonFile ( "ButtonSettings" ); |
998 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 1011 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
999 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 1012 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
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 | * |
1014 | **************************************************/ | 1048 | **************************************************/ |
1015 | 1049 | ||
1016 | bool Yopy::isYopy ( ) | 1050 | bool Yopy::isYopy ( ) |
1017 | { | 1051 | { |
1018 | QFile f( "/proc/cpuinfo" ); | 1052 | QFile f( "/proc/cpuinfo" ); |
1019 | if ( f. open ( IO_ReadOnly ) ) { | 1053 | if ( f. open ( IO_ReadOnly ) ) { |
1020 | QTextStream ts ( &f ); | 1054 | QTextStream ts ( &f ); |
1021 | QString line; | 1055 | QString line; |
1022 | while( line = ts. readLine ( ) ) { | 1056 | while( line = ts. readLine ( ) ) { |
1023 | if ( line. left ( 8 ) == "Hardware" ) { | 1057 | if ( line. left ( 8 ) == "Hardware" ) { |
@@ -1027,79 +1061,79 @@ bool Yopy::isYopy ( ) | |||
1027 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1061 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1028 | return ( model == "Yopy" ); | 1062 | return ( model == "Yopy" ); |
1029 | } | 1063 | } |
1030 | } | 1064 | } |
1031 | } | 1065 | } |
1032 | } | 1066 | } |
1033 | return false; | 1067 | return false; |
1034 | } | 1068 | } |
1035 | 1069 | ||
1036 | void Yopy::init ( ) | 1070 | void Yopy::init ( ) |
1037 | { | 1071 | { |
1038 | d-> m_vendorstr = "G.Mate"; | 1072 | d-> m_vendorstr = "G.Mate"; |
1039 | d-> m_vendor = Vendor_GMate; | 1073 | d-> m_vendor = Vendor_GMate; |
1040 | d-> m_modelstr = "Yopy3700"; | 1074 | d-> m_modelstr = "Yopy3700"; |
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 )) { |
1049 | QTextStream ts ( &f ); | 1083 | QTextStream ts ( &f ); |
1050 | ts.readLine(); | 1084 | ts.readLine(); |
1051 | d-> m_sysverstr = ts. readLine ( ); | 1085 | d-> m_sysverstr = ts. readLine ( ); |
1052 | f. close ( ); | 1086 | f. close ( ); |
1053 | } | 1087 | } |
1054 | } | 1088 | } |
1055 | 1089 | ||
1056 | void Yopy::initButtons ( ) | 1090 | void Yopy::initButtons ( ) |
1057 | { | 1091 | { |
1058 | if ( d-> m_buttons ) | 1092 | if ( d-> m_buttons ) |
1059 | return; | 1093 | return; |
1060 | 1094 | ||
1061 | d-> m_buttons = new QValueList <ODeviceButton>; | 1095 | d-> m_buttons = new QValueList <ODeviceButton>; |
1062 | 1096 | ||
1063 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1097 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
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 | ||
1069 | b. setKeycode ( ib-> code ); | 1103 | b. setKeycode ( ib-> code ); |
1070 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1104 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1071 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1105 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1072 | b. setFactoryPresetPressedAction | 1106 | b. setFactoryPresetPressedAction |
1073 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1107 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1074 | b. setFactoryPresetHeldAction | 1108 | b. setFactoryPresetHeldAction |
1075 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1109 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1076 | 1110 | ||
1077 | d-> m_buttons-> append ( b ); | 1111 | d-> m_buttons-> append ( b ); |
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 | } |
1085 | 1119 | ||
1086 | bool Yopy::suspend() | 1120 | bool 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; |
1092 | } | 1126 | } |
1093 | 1127 | ||
1094 | bool Yopy::setDisplayBrightness(int bright) | 1128 | bool Yopy::setDisplayBrightness(int bright) |
1095 | { | 1129 | { |
1096 | /* The code here works, but is disabled as the current version runs | 1130 | /* The code here works, but is disabled as the current version runs |
1097 | parallel to X, and relies on the existing backlight demon. */ | 1131 | parallel to X, and relies on the existing backlight demon. */ |
1098 | #if 0 | 1132 | #if 0 |
1099 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1133 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1100 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1134 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1101 | if (fd >= 0 ) { | 1135 | if (fd >= 0 ) { |
1102 | if (bright) | 1136 | if (bright) |
1103 | ::write(fd, "1\n", 2); | 1137 | ::write(fd, "1\n", 2); |
1104 | else | 1138 | else |
1105 | ::write(fd, "0\n", 2); | 1139 | ::write(fd, "0\n", 2); |
@@ -1530,33 +1564,33 @@ int iPAQ::lightSensorResolution ( ) const | |||
1530 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 1564 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
1531 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 1565 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
1532 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 1566 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
1533 | // | 1567 | // |
1534 | // Only question right now is: Do we really need to do it? Because as soon | 1568 | // Only question right now is: Do we really need to do it? Because as soon |
1535 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 1569 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
1536 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 1570 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
1537 | // | 1571 | // |
1538 | // Comments? - mickeyl. | 1572 | // Comments? - mickeyl. |
1539 | 1573 | ||
1540 | bool Zaurus::isZaurus() | 1574 | bool Zaurus::isZaurus() |
1541 | { | 1575 | { |
1542 | 1576 | ||
1543 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1577 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
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. |
1549 | bool is_zaurus = false; | 1583 | bool is_zaurus = false; |
1550 | QFile f ( "/proc/cpuinfo" ); | 1584 | QFile f ( "/proc/cpuinfo" ); |
1551 | if ( f. open ( IO_ReadOnly ) ) { | 1585 | if ( f. open ( IO_ReadOnly ) ) { |
1552 | QString model; | 1586 | QString model; |
1553 | QFile f ( "/proc/cpuinfo" ); | 1587 | QFile f ( "/proc/cpuinfo" ); |
1554 | 1588 | ||
1555 | QTextStream ts ( &f ); | 1589 | QTextStream ts ( &f ); |
1556 | QString line; | 1590 | QString line; |
1557 | while( line = ts. readLine ( ) ) { | 1591 | while( line = ts. readLine ( ) ) { |
1558 | if ( line. left ( 8 ) == "Hardware" ) | 1592 | if ( line. left ( 8 ) == "Hardware" ) |
1559 | break; | 1593 | break; |
1560 | } | 1594 | } |
1561 | int loc = line. find ( ":" ); | 1595 | int loc = line. find ( ":" ); |
1562 | if ( loc != -1 ) | 1596 | if ( loc != -1 ) |
@@ -1808,68 +1842,68 @@ void Zaurus::buzzer ( int sound ) | |||
1808 | break; | 1842 | break; |
1809 | default: | 1843 | default: |
1810 | soundname = "alarm"; | 1844 | soundname = "alarm"; |
1811 | 1845 | ||
1812 | } | 1846 | } |
1813 | } | 1847 | } |
1814 | 1848 | ||
1815 | // If a soundname is defined, we expect that this device has | 1849 | // If a soundname is defined, we expect that this device has |
1816 | // sound capabilities.. Otherwise we expect to have the buzzer | 1850 | // sound capabilities.. Otherwise we expect to have the buzzer |
1817 | // device.. | 1851 | // device.. |
1818 | if ( !soundname.isEmpty() ){ | 1852 | if ( !soundname.isEmpty() ){ |
1819 | int fd; | 1853 | int fd; |
1820 | int vol; | 1854 | int vol; |
1821 | bool vol_reset = false; | 1855 | bool vol_reset = false; |
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 ) { |
1827 | Config cfg ( "qpe" ); | 1861 | Config cfg ( "qpe" ); |
1828 | cfg. setGroup ( "Volume" ); | 1862 | cfg. setGroup ( "Volume" ); |
1829 | 1863 | ||
1830 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1864 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1831 | if ( volalarm < 0 ) | 1865 | if ( volalarm < 0 ) |
1832 | volalarm = 0; | 1866 | volalarm = 0; |
1833 | else if ( volalarm > 100 ) | 1867 | else if ( volalarm > 100 ) |
1834 | volalarm = 100; | 1868 | volalarm = 100; |
1835 | volalarm |= ( volalarm << 8 ); | 1869 | volalarm |= ( volalarm << 8 ); |
1836 | 1870 | ||
1837 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1871 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1838 | vol_reset = true; | 1872 | vol_reset = true; |
1839 | } | 1873 | } |
1840 | } | 1874 | } |
1841 | 1875 | ||
1842 | snd. play ( ); | 1876 | snd. play ( ); |
1843 | while ( !snd. isFinished ( )) | 1877 | while ( !snd. isFinished ( )) |
1844 | qApp-> processEvents ( ); | 1878 | qApp-> processEvents ( ); |
1845 | 1879 | ||
1846 | if ( fd >= 0 ) { | 1880 | if ( fd >= 0 ) { |
1847 | if ( vol_reset ) | 1881 | if ( vol_reset ) |
1848 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1882 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
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 ); |
1856 | ::close ( fd ); | 1890 | ::close ( fd ); |
1857 | } | 1891 | } |
1858 | 1892 | ||
1859 | } | 1893 | } |
1860 | #endif | 1894 | #endif |
1861 | } | 1895 | } |
1862 | 1896 | ||
1863 | 1897 | ||
1864 | void Zaurus::alarmSound ( ) | 1898 | void Zaurus::alarmSound ( ) |
1865 | { | 1899 | { |
1866 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1900 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1867 | } | 1901 | } |
1868 | 1902 | ||
1869 | void Zaurus::touchSound ( ) | 1903 | void Zaurus::touchSound ( ) |
1870 | { | 1904 | { |
1871 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1905 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1872 | } | 1906 | } |
1873 | 1907 | ||
1874 | void Zaurus::keySound ( ) | 1908 | void Zaurus::keySound ( ) |
1875 | { | 1909 | { |
@@ -2053,35 +2087,35 @@ bool Zaurus::suspend ( ) | |||
2053 | 2087 | ||
2054 | Transformation Zaurus::rotation ( ) const | 2088 | Transformation Zaurus::rotation ( ) const |
2055 | { | 2089 | { |
2056 | Transformation rot; | 2090 | Transformation rot; |
2057 | int handle = 0; | 2091 | int handle = 0; |
2058 | int retval = 0; | 2092 | int retval = 0; |
2059 | 2093 | ||
2060 | switch ( d-> m_model ) { | 2094 | switch ( d-> m_model ) { |
2061 | case Model_Zaurus_SLC7x0: | 2095 | case Model_Zaurus_SLC7x0: |
2062 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2096 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2063 | if (handle == -1) { | 2097 | if (handle == -1) { |
2064 | return Rot270; | 2098 | return Rot270; |
2065 | } else { | 2099 | } else { |
2066 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2100 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
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 | } |
2074 | break; | 2108 | break; |
2075 | case Model_Zaurus_SLA300: | 2109 | case Model_Zaurus_SLA300: |
2076 | case Model_Zaurus_SLB600: | 2110 | case Model_Zaurus_SLB600: |
2077 | case Model_Zaurus_SL5500: | 2111 | case Model_Zaurus_SL5500: |
2078 | case Model_Zaurus_SL5000: | 2112 | case Model_Zaurus_SL5000: |
2079 | default: | 2113 | default: |
2080 | rot = d-> m_rotation; | 2114 | rot = d-> m_rotation; |
2081 | break; | 2115 | break; |
2082 | } | 2116 | } |
2083 | 2117 | ||
2084 | return rot; | 2118 | return rot; |
2085 | } | 2119 | } |
2086 | ODirection Zaurus::direction ( ) const | 2120 | ODirection Zaurus::direction ( ) const |
2087 | { | 2121 | { |
@@ -2140,32 +2174,60 @@ OHingeStatus Zaurus::readHingeSensor() | |||
2140 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2174 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2141 | ::close (handle); | 2175 | ::close (handle); |
2142 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 2176 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
2143 | { | 2177 | { |
2144 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 2178 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
2145 | return static_cast<OHingeStatus>( retval ); | 2179 | return static_cast<OHingeStatus>( retval ); |
2146 | } | 2180 | } |
2147 | else | 2181 | else |
2148 | { | 2182 | { |
2149 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 2183 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
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 | ||
2162 | void SIMpad::init ( ) | 2224 | void SIMpad::init ( ) |
2163 | { | 2225 | { |
2164 | d-> m_vendorstr = "SIEMENS"; | 2226 | d-> m_vendorstr = "SIEMENS"; |
2165 | d-> m_vendor = Vendor_SIEMENS; | 2227 | d-> m_vendor = Vendor_SIEMENS; |
2166 | 2228 | ||
2167 | QFile f ( "/proc/hal/model" ); | 2229 | QFile f ( "/proc/hal/model" ); |
2168 | 2230 | ||
2169 | //TODO Implement model checking | 2231 | //TODO Implement model checking |
2170 | //FIXME For now we assume an SL4 | 2232 | //FIXME For now we assume an SL4 |
2171 | 2233 | ||
diff --git a/libopie/odevice.h b/libopie/odevice.h index 791d358..fc41079 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -181,34 +181,34 @@ public: | |||
181 | static ODevice *inst ( ); | 181 | static ODevice *inst ( ); |
182 | 182 | ||
183 | // information | 183 | // information |
184 | 184 | ||
185 | QString modelString ( ) const; | 185 | QString modelString ( ) const; |
186 | OModel model ( ) const; | 186 | OModel model ( ) const; |
187 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 187 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
188 | 188 | ||
189 | QString vendorString ( ) const; | 189 | QString vendorString ( ) const; |
190 | OVendor vendor ( ) const; | 190 | OVendor vendor ( ) const; |
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 | ||
205 | virtual bool setDisplayStatus ( bool on ); | 205 | virtual bool setDisplayStatus ( bool on ); |
206 | virtual bool setDisplayBrightness ( int brightness ); | 206 | virtual bool setDisplayBrightness ( int brightness ); |
207 | virtual int displayBrightnessResolution ( ) const; | 207 | virtual int displayBrightnessResolution ( ) const; |
208 | virtual bool setDisplayContrast ( int contrast ); | 208 | virtual bool setDisplayContrast ( int contrast ); |
209 | virtual int displayContrastResolution ( ) const; | 209 | virtual int displayContrastResolution ( ) const; |
210 | 210 | ||
211 | // don't add new virtual methods, use this: | 211 | // don't add new virtual methods, use this: |
212 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | 212 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; |
213 | // and in your subclass do do overwrite | 213 | // and in your subclass do do overwrite |
214 | //protected virtual int virtual_hook(int, void *) | 214 | //protected virtual int virtual_hook(int, void *) |
@@ -216,34 +216,34 @@ public: | |||
216 | 216 | ||
217 | // input / output | 217 | // input / output |
218 | //FIXME playAlarmSound and al might be better -zecke | 218 | //FIXME playAlarmSound and al might be better -zecke |
219 | virtual void alarmSound ( ); | 219 | virtual void alarmSound ( ); |
220 | virtual void keySound ( ); | 220 | virtual void keySound ( ); |
221 | virtual void touchSound ( ); | 221 | virtual void touchSound ( ); |
222 | 222 | ||
223 | virtual QValueList <OLed> ledList ( ) const; | 223 | virtual QValueList <OLed> ledList ( ) const; |
224 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 224 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
225 | virtual OLedState ledState ( OLed led ) const; | 225 | virtual OLedState ledState ( OLed led ) const; |
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 |
240 | * of buttons will vary depending on the device. Button numbers will be assigned | 240 | * of buttons will vary depending on the device. Button numbers will be assigned |
241 | * by the device manufacturer and will be from most preferred button to least preffered | 241 | * by the device manufacturer and will be from most preferred button to least preffered |
242 | * button. Note that this list only contains "user mappable" buttons. | 242 | * button. Note that this list only contains "user mappable" buttons. |
243 | * | 243 | * |
244 | * @todo ### make const | 244 | * @todo ### make const |
245 | */ | 245 | */ |
246 | const QValueList<ODeviceButton> &buttons ( ) /** /todo ### make const */; | 246 | const QValueList<ODeviceButton> &buttons ( ) /** /todo ### make const */; |
247 | 247 | ||
248 | /** | 248 | /** |
249 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 249 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
@@ -265,22 +265,38 @@ public: | |||
265 | 265 | ||
266 | /** | 266 | /** |
267 | * How long (in ms) you have to press a button for a "hold" action | 267 | * How long (in ms) you have to press a button for a "hold" action |
268 | */ | 268 | */ |
269 | uint buttonHoldTime ( ) const; | 269 | uint buttonHoldTime ( ) const; |
270 | 270 | ||
271 | signals: | 271 | signals: |
272 | void buttonMappingChanged ( ); | 272 | void buttonMappingChanged ( ); |
273 | 273 | ||
274 | private slots: | 274 | 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 | ||