-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 50 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 43 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 43 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 43 |
4 files changed, 94 insertions, 85 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 72b9ac7..7d67efe 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
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; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
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 | #include "odevice_ipaq.h" | 30 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | 31 | #include "odevice_jornada.h" |
32 | #include "odevice_ramses.h" | 32 | #include "odevice_ramses.h" |
33 | #include "odevice_simpad.h" | 33 | #include "odevice_simpad.h" |
34 | #include "odevice_yopy.h" | 34 | #include "odevice_yopy.h" |
35 | #include "odevice_zaurus.h" | 35 | #include "odevice_zaurus.h" |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | 42 | ||
43 | /* OPIE */ | 43 | /* OPIE */ |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
48 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <math.h> | 51 | #include <math.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | #include <signal.h> | 53 | #include <signal.h> |
54 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
55 | #include <sys/time.h> | 55 | #include <sys/time.h> |
56 | #include <unistd.h> | 56 | #include <unistd.h> |
@@ -157,65 +157,66 @@ ODevice::~ODevice() | |||
157 | } | 157 | } |
158 | 158 | ||
159 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 159 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
160 | { | 160 | { |
161 | return false; | 161 | return false; |
162 | } | 162 | } |
163 | 163 | ||
164 | //#include <linux/apm_bios.h> | 164 | //#include <linux/apm_bios.h> |
165 | 165 | ||
166 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 166 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * This method will try to suspend the device | 169 | * This method will try to suspend the device |
170 | * It only works if the user is the QWS Server and the apm application | 170 | * It only works if the user is the QWS Server and the apm application |
171 | * is installed. | 171 | * is installed. |
172 | * It tries to suspend and then waits some time cause some distributions | 172 | * It tries to suspend and then waits some time cause some distributions |
173 | * do have asynchronus apm implementations. | 173 | * do have asynchronus apm implementations. |
174 | * This method will either fail and return false or it'll suspend the | 174 | * This method will either fail and return false or it'll suspend the |
175 | * device and return once the device got woken up | 175 | * device and return once the device got woken up |
176 | * | 176 | * |
177 | * @return if the device got suspended | 177 | * @return if the device got suspended |
178 | */ | 178 | */ |
179 | bool ODevice::suspend() | 179 | bool ODevice::suspend() |
180 | { | 180 | { |
181 | qDebug("ODevice::suspend"); | 181 | qDebug("ODevice::suspend"); |
182 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 182 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
183 | return false; | 183 | return false; |
184 | 184 | ||
185 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 185 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
186 | return false; | 186 | return false; |
187 | 187 | ||
188 | bool res = false; | 188 | bool res = false; |
189 | 189 | ODevice::sendSuspendmsg(); | |
190 | |||
190 | struct timeval tvs, tvn; | 191 | struct timeval tvs, tvn; |
191 | ::gettimeofday ( &tvs, 0 ); | 192 | ::gettimeofday ( &tvs, 0 ); |
192 | 193 | ||
193 | ::sync(); // flush fs caches | 194 | ::sync(); // flush fs caches |
194 | res = ( ::system ( "apm --suspend" ) == 0 ); | 195 | res = ( ::system ( "apm --suspend" ) == 0 ); |
195 | 196 | ||
196 | // This is needed because the iPAQ apm implementation is asynchronous and we | 197 | // This is needed because the iPAQ apm implementation is asynchronous and we |
197 | // can not be sure when exactly the device is really suspended | 198 | // can not be sure when exactly the device is really suspended |
198 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 199 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
199 | 200 | ||
200 | if ( res ) { | 201 | if ( res ) { |
201 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 202 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
202 | ::usleep ( 200 * 1000 ); | 203 | ::usleep ( 200 * 1000 ); |
203 | ::gettimeofday ( &tvn, 0 ); | 204 | ::gettimeofday ( &tvn, 0 ); |
204 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 205 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
205 | } | 206 | } |
206 | 207 | ||
207 | return res; | 208 | return res; |
208 | } | 209 | } |
209 | 210 | ||
210 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 211 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
211 | 212 | ||
212 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 213 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
213 | 214 | ||
214 | /* VESA Blanking Levels */ | 215 | /* VESA Blanking Levels */ |
215 | #define VESA_NO_BLANKING 0 | 216 | #define VESA_NO_BLANKING 0 |
216 | #define VESA_VSYNC_SUSPEND 1 | 217 | #define VESA_VSYNC_SUSPEND 1 |
217 | #define VESA_HSYNC_SUSPEND 2 | 218 | #define VESA_HSYNC_SUSPEND 2 |
218 | #define VESA_POWERDOWN 3 | 219 | #define VESA_POWERDOWN 3 |
219 | 220 | ||
220 | /** | 221 | /** |
221 | * This sets the display on or off | 222 | * This sets the display on or off |
@@ -591,32 +592,37 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | |||
591 | Config buttonFile ( "ButtonSettings" ); | 592 | Config buttonFile ( "ButtonSettings" ); |
592 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 593 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
593 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 594 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
594 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 595 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
595 | 596 | ||
596 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 597 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
597 | 598 | ||
598 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 599 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
599 | } | 600 | } |
600 | 601 | ||
601 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 602 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
602 | { | 603 | { |
603 | initButtons(); | 604 | initButtons(); |
604 | 605 | ||
605 | if ( button >= (int) d->m_buttons->count()) | 606 | if ( button >= (int) d->m_buttons->count()) |
606 | return; | 607 | return; |
607 | 608 | ||
608 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 609 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
609 | b. setHeldAction ( action ); | 610 | b. setHeldAction ( action ); |
610 | 611 | ||
611 | Config buttonFile ( "ButtonSettings" ); | 612 | Config buttonFile ( "ButtonSettings" ); |
612 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 613 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
613 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 614 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
614 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 615 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
615 | 616 | ||
616 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 617 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
617 | 618 | ||
618 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 619 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
619 | } | 620 | } |
620 | void ODevice::virtual_hook(int, void* ){ | 621 | void ODevice::virtual_hook(int, void* ){ |
621 | 622 | ||
622 | } | 623 | } |
624 | |||
625 | void ODevice::sendSuspendmsg() | ||
626 | { | ||
627 | QCopEnvelope ( "QPE/System", "aboutSuspend()" ); | ||
628 | } | ||
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 791ccb3..bccb449 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
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; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
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_H_ | 30 | #ifndef ODEVICE_H_ |
31 | #define ODEVICE_H_ | 31 | #define ODEVICE_H_ |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odevicebutton.h> | 34 | #include <opie2/odevicebutton.h> |
35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qnamespace.h> | 38 | #include <qnamespace.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qstrlist.h> | 41 | #include <qstrlist.h> |
42 | 42 | ||
43 | namespace Opie | 43 | namespace Opie |
44 | { | 44 | { |
45 | class ODeviceData; | 45 | class ODeviceData; |
46 | /** | 46 | /** |
47 | * The available devices | 47 | * The available devices |
48 | */ | 48 | */ |
49 | enum OModel { | 49 | enum OModel { |
50 | Model_Unknown, // = 0 | 50 | Model_Unknown, // = 0 |
51 | 51 | ||
52 | Model_Series_Mask = 0xff000000, | 52 | Model_Series_Mask = 0xff000000, |
53 | 53 | ||
54 | Model_iPAQ = ( 1 << 24 ), | 54 | Model_iPAQ = ( 1 << 24 ), |
55 | 55 | ||
56 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 56 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
@@ -152,64 +152,65 @@ enum ODirection { | |||
152 | Flip = 2, | 152 | Flip = 2, |
153 | }; | 153 | }; |
154 | 154 | ||
155 | enum OHingeStatus { | 155 | enum OHingeStatus { |
156 | CASE_CLOSED = 3, | 156 | CASE_CLOSED = 3, |
157 | CASE_PORTRAIT = 2, | 157 | CASE_PORTRAIT = 2, |
158 | CASE_LANDSCAPE = 0, | 158 | CASE_LANDSCAPE = 0, |
159 | CASE_UNKNOWN = 1, | 159 | CASE_UNKNOWN = 1, |
160 | }; | 160 | }; |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * A singleton which gives informations about device specefic option | 163 | * A singleton which gives informations about device specefic option |
164 | * like the Hardware used, LEDs, the Base Distribution and | 164 | * like the Hardware used, LEDs, the Base Distribution and |
165 | * hardware key mappings. | 165 | * hardware key mappings. |
166 | * | 166 | * |
167 | * @short A small class for device specefic options | 167 | * @short A small class for device specefic options |
168 | * @see QObject | 168 | * @see QObject |
169 | * @author Robert Griebl | 169 | * @author Robert Griebl |
170 | * @version 1.0 | 170 | * @version 1.0 |
171 | */ | 171 | */ |
172 | class ODevice : public QObject | 172 | class ODevice : public QObject |
173 | { | 173 | { |
174 | Q_OBJECT | 174 | Q_OBJECT |
175 | 175 | ||
176 | private: | 176 | private: |
177 | /* disable copy */ | 177 | /* disable copy */ |
178 | ODevice ( const ODevice & ); | 178 | ODevice ( const ODevice & ); |
179 | 179 | ||
180 | protected: | 180 | protected: |
181 | ODevice(); | 181 | ODevice(); |
182 | virtual void init(); | 182 | virtual void init(); |
183 | virtual void initButtons(); | 183 | virtual void initButtons(); |
184 | static void sendSuspendmsg(); | ||
184 | 185 | ||
185 | ODeviceData *d; | 186 | ODeviceData *d; |
186 | 187 | ||
187 | public: | 188 | public: |
188 | // sandman do we want to allow destructions? -zecke? | 189 | // sandman do we want to allow destructions? -zecke? |
189 | virtual ~ODevice(); | 190 | virtual ~ODevice(); |
190 | 191 | ||
191 | static ODevice *inst(); | 192 | static ODevice *inst(); |
192 | 193 | ||
193 | // information | 194 | // information |
194 | 195 | ||
195 | QString modelString() const; | 196 | QString modelString() const; |
196 | OModel model() const; | 197 | OModel model() const; |
197 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | 198 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } |
198 | 199 | ||
199 | QString vendorString() const; | 200 | QString vendorString() const; |
200 | OVendor vendor() const; | 201 | OVendor vendor() const; |
201 | 202 | ||
202 | QString systemString() const; | 203 | QString systemString() const; |
203 | OSystem system() const; | 204 | OSystem system() const; |
204 | 205 | ||
205 | QString systemVersionString() const; | 206 | QString systemVersionString() const; |
206 | 207 | ||
207 | virtual Transformation rotation() const; | 208 | virtual Transformation rotation() const; |
208 | virtual ODirection direction() const; | 209 | virtual ODirection direction() const; |
209 | 210 | ||
210 | // system | 211 | // system |
211 | 212 | ||
212 | virtual bool setSoftSuspend ( bool on ); | 213 | virtual bool setSoftSuspend ( bool on ); |
213 | virtual bool suspend(); | 214 | virtual bool suspend(); |
214 | 215 | ||
215 | virtual bool setDisplayStatus ( bool on ); | 216 | virtual bool setDisplayStatus ( bool on ); |
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 4397b78..31b9297 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
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; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
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 | #include "odevice_simpad.h" | 30 | #include "odevice_simpad.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 */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
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 | using namespace Opie; | 56 | using namespace Opie; |
@@ -297,64 +297,65 @@ void SIMpad::playAlarmSound() | |||
297 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 297 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
298 | if ( volalarm < 0 ) | 298 | if ( volalarm < 0 ) |
299 | volalarm = 0; | 299 | volalarm = 0; |
300 | else if ( volalarm > 100 ) | 300 | else if ( volalarm > 100 ) |
301 | volalarm = 100; | 301 | volalarm = 100; |
302 | volalarm |= ( volalarm << 8 ); | 302 | volalarm |= ( volalarm << 8 ); |
303 | 303 | ||
304 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 304 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
305 | vol_reset = true; | 305 | vol_reset = true; |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | snd. play(); | 309 | snd. play(); |
310 | while ( !snd. isFinished()) | 310 | while ( !snd. isFinished()) |
311 | qApp->processEvents(); | 311 | qApp->processEvents(); |
312 | 312 | ||
313 | if ( fd >= 0 ) { | 313 | if ( fd >= 0 ) { |
314 | if ( vol_reset ) | 314 | if ( vol_reset ) |
315 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 315 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
316 | ::close ( fd ); | 316 | ::close ( fd ); |
317 | } | 317 | } |
318 | #endif | 318 | #endif |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 322 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
323 | { | 323 | { |
324 | qDebug( "ODevice for SIMpad: suspend()" ); | 324 | qDebug( "ODevice for SIMpad: suspend()" ); |
325 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 325 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
326 | return false; | 326 | return false; |
327 | 327 | ||
328 | bool res = false; | 328 | bool res = false; |
329 | ODevice::sendSuspendmsg(); | ||
329 | 330 | ||
330 | struct timeval tvs, tvn; | 331 | struct timeval tvs, tvn; |
331 | ::gettimeofday ( &tvs, 0 ); | 332 | ::gettimeofday ( &tvs, 0 ); |
332 | 333 | ||
333 | ::sync(); // flush fs caches | 334 | ::sync(); // flush fs caches |
334 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 335 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
335 | 336 | ||
336 | return res; | 337 | return res; |
337 | } | 338 | } |
338 | 339 | ||
339 | 340 | ||
340 | bool SIMpad::setSoftSuspend ( bool soft ) | 341 | bool SIMpad::setSoftSuspend ( bool soft ) |
341 | { | 342 | { |
342 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 343 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
343 | return false; | 344 | return false; |
344 | } | 345 | } |
345 | 346 | ||
346 | 347 | ||
347 | bool SIMpad::setDisplayStatus ( bool on ) | 348 | bool SIMpad::setDisplayStatus ( bool on ) |
348 | { | 349 | { |
349 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 350 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
350 | 351 | ||
351 | bool res = false; | 352 | bool res = false; |
352 | int fd; | 353 | int fd; |
353 | 354 | ||
354 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 355 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
355 | 356 | ||
356 | res = ( ::system( (const char*) cmdline ) == 0 ); | 357 | res = ( ::system( (const char*) cmdline ) == 0 ); |
357 | 358 | ||
358 | return res; | 359 | return res; |
359 | } | 360 | } |
360 | 361 | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 8bff770..9d23a12 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
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; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
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 | #include "odevice_zaurus.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 */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
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 | using namespace Opie; | 56 | using namespace Opie; |
@@ -537,64 +537,65 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
537 | // standard treatment for devices with the dumb embedix frontlight interface | 537 | // standard treatment for devices with the dumb embedix frontlight interface |
538 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 538 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
539 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 539 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
540 | if ( bright && !bl ) | 540 | if ( bright && !bl ) |
541 | bl = 1; | 541 | bl = 1; |
542 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 542 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
543 | ::close ( fd ); | 543 | ::close ( fd ); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | } | 546 | } |
547 | else | 547 | else |
548 | { | 548 | { |
549 | // special treatment for the OpenZaurus unified interface | 549 | // special treatment for the OpenZaurus unified interface |
550 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 550 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
551 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 551 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
552 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 552 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
553 | ::close ( fd ); | 553 | ::close ( fd ); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | return res; | 556 | return res; |
557 | } | 557 | } |
558 | 558 | ||
559 | bool Zaurus::suspend() | 559 | bool Zaurus::suspend() |
560 | { | 560 | { |
561 | qDebug("ODevice::suspend"); | 561 | qDebug("ODevice::suspend"); |
562 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 562 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
563 | return false; | 563 | return false; |
564 | 564 | ||
565 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 565 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
566 | return false; | 566 | return false; |
567 | 567 | ||
568 | bool res = false; | 568 | bool res = false; |
569 | ODevice::sendSuspendmsg(); | ||
569 | 570 | ||
570 | struct timeval tvs, tvn; | 571 | struct timeval tvs, tvn; |
571 | ::gettimeofday ( &tvs, 0 ); | 572 | ::gettimeofday ( &tvs, 0 ); |
572 | 573 | ||
573 | ::sync(); // flush fs caches | 574 | ::sync(); // flush fs caches |
574 | res = ( ::system ( "apm --suspend" ) == 0 ); | 575 | res = ( ::system ( "apm --suspend" ) == 0 ); |
575 | 576 | ||
576 | // This is needed because the iPAQ apm implementation is asynchronous and we | 577 | // This is needed because the iPAQ apm implementation is asynchronous and we |
577 | // can not be sure when exactly the device is really suspended | 578 | // can not be sure when exactly the device is really suspended |
578 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 579 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
579 | 580 | ||
580 | if ( res ) { | 581 | if ( res ) { |
581 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 582 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
582 | ::usleep ( 200 * 1000 ); | 583 | ::usleep ( 200 * 1000 ); |
583 | ::gettimeofday ( &tvn, 0 ); | 584 | ::gettimeofday ( &tvn, 0 ); |
584 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 585 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
585 | } | 586 | } |
586 | 587 | ||
587 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 588 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
588 | return res; | 589 | return res; |
589 | } | 590 | } |
590 | 591 | ||
591 | 592 | ||
592 | Transformation Zaurus::rotation() const | 593 | Transformation Zaurus::rotation() const |
593 | { | 594 | { |
594 | Transformation rot; | 595 | Transformation rot; |
595 | int handle = 0; | 596 | int handle = 0; |
596 | int retval = 0; | 597 | int retval = 0; |
597 | 598 | ||
598 | switch ( d->m_model ) { | 599 | switch ( d->m_model ) { |
599 | case Model_Zaurus_SLC7x0: | 600 | case Model_Zaurus_SLC7x0: |
600 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 601 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |