author | erik <erik> | 2007-02-08 23:11:26 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-08 23:11:26 (UTC) |
commit | 98353ac16bb90ee4b5df18945acf4fa7f05f9a85 (patch) (unidiff) | |
tree | 67ccd74ecfcc9006bece74089b6739736d78243f | |
parent | 497621fb3ba39ea511842a30cddfcdbda090e7ba (diff) | |
download | opie-98353ac16bb90ee4b5df18945acf4fa7f05f9a85.zip opie-98353ac16bb90ee4b5df18945acf4fa7f05f9a85.tar.gz opie-98353ac16bb90ee4b5df18945acf4fa7f05f9a85.tar.bz2 |
This commit provides fixes that quiet warnings associated to device
information. It should cause no change in behavior.
-rw-r--r-- | libopie2/opiecore/device/odevice_htc.cpp | 10 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_motorola_ezx.cpp | 45 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_palm.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 10 |
4 files changed, 16 insertions, 53 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp index a6ade11..44b33c0 100644 --- a/libopie2/opiecore/device/odevice_htc.cpp +++ b/libopie2/opiecore/device/odevice_htc.cpp | |||
@@ -1,603 +1,605 @@ | |||
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 | #include "odevice_htc.h" | 30 | #include "odevice_htc.h" |
31 | 31 | ||
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 htc_button htc_buttons [] = { | 63 | struct htc_button htc_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 htc_button htc_buttons_universal [] = { | 86 | struct htc_button htc_buttons_universal [] = { |
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,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,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,0}, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | // | 120 | // |
121 | // HTC-Universal (PXA-model w/ 480x640 3.6" lcd) | 121 | // HTC-Universal (PXA-model w/ 480x640 3.6" lcd) |
122 | // HTC-Alpine (PXA-model w/ 240x320 3.5" lcd) | 122 | // HTC-Alpine (PXA-model w/ 240x320 3.5" lcd) |
123 | // HTC-Apache (PXA-model w/ 240x320 2.8" lcd) | 123 | // HTC-Apache (PXA-model w/ 240x320 2.8" lcd) |
124 | // HTC-Beetles (PXA-model w/ 240x240 3.0" lcd) | 124 | // HTC-Beetles (PXA-model w/ 240x240 3.0" lcd) |
125 | // HTC-Blueangel (PXA-model w/ 240x320 3.5" lcd) | 125 | // HTC-Blueangel (PXA-model w/ 240x320 3.5" lcd) |
126 | // HTC-Himalaya (PXA-model w/ 240x320 3.5" lcd) | 126 | // HTC-Himalaya (PXA-model w/ 240x320 3.5" lcd) |
127 | // HTC-Magician (PXA-model w/ 240x320 2.8" lcd) | 127 | // HTC-Magician (PXA-model w/ 240x320 2.8" lcd) |
128 | 128 | ||
129 | void HTC::init(const QString& cpu_info) | 129 | void HTC::init(const QString& cpu_info) |
130 | { | 130 | { |
131 | qDebug( "HTC::init()" ); | 131 | qDebug( "HTC::init()" ); |
132 | // Set the time to wait until the system is really suspended | 132 | // Set the time to wait until the system is really suspended |
133 | // the delta between apm --suspend and sleeping | 133 | // the delta between apm --suspend and sleeping |
134 | setAPMTimeOut( 15000 ); | 134 | setAPMTimeOut( 15000 ); |
135 | 135 | ||
136 | d->m_vendorstr = "Xanadux Team"; | 136 | d->m_vendorstr = "Xanadux Team"; |
137 | d->m_systemstr = "Familiar"; | 137 | d->m_systemstr = "Familiar"; |
138 | d->m_system = System_Familiar; | 138 | d->m_system = System_Familiar; |
139 | 139 | ||
140 | // check the HTC model | 140 | // check the HTC model |
141 | QString model; | 141 | QString model; |
142 | int loc = cpu_info.find( ":" ); | 142 | int loc = cpu_info.find( ":" ); |
143 | if ( loc != -1 ) | 143 | if ( loc != -1 ) |
144 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 144 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
145 | else | 145 | else |
146 | model = cpu_info; | 146 | model = cpu_info; |
147 | 147 | ||
148 | d->m_model = Model_HTC_Universal; | 148 | d->m_model = Model_HTC_Universal; |
149 | d->m_modelstr = "Unknown HTC"; | 149 | d->m_modelstr = "Unknown HTC"; |
150 | 150 | ||
151 | if ( model == "HTC Universal" ) { | 151 | if ( model == "HTC Universal" ) { |
152 | d->m_model = Model_HTC_Universal; | 152 | d->m_model = Model_HTC_Universal; |
153 | d->m_modelstr = "HTC Universal"; | 153 | d->m_modelstr = "HTC Universal"; |
154 | } | 154 | } |
155 | if ( model == "HTC Alpine" ) { | 155 | if ( model == "HTC Alpine" ) { |
156 | d->m_model = Model_HTC_Alpine; | 156 | d->m_model = Model_HTC_Alpine; |
157 | d->m_modelstr = "HTC Alpine"; | 157 | d->m_modelstr = "HTC Alpine"; |
158 | } | 158 | } |
159 | if ( model == "HTC Apache" ) { | 159 | if ( model == "HTC Apache" ) { |
160 | d->m_model = Model_HTC_Apache; | 160 | d->m_model = Model_HTC_Apache; |
161 | d->m_modelstr = "HTC Apache"; | 161 | d->m_modelstr = "HTC Apache"; |
162 | } | 162 | } |
163 | if ( model == "HTC Beetles" ) { | 163 | if ( model == "HTC Beetles" ) { |
164 | d->m_model = Model_HTC_Beetles; | 164 | d->m_model = Model_HTC_Beetles; |
165 | d->m_modelstr = "HTC Beetles"; | 165 | d->m_modelstr = "HTC Beetles"; |
166 | } | 166 | } |
167 | if ( model == "HTC Blueangel" ) { | 167 | if ( model == "HTC Blueangel" ) { |
168 | d->m_model = Model_HTC_Blueangel; | 168 | d->m_model = Model_HTC_Blueangel; |
169 | d->m_modelstr = "HTC Blueangel"; | 169 | d->m_modelstr = "HTC Blueangel"; |
170 | } | 170 | } |
171 | if ( model == "HTC Himalaya" ) { | 171 | if ( model == "HTC Himalaya" ) { |
172 | d->m_model = Model_HTC_Himalaya; | 172 | d->m_model = Model_HTC_Himalaya; |
173 | d->m_modelstr = "HTC Himalaya"; | 173 | d->m_modelstr = "HTC Himalaya"; |
174 | } | 174 | } |
175 | if ( model == "HTC Magician" ) { | 175 | if ( model == "HTC Magician" ) { |
176 | d->m_model = Model_HTC_Magician; | 176 | d->m_model = Model_HTC_Magician; |
177 | d->m_modelstr = "HTC Magician"; | 177 | d->m_modelstr = "HTC Magician"; |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | // set path to backlight device | 181 | // set path to backlight device |
182 | switch ( d->m_model ) | 182 | switch ( d->m_model ) |
183 | { | 183 | { |
184 | case Model_HTC_Universal: | 184 | case Model_HTC_Universal: |
185 | case Model_HTC_Magician: | 185 | case Model_HTC_Magician: |
186 | case Model_HTC_Alpine: | 186 | case Model_HTC_Alpine: |
187 | case Model_HTC_Beetles: | 187 | case Model_HTC_Beetles: |
188 | case Model_HTC_Apache: | 188 | case Model_HTC_Apache: |
189 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; | 189 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
190 | break; | 190 | break; |
191 | case Model_HTC_Blueangel: | 191 | case Model_HTC_Blueangel: |
192 | case Model_HTC_Himalaya: | 192 | case Model_HTC_Himalaya: |
193 | m_backlightdev = "/sys/class/backlight/w100fb/"; | 193 | m_backlightdev = "/sys/class/backlight/w100fb/"; |
194 | break; | 194 | break; |
195 | default: | 195 | default: |
196 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; | 196 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
197 | } | 197 | } |
198 | 198 | ||
199 | // set initial rotation | 199 | // set initial rotation |
200 | switch( d->m_model ) | 200 | switch( d->m_model ) |
201 | { | 201 | { |
202 | case Model_HTC_Universal: | 202 | case Model_HTC_Universal: |
203 | initHingeSensor(); | 203 | initHingeSensor(); |
204 | d->m_rotation = rotation(); | 204 | d->m_rotation = rotation(); |
205 | d->m_direction = direction(); | 205 | d->m_direction = direction(); |
206 | break; | 206 | break; |
207 | default: | 207 | default: |
208 | d->m_rotation = Rot270; | 208 | d->m_rotation = Rot270; |
209 | } | 209 | } |
210 | 210 | ||
211 | // set default qte driver | 211 | // set default qte driver |
212 | switch( d->m_model ) | 212 | switch( d->m_model ) |
213 | { | 213 | { |
214 | default: | 214 | default: |
215 | d->m_qteDriver = "Transformed"; | 215 | d->m_qteDriver = "Transformed"; |
216 | } | 216 | } |
217 | 217 | ||
218 | m_leds[0] = Led_Off; | 218 | m_leds[0] = Led_Off; |
219 | 219 | ||
220 | qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); | 220 | qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); |
221 | } | 221 | } |
222 | 222 | ||
223 | void HTC::initButtons() | 223 | void HTC::initButtons() |
224 | { | 224 | { |
225 | qDebug( "HTC::initButtons()" ); | 225 | qDebug( "HTC::initButtons()" ); |
226 | if ( d->m_buttons ) | 226 | if ( d->m_buttons ) |
227 | return; | 227 | return; |
228 | 228 | ||
229 | d->m_buttons = new QValueList <ODeviceButton>; | 229 | d->m_buttons = new QValueList <ODeviceButton>; |
230 | 230 | ||
231 | struct htc_button * phtc_buttons; | 231 | struct htc_button * phtc_buttons; |
232 | int buttoncount; | 232 | int buttoncount; |
233 | switch ( d->m_model ) | 233 | switch ( d->m_model ) |
234 | { | 234 | { |
235 | case Model_HTC_Universal: | 235 | case Model_HTC_Universal: |
236 | if ( isQWS( ) ) | 236 | if ( isQWS( ) ) |
237 | { | 237 | { |
238 | addPreHandler(this); | 238 | addPreHandler(this); |
239 | } | 239 | } |
240 | phtc_buttons = htc_buttons_universal; | 240 | phtc_buttons = htc_buttons_universal; |
241 | buttoncount = ARRAY_SIZE(htc_buttons_universal); | 241 | buttoncount = ARRAY_SIZE(htc_buttons_universal); |
242 | break; | 242 | break; |
243 | default: | 243 | default: |
244 | phtc_buttons = htc_buttons; | 244 | phtc_buttons = htc_buttons; |
245 | buttoncount = ARRAY_SIZE(htc_buttons); | 245 | buttoncount = ARRAY_SIZE(htc_buttons); |
246 | break; | 246 | break; |
247 | } | 247 | } |
248 | 248 | ||
249 | for ( int i = 0; i < buttoncount; i++ ) { | 249 | for ( int i = 0; i < buttoncount; i++ ) { |
250 | struct htc_button *zb = phtc_buttons + i; | 250 | struct htc_button *zb = phtc_buttons + i; |
251 | ODeviceButton b; | 251 | ODeviceButton b; |
252 | 252 | ||
253 | b.setKeycode( zb->code ); | 253 | b.setKeycode( zb->code ); |
254 | b.setUserText( QObject::tr( "Button", zb->utext )); | 254 | b.setUserText( QObject::tr( "Button", zb->utext )); |
255 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 255 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
256 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 256 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
257 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 257 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
258 | d->m_buttons->append( b ); | 258 | d->m_buttons->append( b ); |
259 | } | 259 | } |
260 | 260 | ||
261 | reloadButtonMapping(); | 261 | reloadButtonMapping(); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | 265 | ||
266 | typedef struct sharp_led_status { | 266 | typedef struct sharp_led_status { |
267 | int which; /* select which LED status is wanted. */ | 267 | int which; /* select which LED status is wanted. */ |
268 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 268 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
269 | } sharp_led_status; | 269 | } sharp_led_status; |
270 | 270 | ||
271 | void HTC::buzzer( int sound ) | 271 | void HTC::buzzer( int sound ) |
272 | { | 272 | { |
273 | #ifndef QT_NO_SOUND | 273 | #ifndef QT_NO_SOUND |
274 | Sound *snd = 0; | 274 | Sound *snd = 0; |
275 | 275 | ||
276 | // All devices except SL5500 have a DSP device | 276 | // All devices except SL5500 have a DSP device |
277 | if ( d->m_model == Model_HTC_Universal ) { | 277 | if ( d->m_model == Model_HTC_Universal ) { |
278 | 278 | ||
279 | switch ( sound ){ | 279 | switch ( sound ){ |
280 | case SHARP_BUZ_TOUCHSOUND: { | 280 | case SHARP_BUZ_TOUCHSOUND: { |
281 | static Sound touch_sound("touchsound"); | 281 | static Sound touch_sound("touchsound"); |
282 | snd = &touch_sound; | 282 | snd = &touch_sound; |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | case SHARP_BUZ_KEYSOUND: { | 285 | case SHARP_BUZ_KEYSOUND: { |
286 | static Sound key_sound( "keysound" ); | 286 | static Sound key_sound( "keysound" ); |
287 | snd = &key_sound; | 287 | snd = &key_sound; |
288 | } | 288 | } |
289 | break; | 289 | break; |
290 | case SHARP_BUZ_SCHEDULE_ALARM: | 290 | case SHARP_BUZ_SCHEDULE_ALARM: |
291 | default: { | 291 | default: { |
292 | static Sound alarm_sound("alarm"); | 292 | static Sound alarm_sound("alarm"); |
293 | snd = &alarm_sound; | 293 | snd = &alarm_sound; |
294 | } | 294 | } |
295 | break; | 295 | break; |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | // If a soundname is defined, we expect that this device has | 299 | // If a soundname is defined, we expect that this device has |
300 | // sound capabilities.. Otherwise we expect to have the buzzer | 300 | // sound capabilities.. Otherwise we expect to have the buzzer |
301 | // device.. | 301 | // device.. |
302 | if ( snd && snd->isFinished() ){ | 302 | if ( snd && snd->isFinished() ){ |
303 | changeMixerForAlarm( 0, "/dev/mixer", snd ); | 303 | changeMixerForAlarm( 0, "/dev/mixer", snd ); |
304 | snd->play(); | 304 | snd->play(); |
305 | } else if( !snd ) { | 305 | } else if( !snd ) { |
306 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 306 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
307 | 307 | ||
308 | if ( fd >= 0 ) { | 308 | if ( fd >= 0 ) { |
309 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 309 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
310 | ::close ( fd ); | 310 | ::close ( fd ); |
311 | } | 311 | } |
312 | 312 | ||
313 | } | 313 | } |
314 | #endif | 314 | #endif |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void HTC::playAlarmSound() | 318 | void HTC::playAlarmSound() |
319 | { | 319 | { |
320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
321 | } | 321 | } |
322 | 322 | ||
323 | void HTC::playTouchSound() | 323 | void HTC::playTouchSound() |
324 | { | 324 | { |
325 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 325 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void HTC::playKeySound() | 328 | void HTC::playKeySound() |
329 | { | 329 | { |
330 | buzzer( SHARP_BUZ_KEYSOUND ); | 330 | buzzer( SHARP_BUZ_KEYSOUND ); |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | QValueList <OLed> HTC::ledList() const | 334 | QValueList <OLed> HTC::ledList() const |
335 | { | 335 | { |
336 | QValueList <OLed> vl; | 336 | QValueList <OLed> vl; |
337 | vl << Led_Mail; | 337 | vl << Led_Mail; |
338 | return vl; | 338 | return vl; |
339 | } | 339 | } |
340 | 340 | ||
341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const | 341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const |
342 | { | 342 | { |
343 | QValueList <OLedState> vl; | 343 | QValueList <OLedState> vl; |
344 | 344 | ||
345 | if ( l == Led_Mail ) | 345 | if ( l == Led_Mail ) |
346 | vl << Led_Off << Led_On << Led_BlinkSlow; | 346 | vl << Led_Off << Led_On << Led_BlinkSlow; |
347 | return vl; | 347 | return vl; |
348 | } | 348 | } |
349 | 349 | ||
350 | OLedState HTC::ledState( OLed which ) const | 350 | OLedState HTC::ledState( OLed which ) const |
351 | { | 351 | { |
352 | if ( which == Led_Mail ) | 352 | if ( which == Led_Mail ) |
353 | return m_leds [0]; | 353 | return m_leds [0]; |
354 | else | 354 | else |
355 | return Led_Off; | 355 | return Led_Off; |
356 | } | 356 | } |
357 | 357 | ||
358 | bool HTC::setLedState( OLed which, OLedState st ) | 358 | bool HTC::setLedState( OLed, OLedState ) |
359 | { | 359 | { |
360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); | 360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); |
361 | return false; | 361 | return false; |
362 | } | 362 | } |
363 | 363 | ||
364 | int HTC::displayBrightnessResolution() const | 364 | int HTC::displayBrightnessResolution() const |
365 | { | 365 | { |
366 | int res = 1; | 366 | int res = 1; |
367 | 367 | ||
368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
369 | 369 | ||
370 | if ( fd ) | 370 | if ( fd ) |
371 | { | 371 | { |
372 | char buf[100]; | 372 | char buf[100]; |
373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
374 | ::close( fd ); | 374 | ::close( fd ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return res; | 377 | return res; |
378 | } | 378 | } |
379 | 379 | ||
380 | bool HTC::setDisplayBrightness( int bright ) | 380 | bool HTC::setDisplayBrightness( int bright ) |
381 | { | 381 | { |
382 | 382 | ||
383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); | 383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); |
384 | bool res = false; | 384 | bool res = false; |
385 | 385 | ||
386 | if ( bright > 255 ) bright = 255; | 386 | if ( bright > 255 ) bright = 255; |
387 | if ( bright < 0 ) bright = 0; | 387 | if ( bright < 0 ) bright = 0; |
388 | 388 | ||
389 | int numberOfSteps = displayBrightnessResolution(); | 389 | int numberOfSteps = displayBrightnessResolution(); |
390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
391 | 391 | ||
392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
393 | if ( fd ) | 393 | if ( fd ) |
394 | { | 394 | { |
395 | char buf[100]; | 395 | char buf[100]; |
396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
397 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 397 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
398 | ::close( fd ); | 398 | ::close( fd ); |
399 | } | 399 | } |
400 | return res; | 400 | return res; |
401 | } | 401 | } |
402 | 402 | ||
403 | bool HTC::setDisplayStatus( bool on ) | 403 | bool HTC::setDisplayStatus( bool on ) |
404 | { | 404 | { |
405 | 405 | ||
406 | bool res = false; | 406 | bool res = false; |
407 | 407 | ||
408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
409 | if ( fd ) | 409 | if ( fd ) |
410 | { | 410 | { |
411 | char buf[10]; | 411 | char buf[10]; |
412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
413 | buf[1] = '\0'; | 413 | buf[1] = '\0'; |
414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
415 | ::close( fd ); | 415 | ::close( fd ); |
416 | } | 416 | } |
417 | return res; | 417 | return res; |
418 | } | 418 | } |
419 | 419 | ||
420 | Transformation HTC::rotation() const | 420 | Transformation HTC::rotation() const |
421 | { | 421 | { |
422 | qDebug( "HTC::rotation()" ); | 422 | qDebug( "HTC::rotation()" ); |
423 | Transformation rot = Rot270; | 423 | Transformation rot = Rot270; |
424 | 424 | ||
425 | switch ( d->m_model ) { | 425 | switch ( d->m_model ) { |
426 | case Model_HTC_Universal: | 426 | case Model_HTC_Universal: |
427 | { | 427 | { |
428 | OHingeStatus hs = readHingeSensor(); | 428 | OHingeStatus hs = readHingeSensor(); |
429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); | 429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); |
430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
432 | } | 432 | } |
433 | break; | 433 | break; |
434 | default: | ||
435 | break; | ||
434 | } | 436 | } |
435 | 437 | ||
436 | qDebug( "HTC::rotation() - returning '%d'", rot ); | 438 | qDebug( "HTC::rotation() - returning '%d'", rot ); |
437 | return rot; | 439 | return rot; |
438 | } | 440 | } |
439 | ODirection HTC::direction() const | 441 | ODirection HTC::direction() const |
440 | { | 442 | { |
441 | ODirection dir; | 443 | ODirection dir; |
442 | 444 | ||
443 | switch ( d->m_model ) { | 445 | switch ( d->m_model ) { |
444 | case Model_HTC_Universal: { | 446 | case Model_HTC_Universal: { |
445 | OHingeStatus hs = readHingeSensor(); | 447 | OHingeStatus hs = readHingeSensor(); |
446 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 448 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
447 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 449 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
448 | else dir = CW; | 450 | else dir = CW; |
449 | } | 451 | } |
450 | break; | 452 | break; |
451 | default: dir = d->m_direction; | 453 | default: dir = d->m_direction; |
452 | break; | 454 | break; |
453 | } | 455 | } |
454 | return dir; | 456 | return dir; |
455 | 457 | ||
456 | } | 458 | } |
457 | 459 | ||
458 | bool HTC::hasHingeSensor() const | 460 | bool HTC::hasHingeSensor() const |
459 | { | 461 | { |
460 | return d->m_model == Model_HTC_Universal; | 462 | return d->m_model == Model_HTC_Universal; |
461 | } | 463 | } |
462 | 464 | ||
463 | OHingeStatus HTC::readHingeSensor() const | 465 | OHingeStatus HTC::readHingeSensor() const |
464 | { | 466 | { |
465 | /* | 467 | /* |
466 | * The HTC Universal keyboard is event source 1 in kernel 2.6. | 468 | * The HTC Universal keyboard is event source 1 in kernel 2.6. |
467 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 469 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
468 | * | 470 | * |
469 | * ------------------------- | 471 | * ------------------------- |
470 | * | SW0 | SW1 | CASE | | 472 | * | SW0 | SW1 | CASE | |
471 | * |-----|-----|-----------| | 473 | * |-----|-----|-----------| |
472 | * | 0 0 Unknown | | 474 | * | 0 0 Unknown | |
473 | * | 1 0 Portrait | | 475 | * | 1 0 Portrait | |
474 | * | 0 1 Closed | | 476 | * | 0 1 Closed | |
475 | * | 1 1 Landscape | | 477 | * | 1 1 Landscape | |
476 | * ------------------------- | 478 | * ------------------------- |
477 | */ | 479 | */ |
478 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); | 480 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); |
479 | bool switch0 = true; | 481 | bool switch0 = true; |
480 | bool switch1 = false; | 482 | bool switch1 = false; |
481 | if ( keyboard ) | 483 | if ( keyboard ) |
482 | { | 484 | { |
483 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); | 485 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
484 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | 486 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); |
485 | } | 487 | } |
486 | if ( switch0 ) | 488 | if ( switch0 ) |
487 | { | 489 | { |
488 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; | 490 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; |
489 | } | 491 | } |
490 | else | 492 | else |
491 | { | 493 | { |
492 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 494 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
493 | } | 495 | } |
494 | } | 496 | } |
495 | 497 | ||
496 | void HTC::initHingeSensor() | 498 | void HTC::initHingeSensor() |
497 | { | 499 | { |
498 | if ( m_embedix ) return; | 500 | if ( m_embedix ) return; |
499 | 501 | ||
500 | m_hinge.setName( "/dev/input/event1" ); | 502 | m_hinge.setName( "/dev/input/event1" ); |
501 | if ( !m_hinge.open( IO_ReadOnly ) ) | 503 | if ( !m_hinge.open( IO_ReadOnly ) ) |
502 | { | 504 | { |
503 | qWarning( "HTC::init() - Couldn't open /dev/input/event1 for read (%s)", strerror( errno ) ); | 505 | qWarning( "HTC::init() - Couldn't open /dev/input/event1 for read (%s)", strerror( errno ) ); |
504 | return; | 506 | return; |
505 | } | 507 | } |
506 | 508 | ||
507 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); | 509 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); |
508 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); | 510 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); |
509 | 511 | ||
510 | qDebug( "HTC::init() - Hinge Sensor Initialization successfully completed" ); | 512 | qDebug( "HTC::init() - Hinge Sensor Initialization successfully completed" ); |
511 | } | 513 | } |
512 | 514 | ||
513 | void HTC::hingeSensorTriggered() | 515 | void HTC::hingeSensorTriggered() |
514 | { | 516 | { |
515 | qDebug( "HTC::hingeSensorTriggered() - got event" ); | 517 | qDebug( "HTC::hingeSensorTriggered() - got event" ); |
516 | struct input_event e; | 518 | struct input_event e; |
517 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) | 519 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) |
518 | { | 520 | { |
519 | qDebug( "HTC::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); | 521 | qDebug( "HTC::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); |
520 | if ( e.type != EV_SW ) return; | 522 | if ( e.type != EV_SW ) return; |
521 | if ( readHingeSensor() != CASE_UNKNOWN ) | 523 | if ( readHingeSensor() != CASE_UNKNOWN ) |
522 | { | 524 | { |
523 | qDebug( "HTC::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); | 525 | qDebug( "HTC::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); |
524 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); | 526 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); |
525 | } | 527 | } |
526 | } | 528 | } |
527 | } | 529 | } |
528 | 530 | ||
529 | void HTC::systemMessage( const QCString &msg, const QByteArray & ) | 531 | void HTC::systemMessage( const QCString &msg, const QByteArray & ) |
530 | { | 532 | { |
531 | if ( msg == "deviceButtonMappingChanged()" ) { | 533 | if ( msg == "deviceButtonMappingChanged()" ) { |
532 | reloadButtonMapping(); | 534 | reloadButtonMapping(); |
533 | } | 535 | } |
534 | } | 536 | } |
535 | 537 | ||
536 | /* | 538 | /* |
537 | * Take code from iPAQ device. | 539 | * Take code from iPAQ device. |
538 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | 540 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. |
539 | * I hope that is ok - Alwin | 541 | * I hope that is ok - Alwin |
540 | */ | 542 | */ |
541 | bool HTC::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 543 | bool HTC::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
542 | { | 544 | { |
543 | int newkeycode = keycode; | 545 | int newkeycode = keycode; |
544 | 546 | ||
545 | if ( !hasHingeSensor() ) return false; | 547 | if ( !hasHingeSensor() ) return false; |
546 | 548 | ||
547 | /* map cursor keys depending on the hinge status */ | 549 | /* map cursor keys depending on the hinge status */ |
548 | switch ( keycode ) { | 550 | switch ( keycode ) { |
549 | // Rotate cursor keys | 551 | // Rotate cursor keys |
550 | case Key_Left : | 552 | case Key_Left : |
551 | case Key_Right: | 553 | case Key_Right: |
552 | case Key_Up : | 554 | case Key_Up : |
553 | case Key_Down : | 555 | case Key_Down : |
554 | { | 556 | { |
555 | if (rotation()==Rot90) { | 557 | if (rotation()==Rot90) { |
556 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 558 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
557 | } | 559 | } |
558 | } | 560 | } |
559 | break; | 561 | break; |
560 | 562 | ||
561 | } | 563 | } |
562 | if (newkeycode!=keycode) { | 564 | if (newkeycode!=keycode) { |
563 | if ( newkeycode != Key_unknown ) { | 565 | if ( newkeycode != Key_unknown ) { |
564 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 566 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
565 | } | 567 | } |
566 | return true; | 568 | return true; |
567 | } | 569 | } |
568 | return false; | 570 | return false; |
569 | } | 571 | } |
570 | 572 | ||
571 | bool HTC::suspend() { | 573 | bool HTC::suspend() { |
572 | 574 | ||
573 | /* MV */ | 575 | /* MV */ |
574 | return false; | 576 | return false; |
575 | 577 | ||
576 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 578 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
577 | return false; | 579 | return false; |
578 | 580 | ||
579 | bool res = false; | 581 | bool res = false; |
580 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 582 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
581 | 583 | ||
582 | struct timeval tvs, tvn; | 584 | struct timeval tvs, tvn; |
583 | ::gettimeofday ( &tvs, 0 ); | 585 | ::gettimeofday ( &tvs, 0 ); |
584 | 586 | ||
585 | ::sync(); // flush fs caches | 587 | ::sync(); // flush fs caches |
586 | res = ( ::system ( "apm --suspend" ) == 0 ); | 588 | res = ( ::system ( "apm --suspend" ) == 0 ); |
587 | 589 | ||
588 | // This is needed because some apm implementations are asynchronous and we | 590 | // This is needed because some apm implementations are asynchronous and we |
589 | // can not be sure when exactly the device is really suspended | 591 | // can not be sure when exactly the device is really suspended |
590 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 592 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
591 | // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. | 593 | // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. |
592 | 594 | ||
593 | if ( res && m_embedix) { | 595 | if ( res && m_embedix) { |
594 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 596 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
595 | ::usleep ( 200 * 1000 ); | 597 | ::usleep ( 200 * 1000 ); |
596 | ::gettimeofday ( &tvn, 0 ); | 598 | ::gettimeofday ( &tvn, 0 ); |
597 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); | 599 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); |
598 | } | 600 | } |
599 | 601 | ||
600 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | 602 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); |
601 | 603 | ||
602 | return res; | 604 | return res; |
603 | } | 605 | } |
diff --git a/libopie2/opiecore/device/odevice_motorola_ezx.cpp b/libopie2/opiecore/device/odevice_motorola_ezx.cpp index eed81ac..67a2b9b 100644 --- a/libopie2/opiecore/device/odevice_motorola_ezx.cpp +++ b/libopie2/opiecore/device/odevice_motorola_ezx.cpp | |||
@@ -1,292 +1,251 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2006 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2006 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "odevice_motorola_ezx.h" | 29 | #include "odevice_motorola_ezx.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <opie2/oinputsystem.h> | 32 | #include <opie2/oinputsystem.h> |
33 | #include <opie2/oresource.h> | 33 | #include <opie2/oresource.h> |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/sound.h> | 36 | #include <qpe/sound.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qwindowsystem_qws.h> | 42 | #include <qwindowsystem_qws.h> |
43 | #include <qcopchannel_qws.h> | 43 | #include <qcopchannel_qws.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <assert.h> | 46 | #include <assert.h> |
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 ezx_button ezx_buttons [] = { | 63 | struct ezx_button ezx_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 | void Motorola_EZX::init(const QString& cpu_info) | 86 | void Motorola_EZX::init(const QString& cpu_info) |
87 | { | 87 | { |
88 | qDebug( "Motorola_EZX::init()" ); | 88 | qDebug( "Motorola_EZX::init()" ); |
89 | // Set the time to wait until the system is really suspended | 89 | // Set the time to wait until the system is really suspended |
90 | // the delta between apm --suspend and sleeping | 90 | // the delta between apm --suspend and sleeping |
91 | setAPMTimeOut( 15000 ); | 91 | setAPMTimeOut( 15000 ); |
92 | 92 | ||
93 | d->m_vendorstr = "OpenEZX Team"; | 93 | d->m_vendorstr = "OpenEZX Team"; |
94 | d->m_systemstr = "OpenEZX"; | 94 | d->m_systemstr = "OpenEZX"; |
95 | d->m_system = System_OpenEZX; | 95 | d->m_system = System_OpenEZX; |
96 | // sysver already gathered | 96 | // sysver already gathered |
97 | 97 | ||
98 | // check the Motorola_EZX model | 98 | // check the Motorola_EZX model |
99 | QString model; | 99 | QString model; |
100 | int loc = cpu_info.find( ":" ); | 100 | int loc = cpu_info.find( ":" ); |
101 | if ( loc != -1 ) | 101 | if ( loc != -1 ) |
102 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 102 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
103 | else | 103 | else |
104 | model = cpu_info; | 104 | model = cpu_info; |
105 | 105 | ||
106 | if ( model == "Motorola Ezx Platform" ) { | 106 | if ( model == "Motorola Ezx Platform" ) { |
107 | d->m_model = Model_Motorola_EZX; | 107 | d->m_model = Model_Motorola_EZX; |
108 | d->m_modelstr = "Motorola_EZX"; | 108 | d->m_modelstr = "Motorola_EZX"; |
109 | } else assert( 0 ); | 109 | } else assert( 0 ); |
110 | 110 | ||
111 | // set path to backlight device in kernel 2.6 | 111 | // set path to backlight device in kernel 2.6 |
112 | m_backlightdev = "/sys/class/backlight/ezx-bl/"; | 112 | m_backlightdev = "/sys/class/backlight/ezx-bl/"; |
113 | d->m_rotation = Rot0; | 113 | d->m_rotation = Rot0; |
114 | //initHingeSensor(); | 114 | //initHingeSensor(); |
115 | 115 | ||
116 | // set default qte driver and led state | 116 | // set default qte driver and led state |
117 | d->m_qteDriver = "Transformed"; | 117 | d->m_qteDriver = "Transformed"; |
118 | m_leds[0] = Led_Off; | 118 | m_leds[0] = Led_Off; |
119 | 119 | ||
120 | qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr ); | 120 | qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void Motorola_EZX::initButtons() | 123 | void Motorola_EZX::initButtons() |
124 | { | 124 | { |
125 | qDebug( "Motorola_EZX::initButtons()" ); | 125 | qDebug( "Motorola_EZX::initButtons()" ); |
126 | if ( d->m_buttons ) | 126 | if ( d->m_buttons ) |
127 | return; | 127 | return; |
128 | 128 | ||
129 | d->m_buttons = new QValueList <ODeviceButton>; | 129 | d->m_buttons = new QValueList <ODeviceButton>; |
130 | |||
131 | struct ezx_button * ezx_buttons; | ||
132 | int buttoncount; | ||
133 | |||
134 | /* | ||
135 | |||
136 | switch ( d->m_model ) | ||
137 | { | ||
138 | case Model_Motorola_EZX_SL6000: | ||
139 | pezx_buttons = ezx_buttons_6000; | ||
140 | buttoncount = ARRAY_SIZE(ezx_buttons_6000); | ||
141 | break; | ||
142 | case Model_Motorola_EZX_SLC3100: // fallthrough | ||
143 | case Model_Motorola_EZX_SLC3000: // fallthrough | ||
144 | case Model_Motorola_EZX_SLC1000: // fallthrough | ||
145 | case Model_Motorola_EZX_SLC7x0: | ||
146 | if ( isQWS( ) ) | ||
147 | { | ||
148 | addPreHandler(this); | ||
149 | } | ||
150 | pezx_buttons = ezx_buttons_c700; | ||
151 | buttoncount = ARRAY_SIZE(ezx_buttons_c700); | ||
152 | break; | ||
153 | default: | ||
154 | pezx_buttons = ezx_buttons; | ||
155 | buttoncount = ARRAY_SIZE(ezx_buttons); | ||
156 | break; | ||
157 | } | ||
158 | |||
159 | for ( int i = 0; i < buttoncount; i++ ) { | ||
160 | struct ezx_button *zb = pezx_buttons + i; | ||
161 | ODeviceButton b; | ||
162 | |||
163 | b.setKeycode( zb->code ); | ||
164 | b.setUserText( QObject::tr( "Button", zb->utext )); | ||
165 | b.setPixmap( OResource::loadPixmap( zb->pix )); | ||
166 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | ||
167 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | ||
168 | d->m_buttons->append( b ); | ||
169 | } | ||
170 | */ | ||
171 | reloadButtonMapping(); | 130 | reloadButtonMapping(); |
172 | } | 131 | } |
173 | 132 | ||
174 | void Motorola_EZX::playAlarmSound() | 133 | void Motorola_EZX::playAlarmSound() |
175 | { | 134 | { |
176 | #ifndef QT_NO_SOUND | 135 | #ifndef QT_NO_SOUND |
177 | static Sound snd ( "alarm" ); | 136 | static Sound snd ( "alarm" ); |
178 | if(!snd.isFinished()) | 137 | if(!snd.isFinished()) |
179 | return; | 138 | return; |
180 | 139 | ||
181 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 140 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
182 | snd. play(); | 141 | snd. play(); |
183 | #endif | 142 | #endif |
184 | } | 143 | } |
185 | 144 | ||
186 | QValueList <OLed> Motorola_EZX::ledList() const | 145 | QValueList <OLed> Motorola_EZX::ledList() const |
187 | { | 146 | { |
188 | QValueList <OLed> vl; | 147 | QValueList <OLed> vl; |
189 | vl << Led_Mail; | 148 | vl << Led_Mail; |
190 | return vl; | 149 | return vl; |
191 | } | 150 | } |
192 | 151 | ||
193 | QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const | 152 | QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const |
194 | { | 153 | { |
195 | QValueList <OLedState> vl; | 154 | QValueList <OLedState> vl; |
196 | 155 | ||
197 | if ( l == Led_Mail ) | 156 | if ( l == Led_Mail ) |
198 | vl << Led_Off << Led_On << Led_BlinkSlow; | 157 | vl << Led_Off << Led_On << Led_BlinkSlow; |
199 | return vl; | 158 | return vl; |
200 | } | 159 | } |
201 | 160 | ||
202 | OLedState Motorola_EZX::ledState( OLed which ) const | 161 | OLedState Motorola_EZX::ledState( OLed which ) const |
203 | { | 162 | { |
204 | if ( which == Led_Mail ) | 163 | if ( which == Led_Mail ) |
205 | return m_leds [0]; | 164 | return m_leds [0]; |
206 | else | 165 | else |
207 | return Led_Off; | 166 | return Led_Off; |
208 | } | 167 | } |
209 | 168 | ||
210 | bool Motorola_EZX::setLedState( OLed which, OLedState st ) | 169 | bool Motorola_EZX::setLedState( OLed, OLedState ) |
211 | { | 170 | { |
212 | // Currently not supported | 171 | // Currently not supported |
213 | qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" ); | 172 | qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" ); |
214 | return false; | 173 | return false; |
215 | } | 174 | } |
216 | 175 | ||
217 | int Motorola_EZX::displayBrightnessResolution() const | 176 | int Motorola_EZX::displayBrightnessResolution() const |
218 | { | 177 | { |
219 | int res = 1; | 178 | int res = 1; |
220 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 179 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
221 | if ( fd ) | 180 | if ( fd ) |
222 | { | 181 | { |
223 | char buf[100]; | 182 | char buf[100]; |
224 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 183 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
225 | ::close( fd ); | 184 | ::close( fd ); |
226 | } | 185 | } |
227 | return res; | 186 | return res; |
228 | } | 187 | } |
229 | 188 | ||
230 | bool Motorola_EZX::setDisplayBrightness( int bright ) | 189 | bool Motorola_EZX::setDisplayBrightness( int bright ) |
231 | { | 190 | { |
232 | qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright ); | 191 | qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright ); |
233 | return false; | 192 | return false; |
234 | 193 | ||
235 | bool res = false; | 194 | bool res = false; |
236 | 195 | ||
237 | if ( bright > 255 ) bright = 255; | 196 | if ( bright > 255 ) bright = 255; |
238 | if ( bright < 0 ) bright = 0; | 197 | if ( bright < 0 ) bright = 0; |
239 | 198 | ||
240 | int numberOfSteps = displayBrightnessResolution(); | 199 | int numberOfSteps = displayBrightnessResolution(); |
241 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 200 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
242 | 201 | ||
243 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 202 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
244 | if ( fd ) | 203 | if ( fd ) |
245 | { | 204 | { |
246 | char buf[100]; | 205 | char buf[100]; |
247 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 206 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
248 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 207 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
249 | ::close( fd ); | 208 | ::close( fd ); |
250 | } | 209 | } |
251 | return res; | 210 | return res; |
252 | } | 211 | } |
253 | 212 | ||
254 | bool Motorola_EZX::setDisplayStatus( bool on ) | 213 | bool Motorola_EZX::setDisplayStatus( bool on ) |
255 | { | 214 | { |
256 | bool res = false; | 215 | bool res = false; |
257 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 216 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
258 | if ( fd ) | 217 | if ( fd ) |
259 | { | 218 | { |
260 | char buf[10]; | 219 | char buf[10]; |
261 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 220 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
262 | buf[1] = '\0'; | 221 | buf[1] = '\0'; |
263 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 222 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
264 | ::close( fd ); | 223 | ::close( fd ); |
265 | } | 224 | } |
266 | return res; | 225 | return res; |
267 | } | 226 | } |
268 | 227 | ||
269 | void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & ) | 228 | void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & ) |
270 | { | 229 | { |
271 | if ( msg == "deviceButtonMappingChanged()" ) { | 230 | if ( msg == "deviceButtonMappingChanged()" ) { |
272 | reloadButtonMapping(); | 231 | reloadButtonMapping(); |
273 | } | 232 | } |
274 | } | 233 | } |
275 | 234 | ||
276 | bool Motorola_EZX::suspend() { | 235 | bool Motorola_EZX::suspend() { |
277 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 236 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
278 | return false; | 237 | return false; |
279 | 238 | ||
280 | bool res = false; | 239 | bool res = false; |
281 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 240 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
282 | 241 | ||
283 | struct timeval tvs, tvn; | 242 | struct timeval tvs; |
284 | ::gettimeofday ( &tvs, 0 ); | 243 | ::gettimeofday ( &tvs, 0 ); |
285 | 244 | ||
286 | ::sync(); // flush fs caches | 245 | ::sync(); // flush fs caches |
287 | res = ( ::system ( "apm --suspend" ) == 0 ); | 246 | res = ( ::system ( "apm --suspend" ) == 0 ); |
288 | 247 | ||
289 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | 248 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); |
290 | 249 | ||
291 | return res; | 250 | return res; |
292 | } | 251 | } |
diff --git a/libopie2/opiecore/device/odevice_palm.cpp b/libopie2/opiecore/device/odevice_palm.cpp index 76399f8..399c08c 100644 --- a/libopie2/opiecore/device/odevice_palm.cpp +++ b/libopie2/opiecore/device/odevice_palm.cpp | |||
@@ -1,282 +1,284 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | 4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "odevice_palm.h" | 31 | #include "odevice_palm.h" |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #include <qgfx_qws.h> | 38 | #include <qgfx_qws.h> |
39 | 39 | ||
40 | /* OPIE */ | 40 | /* OPIE */ |
41 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | 44 | ||
45 | #include <opie2/okeyfilter.h> | 45 | #include <opie2/okeyfilter.h> |
46 | #include <opie2/oresource.h> | 46 | #include <opie2/oresource.h> |
47 | 47 | ||
48 | /* STD */ | 48 | /* STD */ |
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 palm_button palm_buttons [] = { | 63 | struct palm_button palm_buttons [] = { |
64 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | 64 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, |
65 | Qt::Key_F9, QT_TRANSLATE_NOOP( "Button", "Home Button" ), | 65 | Qt::Key_F9, QT_TRANSLATE_NOOP( "Button", "Home Button" ), |
66 | "devicebuttons/palm_home", | 66 | "devicebuttons/palm_home", |
67 | "QPE/Launcher", "home()", | 67 | "QPE/Launcher", "home()", |
68 | "buttonsettings", "raise()" }, | 68 | "buttonsettings", "raise()" }, |
69 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | 69 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, |
70 | Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Calendar Button" ), | 70 | Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Calendar Button" ), |
71 | "devicebuttons/palm_calendar", | 71 | "devicebuttons/palm_calendar", |
72 | "datebook", "nextView()", | 72 | "datebook", "nextView()", |
73 | "today", "raise()" }, | 73 | "today", "raise()" }, |
74 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | 74 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, |
75 | Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "Todo Button" ), | 75 | Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "Todo Button" ), |
76 | "devicebuttons/palm_todo", | 76 | "devicebuttons/palm_todo", |
77 | "todolist", "raise()", | 77 | "todolist", "raise()", |
78 | "todolist", "create()" }, | 78 | "todolist", "create()" }, |
79 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | 79 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, |
80 | Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "Mail Button" ), | 80 | Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "Mail Button" ), |
81 | "devicebuttons/palm_mail", | 81 | "devicebuttons/palm_mail", |
82 | "opiemail", "raise()", | 82 | "opiemail", "raise()", |
83 | "opiemail", "newmail()" }, | 83 | "opiemail", "newmail()" }, |
84 | { Model_Palm_LD, | 84 | { Model_Palm_LD, |
85 | Qt::Key_F7, QT_TRANSLATE_NOOP( "Button", "Voice Memo Button" ), | 85 | Qt::Key_F7, QT_TRANSLATE_NOOP( "Button", "Voice Memo Button" ), |
86 | "devicebuttons/palm_voice_memo", | 86 | "devicebuttons/palm_voice_memo", |
87 | "QPE/TaskBar", "toggleMenu()", | 87 | "QPE/TaskBar", "toggleMenu()", |
88 | "QPE/TaskBar", "toggleStartMenu()" }, | 88 | "QPE/TaskBar", "toggleStartMenu()" }, |
89 | { Model_Palm_LD, | 89 | { Model_Palm_LD, |
90 | Qt::Key_F8, QT_TRANSLATE_NOOP( "Button", "Rotate Button" ), | 90 | Qt::Key_F8, QT_TRANSLATE_NOOP( "Button", "Rotate Button" ), |
91 | "devicebuttons/palm_rotate", | 91 | "devicebuttons/palm_rotate", |
92 | "QPE/Rotation", "flip()",0}, | 92 | "QPE/Rotation", "flip()",0,0}, |
93 | }; | 93 | }; |
94 | 94 | ||
95 | void Palm::init(const QString& cpu_info) | 95 | void Palm::init(const QString& cpu_info) |
96 | { | 96 | { |
97 | d->m_vendorstr = "Palm"; | 97 | d->m_vendorstr = "Palm"; |
98 | d->m_vendor = Vendor_Palm; | 98 | d->m_vendor = Vendor_Palm; |
99 | 99 | ||
100 | QString model = "unknown"; | 100 | QString model = "unknown"; |
101 | 101 | ||
102 | int loc = cpu_info.find( ":" ); | 102 | int loc = cpu_info.find( ":" ); |
103 | if ( loc != -1 ) | 103 | if ( loc != -1 ) |
104 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 104 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
105 | else | 105 | else |
106 | model = cpu_info; | 106 | model = cpu_info; |
107 | 107 | ||
108 | if ( model == "Palm LifeDrive" ) { | 108 | if ( model == "Palm LifeDrive" ) { |
109 | d->m_modelstr = "Palm LifeDrive"; | 109 | d->m_modelstr = "Palm LifeDrive"; |
110 | d->m_model = Model_Palm_LD; | 110 | d->m_model = Model_Palm_LD; |
111 | } | 111 | } |
112 | else if ( model == "Palm TX" ) { | 112 | else if ( model == "Palm TX" ) { |
113 | d->m_modelstr = "Palm TX"; | 113 | d->m_modelstr = "Palm TX"; |
114 | d->m_model = Model_Palm_TX; | 114 | d->m_model = Model_Palm_TX; |
115 | } | 115 | } |
116 | else if ( model == "Palm Zire 72" ) { | 116 | else if ( model == "Palm Zire 72" ) { |
117 | d->m_modelstr = "Palm Zire 72"; | 117 | d->m_modelstr = "Palm Zire 72"; |
118 | d->m_model = Model_Palm_Z72; | 118 | d->m_model = Model_Palm_Z72; |
119 | } | 119 | } |
120 | else | 120 | else |
121 | d->m_model = Model_Unknown; | 121 | d->m_model = Model_Unknown; |
122 | 122 | ||
123 | switch ( d->m_model ) | 123 | switch ( d->m_model ) |
124 | { | 124 | { |
125 | case Model_Palm_LD: | 125 | case Model_Palm_LD: |
126 | case Model_Palm_TX: | 126 | case Model_Palm_TX: |
127 | case Model_Palm_Z72: | 127 | case Model_Palm_Z72: |
128 | m_backlightdev = "/sys/class/backlight/pxapwm-bl/"; | 128 | m_backlightdev = "/sys/class/backlight/pxapwm-bl/"; |
129 | d->m_rotation = Rot0; | 129 | d->m_rotation = Rot0; |
130 | d->m_direction = CCW; | 130 | d->m_direction = CCW; |
131 | d->m_qteDriver = "Transformed"; | 131 | d->m_qteDriver = "Transformed"; |
132 | break; | 132 | break; |
133 | default: | 133 | default: |
134 | m_backlightdev = ""; | 134 | m_backlightdev = ""; |
135 | } | 135 | } |
136 | 136 | ||
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | void Palm::initButtons() | 140 | void Palm::initButtons() |
141 | { | 141 | { |
142 | 142 | ||
143 | if ( d->m_buttons ) | 143 | if ( d->m_buttons ) |
144 | return ; | 144 | return ; |
145 | 145 | ||
146 | if ( isQWS( ) ) { | 146 | if ( isQWS( ) ) { |
147 | addPreHandler(this); | 147 | addPreHandler(this); |
148 | } | 148 | } |
149 | 149 | ||
150 | d->m_buttons = new QValueList <ODeviceButton>; | 150 | d->m_buttons = new QValueList <ODeviceButton>; |
151 | 151 | ||
152 | for ( uint i = 0; i < ( sizeof( palm_buttons ) / sizeof( palm_button ) ); i++ ) | 152 | for ( uint i = 0; i < ( sizeof( palm_buttons ) / sizeof( palm_button ) ); i++ ) |
153 | { | 153 | { |
154 | palm_button *ib = palm_buttons + i; | 154 | palm_button *ib = palm_buttons + i; |
155 | ODeviceButton b; | 155 | ODeviceButton b; |
156 | 156 | ||
157 | if (( ib->model & d->m_model ) == d->m_model ) { | 157 | if (( ib->model & d->m_model ) == d->m_model ) { |
158 | b. setKeycode ( ib->code ); | 158 | b. setKeycode ( ib->code ); |
159 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 159 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
160 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); | 160 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
163 | 163 | ||
164 | d->m_buttons->append ( b ); | 164 | d->m_buttons->append ( b ); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | reloadButtonMapping(); | 167 | reloadButtonMapping(); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | bool Palm::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 171 | bool Palm::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
172 | { | 172 | { |
173 | int newkeycode = keycode; | 173 | int newkeycode = keycode; |
174 | 174 | ||
175 | if (qt_screen->transformOrientation() != Rot0){ | 175 | if (qt_screen->transformOrientation() != Rot0){ |
176 | 176 | ||
177 | switch ( keycode ) { | 177 | switch ( keycode ) { |
178 | case Key_Left : | 178 | case Key_Left : |
179 | case Key_Right: | 179 | case Key_Right: |
180 | case Key_Up : | 180 | case Key_Up : |
181 | case Key_Down : | 181 | case Key_Down : |
182 | newkeycode = Key_Left + ( keycode - Key_Left + (int) qt_screen->transformOrientation() ) % 4; | 182 | newkeycode = Key_Left + ( keycode - Key_Left + (int) qt_screen->transformOrientation() ) % 4; |
183 | default: | 183 | default: |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | 186 | ||
187 | if (newkeycode!=keycode) { | 187 | if (newkeycode!=keycode) { |
188 | if ( newkeycode != Key_unknown ) { | 188 | if ( newkeycode != Key_unknown ) { |
189 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 189 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
190 | } | 190 | } |
191 | return true; | 191 | return true; |
192 | } | 192 | } |
193 | 193 | ||
194 | } | 194 | } |
195 | 195 | ||
196 | return false; | 196 | return false; |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | bool Palm::suspend() | 200 | bool Palm::suspend() |
201 | { | 201 | { |
202 | // some Palms do not implement their own power management at the moment. | 202 | // some Palms do not implement their own power management at the moment. |
203 | 203 | ||
204 | bool res = false; | 204 | bool res = false; |
205 | 205 | ||
206 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 206 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
207 | return false; | 207 | return false; |
208 | 208 | ||
209 | switch ( d->m_model ) { | 209 | switch ( d->m_model ) { |
210 | case Model_Palm_LD: | 210 | case Model_Palm_LD: |
211 | case Model_Palm_Z72: | 211 | case Model_Palm_Z72: |
212 | { | 212 | { |
213 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 213 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
214 | 214 | ||
215 | ::sync(); // flush fs caches | 215 | ::sync(); // flush fs caches |
216 | res = ( ::system ( "apm --suspend" ) == 0 ); | 216 | res = ( ::system ( "apm --suspend" ) == 0 ); |
217 | 217 | ||
218 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | 218 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); |
219 | } | 219 | } |
220 | break; | 220 | break; |
221 | default: | ||
222 | break; | ||
221 | } | 223 | } |
222 | 224 | ||
223 | return res; | 225 | return res; |
224 | } | 226 | } |
225 | 227 | ||
226 | 228 | ||
227 | int Palm::displayBrightnessResolution() const | 229 | int Palm::displayBrightnessResolution() const |
228 | { | 230 | { |
229 | int res = 1; | 231 | int res = 1; |
230 | 232 | ||
231 | switch ( d->m_model ) | 233 | switch ( d->m_model ) |
232 | { | 234 | { |
233 | case Model_Palm_LD: | 235 | case Model_Palm_LD: |
234 | case Model_Palm_TX: | 236 | case Model_Palm_TX: |
235 | case Model_Palm_Z72: | 237 | case Model_Palm_Z72: |
236 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 238 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
237 | if ( fd ) | 239 | if ( fd ) |
238 | { | 240 | { |
239 | char buf[100]; | 241 | char buf[100]; |
240 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 242 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
241 | ::close( fd ); | 243 | ::close( fd ); |
242 | } | 244 | } |
243 | break; | 245 | break; |
244 | 246 | ||
245 | default: | 247 | default: |
246 | res = 1; | 248 | res = 1; |
247 | } | 249 | } |
248 | 250 | ||
249 | return res; | 251 | return res; |
250 | } | 252 | } |
251 | 253 | ||
252 | 254 | ||
253 | bool Palm::setDisplayBrightness( int bright ) | 255 | bool Palm::setDisplayBrightness( int bright ) |
254 | { | 256 | { |
255 | bool res = false; | 257 | bool res = false; |
256 | 258 | ||
257 | if ( bright > 255 ) bright = 255; | 259 | if ( bright > 255 ) bright = 255; |
258 | if ( bright < 0 ) bright = 0; | 260 | if ( bright < 0 ) bright = 0; |
259 | 261 | ||
260 | int numberOfSteps = displayBrightnessResolution(); | 262 | int numberOfSteps = displayBrightnessResolution(); |
261 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 263 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
262 | 264 | ||
263 | switch ( d->m_model ) | 265 | switch ( d->m_model ) |
264 | { | 266 | { |
265 | 267 | ||
266 | case Model_Palm_LD: | 268 | case Model_Palm_LD: |
267 | case Model_Palm_TX: | 269 | case Model_Palm_TX: |
268 | case Model_Palm_Z72: | 270 | case Model_Palm_Z72: |
269 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 271 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
270 | if ( fd ) | 272 | if ( fd ) |
271 | { | 273 | { |
272 | char buf[100]; | 274 | char buf[100]; |
273 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 275 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
274 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 276 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
275 | ::close( fd ); | 277 | ::close( fd ); |
276 | } | 278 | } |
277 | break; | 279 | break; |
278 | 280 | ||
279 | default: res = false; | 281 | default: res = false; |
280 | } | 282 | } |
281 | return res; | 283 | return res; |
282 | } | 284 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 4963f54..9d2ebbb 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,527 +1,527 @@ | |||
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 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
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,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,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,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, "QPE/Rotation", |
143 | "QPE/Rotation", "rotateDefault()" }, | 143 | "rotateDefault()", 0 }, |
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 | qDebug( "Zaurus::init()" ); |
161 | // Set the time to wait until the system is really suspended | 161 | // Set the time to wait until the system is really suspended |
162 | // the delta between apm --suspend and sleeping | 162 | // the delta between apm --suspend and sleeping |
163 | setAPMTimeOut( 15000 ); | 163 | setAPMTimeOut( 15000 ); |
164 | 164 | ||
165 | // generic distribution code already scanned /etc/issue at that point - | 165 | // generic distribution code already scanned /etc/issue at that point - |
166 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 166 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
167 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 167 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
168 | { | 168 | { |
169 | d->m_vendorstr = "Sharp"; | 169 | d->m_vendorstr = "Sharp"; |
170 | d->m_vendor = Vendor_Sharp; | 170 | d->m_vendor = Vendor_Sharp; |
171 | d->m_systemstr = "Zaurus"; | 171 | d->m_systemstr = "Zaurus"; |
172 | d->m_system = System_Zaurus; | 172 | d->m_system = System_Zaurus; |
173 | m_embedix = true; | 173 | m_embedix = true; |
174 | } | 174 | } |
175 | else | 175 | else |
176 | { | 176 | { |
177 | d->m_vendorstr = "OpenZaurus Team"; | 177 | d->m_vendorstr = "OpenZaurus Team"; |
178 | d->m_systemstr = "OpenZaurus"; | 178 | d->m_systemstr = "OpenZaurus"; |
179 | d->m_system = System_OpenZaurus; | 179 | d->m_system = System_OpenZaurus; |
180 | // sysver already gathered | 180 | // sysver already gathered |
181 | 181 | ||
182 | // 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 |
183 | FILE *uname = popen("uname -r", "r"); | 183 | FILE *uname = popen("uname -r", "r"); |
184 | QFile f; | 184 | QFile f; |
185 | QString line; | 185 | QString line; |
186 | if ( f.open(IO_ReadOnly, uname) ) { | 186 | if ( f.open(IO_ReadOnly, uname) ) { |
187 | QTextStream ts ( &f ); | 187 | QTextStream ts ( &f ); |
188 | line = ts.readLine(); | 188 | line = ts.readLine(); |
189 | m_embedix = line.startsWith( "2.4." ); | 189 | m_embedix = line.startsWith( "2.4." ); |
190 | f.close(); | 190 | f.close(); |
191 | } | 191 | } |
192 | pclose(uname); | 192 | pclose(uname); |
193 | } | 193 | } |
194 | 194 | ||
195 | // check the Zaurus model | 195 | // check the Zaurus model |
196 | QString model; | 196 | QString model; |
197 | int loc = cpu_info.find( ":" ); | 197 | int loc = cpu_info.find( ":" ); |
198 | if ( loc != -1 ) | 198 | if ( loc != -1 ) |
199 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 199 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
200 | else | 200 | else |
201 | model = cpu_info; | 201 | model = cpu_info; |
202 | 202 | ||
203 | if ( model == "SHARP Corgi" ) { | 203 | if ( model == "SHARP Corgi" ) { |
204 | d->m_model = Model_Zaurus_SLC7x0; | 204 | d->m_model = Model_Zaurus_SLC7x0; |
205 | d->m_modelstr = "Zaurus SL-C700"; | 205 | d->m_modelstr = "Zaurus SL-C700"; |
206 | } else if ( model == "SHARP Shepherd" ) { | 206 | } else if ( model == "SHARP Shepherd" ) { |
207 | d->m_model = Model_Zaurus_SLC7x0; | 207 | d->m_model = Model_Zaurus_SLC7x0; |
208 | d->m_modelstr = "Zaurus SL-C750"; | 208 | d->m_modelstr = "Zaurus SL-C750"; |
209 | } else if ( model == "SHARP Husky" ) { | 209 | } else if ( model == "SHARP Husky" ) { |
210 | d->m_model = Model_Zaurus_SLC7x0; | 210 | d->m_model = Model_Zaurus_SLC7x0; |
211 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 211 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
212 | } else if ( model == "SHARP Boxer" ) { | 212 | } else if ( model == "SHARP Boxer" ) { |
213 | d->m_model = Model_Zaurus_SLC7x0; | 213 | d->m_model = Model_Zaurus_SLC7x0; |
214 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 214 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
215 | } else if ( model == "SHARP Poodle" ) { | 215 | } else if ( model == "SHARP Poodle" ) { |
216 | d->m_model = Model_Zaurus_SLB600; | 216 | d->m_model = Model_Zaurus_SLB600; |
217 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 217 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
218 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 218 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
219 | d->m_model = Model_Zaurus_SL5500; | 219 | d->m_model = Model_Zaurus_SL5500; |
220 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 220 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
221 | } else if ( model == "SHARP Tosa" ) { | 221 | } else if ( model == "SHARP Tosa" ) { |
222 | d->m_model = Model_Zaurus_SL6000; | 222 | d->m_model = Model_Zaurus_SL6000; |
223 | d->m_modelstr = "Zaurus SL-6000"; | 223 | d->m_modelstr = "Zaurus SL-6000"; |
224 | } else if ( model == "SHARP Spitz" ) { | 224 | } else if ( model == "SHARP Spitz" ) { |
225 | d->m_model = Model_Zaurus_SLC3000; | 225 | d->m_model = Model_Zaurus_SLC3000; |
226 | d->m_modelstr = "Zaurus SL-C3000"; | 226 | d->m_modelstr = "Zaurus SL-C3000"; |
227 | } else if ( model == "SHARP Akita" ) { | 227 | } else if ( model == "SHARP Akita" ) { |
228 | d->m_model = Model_Zaurus_SLC1000; | 228 | d->m_model = Model_Zaurus_SLC1000; |
229 | d->m_modelstr = "Zaurus SL-C1000"; | 229 | d->m_modelstr = "Zaurus SL-C1000"; |
230 | } else if ( model == "SHARP Borzoi" ) { | 230 | } else if ( model == "SHARP Borzoi" ) { |
231 | d->m_model = Model_Zaurus_SLC3100; | 231 | d->m_model = Model_Zaurus_SLC3100; |
232 | d->m_modelstr = "Zaurus SL-C3100"; | 232 | d->m_modelstr = "Zaurus SL-C3100"; |
233 | } else { | 233 | } else { |
234 | d->m_model = Model_Zaurus_SL5500; | 234 | d->m_model = Model_Zaurus_SL5500; |
235 | d->m_modelstr = "Unknown Zaurus"; | 235 | d->m_modelstr = "Unknown Zaurus"; |
236 | } | 236 | } |
237 | 237 | ||
238 | // set path to backlight device in kernel 2.6 | 238 | // set path to backlight device in kernel 2.6 |
239 | switch ( d->m_model ) | 239 | switch ( d->m_model ) |
240 | { | 240 | { |
241 | case Model_Zaurus_SLB600: // fallthrough | 241 | case Model_Zaurus_SLB600: // fallthrough |
242 | case Model_Zaurus_SL5500: | 242 | case Model_Zaurus_SL5500: |
243 | m_backlightdev = "/sys/class/backlight/locomo-bl/"; | 243 | m_backlightdev = "/sys/class/backlight/locomo-bl/"; |
244 | break; | 244 | break; |
245 | default: | 245 | default: |
246 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; | 246 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
247 | } | 247 | } |
248 | 248 | ||
249 | // set initial rotation | 249 | // set initial rotation |
250 | switch( d->m_model ) | 250 | switch( d->m_model ) |
251 | { | 251 | { |
252 | case Model_Zaurus_SL6000: // fallthrough | 252 | case Model_Zaurus_SL6000: // fallthrough |
253 | case Model_Zaurus_SLA300: | 253 | case Model_Zaurus_SLA300: |
254 | d->m_rotation = Rot0; | 254 | d->m_rotation = Rot0; |
255 | break; | 255 | break; |
256 | case Model_Zaurus_SLC3100: // fallthrough | 256 | case Model_Zaurus_SLC3100: // fallthrough |
257 | case Model_Zaurus_SLC3000: // fallthrough | 257 | case Model_Zaurus_SLC3000: // fallthrough |
258 | case Model_Zaurus_SLC1000: // fallthrough | 258 | case Model_Zaurus_SLC1000: // fallthrough |
259 | case Model_Zaurus_SLC7x0: | 259 | case Model_Zaurus_SLC7x0: |
260 | initHingeSensor(); | 260 | initHingeSensor(); |
261 | d->m_rotation = rotation(); | 261 | d->m_rotation = rotation(); |
262 | d->m_direction = direction(); | 262 | d->m_direction = direction(); |
263 | break; | 263 | break; |
264 | case Model_Zaurus_SLB600: // fallthrough | 264 | case Model_Zaurus_SLB600: // fallthrough |
265 | case Model_Zaurus_SL5000: // fallthrough | 265 | case Model_Zaurus_SL5000: // fallthrough |
266 | case Model_Zaurus_SL5500: // fallthrough | 266 | case Model_Zaurus_SL5500: // fallthrough |
267 | default: | 267 | default: |
268 | d->m_rotation = Rot270; | 268 | d->m_rotation = Rot270; |
269 | } | 269 | } |
270 | 270 | ||
271 | // set default qte driver | 271 | // set default qte driver |
272 | switch( d->m_model ) | 272 | switch( d->m_model ) |
273 | { | 273 | { |
274 | case Model_Zaurus_SLC7x0: | 274 | case Model_Zaurus_SLC7x0: |
275 | d->m_qteDriver = "W100"; | 275 | d->m_qteDriver = "W100"; |
276 | break; | 276 | break; |
277 | default: | 277 | default: |
278 | d->m_qteDriver = "Transformed"; | 278 | d->m_qteDriver = "Transformed"; |
279 | } | 279 | } |
280 | 280 | ||
281 | m_leds[0] = Led_Off; | 281 | m_leds[0] = Led_Off; |
282 | 282 | ||
283 | if ( m_embedix ) | 283 | if ( m_embedix ) |
284 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | 284 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); |
285 | else | 285 | else |
286 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 286 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
287 | } | 287 | } |
288 | 288 | ||
289 | void Zaurus::initButtons() | 289 | void Zaurus::initButtons() |
290 | { | 290 | { |
291 | qDebug( "Zaurus::initButtons()" ); | 291 | qDebug( "Zaurus::initButtons()" ); |
292 | if ( d->m_buttons ) | 292 | if ( d->m_buttons ) |
293 | return; | 293 | return; |
294 | 294 | ||
295 | d->m_buttons = new QValueList <ODeviceButton>; | 295 | d->m_buttons = new QValueList <ODeviceButton>; |
296 | 296 | ||
297 | struct z_button * pz_buttons; | 297 | struct z_button * pz_buttons; |
298 | int buttoncount; | 298 | int buttoncount; |
299 | switch ( d->m_model ) | 299 | switch ( d->m_model ) |
300 | { | 300 | { |
301 | case Model_Zaurus_SL6000: | 301 | case Model_Zaurus_SL6000: |
302 | pz_buttons = z_buttons_6000; | 302 | pz_buttons = z_buttons_6000; |
303 | buttoncount = ARRAY_SIZE(z_buttons_6000); | 303 | buttoncount = ARRAY_SIZE(z_buttons_6000); |
304 | break; | 304 | break; |
305 | case Model_Zaurus_SLC3100: // fallthrough | 305 | case Model_Zaurus_SLC3100: // fallthrough |
306 | case Model_Zaurus_SLC3000: // fallthrough | 306 | case Model_Zaurus_SLC3000: // fallthrough |
307 | case Model_Zaurus_SLC1000: // fallthrough | 307 | case Model_Zaurus_SLC1000: // fallthrough |
308 | case Model_Zaurus_SLC7x0: | 308 | case Model_Zaurus_SLC7x0: |
309 | if ( isQWS( ) ) | 309 | if ( isQWS( ) ) |
310 | { | 310 | { |
311 | addPreHandler(this); | 311 | addPreHandler(this); |
312 | } | 312 | } |
313 | pz_buttons = z_buttons_c700; | 313 | pz_buttons = z_buttons_c700; |
314 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 314 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
315 | break; | 315 | break; |
316 | default: | 316 | default: |
317 | pz_buttons = z_buttons; | 317 | pz_buttons = z_buttons; |
318 | buttoncount = ARRAY_SIZE(z_buttons); | 318 | buttoncount = ARRAY_SIZE(z_buttons); |
319 | break; | 319 | break; |
320 | } | 320 | } |
321 | 321 | ||
322 | for ( int i = 0; i < buttoncount; i++ ) { | 322 | for ( int i = 0; i < buttoncount; i++ ) { |
323 | struct z_button *zb = pz_buttons + i; | 323 | struct z_button *zb = pz_buttons + i; |
324 | ODeviceButton b; | 324 | ODeviceButton b; |
325 | 325 | ||
326 | b.setKeycode( zb->code ); | 326 | b.setKeycode( zb->code ); |
327 | b.setUserText( QObject::tr( "Button", zb->utext )); | 327 | b.setUserText( QObject::tr( "Button", zb->utext )); |
328 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 328 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
329 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 329 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
330 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 330 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
331 | d->m_buttons->append( b ); | 331 | d->m_buttons->append( b ); |
332 | } | 332 | } |
333 | 333 | ||
334 | reloadButtonMapping(); | 334 | reloadButtonMapping(); |
335 | } | 335 | } |
336 | 336 | ||
337 | 337 | ||
338 | 338 | ||
339 | typedef struct sharp_led_status { | 339 | typedef struct sharp_led_status { |
340 | int which; /* select which LED status is wanted. */ | 340 | int which; /* select which LED status is wanted. */ |
341 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 341 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
342 | } sharp_led_status; | 342 | } sharp_led_status; |
343 | 343 | ||
344 | void Zaurus::buzzer( int sound ) | 344 | void Zaurus::buzzer( int sound ) |
345 | { | 345 | { |
346 | #ifndef QT_NO_SOUND | 346 | #ifndef QT_NO_SOUND |
347 | Sound *snd = 0; | 347 | Sound *snd = 0; |
348 | 348 | ||
349 | // All devices except SL5500 have a DSP device | 349 | // All devices except SL5500 have a DSP device |
350 | if ( d->m_model != Model_Zaurus_SL5000 | 350 | if ( d->m_model != Model_Zaurus_SL5000 |
351 | && d->m_model != Model_Zaurus_SL5500 ) { | 351 | && d->m_model != Model_Zaurus_SL5500 ) { |
352 | 352 | ||
353 | switch ( sound ){ | 353 | switch ( sound ){ |
354 | case SHARP_BUZ_TOUCHSOUND: { | 354 | case SHARP_BUZ_TOUCHSOUND: { |
355 | static Sound touch_sound("touchsound"); | 355 | static Sound touch_sound("touchsound"); |
356 | snd = &touch_sound; | 356 | snd = &touch_sound; |
357 | } | 357 | } |
358 | break; | 358 | break; |
359 | case SHARP_BUZ_KEYSOUND: { | 359 | case SHARP_BUZ_KEYSOUND: { |
360 | static Sound key_sound( "keysound" ); | 360 | static Sound key_sound( "keysound" ); |
361 | snd = &key_sound; | 361 | snd = &key_sound; |
362 | } | 362 | } |
363 | break; | 363 | break; |
364 | case SHARP_BUZ_SCHEDULE_ALARM: | 364 | case SHARP_BUZ_SCHEDULE_ALARM: |
365 | default: { | 365 | default: { |
366 | static Sound alarm_sound("alarm"); | 366 | static Sound alarm_sound("alarm"); |
367 | snd = &alarm_sound; | 367 | snd = &alarm_sound; |
368 | } | 368 | } |
369 | break; | 369 | break; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | // If a soundname is defined, we expect that this device has | 373 | // If a soundname is defined, we expect that this device has |
374 | // sound capabilities.. Otherwise we expect to have the buzzer | 374 | // sound capabilities.. Otherwise we expect to have the buzzer |
375 | // device.. | 375 | // device.. |
376 | if ( snd && snd->isFinished() ){ | 376 | if ( snd && snd->isFinished() ){ |
377 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 377 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
378 | snd->play(); | 378 | snd->play(); |
379 | } else if( !snd ) { | 379 | } else if( !snd ) { |
380 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 380 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
381 | 381 | ||
382 | if ( fd >= 0 ) { | 382 | if ( fd >= 0 ) { |
383 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 383 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
384 | ::close ( fd ); | 384 | ::close ( fd ); |
385 | } | 385 | } |
386 | 386 | ||
387 | } | 387 | } |
388 | #endif | 388 | #endif |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | void Zaurus::playAlarmSound() | 392 | void Zaurus::playAlarmSound() |
393 | { | 393 | { |
394 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 394 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
395 | } | 395 | } |
396 | 396 | ||
397 | void Zaurus::playTouchSound() | 397 | void Zaurus::playTouchSound() |
398 | { | 398 | { |
399 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 399 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
400 | } | 400 | } |
401 | 401 | ||
402 | void Zaurus::playKeySound() | 402 | void Zaurus::playKeySound() |
403 | { | 403 | { |
404 | buzzer( SHARP_BUZ_KEYSOUND ); | 404 | buzzer( SHARP_BUZ_KEYSOUND ); |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | QValueList <OLed> Zaurus::ledList() const | 408 | QValueList <OLed> Zaurus::ledList() const |
409 | { | 409 | { |
410 | QValueList <OLed> vl; | 410 | QValueList <OLed> vl; |
411 | vl << Led_Mail; | 411 | vl << Led_Mail; |
412 | return vl; | 412 | return vl; |
413 | } | 413 | } |
414 | 414 | ||
415 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 415 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
416 | { | 416 | { |
417 | QValueList <OLedState> vl; | 417 | QValueList <OLedState> vl; |
418 | 418 | ||
419 | if ( l == Led_Mail ) | 419 | if ( l == Led_Mail ) |
420 | vl << Led_Off << Led_On << Led_BlinkSlow; | 420 | vl << Led_Off << Led_On << Led_BlinkSlow; |
421 | return vl; | 421 | return vl; |
422 | } | 422 | } |
423 | 423 | ||
424 | OLedState Zaurus::ledState( OLed which ) const | 424 | OLedState Zaurus::ledState( OLed which ) const |
425 | { | 425 | { |
426 | if ( which == Led_Mail ) | 426 | if ( which == Led_Mail ) |
427 | return m_leds [0]; | 427 | return m_leds [0]; |
428 | else | 428 | else |
429 | return Led_Off; | 429 | return Led_Off; |
430 | } | 430 | } |
431 | 431 | ||
432 | bool Zaurus::setLedState( OLed which, OLedState st ) | 432 | bool Zaurus::setLedState( OLed which, OLedState st ) |
433 | { | 433 | { |
434 | // Currently not supported on non_embedix kernels | 434 | // Currently not supported on non_embedix kernels |
435 | if (!m_embedix) | 435 | if (!m_embedix) |
436 | { | 436 | { |
437 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 437 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
438 | return false; | 438 | return false; |
439 | } | 439 | } |
440 | 440 | ||
441 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 441 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
442 | 442 | ||
443 | if ( which == Led_Mail ) { | 443 | if ( which == Led_Mail ) { |
444 | if ( fd >= 0 ) { | 444 | if ( fd >= 0 ) { |
445 | struct sharp_led_status leds; | 445 | struct sharp_led_status leds; |
446 | ::memset ( &leds, 0, sizeof( leds )); | 446 | ::memset ( &leds, 0, sizeof( leds )); |
447 | leds. which = SHARP_LED_MAIL_EXISTS; | 447 | leds. which = SHARP_LED_MAIL_EXISTS; |
448 | bool ok = true; | 448 | bool ok = true; |
449 | 449 | ||
450 | switch ( st ) { | 450 | switch ( st ) { |
451 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 451 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
452 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 452 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
453 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 453 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
454 | default : ok = false; | 454 | default : ok = false; |
455 | } | 455 | } |
456 | 456 | ||
457 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 457 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
458 | m_leds [0] = st; | 458 | m_leds [0] = st; |
459 | return true; | 459 | return true; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | } | 462 | } |
463 | return false; | 463 | return false; |
464 | } | 464 | } |
465 | 465 | ||
466 | int Zaurus::displayBrightnessResolution() const | 466 | int Zaurus::displayBrightnessResolution() const |
467 | { | 467 | { |
468 | int res = 1; | 468 | int res = 1; |
469 | if (m_embedix) | 469 | if (m_embedix) |
470 | { | 470 | { |
471 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 471 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
472 | if ( fd ) | 472 | if ( fd ) |
473 | { | 473 | { |
474 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 474 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
475 | ::close( fd ); | 475 | ::close( fd ); |
476 | return value ? value : res; | 476 | return value ? value : res; |
477 | } | 477 | } |
478 | } | 478 | } |
479 | else | 479 | else |
480 | { | 480 | { |
481 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 481 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
482 | if ( fd ) | 482 | if ( fd ) |
483 | { | 483 | { |
484 | char buf[100]; | 484 | char buf[100]; |
485 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 485 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
486 | ::close( fd ); | 486 | ::close( fd ); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | return res; | 489 | return res; |
490 | } | 490 | } |
491 | 491 | ||
492 | bool Zaurus::setDisplayBrightness( int bright ) | 492 | bool Zaurus::setDisplayBrightness( int bright ) |
493 | { | 493 | { |
494 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 494 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
495 | bool res = false; | 495 | bool res = false; |
496 | 496 | ||
497 | if ( bright > 255 ) bright = 255; | 497 | if ( bright > 255 ) bright = 255; |
498 | if ( bright < 0 ) bright = 0; | 498 | if ( bright < 0 ) bright = 0; |
499 | 499 | ||
500 | int numberOfSteps = displayBrightnessResolution(); | 500 | int numberOfSteps = displayBrightnessResolution(); |
501 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 501 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
502 | 502 | ||
503 | if ( m_embedix ) | 503 | if ( m_embedix ) |
504 | { | 504 | { |
505 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 505 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
506 | if ( fd ) | 506 | if ( fd ) |
507 | { | 507 | { |
508 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 508 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
509 | ::close( fd ); | 509 | ::close( fd ); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | else | 512 | else |
513 | { | 513 | { |
514 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 514 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
515 | if ( fd ) | 515 | if ( fd ) |
516 | { | 516 | { |
517 | char buf[100]; | 517 | char buf[100]; |
518 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 518 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
519 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 519 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
520 | ::close( fd ); | 520 | ::close( fd ); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | return res; | 523 | return res; |
524 | } | 524 | } |
525 | 525 | ||
526 | bool Zaurus::setDisplayStatus( bool on ) | 526 | bool Zaurus::setDisplayStatus( bool on ) |
527 | { | 527 | { |