-rw-r--r-- | libopie2/opiecore/device/odevice.h | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 18 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 3 |
3 files changed, 19 insertions, 4 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 0eed1c9..492c97b 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -96,257 +96,257 @@ enum OModel { | |||
96 | 96 | ||
97 | Model_Ramses = ( 4 << 16 ), | 97 | Model_Ramses = ( 4 << 16 ), |
98 | 98 | ||
99 | Model_Ramses_All = ( Model_Ramses | 0xffff ), | 99 | Model_Ramses_All = ( Model_Ramses | 0xffff ), |
100 | Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), | 100 | Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), |
101 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), | 101 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), |
102 | 102 | ||
103 | Model_Yopy = ( 5 << 16 ), | 103 | Model_Yopy = ( 5 << 16 ), |
104 | 104 | ||
105 | Model_Yopy_All = ( Model_Yopy | 0xffff ), | 105 | Model_Yopy_All = ( Model_Yopy | 0xffff ), |
106 | Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), | 106 | Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), |
107 | Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), | 107 | Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), |
108 | Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), | 108 | Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), |
109 | 109 | ||
110 | Model_Beagle = ( 6 << 16 ), | 110 | Model_Beagle = ( 6 << 16 ), |
111 | 111 | ||
112 | Model_Beagle_All = ( Model_Beagle | 0xffff ), | 112 | Model_Beagle_All = ( Model_Beagle | 0xffff ), |
113 | Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), | 113 | Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), |
114 | 114 | ||
115 | Model_GenuineIntel = ( 7 << 16 ), | 115 | Model_GenuineIntel = ( 7 << 16 ), |
116 | 116 | ||
117 | Model_MyPal = ( 8 << 16 ), | 117 | Model_MyPal = ( 8 << 16 ), |
118 | 118 | ||
119 | Model_MyPal_All = ( Model_MyPal | 0xffff ), | 119 | Model_MyPal_All = ( Model_MyPal | 0xffff ), |
120 | Model_MyPal_620 = ( Model_MyPal | 0x0001 ), | 120 | Model_MyPal_620 = ( Model_MyPal | 0x0001 ), |
121 | Model_MyPal_716 = ( Model_MyPal | 0x0002 ), | 121 | Model_MyPal_716 = ( Model_MyPal | 0x0002 ), |
122 | Model_MyPal_730 = ( Model_MyPal | 0x0003 ) | 122 | Model_MyPal_730 = ( Model_MyPal | 0x0003 ) |
123 | }; | 123 | }; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * The vendor of the device | 126 | * The vendor of the device |
127 | */ | 127 | */ |
128 | enum OVendor { | 128 | enum OVendor { |
129 | Vendor_Unknown, | 129 | Vendor_Unknown, |
130 | 130 | ||
131 | Vendor_HP, | 131 | Vendor_HP, |
132 | Vendor_Sharp, | 132 | Vendor_Sharp, |
133 | Vendor_SIEMENS, | 133 | Vendor_SIEMENS, |
134 | Vendor_MundN, | 134 | Vendor_MundN, |
135 | Vendor_GMate, | 135 | Vendor_GMate, |
136 | Vendor_MasterIA, | 136 | Vendor_MasterIA, |
137 | Vendor_GenuineIntel, | 137 | Vendor_GenuineIntel, |
138 | Vendor_Asus | 138 | Vendor_Asus |
139 | }; | 139 | }; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * The System used | 142 | * The System used |
143 | */ | 143 | */ |
144 | enum OSystem { | 144 | enum OSystem { |
145 | System_Unknown, | 145 | System_Unknown, |
146 | 146 | ||
147 | System_Familiar, | 147 | System_Familiar, |
148 | System_Zaurus, | 148 | System_Zaurus, |
149 | System_OpenZaurus, | 149 | System_OpenZaurus, |
150 | System_Linupy, | 150 | System_Linupy, |
151 | System_OpenEmbedded, | 151 | System_OpenEmbedded, |
152 | System_PC | 152 | System_PC |
153 | }; | 153 | }; |
154 | 154 | ||
155 | typedef struct { | 155 | typedef struct { |
156 | OSystem system; | 156 | OSystem system; |
157 | char* sysstr; | 157 | char* sysstr; |
158 | char* sysvfile; | 158 | char* sysvfile; |
159 | } ODistribution; | 159 | } ODistribution; |
160 | 160 | ||
161 | extern ODistribution distributions[]; | 161 | extern ODistribution distributions[]; |
162 | 162 | ||
163 | 163 | ||
164 | enum OLedState { | 164 | enum OLedState { |
165 | Led_Off, | 165 | Led_Off, |
166 | Led_On, | 166 | Led_On, |
167 | Led_BlinkSlow, | 167 | Led_BlinkSlow, |
168 | Led_BlinkFast | 168 | Led_BlinkFast |
169 | }; | 169 | }; |
170 | 170 | ||
171 | enum OLed { | 171 | enum OLed { |
172 | Led_Mail, | 172 | Led_Mail, |
173 | Led_Power, | 173 | Led_Power, |
174 | Led_BlueTooth | 174 | Led_BlueTooth |
175 | }; | 175 | }; |
176 | 176 | ||
177 | enum OHardKey { | 177 | enum OHardKey { |
178 | HardKey_Datebook = Qt::Key_F9, | 178 | HardKey_Datebook = Qt::Key_F9, |
179 | HardKey_Contacts = Qt::Key_F10, | 179 | HardKey_Contacts = Qt::Key_F10, |
180 | HardKey_Menu = Qt::Key_F11, | 180 | HardKey_Menu = Qt::Key_F11, |
181 | HardKey_Home = Qt::Key_F12, | 181 | HardKey_Home = Qt::Key_F12, |
182 | HardKey_Mail = Qt::Key_F13, | 182 | HardKey_Mail = Qt::Key_F13, |
183 | HardKey_Record = Qt::Key_F24, | 183 | HardKey_Record = Qt::Key_F24, |
184 | HardKey_Suspend = Qt::Key_F34, | 184 | HardKey_Suspend = Qt::Key_F34, |
185 | HardKey_Backlight = Qt::Key_F35, | 185 | HardKey_Backlight = Qt::Key_F35, |
186 | HardKey_Action = Qt::Key_F10, | 186 | HardKey_Action = Qt::Key_F10, |
187 | HardKey_OK = Qt::Key_F11, | 187 | HardKey_OK = Qt::Key_F11, |
188 | HardKey_End = Qt::Key_F12, | 188 | HardKey_End = Qt::Key_F12, |
189 | }; | 189 | }; |
190 | 190 | ||
191 | enum ODirection { | 191 | enum ODirection { |
192 | CW = 0, | 192 | CW = 0, |
193 | CCW = 1, | 193 | CCW = 1, |
194 | Flip = 2, | 194 | Flip = 2, |
195 | }; | 195 | }; |
196 | 196 | ||
197 | enum OHingeStatus { | 197 | enum OHingeStatus { |
198 | CASE_CLOSED = 3, | 198 | CASE_CLOSED = 3, |
199 | CASE_PORTRAIT = 2, | 199 | CASE_PORTRAIT = 2, |
200 | CASE_LANDSCAPE = 0, | 200 | CASE_LANDSCAPE = 0, |
201 | CASE_UNKNOWN = 1, | 201 | CASE_UNKNOWN = 1, |
202 | }; | 202 | }; |
203 | 203 | ||
204 | /* default button for qvfb or such | 204 | /* default button for qvfb or such |
205 | * see odevice.cpp for details. | 205 | * see odevice.cpp for details. |
206 | * hint: manage a user defined button for qvfb? | 206 | * hint: manage a user defined button for qvfb? |
207 | * alwin | 207 | * alwin |
208 | */ | 208 | */ |
209 | struct default_button { | 209 | struct default_button { |
210 | Qt::Key code; | 210 | Qt::Key code; |
211 | char *utext; | 211 | char *utext; |
212 | char *pix; | 212 | char *pix; |
213 | char *fpressedservice; | 213 | char *fpressedservice; |
214 | char *fpressedaction; | 214 | char *fpressedaction; |
215 | char *fheldservice; | 215 | char *fheldservice; |
216 | char *fheldaction; | 216 | char *fheldaction; |
217 | }; | 217 | }; |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * A singleton which gives informations about device specefic option | 220 | * A singleton which gives informations about device specefic option |
221 | * like the Hardware used, LEDs, the Base Distribution and | 221 | * like the Hardware used, LEDs, the Base Distribution and |
222 | * hardware key mappings. | 222 | * hardware key mappings. |
223 | * | 223 | * |
224 | * @short A small class for device specefic options | 224 | * @short A small class for device specific options |
225 | * @see QObject | 225 | * @see QObject |
226 | * @author Robert Griebl | 226 | * @author Robert Griebl |
227 | * @version 1.0 | 227 | * @version 1.0 |
228 | */ | 228 | */ |
229 | class ODevice : public QObject | 229 | class ODevice : public QObject |
230 | { | 230 | { |
231 | Q_OBJECT | 231 | Q_OBJECT |
232 | 232 | ||
233 | private: | 233 | private: |
234 | /* disable copy */ | 234 | /* disable copy */ |
235 | ODevice ( const ODevice & ); | 235 | ODevice ( const ODevice & ); |
236 | 236 | ||
237 | protected: | 237 | protected: |
238 | ODevice(); | 238 | ODevice(); |
239 | virtual void init(const QString&); | 239 | virtual void init(const QString&); |
240 | virtual void initButtons(); | 240 | virtual void initButtons(); |
241 | static void sendSuspendmsg(); | 241 | static void sendSuspendmsg(); |
242 | 242 | ||
243 | ODeviceData *d; | 243 | ODeviceData *d; |
244 | 244 | ||
245 | public: | 245 | public: |
246 | // sandman do we want to allow destructions? -zecke? | 246 | // sandman do we want to allow destructions? -zecke? |
247 | virtual ~ODevice(); | 247 | virtual ~ODevice(); |
248 | static ODevice *inst(); | 248 | static ODevice *inst(); |
249 | 249 | ||
250 | // information | 250 | // information |
251 | QString modelString() const; | 251 | QString modelString() const; |
252 | OModel model() const; | 252 | OModel model() const; |
253 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | 253 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } |
254 | 254 | ||
255 | QString vendorString() const; | 255 | QString vendorString() const; |
256 | OVendor vendor() const; | 256 | OVendor vendor() const; |
257 | 257 | ||
258 | QString systemString() const; | 258 | QString systemString() const; |
259 | OSystem system() const; | 259 | OSystem system() const; |
260 | 260 | ||
261 | QString systemVersionString() const; | 261 | QString systemVersionString() const; |
262 | 262 | ||
263 | virtual Transformation rotation() const; | 263 | virtual Transformation rotation() const; |
264 | virtual ODirection direction() const; | 264 | virtual ODirection direction() const; |
265 | 265 | ||
266 | QString qteDriver() const; | 266 | QString qteDriver() const; |
267 | 267 | ||
268 | // system | 268 | // system |
269 | virtual bool suspend(); | 269 | virtual bool suspend(); |
270 | 270 | ||
271 | virtual bool setDisplayStatus ( bool on ); | 271 | virtual bool setDisplayStatus ( bool on ); |
272 | virtual bool setDisplayBrightness ( int brightness ); | 272 | virtual bool setDisplayBrightness ( int brightness ); |
273 | virtual int displayBrightnessResolution() const; | 273 | virtual int displayBrightnessResolution() const; |
274 | virtual bool setDisplayContrast ( int contrast ); | 274 | virtual bool setDisplayContrast ( int contrast ); |
275 | virtual int displayContrastResolution() const; | 275 | virtual int displayContrastResolution() const; |
276 | 276 | ||
277 | // don't add new virtual methods, use this: | 277 | // don't add new virtual methods, use this: |
278 | // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | 278 | // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; |
279 | // and in your subclass do overwrite | 279 | // and in your subclass do overwrite |
280 | // protected virtual int virtual_hook(int, void *) | 280 | // protected virtual int virtual_hook(int, void *) |
281 | // which is defined below | 281 | // which is defined below |
282 | 282 | ||
283 | // input / output | 283 | // input / output |
284 | virtual void playAlarmSound(); | 284 | virtual void playAlarmSound(); |
285 | virtual void playKeySound(); | 285 | virtual void playKeySound(); |
286 | virtual void playTouchSound(); | 286 | virtual void playTouchSound(); |
287 | 287 | ||
288 | virtual QValueList <OLed> ledList() const; | 288 | virtual QValueList <OLed> ledList() const; |
289 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 289 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
290 | virtual OLedState ledState ( OLed led ) const; | 290 | virtual OLedState ledState ( OLed led ) const; |
291 | virtual bool setLedState ( OLed led, OLedState st ); | 291 | virtual bool setLedState ( OLed led, OLedState st ); |
292 | 292 | ||
293 | virtual bool hasLightSensor() const; | 293 | virtual bool hasLightSensor() const; |
294 | virtual int readLightSensor(); | 294 | virtual int readLightSensor(); |
295 | virtual int lightSensorResolution() const; | 295 | virtual int lightSensorResolution() const; |
296 | 296 | ||
297 | virtual bool hasHingeSensor() const; | 297 | virtual bool hasHingeSensor() const; |
298 | virtual OHingeStatus readHingeSensor()const; | 298 | virtual OHingeStatus readHingeSensor()const; |
299 | 299 | ||
300 | const QStrList &allowedCpuFrequencies() const; | 300 | const QStrList &allowedCpuFrequencies() const; |
301 | bool setCurrentCpuFrequency(uint index); | 301 | bool setCurrentCpuFrequency(uint index); |
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Returns the available buttons on this device. The number and location | 304 | * Returns the available buttons on this device. The number and location |
305 | * of buttons will vary depending on the device. Button numbers will be assigned | 305 | * of buttons will vary depending on the device. Button numbers will be assigned |
306 | * by the device manufacturer and will be from most preferred button to least preffered | 306 | * by the device manufacturer and will be from most preferred button to least preffered |
307 | * button. Note that this list only contains "user mappable" buttons. | 307 | * button. Note that this list only contains "user mappable" buttons. |
308 | * | 308 | * |
309 | * @todo Make method const and take care of calling initButtons or make that const too | 309 | * @todo Make method const and take care of calling initButtons or make that const too |
310 | * | 310 | * |
311 | */ | 311 | */ |
312 | const QValueList<ODeviceButton> &buttons(); | 312 | const QValueList<ODeviceButton> &buttons(); |
313 | 313 | ||
314 | /** | 314 | /** |
315 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 315 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
316 | * returns 0L | 316 | * returns 0L |
317 | */ | 317 | */ |
318 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 318 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | * Reassigns the pressed action for \a button. To return to the factory | 321 | * Reassigns the pressed action for \a button. To return to the factory |
322 | * default pass an empty string as \a qcopMessage. | 322 | * default pass an empty string as \a qcopMessage. |
323 | */ | 323 | */ |
324 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 324 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * Reassigns the held action for \a button. To return to the factory | 327 | * Reassigns the held action for \a button. To return to the factory |
328 | * default pass an empty string as \a qcopMessage. | 328 | * default pass an empty string as \a qcopMessage. |
329 | */ | 329 | */ |
330 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 330 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
331 | 331 | ||
332 | /** | 332 | /** |
333 | * How long (in ms) you have to press a button for a "hold" action | 333 | * How long (in ms) you have to press a button for a "hold" action |
334 | */ | 334 | */ |
335 | uint buttonHoldTime() const; | 335 | uint buttonHoldTime() const; |
336 | 336 | ||
337 | signals: | 337 | signals: |
338 | void buttonMappingChanged(); | 338 | void buttonMappingChanged(); |
339 | 339 | ||
340 | private slots: | 340 | private slots: |
341 | void systemMessage ( const QCString &, const QByteArray & ); | 341 | void systemMessage ( const QCString &, const QByteArray & ); |
342 | void playingStopped(); | 342 | void playingStopped(); |
343 | 343 | ||
344 | protected: | 344 | protected: |
345 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); | 345 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); |
346 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); | 346 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); |
347 | void reloadButtonMapping(); | 347 | void reloadButtonMapping(); |
348 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); | 348 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); |
349 | 349 | ||
350 | /* ugly virtual hook */ | 350 | /* ugly virtual hook */ |
351 | virtual void virtual_hook( int id, void* data ); | 351 | virtual void virtual_hook( int id, void* data ); |
352 | }; | 352 | }; |
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index a75f566..8a7e252 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -32,409 +32,411 @@ | |||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/oinputsystem.h> | 33 | #include <opie2/oinputsystem.h> |
34 | #include <opie2/oresource.h> | 34 | #include <opie2/oresource.h> |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/sound.h> | 37 | #include <qpe/sound.h> |
38 | 38 | ||
39 | /* QT */ | 39 | /* QT */ |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qwindowsystem_qws.h> | 43 | #include <qwindowsystem_qws.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <string.h> | 47 | #include <string.h> |
48 | #include <errno.h> | 48 | #include <errno.h> |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> |
50 | #include <math.h> | 50 | #include <math.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <signal.h> | 52 | #include <signal.h> |
53 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
54 | #include <sys/time.h> | 54 | #include <sys/time.h> |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | #ifndef QT_NO_SOUND | 56 | #ifndef QT_NO_SOUND |
57 | #include <linux/soundcard.h> | 57 | #include <linux/soundcard.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | using namespace Opie::Core; | 60 | using namespace Opie::Core; |
61 | using namespace Opie::Core::Internal; | 61 | using namespace Opie::Core::Internal; |
62 | 62 | ||
63 | struct z_button z_buttons [] = { | 63 | struct z_button z_buttons [] = { |
64 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 64 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
65 | "devicebuttons/z_calendar", | 65 | "devicebuttons/z_calendar", |
66 | "datebook", "nextView()", | 66 | "datebook", "nextView()", |
67 | "today", "raise()" }, | 67 | "today", "raise()" }, |
68 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 68 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
69 | "devicebuttons/z_contact", | 69 | "devicebuttons/z_contact", |
70 | "addressbook", "raise()", | 70 | "addressbook", "raise()", |
71 | "addressbook", "beamBusinessCard()" }, | 71 | "addressbook", "beamBusinessCard()" }, |
72 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 72 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
73 | "devicebuttons/z_home", | 73 | "devicebuttons/z_home", |
74 | "QPE/Launcher", "home()", | 74 | "QPE/Launcher", "home()", |
75 | "buttonsettings", "raise()" }, | 75 | "buttonsettings", "raise()" }, |
76 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 76 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
77 | "devicebuttons/z_menu", | 77 | "devicebuttons/z_menu", |
78 | "QPE/TaskBar", "toggleMenu()", | 78 | "QPE/TaskBar", "toggleMenu()", |
79 | "QPE/TaskBar", "toggleStartMenu()" }, | 79 | "QPE/TaskBar", "toggleStartMenu()" }, |
80 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 80 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
81 | "devicebuttons/z_mail", | 81 | "devicebuttons/z_mail", |
82 | "opiemail", "raise()", | 82 | "opiemail", "raise()", |
83 | "opiemail", "newMail()" }, | 83 | "opiemail", "newMail()" }, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | struct z_button z_buttons_c700 [] = { | 86 | struct z_button z_buttons_c700 [] = { |
87 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 87 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
88 | "devicebuttons/z_calendar", | 88 | "devicebuttons/z_calendar", |
89 | "datebook", "nextView()", | 89 | "datebook", "nextView()", |
90 | "today", "raise()" }, | 90 | "today", "raise()" }, |
91 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 91 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
92 | "devicebuttons/z_contact", | 92 | "devicebuttons/z_contact", |
93 | "addressbook", "raise()", | 93 | "addressbook", "raise()", |
94 | "addressbook", "beamBusinessCard()" }, | 94 | "addressbook", "beamBusinessCard()" }, |
95 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 95 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
96 | "devicebuttons/z_home", | 96 | "devicebuttons/z_home", |
97 | "QPE/Launcher", "home()", | 97 | "QPE/Launcher", "home()", |
98 | "buttonsettings", "raise()" }, | 98 | "buttonsettings", "raise()" }, |
99 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 99 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
100 | "devicebuttons/z_menu", | 100 | "devicebuttons/z_menu", |
101 | "QPE/TaskBar", "toggleMenu()", | 101 | "QPE/TaskBar", "toggleMenu()", |
102 | "QPE/TaskBar", "toggleStartMenu()" }, | 102 | "QPE/TaskBar", "toggleStartMenu()" }, |
103 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 103 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
104 | "devicebuttons/z_mail", | 104 | "devicebuttons/z_mail", |
105 | "opiemail", "raise()", | 105 | "opiemail", "raise()", |
106 | "opiemail", "newMail()" }, | 106 | "opiemail", "newMail()" }, |
107 | 107 | ||
108 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), | 108 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), |
109 | "devicebuttons/z_hinge1", | 109 | "devicebuttons/z_hinge1", |
110 | "QPE/Rotation", "rotateDefault()",0}, | 110 | "QPE/Rotation", "rotateDefault()",0}, |
111 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), | 111 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
112 | "devicebuttons/z_hinge2", | 112 | "devicebuttons/z_hinge2", |
113 | "QPE/Rotation", "rotateDefault()",0}, | 113 | "QPE/Rotation", "rotateDefault()",0}, |
114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
115 | "devicebuttons/z_hinge3", | 115 | "devicebuttons/z_hinge3", |
116 | "QPE/Rotation", "rotateDefault()",0}, | 116 | "QPE/Rotation", "rotateDefault()",0}, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | struct z_button z_buttons_6000 [] = { | 119 | struct z_button z_buttons_6000 [] = { |
120 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 120 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
121 | "devicebuttons/z_calendar", | 121 | "devicebuttons/z_calendar", |
122 | "datebook", "nextView()", | 122 | "datebook", "nextView()", |
123 | "today", "raise()" }, | 123 | "today", "raise()" }, |
124 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 124 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
125 | "devicebuttons/z_contact", | 125 | "devicebuttons/z_contact", |
126 | "addressbook", "raise()", | 126 | "addressbook", "raise()", |
127 | "addressbook", "beamBusinessCard()" }, | 127 | "addressbook", "beamBusinessCard()" }, |
128 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 128 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
129 | "devicebuttons/z_home", | 129 | "devicebuttons/z_home", |
130 | "QPE/Launcher", "home()", | 130 | "QPE/Launcher", "home()", |
131 | "buttonsettings", "raise()" }, | 131 | "buttonsettings", "raise()" }, |
132 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 132 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
133 | "devicebuttons/z_menu", | 133 | "devicebuttons/z_menu", |
134 | "QPE/TaskBar", "toggleMenu()", | 134 | "QPE/TaskBar", "toggleMenu()", |
135 | "QPE/TaskBar", "toggleStartMenu()" }, | 135 | "QPE/TaskBar", "toggleStartMenu()" }, |
136 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 136 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
137 | "devicebuttons/z_mail", | 137 | "devicebuttons/z_mail", |
138 | "opiemail", "raise()", | 138 | "opiemail", "raise()", |
139 | "opiemail", "newMail()" }, | 139 | "opiemail", "newMail()" }, |
140 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), | 140 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), |
141 | "devicebuttons/z_rotate", | 141 | "devicebuttons/z_rotate", |
142 | 0, | 142 | 0, |
143 | "QPE/Rotation", "rotateDefault()" }, | 143 | "QPE/Rotation", "rotateDefault()" }, |
144 | { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 144 | { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
145 | "devicebuttons/z_hinge3", | 145 | "devicebuttons/z_hinge3", |
146 | "QPE/VMemo", "toggleRecord()", | 146 | "QPE/VMemo", "toggleRecord()", |
147 | "sound", "raise()" }, | 147 | "sound", "raise()" }, |
148 | }; | 148 | }; |
149 | 149 | ||
150 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 150 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
151 | // class up into individual classes. We would need three classes | 151 | // class up into individual classes. We would need three classes |
152 | // | 152 | // |
153 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 153 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
154 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 154 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
155 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100) | 155 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100) |
156 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 156 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
157 | 157 | ||
158 | void Zaurus::init(const QString& cpu_info) | 158 | void Zaurus::init(const QString& cpu_info) |
159 | { | 159 | { |
160 | qDebug( "Zaurus::init()" ); | ||
160 | // Set the time to wait until the system is really suspended | 161 | // Set the time to wait until the system is really suspended |
161 | // the delta between apm --suspend and sleeping | 162 | // the delta between apm --suspend and sleeping |
162 | setAPMTimeOut( 15000 ); | 163 | setAPMTimeOut( 15000 ); |
163 | 164 | ||
164 | // generic distribution code already scanned /etc/issue at that point - | 165 | // generic distribution code already scanned /etc/issue at that point - |
165 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 166 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
166 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 167 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
167 | { | 168 | { |
168 | d->m_vendorstr = "Sharp"; | 169 | d->m_vendorstr = "Sharp"; |
169 | d->m_vendor = Vendor_Sharp; | 170 | d->m_vendor = Vendor_Sharp; |
170 | d->m_systemstr = "Zaurus"; | 171 | d->m_systemstr = "Zaurus"; |
171 | d->m_system = System_Zaurus; | 172 | d->m_system = System_Zaurus; |
172 | m_embedix = true; | 173 | m_embedix = true; |
173 | } | 174 | } |
174 | else | 175 | else |
175 | { | 176 | { |
176 | d->m_vendorstr = "OpenZaurus Team"; | 177 | d->m_vendorstr = "OpenZaurus Team"; |
177 | d->m_systemstr = "OpenZaurus"; | 178 | d->m_systemstr = "OpenZaurus"; |
178 | d->m_system = System_OpenZaurus; | 179 | d->m_system = System_OpenZaurus; |
179 | // sysver already gathered | 180 | // sysver already gathered |
180 | 181 | ||
181 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one | 182 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one |
182 | FILE *uname = popen("uname -r", "r"); | 183 | FILE *uname = popen("uname -r", "r"); |
183 | QFile f; | 184 | QFile f; |
184 | QString line; | 185 | QString line; |
185 | if ( f.open(IO_ReadOnly, uname) ) { | 186 | if ( f.open(IO_ReadOnly, uname) ) { |
186 | QTextStream ts ( &f ); | 187 | QTextStream ts ( &f ); |
187 | line = ts.readLine(); | 188 | line = ts.readLine(); |
188 | m_embedix = line.startsWith( "2.4." ); | 189 | m_embedix = line.startsWith( "2.4." ); |
189 | f.close(); | 190 | f.close(); |
190 | } | 191 | } |
191 | pclose(uname); | 192 | pclose(uname); |
192 | } | 193 | } |
193 | 194 | ||
194 | // check the Zaurus model | 195 | // check the Zaurus model |
195 | QString model; | 196 | QString model; |
196 | int loc = cpu_info.find( ":" ); | 197 | int loc = cpu_info.find( ":" ); |
197 | if ( loc != -1 ) | 198 | if ( loc != -1 ) |
198 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 199 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
199 | else | 200 | else |
200 | model = cpu_info; | 201 | model = cpu_info; |
201 | 202 | ||
202 | if ( model == "SHARP Corgi" ) { | 203 | if ( model == "SHARP Corgi" ) { |
203 | d->m_model = Model_Zaurus_SLC7x0; | 204 | d->m_model = Model_Zaurus_SLC7x0; |
204 | d->m_modelstr = "Zaurus SL-C700"; | 205 | d->m_modelstr = "Zaurus SL-C700"; |
205 | } else if ( model == "SHARP Shepherd" ) { | 206 | } else if ( model == "SHARP Shepherd" ) { |
206 | d->m_model = Model_Zaurus_SLC7x0; | 207 | d->m_model = Model_Zaurus_SLC7x0; |
207 | d->m_modelstr = "Zaurus SL-C750"; | 208 | d->m_modelstr = "Zaurus SL-C750"; |
208 | } else if ( model == "SHARP Husky" ) { | 209 | } else if ( model == "SHARP Husky" ) { |
209 | d->m_model = Model_Zaurus_SLC7x0; | 210 | d->m_model = Model_Zaurus_SLC7x0; |
210 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 211 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
211 | } else if ( model == "SHARP Boxer" ) { | 212 | } else if ( model == "SHARP Boxer" ) { |
212 | d->m_model = Model_Zaurus_SLC7x0; | 213 | d->m_model = Model_Zaurus_SLC7x0; |
213 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 214 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
214 | } else if ( model == "SHARP Poodle" ) { | 215 | } else if ( model == "SHARP Poodle" ) { |
215 | d->m_model = Model_Zaurus_SLB600; | 216 | d->m_model = Model_Zaurus_SLB600; |
216 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 217 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
217 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 218 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
218 | d->m_model = Model_Zaurus_SL5500; | 219 | d->m_model = Model_Zaurus_SL5500; |
219 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 220 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
220 | } else if ( model == "SHARP Tosa" ) { | 221 | } else if ( model == "SHARP Tosa" ) { |
221 | d->m_model = Model_Zaurus_SL6000; | 222 | d->m_model = Model_Zaurus_SL6000; |
222 | d->m_modelstr = "Zaurus SL-6000"; | 223 | d->m_modelstr = "Zaurus SL-6000"; |
223 | } else if ( model == "SHARP Spitz" ) { | 224 | } else if ( model == "SHARP Spitz" ) { |
224 | d->m_model = Model_Zaurus_SLC3000; | 225 | d->m_model = Model_Zaurus_SLC3000; |
225 | d->m_modelstr = "Zaurus SL-C3000"; | 226 | d->m_modelstr = "Zaurus SL-C3000"; |
226 | } else if ( model == "SHARP Akita" ) { | 227 | } else if ( model == "SHARP Akita" ) { |
227 | d->m_model = Model_Zaurus_SLC1000; | 228 | d->m_model = Model_Zaurus_SLC1000; |
228 | d->m_modelstr = "Zaurus SL-C1000"; | 229 | d->m_modelstr = "Zaurus SL-C1000"; |
229 | } else if ( model == "SHARP Borzoi" ) { | 230 | } else if ( model == "SHARP Borzoi" ) { |
230 | d->m_model = Model_Zaurus_SLC3100; | 231 | d->m_model = Model_Zaurus_SLC3100; |
231 | d->m_modelstr = "Zaurus SL-C3100"; | 232 | d->m_modelstr = "Zaurus SL-C3100"; |
232 | } else { | 233 | } else { |
233 | d->m_model = Model_Zaurus_SL5500; | 234 | d->m_model = Model_Zaurus_SL5500; |
234 | d->m_modelstr = "Unknown Zaurus"; | 235 | d->m_modelstr = "Unknown Zaurus"; |
235 | } | 236 | } |
236 | 237 | ||
237 | // set path to backlight device in kernel 2.6 | 238 | // set path to backlight device in kernel 2.6 |
238 | switch ( d->m_model ) | 239 | switch ( d->m_model ) |
239 | { | 240 | { |
240 | case Model_Zaurus_SLB600: // fallthrough | 241 | case Model_Zaurus_SLB600: // fallthrough |
241 | case Model_Zaurus_SL5500: | 242 | case Model_Zaurus_SL5500: |
242 | m_backlightdev = "/sys/class/backlight/locomo-backlight/"; | 243 | m_backlightdev = "/sys/class/backlight/locomo-backlight/"; |
243 | break; | 244 | break; |
244 | case Model_Zaurus_SL6000: | 245 | case Model_Zaurus_SL6000: |
245 | m_backlightdev = "/sys/class/backlight/tosa-bl/"; | 246 | m_backlightdev = "/sys/class/backlight/tosa-bl/"; |
246 | break; | 247 | break; |
247 | default: | 248 | default: |
248 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; | 249 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
249 | } | 250 | } |
250 | 251 | ||
251 | // set initial rotation | 252 | // set initial rotation |
252 | switch( d->m_model ) | 253 | switch( d->m_model ) |
253 | { | 254 | { |
254 | case Model_Zaurus_SL6000: // fallthrough | 255 | case Model_Zaurus_SL6000: // fallthrough |
255 | case Model_Zaurus_SLA300: | 256 | case Model_Zaurus_SLA300: |
256 | d->m_rotation = Rot0; | 257 | d->m_rotation = Rot0; |
257 | break; | 258 | break; |
258 | case Model_Zaurus_SLC3100: // fallthrough | 259 | case Model_Zaurus_SLC3100: // fallthrough |
259 | case Model_Zaurus_SLC3000: // fallthrough | 260 | case Model_Zaurus_SLC3000: // fallthrough |
260 | case Model_Zaurus_SLC1000: // fallthrough | 261 | case Model_Zaurus_SLC1000: // fallthrough |
261 | case Model_Zaurus_SLC7x0: | 262 | case Model_Zaurus_SLC7x0: |
263 | initHingeSensor(); | ||
262 | d->m_rotation = rotation(); | 264 | d->m_rotation = rotation(); |
263 | d->m_direction = direction(); | 265 | d->m_direction = direction(); |
264 | break; | 266 | break; |
265 | case Model_Zaurus_SLB600: // fallthrough | 267 | case Model_Zaurus_SLB600: // fallthrough |
266 | case Model_Zaurus_SL5000: // fallthrough | 268 | case Model_Zaurus_SL5000: // fallthrough |
267 | case Model_Zaurus_SL5500: // fallthrough | 269 | case Model_Zaurus_SL5500: // fallthrough |
268 | default: | 270 | default: |
269 | d->m_rotation = Rot270; | 271 | d->m_rotation = Rot270; |
270 | } | 272 | } |
271 | 273 | ||
272 | // set default qte driver | 274 | // set default qte driver |
273 | switch( d->m_model ) | 275 | switch( d->m_model ) |
274 | { | 276 | { |
275 | case Model_Zaurus_SLC7x0: | 277 | case Model_Zaurus_SLC7x0: |
276 | d->m_qteDriver = "W100"; | 278 | d->m_qteDriver = "W100"; |
277 | break; | 279 | break; |
278 | default: | 280 | default: |
279 | d->m_qteDriver = "Transformed"; | 281 | d->m_qteDriver = "Transformed"; |
280 | } | 282 | } |
281 | 283 | ||
282 | m_leds[0] = Led_Off; | 284 | m_leds[0] = Led_Off; |
283 | 285 | ||
284 | if ( m_embedix ) | 286 | if ( m_embedix ) |
285 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | 287 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); |
286 | else | 288 | else |
287 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 289 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
288 | } | 290 | } |
289 | 291 | ||
290 | void Zaurus::initButtons() | 292 | void Zaurus::initButtons() |
291 | { | 293 | { |
294 | qDebug( "Zaurus::initButtons()" ); | ||
292 | if ( d->m_buttons ) | 295 | if ( d->m_buttons ) |
293 | return; | 296 | return; |
294 | 297 | ||
295 | d->m_buttons = new QValueList <ODeviceButton>; | 298 | d->m_buttons = new QValueList <ODeviceButton>; |
296 | 299 | ||
297 | struct z_button * pz_buttons; | 300 | struct z_button * pz_buttons; |
298 | int buttoncount; | 301 | int buttoncount; |
299 | switch ( d->m_model ) | 302 | switch ( d->m_model ) |
300 | { | 303 | { |
301 | case Model_Zaurus_SL6000: | 304 | case Model_Zaurus_SL6000: |
302 | pz_buttons = z_buttons_6000; | 305 | pz_buttons = z_buttons_6000; |
303 | buttoncount = ARRAY_SIZE(z_buttons_6000); | 306 | buttoncount = ARRAY_SIZE(z_buttons_6000); |
304 | break; | 307 | break; |
305 | case Model_Zaurus_SLC3100: // fallthrough | 308 | case Model_Zaurus_SLC3100: // fallthrough |
306 | case Model_Zaurus_SLC3000: // fallthrough | 309 | case Model_Zaurus_SLC3000: // fallthrough |
307 | case Model_Zaurus_SLC1000: // fallthrough | 310 | case Model_Zaurus_SLC1000: // fallthrough |
308 | case Model_Zaurus_SLC7x0: | 311 | case Model_Zaurus_SLC7x0: |
309 | if ( isQWS( ) ) | 312 | if ( isQWS( ) ) |
310 | { // setup hinge sensor stuff | 313 | { |
311 | addPreHandler(this); | 314 | addPreHandler(this); |
312 | initHingeSensor(); | ||
313 | } | 315 | } |
314 | pz_buttons = z_buttons_c700; | 316 | pz_buttons = z_buttons_c700; |
315 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 317 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
316 | break; | 318 | break; |
317 | default: | 319 | default: |
318 | pz_buttons = z_buttons; | 320 | pz_buttons = z_buttons; |
319 | buttoncount = ARRAY_SIZE(z_buttons); | 321 | buttoncount = ARRAY_SIZE(z_buttons); |
320 | break; | 322 | break; |
321 | } | 323 | } |
322 | 324 | ||
323 | for ( int i = 0; i < buttoncount; i++ ) { | 325 | for ( int i = 0; i < buttoncount; i++ ) { |
324 | struct z_button *zb = pz_buttons + i; | 326 | struct z_button *zb = pz_buttons + i; |
325 | ODeviceButton b; | 327 | ODeviceButton b; |
326 | 328 | ||
327 | b.setKeycode( zb->code ); | 329 | b.setKeycode( zb->code ); |
328 | b.setUserText( QObject::tr( "Button", zb->utext )); | 330 | b.setUserText( QObject::tr( "Button", zb->utext )); |
329 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 331 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
330 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 332 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
331 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 333 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
332 | d->m_buttons->append( b ); | 334 | d->m_buttons->append( b ); |
333 | } | 335 | } |
334 | 336 | ||
335 | reloadButtonMapping(); | 337 | reloadButtonMapping(); |
336 | } | 338 | } |
337 | 339 | ||
338 | 340 | ||
339 | 341 | ||
340 | typedef struct sharp_led_status { | 342 | typedef struct sharp_led_status { |
341 | int which; /* select which LED status is wanted. */ | 343 | int which; /* select which LED status is wanted. */ |
342 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 344 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
343 | } sharp_led_status; | 345 | } sharp_led_status; |
344 | 346 | ||
345 | void Zaurus::buzzer( int sound ) | 347 | void Zaurus::buzzer( int sound ) |
346 | { | 348 | { |
347 | #ifndef QT_NO_SOUND | 349 | #ifndef QT_NO_SOUND |
348 | Sound *snd = 0; | 350 | Sound *snd = 0; |
349 | 351 | ||
350 | // All devices except SL5500 have a DSP device | 352 | // All devices except SL5500 have a DSP device |
351 | if ( d->m_model != Model_Zaurus_SL5000 | 353 | if ( d->m_model != Model_Zaurus_SL5000 |
352 | && d->m_model != Model_Zaurus_SL5500 ) { | 354 | && d->m_model != Model_Zaurus_SL5500 ) { |
353 | 355 | ||
354 | switch ( sound ){ | 356 | switch ( sound ){ |
355 | case SHARP_BUZ_TOUCHSOUND: { | 357 | case SHARP_BUZ_TOUCHSOUND: { |
356 | static Sound touch_sound("touchsound"); | 358 | static Sound touch_sound("touchsound"); |
357 | snd = &touch_sound; | 359 | snd = &touch_sound; |
358 | } | 360 | } |
359 | break; | 361 | break; |
360 | case SHARP_BUZ_KEYSOUND: { | 362 | case SHARP_BUZ_KEYSOUND: { |
361 | static Sound key_sound( "keysound" ); | 363 | static Sound key_sound( "keysound" ); |
362 | snd = &key_sound; | 364 | snd = &key_sound; |
363 | } | 365 | } |
364 | break; | 366 | break; |
365 | case SHARP_BUZ_SCHEDULE_ALARM: | 367 | case SHARP_BUZ_SCHEDULE_ALARM: |
366 | default: { | 368 | default: { |
367 | static Sound alarm_sound("alarm"); | 369 | static Sound alarm_sound("alarm"); |
368 | snd = &alarm_sound; | 370 | snd = &alarm_sound; |
369 | } | 371 | } |
370 | break; | 372 | break; |
371 | } | 373 | } |
372 | } | 374 | } |
373 | 375 | ||
374 | // If a soundname is defined, we expect that this device has | 376 | // If a soundname is defined, we expect that this device has |
375 | // sound capabilities.. Otherwise we expect to have the buzzer | 377 | // sound capabilities.. Otherwise we expect to have the buzzer |
376 | // device.. | 378 | // device.. |
377 | if ( snd && snd->isFinished() ){ | 379 | if ( snd && snd->isFinished() ){ |
378 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 380 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
379 | snd->play(); | 381 | snd->play(); |
380 | } else if( !snd ) { | 382 | } else if( !snd ) { |
381 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 383 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
382 | 384 | ||
383 | if ( fd >= 0 ) { | 385 | if ( fd >= 0 ) { |
384 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 386 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
385 | ::close ( fd ); | 387 | ::close ( fd ); |
386 | } | 388 | } |
387 | 389 | ||
388 | } | 390 | } |
389 | #endif | 391 | #endif |
390 | } | 392 | } |
391 | 393 | ||
392 | 394 | ||
393 | void Zaurus::playAlarmSound() | 395 | void Zaurus::playAlarmSound() |
394 | { | 396 | { |
395 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 397 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
396 | } | 398 | } |
397 | 399 | ||
398 | void Zaurus::playTouchSound() | 400 | void Zaurus::playTouchSound() |
399 | { | 401 | { |
400 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 402 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
401 | } | 403 | } |
402 | 404 | ||
403 | void Zaurus::playKeySound() | 405 | void Zaurus::playKeySound() |
404 | { | 406 | { |
405 | buzzer( SHARP_BUZ_KEYSOUND ); | 407 | buzzer( SHARP_BUZ_KEYSOUND ); |
406 | } | 408 | } |
407 | 409 | ||
408 | 410 | ||
409 | QValueList <OLed> Zaurus::ledList() const | 411 | QValueList <OLed> Zaurus::ledList() const |
410 | { | 412 | { |
411 | QValueList <OLed> vl; | 413 | QValueList <OLed> vl; |
412 | vl << Led_Mail; | 414 | vl << Led_Mail; |
413 | return vl; | 415 | return vl; |
414 | } | 416 | } |
415 | 417 | ||
416 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 418 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
417 | { | 419 | { |
418 | QValueList <OLedState> vl; | 420 | QValueList <OLedState> vl; |
419 | 421 | ||
420 | if ( l == Led_Mail ) | 422 | if ( l == Led_Mail ) |
421 | vl << Led_Off << Led_On << Led_BlinkSlow; | 423 | vl << Led_Off << Led_On << Led_BlinkSlow; |
422 | return vl; | 424 | return vl; |
423 | } | 425 | } |
424 | 426 | ||
425 | OLedState Zaurus::ledState( OLed which ) const | 427 | OLedState Zaurus::ledState( OLed which ) const |
426 | { | 428 | { |
427 | if ( which == Led_Mail ) | 429 | if ( which == Led_Mail ) |
428 | return m_leds [0]; | 430 | return m_leds [0]; |
429 | else | 431 | else |
430 | return Led_Off; | 432 | return Led_Off; |
431 | } | 433 | } |
432 | 434 | ||
433 | bool Zaurus::setLedState( OLed which, OLedState st ) | 435 | bool Zaurus::setLedState( OLed which, OLedState st ) |
434 | { | 436 | { |
435 | // Currently not supported on non_embedix kernels | 437 | // Currently not supported on non_embedix kernels |
436 | if (!m_embedix) | 438 | if (!m_embedix) |
437 | { | 439 | { |
438 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 440 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
439 | return false; | 441 | return false; |
440 | } | 442 | } |
@@ -476,320 +478,330 @@ int Zaurus::displayBrightnessResolution() const | |||
476 | ::close( fd ); | 478 | ::close( fd ); |
477 | return value ? value : res; | 479 | return value ? value : res; |
478 | } | 480 | } |
479 | } | 481 | } |
480 | else | 482 | else |
481 | { | 483 | { |
482 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 484 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
483 | if ( fd ) | 485 | if ( fd ) |
484 | { | 486 | { |
485 | char buf[100]; | 487 | char buf[100]; |
486 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 488 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
487 | ::close( fd ); | 489 | ::close( fd ); |
488 | } | 490 | } |
489 | } | 491 | } |
490 | return res; | 492 | return res; |
491 | } | 493 | } |
492 | 494 | ||
493 | bool Zaurus::setDisplayBrightness( int bright ) | 495 | bool Zaurus::setDisplayBrightness( int bright ) |
494 | { | 496 | { |
495 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 497 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
496 | bool res = false; | 498 | bool res = false; |
497 | 499 | ||
498 | if ( bright > 255 ) bright = 255; | 500 | if ( bright > 255 ) bright = 255; |
499 | if ( bright < 0 ) bright = 0; | 501 | if ( bright < 0 ) bright = 0; |
500 | 502 | ||
501 | int numberOfSteps = displayBrightnessResolution(); | 503 | int numberOfSteps = displayBrightnessResolution(); |
502 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 504 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
503 | 505 | ||
504 | if ( m_embedix ) | 506 | if ( m_embedix ) |
505 | { | 507 | { |
506 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 508 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
507 | if ( fd ) | 509 | if ( fd ) |
508 | { | 510 | { |
509 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 511 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
510 | ::close( fd ); | 512 | ::close( fd ); |
511 | } | 513 | } |
512 | } | 514 | } |
513 | else | 515 | else |
514 | { | 516 | { |
515 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 517 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
516 | if ( fd ) | 518 | if ( fd ) |
517 | { | 519 | { |
518 | char buf[100]; | 520 | char buf[100]; |
519 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 521 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
520 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 522 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
521 | ::close( fd ); | 523 | ::close( fd ); |
522 | } | 524 | } |
523 | } | 525 | } |
524 | return res; | 526 | return res; |
525 | } | 527 | } |
526 | 528 | ||
527 | bool Zaurus::setDisplayStatus( bool on ) | 529 | bool Zaurus::setDisplayStatus( bool on ) |
528 | { | 530 | { |
529 | bool res = false; | 531 | bool res = false; |
530 | if ( m_embedix ) | 532 | if ( m_embedix ) |
531 | { | 533 | { |
532 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 534 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
533 | if ( fd ) | 535 | if ( fd ) |
534 | { | 536 | { |
535 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 537 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
536 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 538 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
537 | ::close ( fd ); | 539 | ::close ( fd ); |
538 | } | 540 | } |
539 | } | 541 | } |
540 | else | 542 | else |
541 | { | 543 | { |
542 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 544 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
543 | if ( fd ) | 545 | if ( fd ) |
544 | { | 546 | { |
545 | char buf[10]; | 547 | char buf[10]; |
546 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 548 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
547 | buf[1] = '\0'; | 549 | buf[1] = '\0'; |
548 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 550 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
549 | ::close( fd ); | 551 | ::close( fd ); |
550 | } | 552 | } |
551 | } | 553 | } |
552 | return res; | 554 | return res; |
553 | } | 555 | } |
554 | 556 | ||
555 | Transformation Zaurus::rotation() const | 557 | Transformation Zaurus::rotation() const |
556 | { | 558 | { |
557 | qDebug( "Zaurus::rotation()" ); | 559 | qDebug( "Zaurus::rotation()" ); |
558 | Transformation rot; | 560 | Transformation rot; |
559 | 561 | ||
560 | switch ( d->m_model ) { | 562 | switch ( d->m_model ) { |
561 | case Model_Zaurus_SLC3100: // fallthrough | 563 | case Model_Zaurus_SLC3100: // fallthrough |
562 | case Model_Zaurus_SLC3000: // fallthrough | 564 | case Model_Zaurus_SLC3000: // fallthrough |
563 | case Model_Zaurus_SLC1000: | 565 | case Model_Zaurus_SLC1000: |
564 | { | 566 | { |
565 | OHingeStatus hs = readHingeSensor(); | 567 | OHingeStatus hs = readHingeSensor(); |
566 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 568 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
567 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 569 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
568 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 570 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
569 | else rot = Rot270; | 571 | else rot = Rot270; |
570 | } | 572 | } |
571 | break; | 573 | break; |
572 | 574 | ||
573 | // SLC7x0 needs a special case here, because we were able to set the W100 | 575 | // SLC7x0 needs a special case here, because we were able to set the W100 |
574 | // hardware default rotation on kernel 2.6 to Rot0 | 576 | // hardware default rotation on kernel 2.6 to Rot0 |
575 | case Model_Zaurus_SLC7x0: | 577 | case Model_Zaurus_SLC7x0: |
576 | { | 578 | { |
577 | OHingeStatus hs = readHingeSensor(); | 579 | OHingeStatus hs = readHingeSensor(); |
578 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 580 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
579 | 581 | ||
580 | if ( m_embedix ) | 582 | if ( m_embedix ) |
581 | { | 583 | { |
582 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 584 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
583 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 585 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
584 | else rot = Rot270; | 586 | else rot = Rot270; |
585 | } | 587 | } |
586 | else | 588 | else |
587 | { | 589 | { |
588 | if ( hs == CASE_PORTRAIT ) rot = Rot90; | 590 | if ( hs == CASE_PORTRAIT ) rot = Rot90; |
589 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 591 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
590 | else rot = Rot0; | 592 | else rot = Rot0; |
591 | } | 593 | } |
592 | } | 594 | } |
593 | break; | 595 | break; |
594 | case Model_Zaurus_SL6000: | 596 | case Model_Zaurus_SL6000: |
595 | case Model_Zaurus_SLB600: | 597 | case Model_Zaurus_SLB600: |
596 | case Model_Zaurus_SLA300: | 598 | case Model_Zaurus_SLA300: |
597 | case Model_Zaurus_SL5500: | 599 | case Model_Zaurus_SL5500: |
598 | case Model_Zaurus_SL5000: | 600 | case Model_Zaurus_SL5000: |
599 | default: | 601 | default: |
600 | rot = d->m_rotation; | 602 | rot = d->m_rotation; |
601 | break; | 603 | break; |
602 | } | 604 | } |
603 | 605 | ||
606 | qDebug( "Zaurus::rotation() - returning '%d'", rot ); | ||
604 | return rot; | 607 | return rot; |
605 | } | 608 | } |
606 | ODirection Zaurus::direction() const | 609 | ODirection Zaurus::direction() const |
607 | { | 610 | { |
608 | ODirection dir; | 611 | ODirection dir; |
609 | 612 | ||
610 | switch ( d->m_model ) { | 613 | switch ( d->m_model ) { |
611 | case Model_Zaurus_SLC3100: // fallthrough | 614 | case Model_Zaurus_SLC3100: // fallthrough |
612 | case Model_Zaurus_SLC3000: // fallthrough | 615 | case Model_Zaurus_SLC3000: // fallthrough |
613 | case Model_Zaurus_SLC1000: // fallthrough | 616 | case Model_Zaurus_SLC1000: // fallthrough |
614 | case Model_Zaurus_SLC7x0: { | 617 | case Model_Zaurus_SLC7x0: { |
615 | OHingeStatus hs = readHingeSensor(); | 618 | OHingeStatus hs = readHingeSensor(); |
616 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 619 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
617 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 620 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
618 | else dir = CW; | 621 | else dir = CW; |
619 | } | 622 | } |
620 | break; | 623 | break; |
621 | case Model_Zaurus_SL6000: | 624 | case Model_Zaurus_SL6000: |
622 | case Model_Zaurus_SLA300: | 625 | case Model_Zaurus_SLA300: |
623 | case Model_Zaurus_SLB600: | 626 | case Model_Zaurus_SLB600: |
624 | case Model_Zaurus_SL5500: | 627 | case Model_Zaurus_SL5500: |
625 | case Model_Zaurus_SL5000: | 628 | case Model_Zaurus_SL5000: |
626 | default: dir = d->m_direction; | 629 | default: dir = d->m_direction; |
627 | break; | 630 | break; |
628 | } | 631 | } |
629 | return dir; | 632 | return dir; |
630 | 633 | ||
631 | } | 634 | } |
632 | 635 | ||
633 | bool Zaurus::hasHingeSensor() const | 636 | bool Zaurus::hasHingeSensor() const |
634 | { | 637 | { |
635 | return d->m_model == Model_Zaurus_SLC7x0 || | 638 | return d->m_model == Model_Zaurus_SLC7x0 || |
636 | d->m_model == Model_Zaurus_SLC3100 || | 639 | d->m_model == Model_Zaurus_SLC3100 || |
637 | d->m_model == Model_Zaurus_SLC3000 || | 640 | d->m_model == Model_Zaurus_SLC3000 || |
638 | d->m_model == Model_Zaurus_SLC1000; | 641 | d->m_model == Model_Zaurus_SLC1000; |
639 | } | 642 | } |
640 | 643 | ||
641 | OHingeStatus Zaurus::readHingeSensor() const | 644 | OHingeStatus Zaurus::readHingeSensor() const |
642 | { | 645 | { |
643 | if (m_embedix) | 646 | if (m_embedix) |
644 | { | 647 | { |
645 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 648 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
646 | if (handle == -1) | 649 | if (handle == -1) |
647 | { | 650 | { |
648 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 651 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
649 | return CASE_UNKNOWN; | 652 | return CASE_UNKNOWN; |
650 | } | 653 | } |
651 | else | 654 | else |
652 | { | 655 | { |
653 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 656 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
654 | ::close (handle); | 657 | ::close (handle); |
655 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 658 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
656 | { | 659 | { |
657 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 660 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
658 | return static_cast<OHingeStatus>( retval ); | 661 | return static_cast<OHingeStatus>( retval ); |
659 | } | 662 | } |
660 | else | 663 | else |
661 | { | 664 | { |
662 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 665 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
663 | return CASE_UNKNOWN; | 666 | return CASE_UNKNOWN; |
664 | } | 667 | } |
665 | } | 668 | } |
666 | } | 669 | } |
667 | else | 670 | else |
668 | { | 671 | { |
669 | /* | 672 | /* |
670 | * The corgi keyboard is event source 0 in OZ kernel 2.6. | 673 | * The corgi keyboard is event source 0 in OZ kernel 2.6. |
671 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 674 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
672 | * | 675 | * |
673 | * ------------------------- | 676 | * ------------------------- |
674 | * | SW0 | SW1 | CASE | | 677 | * | SW0 | SW1 | CASE | |
675 | * |-----|-----|-----------| | 678 | * |-----|-----|-----------| |
676 | * | 0 0 Landscape | | 679 | * | 0 0 Landscape | |
677 | * | 0 1 Portrait | | 680 | * | 0 1 Portrait | |
678 | * | 1 0 Unknown | | 681 | * | 1 0 Unknown | |
679 | * | 1 1 Closed | | 682 | * | 1 1 Closed | |
680 | * ------------------------- | 683 | * ------------------------- |
681 | */ | 684 | */ |
682 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 685 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
683 | bool switch0 = true; | 686 | bool switch0 = true; |
684 | bool switch1 = false; | 687 | bool switch1 = false; |
685 | if ( keyboard ) | 688 | if ( keyboard ) |
686 | { | 689 | { |
687 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); | 690 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
688 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | 691 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); |
689 | } | 692 | } |
690 | if ( switch0 ) | 693 | if ( switch0 ) |
691 | { | 694 | { |
692 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 695 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
693 | } | 696 | } |
694 | else | 697 | else |
695 | { | 698 | { |
696 | return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE; | 699 | return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE; |
697 | } | 700 | } |
698 | } | 701 | } |
699 | } | 702 | } |
700 | 703 | ||
701 | void Zaurus::initHingeSensor() | 704 | void Zaurus::initHingeSensor() |
702 | { | 705 | { |
703 | if ( m_embedix ) return; | 706 | if ( m_embedix ) return; |
704 | 707 | ||
705 | m_hinge.setName( "/dev/input/event0" ); | 708 | m_hinge.setName( "/dev/input/event0" ); |
706 | if ( !m_hinge.open( IO_ReadOnly ) ) | 709 | if ( !m_hinge.open( IO_ReadOnly ) ) |
707 | { | 710 | { |
708 | qDebug( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) ); | 711 | qWarning( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) ); |
709 | return; | 712 | return; |
710 | } | 713 | } |
711 | 714 | ||
712 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); | 715 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); |
713 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); | 716 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); |
717 | |||
718 | qDebug( "Zaurus::init() - Hinge Sensor Initialization successfully completed" ); | ||
714 | } | 719 | } |
715 | 720 | ||
716 | void Zaurus::hingeSensorTriggered() | 721 | void Zaurus::hingeSensorTriggered() |
717 | { | 722 | { |
718 | qDebug( "Zaurus::hingeSensorTriggered() - got event" ); | 723 | qDebug( "Zaurus::hingeSensorTriggered() - got event" ); |
719 | struct input_event e; | 724 | struct input_event e; |
720 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) | 725 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) |
721 | { | 726 | { |
722 | qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); | 727 | qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); |
723 | if ( e.type != EV_SW ) return; | 728 | if ( e.type != EV_SW ) return; |
724 | if ( readHingeSensor() != CASE_UNKNOWN ) | 729 | if ( readHingeSensor() != CASE_UNKNOWN ) |
725 | { | 730 | { |
726 | qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); | 731 | qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); |
727 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); | 732 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); |
728 | } | 733 | } |
729 | } | 734 | } |
730 | } | 735 | } |
731 | 736 | ||
737 | void Zaurus::systemMessage( const QCString &msg, const QByteArray & ) | ||
738 | { | ||
739 | if ( msg == "deviceButtonMappingChanged()" ) { | ||
740 | reloadButtonMapping(); | ||
741 | } | ||
742 | } | ||
743 | |||
732 | /* | 744 | /* |
733 | * Take code from iPAQ device. | 745 | * Take code from iPAQ device. |
734 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | 746 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. |
735 | * I hope that is ok - Alwin | 747 | * I hope that is ok - Alwin |
736 | */ | 748 | */ |
737 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 749 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
738 | { | 750 | { |
739 | int newkeycode = keycode; | 751 | int newkeycode = keycode; |
740 | 752 | ||
741 | if ( !hasHingeSensor() ) return false; | 753 | if ( !hasHingeSensor() ) return false; |
742 | 754 | ||
743 | /* map cursor keys depending on the hinge status */ | 755 | /* map cursor keys depending on the hinge status */ |
744 | switch ( keycode ) { | 756 | switch ( keycode ) { |
745 | // Rotate cursor keys | 757 | // Rotate cursor keys |
746 | case Key_Left : | 758 | case Key_Left : |
747 | case Key_Right: | 759 | case Key_Right: |
748 | case Key_Up : | 760 | case Key_Up : |
749 | case Key_Down : | 761 | case Key_Down : |
750 | { | 762 | { |
751 | if (rotation()==Rot90) { | 763 | if (rotation()==Rot90) { |
752 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 764 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
753 | } | 765 | } |
754 | } | 766 | } |
755 | break; | 767 | break; |
756 | 768 | ||
757 | } | 769 | } |
758 | if (newkeycode!=keycode) { | 770 | if (newkeycode!=keycode) { |
759 | if ( newkeycode != Key_unknown ) { | 771 | if ( newkeycode != Key_unknown ) { |
760 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 772 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
761 | } | 773 | } |
762 | return true; | 774 | return true; |
763 | } | 775 | } |
764 | return false; | 776 | return false; |
765 | } | 777 | } |
766 | 778 | ||
767 | bool Zaurus::suspend() { | 779 | bool Zaurus::suspend() { |
768 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 780 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
769 | return false; | 781 | return false; |
770 | 782 | ||
771 | bool res = false; | 783 | bool res = false; |
772 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 784 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
773 | 785 | ||
774 | struct timeval tvs, tvn; | 786 | struct timeval tvs, tvn; |
775 | ::gettimeofday ( &tvs, 0 ); | 787 | ::gettimeofday ( &tvs, 0 ); |
776 | 788 | ||
777 | ::sync(); // flush fs caches | 789 | ::sync(); // flush fs caches |
778 | res = ( ::system ( "apm --suspend" ) == 0 ); | 790 | res = ( ::system ( "apm --suspend" ) == 0 ); |
779 | 791 | ||
780 | // This is needed because some apm implementations are asynchronous and we | 792 | // This is needed because some apm implementations are asynchronous and we |
781 | // can not be sure when exactly the device is really suspended | 793 | // can not be sure when exactly the device is really suspended |
782 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 794 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
783 | // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. | 795 | // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. |
784 | 796 | ||
785 | if ( res && m_embedix) { | 797 | if ( res && m_embedix) { |
786 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 798 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
787 | ::usleep ( 200 * 1000 ); | 799 | ::usleep ( 200 * 1000 ); |
788 | ::gettimeofday ( &tvn, 0 ); | 800 | ::gettimeofday ( &tvn, 0 ); |
789 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); | 801 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); |
790 | } | 802 | } |
791 | 803 | ||
792 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | 804 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); |
793 | 805 | ||
794 | return res; | 806 | return res; |
795 | } | 807 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index bf30bc6..8a66f9c 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -1,151 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
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 | #ifndef ODEVICE_ZAURUS | 30 | #ifndef ODEVICE_ZAURUS |
31 | #define ODEVICE_ZAURUS | 31 | #define ODEVICE_ZAURUS |
32 | 32 | ||
33 | #include "odevice_abstractmobiledevice.h" | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | 38 | ||
39 | #ifndef ARRAY_SIZE | 39 | #ifndef ARRAY_SIZE |
40 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 40 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | // _IO and friends are only defined in kernel headers ... | 43 | // _IO and friends are only defined in kernel headers ... |
44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
45 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 45 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
46 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 46 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
47 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 47 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
48 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 48 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
49 | 49 | ||
50 | // Audio | 50 | // Audio |
51 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 51 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
52 | 52 | ||
53 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 53 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
54 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 54 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
55 | 55 | ||
56 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 56 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
57 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 57 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
58 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 58 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
59 | 59 | ||
60 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 60 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
61 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 61 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
62 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 62 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
63 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 63 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
64 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 64 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
65 | 65 | ||
66 | // LED | 66 | // LED |
67 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 67 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
68 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 68 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
69 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 69 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
70 | 70 | ||
71 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 71 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
72 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 72 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
73 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 73 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
74 | 74 | ||
75 | // Rotation and Power Management | 75 | // Rotation and Power Management |
76 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 76 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
77 | 77 | ||
78 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 78 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
79 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 79 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
80 | #define APM_EVT_POWER_BUTTON (1 << 0) | 80 | #define APM_EVT_POWER_BUTTON (1 << 0) |
81 | 81 | ||
82 | // Brightness Embedix | 82 | // Brightness Embedix |
83 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" | 83 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" |
84 | #define SHARP_FL_IOCTL_ON 1 | 84 | #define SHARP_FL_IOCTL_ON 1 |
85 | #define SHARP_FL_IOCTL_OFF 2 | 85 | #define SHARP_FL_IOCTL_OFF 2 |
86 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 | 86 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 |
87 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 | 87 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 |
88 | #define SHARP_FL_IOCTL_GET_STEP 102 | 88 | #define SHARP_FL_IOCTL_GET_STEP 102 |
89 | 89 | ||
90 | // Vesa Standard | 90 | // Vesa Standard |
91 | #define FB_BLANK_UNBLANK 0 | 91 | #define FB_BLANK_UNBLANK 0 |
92 | #define FB_BLANK_POWERDOWN 4 | 92 | #define FB_BLANK_POWERDOWN 4 |
93 | 93 | ||
94 | namespace Opie { | 94 | namespace Opie { |
95 | namespace Core { | 95 | namespace Core { |
96 | namespace Internal { | 96 | namespace Internal { |
97 | 97 | ||
98 | class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter | 98 | class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter |
99 | { | 99 | { |
100 | Q_OBJECT | ||
101 | |||
100 | protected: | 102 | protected: |
101 | virtual void init(const QString&); | 103 | virtual void init(const QString&); |
102 | virtual void initButtons(); | 104 | virtual void initButtons(); |
103 | void initHingeSensor(); | 105 | void initHingeSensor(); |
104 | 106 | ||
105 | protected slots: | 107 | protected slots: |
106 | void hingeSensorTriggered(); | 108 | void hingeSensorTriggered(); |
109 | void systemMessage( const QCString &msg, const QByteArray & ); | ||
107 | 110 | ||
108 | public: | 111 | public: |
109 | virtual bool setDisplayBrightness( int b ); | 112 | virtual bool setDisplayBrightness( int b ); |
110 | virtual bool setDisplayStatus( bool on ); | 113 | virtual bool setDisplayStatus( bool on ); |
111 | virtual int displayBrightnessResolution() const; | 114 | virtual int displayBrightnessResolution() const; |
112 | 115 | ||
113 | virtual void playAlarmSound(); | 116 | virtual void playAlarmSound(); |
114 | virtual void playKeySound(); | 117 | virtual void playKeySound(); |
115 | virtual void playTouchSound(); | 118 | virtual void playTouchSound(); |
116 | 119 | ||
117 | virtual QValueList <OLed> ledList() const; | 120 | virtual QValueList <OLed> ledList() const; |
118 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 121 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
119 | virtual OLedState ledState( OLed led ) const; | 122 | virtual OLedState ledState( OLed led ) const; |
120 | virtual bool setLedState( OLed led, OLedState st ); | 123 | virtual bool setLedState( OLed led, OLedState st ); |
121 | 124 | ||
122 | virtual bool hasHingeSensor() const; | 125 | virtual bool hasHingeSensor() const; |
123 | virtual OHingeStatus readHingeSensor() const; | 126 | virtual OHingeStatus readHingeSensor() const; |
124 | 127 | ||
125 | virtual Transformation rotation() const; | 128 | virtual Transformation rotation() const; |
126 | virtual ODirection direction() const; | 129 | virtual ODirection direction() const; |
127 | virtual bool suspend(); | 130 | virtual bool suspend(); |
128 | 131 | ||
129 | protected: | 132 | protected: |
130 | virtual void buzzer( int snd ); | 133 | virtual void buzzer( int snd ); |
131 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 134 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
132 | 135 | ||
133 | QString m_backlightdev; | 136 | QString m_backlightdev; |
134 | OLedState m_leds[1]; | 137 | OLedState m_leds[1]; |
135 | bool m_embedix; | 138 | bool m_embedix; |
136 | QFile m_hinge; | 139 | QFile m_hinge; |
137 | }; | 140 | }; |
138 | 141 | ||
139 | struct z_button { | 142 | struct z_button { |
140 | Qt::Key code; | 143 | Qt::Key code; |
141 | char *utext; | 144 | char *utext; |
142 | char *pix; | 145 | char *pix; |
143 | char *fpressedservice; | 146 | char *fpressedservice; |
144 | char *fpressedaction; | 147 | char *fpressedaction; |
145 | char *fheldservice; | 148 | char *fheldservice; |
146 | char *fheldaction; | 149 | char *fheldaction; |
147 | }; | 150 | }; |
148 | } | 151 | } |
149 | } | 152 | } |
150 | } | 153 | } |
151 | #endif | 154 | #endif |