Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 103 |
1 files changed, 2 insertions, 101 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index a6e8b82..78bc62e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -22,17 +22,17 @@ | |||
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
@@ -48,78 +48,19 @@ | |||
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | ||
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | |||
69 | using namespace Opie; | 56 | using namespace Opie; |
70 | 57 | ||
71 | class Zaurus : public ODevice | 58 | struct z_button z_buttons [] = { |
72 | { | ||
73 | |||
74 | protected: | ||
75 | virtual void init(); | ||
76 | virtual void initButtons(); | ||
77 | |||
78 | public: | ||
79 | virtual bool setSoftSuspend ( bool soft ); | ||
80 | |||
81 | virtual bool setDisplayBrightness ( int b ); | ||
82 | virtual int displayBrightnessResolution() const; | ||
83 | |||
84 | virtual void alarmSound(); | ||
85 | virtual void keySound(); | ||
86 | virtual void touchSound(); | ||
87 | |||
88 | virtual QValueList <OLed> ledList() const; | ||
89 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | ||
90 | virtual OLedState ledState( OLed led ) const; | ||
91 | virtual bool setLedState( OLed led, OLedState st ); | ||
92 | |||
93 | virtual bool hasHingeSensor() const; | ||
94 | virtual OHingeStatus readHingeSensor(); | ||
95 | |||
96 | static bool isZaurus(); | ||
97 | |||
98 | virtual bool suspend(); | ||
99 | virtual Transformation rotation() const; | ||
100 | virtual ODirection direction() const; | ||
101 | |||
102 | protected: | ||
103 | virtual void buzzer ( int snd ); | ||
104 | |||
105 | OLedState m_leds [1]; | ||
106 | bool m_embedix; | ||
107 | }; | ||
108 | |||
109 | struct z_button { | ||
110 | Qt::Key code; | ||
111 | char *utext; | ||
112 | char *pix; | ||
113 | char *fpressedservice; | ||
114 | char *fpressedaction; | ||
115 | char *fheldservice; | ||
116 | char *fheldaction; | ||
117 | } z_buttons [] = { | ||
118 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 59 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
119 | "devicebuttons/z_calendar", | 60 | "devicebuttons/z_calendar", |
120 | "datebook", "nextView()", | 61 | "datebook", "nextView()", |
121 | "today", "raise()" }, | 62 | "today", "raise()" }, |
122 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 63 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
123 | "devicebuttons/z_contact", | 64 | "devicebuttons/z_contact", |
124 | "addressbook", "raise()", | 65 | "addressbook", "raise()", |
125 | "addressbook", "beamBusinessCard()" }, | 66 | "addressbook", "beamBusinessCard()" }, |
@@ -155,69 +96,29 @@ struct z_button z_buttons_c700 [] = { | |||
155 | "QPE/TaskBar", "toggleMenu()", | 96 | "QPE/TaskBar", "toggleMenu()", |
156 | "QPE/TaskBar", "toggleStartMenu()" }, | 97 | "QPE/TaskBar", "toggleStartMenu()" }, |
157 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 98 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
158 | "devicebuttons/z_hinge", | 99 | "devicebuttons/z_hinge", |
159 | "QPE/Rotation", "rotateDefault()", | 100 | "QPE/Rotation", "rotateDefault()", |
160 | "QPE/Dummy", "doNothing()" }, | 101 | "QPE/Dummy", "doNothing()" }, |
161 | }; | 102 | }; |
162 | 103 | ||
163 | // Check whether this device is the sharp zaurus.. | ||
164 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 104 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
165 | // class up into individual classes. We need three classes | 105 | // class up into individual classes. We need three classes |
166 | // | 106 | // |
167 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 107 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
168 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 108 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
169 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 109 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
170 | // | 110 | // |
171 | // Only question right now is: Do we really need to do it? Because as soon | 111 | // Only question right now is: Do we really need to do it? Because as soon |
172 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 112 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
173 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 113 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
174 | // | 114 | // |
175 | // Comments? - mickeyl. | 115 | // Comments? - mickeyl. |
176 | 116 | ||
177 | bool Zaurus::isZaurus() | ||
178 | { | ||
179 | |||
180 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | ||
181 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | ||
182 | return true; | ||
183 | } | ||
184 | |||
185 | // On non-embedix kernels, we have to look closer. | ||
186 | bool is_zaurus = false; | ||
187 | QFile f ( "/proc/cpuinfo" ); | ||
188 | if ( f. open ( IO_ReadOnly ) ) { | ||
189 | QString model; | ||
190 | QFile f ( "/proc/cpuinfo" ); | ||
191 | |||
192 | QTextStream ts ( &f ); | ||
193 | QString line; | ||
194 | while( line = ts. readLine() ) { | ||
195 | if ( line. left ( 8 ) == "Hardware" ) | ||
196 | break; | ||
197 | } | ||
198 | int loc = line. find ( ":" ); | ||
199 | if ( loc != -1 ) | ||
200 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | ||
201 | |||
202 | if ( model == "Sharp-Collie" | ||
203 | || model == "Collie" | ||
204 | || model == "SHARP Corgi" | ||
205 | || model == "SHARP Shepherd" | ||
206 | || model == "SHARP Poodle" | ||
207 | || model == "SHARP Husky" | ||
208 | ) | ||
209 | is_zaurus = true; | ||
210 | |||
211 | } | ||
212 | return is_zaurus; | ||
213 | } | ||
214 | |||
215 | |||
216 | void Zaurus::init() | 117 | void Zaurus::init() |
217 | { | 118 | { |
218 | d->m_vendorstr = "Sharp"; | 119 | d->m_vendorstr = "Sharp"; |
219 | d->m_vendor = Vendor_Sharp; | 120 | d->m_vendor = Vendor_Sharp; |
220 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 121 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
221 | 122 | ||
222 | // QFile f ( "/proc/filesystems" ); | 123 | // QFile f ( "/proc/filesystems" ); |
223 | QString model; | 124 | QString model; |