-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 33 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 2 |
2 files changed, 10 insertions, 25 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index d3ab63a..b22ee70 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,642 +1,627 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2003-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; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | using namespace Opie::Core; | 56 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 57 | using namespace Opie::Core::Internal; |
58 | 58 | ||
59 | struct z_button z_buttons [] = { | 59 | struct z_button z_buttons [] = { |
60 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 60 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
61 | "devicebuttons/z_calendar", | 61 | "devicebuttons/z_calendar", |
62 | "datebook", "nextView()", | 62 | "datebook", "nextView()", |
63 | "today", "raise()" }, | 63 | "today", "raise()" }, |
64 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 64 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
65 | "devicebuttons/z_contact", | 65 | "devicebuttons/z_contact", |
66 | "addressbook", "raise()", | 66 | "addressbook", "raise()", |
67 | "addressbook", "beamBusinessCard()" }, | 67 | "addressbook", "beamBusinessCard()" }, |
68 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 68 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
69 | "devicebuttons/z_home", | 69 | "devicebuttons/z_home", |
70 | "QPE/Launcher", "home()", | 70 | "QPE/Launcher", "home()", |
71 | "buttonsettings", "raise()" }, | 71 | "buttonsettings", "raise()" }, |
72 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 72 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
73 | "devicebuttons/z_menu", | 73 | "devicebuttons/z_menu", |
74 | "QPE/TaskBar", "toggleMenu()", | 74 | "QPE/TaskBar", "toggleMenu()", |
75 | "QPE/TaskBar", "toggleStartMenu()" }, | 75 | "QPE/TaskBar", "toggleStartMenu()" }, |
76 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 76 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
77 | "devicebuttons/z_mail", | 77 | "devicebuttons/z_mail", |
78 | "opiemail", "raise()", | 78 | "opiemail", "raise()", |
79 | "opiemail", "newMail()" }, | 79 | "opiemail", "newMail()" }, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct z_button z_buttons_c700 [] = { | 82 | struct z_button z_buttons_c700 [] = { |
83 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 83 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
84 | "devicebuttons/z_calendar", | 84 | "devicebuttons/z_calendar", |
85 | "datebook", "nextView()", | 85 | "datebook", "nextView()", |
86 | "today", "raise()" }, | 86 | "today", "raise()" }, |
87 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 87 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
88 | "devicebuttons/z_contact", | 88 | "devicebuttons/z_contact", |
89 | "addressbook", "raise()", | 89 | "addressbook", "raise()", |
90 | "addressbook", "beamBusinessCard()" }, | 90 | "addressbook", "beamBusinessCard()" }, |
91 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 91 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
92 | "devicebuttons/z_home", | 92 | "devicebuttons/z_home", |
93 | "QPE/Launcher", "home()", | 93 | "QPE/Launcher", "home()", |
94 | "buttonsettings", "raise()" }, | 94 | "buttonsettings", "raise()" }, |
95 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 95 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
96 | "devicebuttons/z_menu", | 96 | "devicebuttons/z_menu", |
97 | "QPE/TaskBar", "toggleMenu()", | 97 | "QPE/TaskBar", "toggleMenu()", |
98 | "QPE/TaskBar", "toggleStartMenu()" }, | 98 | "QPE/TaskBar", "toggleStartMenu()" }, |
99 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 99 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
100 | "devicebuttons/z_hinge", | 100 | "devicebuttons/z_hinge", |
101 | "QPE/Rotation", "rotateDefault()", | 101 | "QPE/Rotation", "rotateDefault()", |
102 | "QPE/Dummy", "doNothing()" }, | 102 | "QPE/Dummy", "doNothing()" }, |
103 | }; | 103 | }; |
104 | 104 | ||
105 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 105 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
106 | // class up into individual classes. We need three classes | 106 | // class up into individual classes. We need three classes |
107 | // | 107 | // |
108 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 108 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
109 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 109 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
110 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) | 110 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) |
111 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 111 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
112 | // | 112 | // |
113 | // Only question right now is: Do we really need to do it? Because as soon | 113 | // Only question right now is: Do we really need to do it? Because as soon |
114 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 114 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
115 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 115 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
116 | // | 116 | // |
117 | // Comments? - mickeyl. | 117 | // Comments? - mickeyl. |
118 | 118 | ||
119 | void Zaurus::init(const QString& cpu_info) | 119 | void Zaurus::init(const QString& cpu_info) |
120 | { | 120 | { |
121 | // generic distribution code already scanned /etc/issue at that point - | 121 | // generic distribution code already scanned /etc/issue at that point - |
122 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 122 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
123 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 123 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
124 | { | 124 | { |
125 | d->m_vendorstr = "Sharp"; | 125 | d->m_vendorstr = "Sharp"; |
126 | d->m_vendor = Vendor_Sharp; | 126 | d->m_vendor = Vendor_Sharp; |
127 | d->m_systemstr = "Zaurus"; | 127 | d->m_systemstr = "Zaurus"; |
128 | d->m_system = System_Zaurus; | 128 | d->m_system = System_Zaurus; |
129 | m_embedix = true; | 129 | m_embedix = true; |
130 | } | 130 | } |
131 | else | 131 | else |
132 | { | 132 | { |
133 | d->m_vendorstr = "OpenZaurus Team"; | 133 | d->m_vendorstr = "OpenZaurus Team"; |
134 | d->m_systemstr = "OpenZaurus"; | 134 | d->m_systemstr = "OpenZaurus"; |
135 | d->m_system = System_OpenZaurus; | 135 | d->m_system = System_OpenZaurus; |
136 | // sysver already gathered | 136 | // sysver already gathered |
137 | 137 | ||
138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one | 138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one |
139 | FILE *uname = popen("uname -r", "r"); | 139 | FILE *uname = popen("uname -r", "r"); |
140 | QFile f; | 140 | QFile f; |
141 | QString line; | 141 | QString line; |
142 | if ( f.open(IO_ReadOnly, uname) ) { | 142 | if ( f.open(IO_ReadOnly, uname) ) { |
143 | QTextStream ts ( &f ); | 143 | QTextStream ts ( &f ); |
144 | line = ts. readLine(); | 144 | line = ts. readLine(); |
145 | int loc = line. find ( "embedix" ); | 145 | int loc = line. find ( "embedix" ); |
146 | if ( loc != -1 ) | 146 | if ( loc != -1 ) |
147 | m_embedix = true; | 147 | m_embedix = true; |
148 | else | 148 | else |
149 | m_embedix = false; | 149 | m_embedix = false; |
150 | f.close(); | 150 | f.close(); |
151 | } | 151 | } |
152 | pclose(uname); | 152 | pclose(uname); |
153 | } | 153 | } |
154 | 154 | ||
155 | // check the Zaurus model | 155 | // check the Zaurus model |
156 | QString model; | 156 | QString model; |
157 | int loc = cpu_info.find( ":" ); | 157 | int loc = cpu_info.find( ":" ); |
158 | if ( loc != -1 ) | 158 | if ( loc != -1 ) |
159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
160 | else | 160 | else |
161 | model = cpu_info; | 161 | model = cpu_info; |
162 | 162 | ||
163 | if ( model == "SHARP Corgi" ) { | 163 | if ( model == "SHARP Corgi" ) { |
164 | d->m_model = Model_Zaurus_SLC7x0; | 164 | d->m_model = Model_Zaurus_SLC7x0; |
165 | d->m_modelstr = "Zaurus SL-C700"; | 165 | d->m_modelstr = "Zaurus SL-C700"; |
166 | } else if ( model == "SHARP Shepherd" ) { | 166 | } else if ( model == "SHARP Shepherd" ) { |
167 | d->m_model = Model_Zaurus_SLC7x0; | 167 | d->m_model = Model_Zaurus_SLC7x0; |
168 | d->m_modelstr = "Zaurus SL-C750"; | 168 | d->m_modelstr = "Zaurus SL-C750"; |
169 | } else if ( model == "SHARP Husky" ) { | 169 | } else if ( model == "SHARP Husky" ) { |
170 | d->m_model = Model_Zaurus_SLC7x0; | 170 | d->m_model = Model_Zaurus_SLC7x0; |
171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
172 | } else if ( model == "SHARP Boxer" ) { | 172 | } else if ( model == "SHARP Boxer" ) { |
173 | d->m_model = Model_Zaurus_SLC7x0; | 173 | d->m_model = Model_Zaurus_SLC7x0; |
174 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 174 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
175 | } else if ( model == "SHARP Poodle" ) { | 175 | } else if ( model == "SHARP Poodle" ) { |
176 | d->m_model = Model_Zaurus_SLB600; | 176 | d->m_model = Model_Zaurus_SLB600; |
177 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 177 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
178 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 178 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
179 | d->m_model = Model_Zaurus_SL5500; | 179 | d->m_model = Model_Zaurus_SL5500; |
180 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 180 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
181 | } else if ( model == "SHARP Tosa" ) { | 181 | } else if ( model == "SHARP Tosa" ) { |
182 | d->m_model = Model_Zaurus_SL6000; | 182 | d->m_model = Model_Zaurus_SL6000; |
183 | d->m_modelstr = "Zaurus SL-6000"; | 183 | d->m_modelstr = "Zaurus SL-6000"; |
184 | } else if ( model == "SHARP Spitz" ) { | 184 | } else if ( model == "SHARP Spitz" ) { |
185 | d->m_model = Model_Zaurus_SLC3000; | 185 | d->m_model = Model_Zaurus_SLC3000; |
186 | d->m_modelstr = "Zaurus SL-C3000"; | 186 | d->m_modelstr = "Zaurus SL-C3000"; |
187 | } else { | 187 | } else { |
188 | d->m_model = Model_Zaurus_SL5500; | 188 | d->m_model = Model_Zaurus_SL5500; |
189 | d->m_modelstr = "Unknown Zaurus"; | 189 | d->m_modelstr = "Unknown Zaurus"; |
190 | } | 190 | } |
191 | 191 | ||
192 | // set initial rotation | 192 | // set initial rotation |
193 | switch( d->m_model ) { | 193 | switch( d->m_model ) { |
194 | case Model_Zaurus_SL6000: // fallthrough | 194 | case Model_Zaurus_SL6000: // fallthrough |
195 | case Model_Zaurus_SLA300: | 195 | case Model_Zaurus_SLA300: |
196 | d->m_rotation = Rot0; | 196 | d->m_rotation = Rot0; |
197 | break; | 197 | break; |
198 | case Model_Zaurus_SLC3000: // fallthrough | 198 | case Model_Zaurus_SLC3000: // fallthrough |
199 | case Model_Zaurus_SLC7x0: | 199 | case Model_Zaurus_SLC7x0: |
200 | d->m_rotation = rotation(); | 200 | d->m_rotation = rotation(); |
201 | d->m_direction = direction(); | 201 | d->m_direction = direction(); |
202 | break; | 202 | break; |
203 | case Model_Zaurus_SLB600: // fallthrough | 203 | case Model_Zaurus_SLB600: // fallthrough |
204 | case Model_Zaurus_SL5000: // fallthrough | 204 | case Model_Zaurus_SL5000: // fallthrough |
205 | case Model_Zaurus_SL5500: // fallthrough | 205 | case Model_Zaurus_SL5500: // fallthrough |
206 | default: | 206 | default: |
207 | d->m_rotation = Rot270; | 207 | d->m_rotation = Rot270; |
208 | break; | 208 | break; |
209 | } | 209 | } |
210 | m_leds[0] = Led_Off; | 210 | m_leds[0] = Led_Off; |
211 | 211 | ||
212 | if ( m_embedix ) | 212 | if ( m_embedix ) |
213 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); | 213 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); |
214 | else | 214 | else |
215 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 215 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
216 | } | 216 | } |
217 | 217 | ||
218 | void Zaurus::initButtons() | 218 | void Zaurus::initButtons() |
219 | { | 219 | { |
220 | if ( d->m_buttons ) | 220 | if ( d->m_buttons ) |
221 | return; | 221 | return; |
222 | 222 | ||
223 | d->m_buttons = new QValueList <ODeviceButton>; | 223 | d->m_buttons = new QValueList <ODeviceButton>; |
224 | 224 | ||
225 | struct z_button * pz_buttons; | 225 | struct z_button * pz_buttons; |
226 | int buttoncount; | 226 | int buttoncount; |
227 | switch ( d->m_model ) { | 227 | switch ( d->m_model ) { |
228 | case Model_Zaurus_SLC3000: // fallthrough | 228 | case Model_Zaurus_SLC3000: // fallthrough |
229 | case Model_Zaurus_SLC7x0: | 229 | case Model_Zaurus_SLC7x0: |
230 | pz_buttons = z_buttons_c700; | 230 | pz_buttons = z_buttons_c700; |
231 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 231 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
232 | break; | 232 | break; |
233 | default: | 233 | default: |
234 | pz_buttons = z_buttons; | 234 | pz_buttons = z_buttons; |
235 | buttoncount = ARRAY_SIZE(z_buttons); | 235 | buttoncount = ARRAY_SIZE(z_buttons); |
236 | break; | 236 | break; |
237 | } | 237 | } |
238 | 238 | ||
239 | for ( int i = 0; i < buttoncount; i++ ) { | 239 | for ( int i = 0; i < buttoncount; i++ ) { |
240 | struct z_button *zb = pz_buttons + i; | 240 | struct z_button *zb = pz_buttons + i; |
241 | ODeviceButton b; | 241 | ODeviceButton b; |
242 | 242 | ||
243 | b.setKeycode( zb->code ); | 243 | b.setKeycode( zb->code ); |
244 | b.setUserText( QObject::tr( "Button", zb->utext )); | 244 | b.setUserText( QObject::tr( "Button", zb->utext )); |
245 | b.setPixmap( Resource::loadPixmap( zb->pix )); | 245 | b.setPixmap( Resource::loadPixmap( zb->pix )); |
246 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 246 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
247 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 247 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
248 | d->m_buttons->append( b ); | 248 | d->m_buttons->append( b ); |
249 | } | 249 | } |
250 | 250 | ||
251 | reloadButtonMapping(); | 251 | reloadButtonMapping(); |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | 255 | ||
256 | typedef struct sharp_led_status { | 256 | typedef struct sharp_led_status { |
257 | int which; /* select which LED status is wanted. */ | 257 | int which; /* select which LED status is wanted. */ |
258 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 258 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
259 | } sharp_led_status; | 259 | } sharp_led_status; |
260 | 260 | ||
261 | void Zaurus::buzzer( int sound ) | 261 | void Zaurus::buzzer( int sound ) |
262 | { | 262 | { |
263 | #ifndef QT_NO_SOUND | 263 | #ifndef QT_NO_SOUND |
264 | Sound *snd = 0; | 264 | Sound *snd = 0; |
265 | 265 | ||
266 | // All devices except SL5500 have a DSP device | 266 | // All devices except SL5500 have a DSP device |
267 | if ( d->m_model != Model_Zaurus_SL5000 | 267 | if ( d->m_model != Model_Zaurus_SL5000 |
268 | && d->m_model != Model_Zaurus_SL5500 ) { | 268 | && d->m_model != Model_Zaurus_SL5500 ) { |
269 | 269 | ||
270 | switch ( sound ){ | 270 | switch ( sound ){ |
271 | case SHARP_BUZ_TOUCHSOUND: { | 271 | case SHARP_BUZ_TOUCHSOUND: { |
272 | static Sound touch_sound("touchsound"); | 272 | static Sound touch_sound("touchsound"); |
273 | snd = &touch_sound; | 273 | snd = &touch_sound; |
274 | } | 274 | } |
275 | break; | 275 | break; |
276 | case SHARP_BUZ_KEYSOUND: { | 276 | case SHARP_BUZ_KEYSOUND: { |
277 | static Sound key_sound( "keysound" ); | 277 | static Sound key_sound( "keysound" ); |
278 | snd = &key_sound; | 278 | snd = &key_sound; |
279 | } | 279 | } |
280 | break; | 280 | break; |
281 | case SHARP_BUZ_SCHEDULE_ALARM: | 281 | case SHARP_BUZ_SCHEDULE_ALARM: |
282 | default: { | 282 | default: { |
283 | static Sound alarm_sound("alarm"); | 283 | static Sound alarm_sound("alarm"); |
284 | snd = &alarm_sound; | 284 | snd = &alarm_sound; |
285 | } | 285 | } |
286 | break; | 286 | break; |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | // If a soundname is defined, we expect that this device has | 290 | // If a soundname is defined, we expect that this device has |
291 | // sound capabilities.. Otherwise we expect to have the buzzer | 291 | // sound capabilities.. Otherwise we expect to have the buzzer |
292 | // device.. | 292 | // device.. |
293 | if ( snd && snd->isFinished() ){ | 293 | if ( snd && snd->isFinished() ){ |
294 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 294 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
295 | snd->play(); | 295 | snd->play(); |
296 | } else if( !snd ) { | 296 | } else if( !snd ) { |
297 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 297 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
298 | 298 | ||
299 | if ( fd >= 0 ) { | 299 | if ( fd >= 0 ) { |
300 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 300 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
301 | ::close ( fd ); | 301 | ::close ( fd ); |
302 | } | 302 | } |
303 | 303 | ||
304 | } | 304 | } |
305 | #endif | 305 | #endif |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | void Zaurus::playAlarmSound() | 309 | void Zaurus::playAlarmSound() |
310 | { | 310 | { |
311 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 311 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
312 | } | 312 | } |
313 | 313 | ||
314 | void Zaurus::playTouchSound() | 314 | void Zaurus::playTouchSound() |
315 | { | 315 | { |
316 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 316 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
317 | } | 317 | } |
318 | 318 | ||
319 | void Zaurus::playKeySound() | 319 | void Zaurus::playKeySound() |
320 | { | 320 | { |
321 | buzzer( SHARP_BUZ_KEYSOUND ); | 321 | buzzer( SHARP_BUZ_KEYSOUND ); |
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | QValueList <OLed> Zaurus::ledList() const | 325 | QValueList <OLed> Zaurus::ledList() const |
326 | { | 326 | { |
327 | QValueList <OLed> vl; | 327 | QValueList <OLed> vl; |
328 | vl << Led_Mail; | 328 | vl << Led_Mail; |
329 | return vl; | 329 | return vl; |
330 | } | 330 | } |
331 | 331 | ||
332 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 332 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
333 | { | 333 | { |
334 | QValueList <OLedState> vl; | 334 | QValueList <OLedState> vl; |
335 | 335 | ||
336 | if ( l == Led_Mail ) | 336 | if ( l == Led_Mail ) |
337 | vl << Led_Off << Led_On << Led_BlinkSlow; | 337 | vl << Led_Off << Led_On << Led_BlinkSlow; |
338 | return vl; | 338 | return vl; |
339 | } | 339 | } |
340 | 340 | ||
341 | OLedState Zaurus::ledState( OLed which ) const | 341 | OLedState Zaurus::ledState( OLed which ) const |
342 | { | 342 | { |
343 | if ( which == Led_Mail ) | 343 | if ( which == Led_Mail ) |
344 | return m_leds [0]; | 344 | return m_leds [0]; |
345 | else | 345 | else |
346 | return Led_Off; | 346 | return Led_Off; |
347 | } | 347 | } |
348 | 348 | ||
349 | bool Zaurus::setLedState( OLed which, OLedState st ) | 349 | bool Zaurus::setLedState( OLed which, OLedState st ) |
350 | { | 350 | { |
351 | // Currently not supported on non_embedix kernels | 351 | // Currently not supported on non_embedix kernels |
352 | if (!m_embedix) | 352 | if (!m_embedix) |
353 | { | 353 | { |
354 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 354 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
355 | return false; | 355 | return false; |
356 | } | 356 | } |
357 | 357 | ||
358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
359 | 359 | ||
360 | if ( which == Led_Mail ) { | 360 | if ( which == Led_Mail ) { |
361 | if ( fd >= 0 ) { | 361 | if ( fd >= 0 ) { |
362 | struct sharp_led_status leds; | 362 | struct sharp_led_status leds; |
363 | ::memset ( &leds, 0, sizeof( leds )); | 363 | ::memset ( &leds, 0, sizeof( leds )); |
364 | leds. which = SHARP_LED_MAIL_EXISTS; | 364 | leds. which = SHARP_LED_MAIL_EXISTS; |
365 | bool ok = true; | 365 | bool ok = true; |
366 | 366 | ||
367 | switch ( st ) { | 367 | switch ( st ) { |
368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
371 | default : ok = false; | 371 | default : ok = false; |
372 | } | 372 | } |
373 | 373 | ||
374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
375 | m_leds [0] = st; | 375 | m_leds [0] = st; |
376 | return true; | 376 | return true; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | return false; | 380 | return false; |
381 | } | 381 | } |
382 | 382 | ||
383 | bool Zaurus::setSoftSuspend ( bool soft ) | 383 | bool Zaurus::setSoftSuspend ( bool soft ) |
384 | { | 384 | { |
385 | if (!m_embedix) { | 385 | if (!m_embedix) { |
386 | /* non-Embedix kernels dont have kernel autosuspend */ | 386 | /* non-Embedix kernels dont have kernel autosuspend */ |
387 | return ODevice::setSoftSuspend( soft ); | 387 | return ODevice::setSoftSuspend( soft ); |
388 | } | 388 | } |
389 | 389 | ||
390 | bool res = false; | 390 | bool res = false; |
391 | int fd; | 391 | int fd; |
392 | 392 | ||
393 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 393 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
394 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 394 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
395 | 395 | ||
396 | int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 396 | int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
397 | 397 | ||
398 | if ( sources >= 0 ) { | 398 | if ( sources >= 0 ) { |
399 | if ( soft ) | 399 | if ( soft ) |
400 | sources &= ~APM_EVT_POWER_BUTTON; | 400 | sources &= ~APM_EVT_POWER_BUTTON; |
401 | else | 401 | else |
402 | sources |= APM_EVT_POWER_BUTTON; | 402 | sources |= APM_EVT_POWER_BUTTON; |
403 | 403 | ||
404 | if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 404 | if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
405 | res = true; | 405 | res = true; |
406 | else | 406 | else |
407 | perror ( "APM_IOCGEVTSRC" ); | 407 | perror ( "APM_IOCGEVTSRC" ); |
408 | } | 408 | } |
409 | else | 409 | else |
410 | perror ( "APM_IOCGEVTSRC" ); | 410 | perror ( "APM_IOCGEVTSRC" ); |
411 | 411 | ||
412 | ::close( fd ); | 412 | ::close( fd ); |
413 | } | 413 | } |
414 | else | 414 | else |
415 | perror( "/dev/apm_bios or /dev/misc/apm_bios" ); | 415 | perror( "/dev/apm_bios or /dev/misc/apm_bios" ); |
416 | 416 | ||
417 | return res; | 417 | return res; |
418 | } | 418 | } |
419 | 419 | ||
420 | int Zaurus::displayBrightnessResolution() const | 420 | int Zaurus::displayBrightnessResolution() const |
421 | { | 421 | { |
422 | int res = 1; | 422 | int res = 1; |
423 | if (m_embedix) | 423 | if (m_embedix) |
424 | { | 424 | { |
425 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 425 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
426 | if ( fd ) | 426 | if ( fd ) |
427 | { | 427 | { |
428 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 428 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
429 | ::close( fd ); | 429 | ::close( fd ); |
430 | return value ? value : res; | 430 | return value ? value : res; |
431 | } | 431 | } |
432 | } | 432 | } |
433 | else | 433 | else |
434 | { | 434 | { |
435 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); | 435 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); |
436 | if ( fd ) | 436 | if ( fd ) |
437 | { | 437 | { |
438 | char buf[100]; | 438 | char buf[100]; |
439 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 439 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
440 | ::close( fd ); | 440 | ::close( fd ); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | return res; | 443 | return res; |
444 | } | 444 | } |
445 | 445 | ||
446 | bool Zaurus::setDisplayBrightness( int bright ) | 446 | bool Zaurus::setDisplayBrightness( int bright ) |
447 | { | 447 | { |
448 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 448 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
449 | bool res = false; | 449 | bool res = false; |
450 | 450 | ||
451 | if ( bright > 255 ) bright = 255; | 451 | if ( bright > 255 ) bright = 255; |
452 | if ( bright < 0 ) bright = 0; | 452 | if ( bright < 0 ) bright = 0; |
453 | 453 | ||
454 | int numberOfSteps = displayBrightnessResolution(); | 454 | int numberOfSteps = displayBrightnessResolution(); |
455 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 455 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
456 | 456 | ||
457 | if ( m_embedix ) | 457 | if ( m_embedix ) |
458 | { | 458 | { |
459 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 459 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
460 | if ( fd ) | 460 | if ( fd ) |
461 | { | 461 | { |
462 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 462 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
463 | ::close( fd ); | 463 | ::close( fd ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | else | 466 | else |
467 | { | 467 | { |
468 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); | 468 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); |
469 | if ( fd ) | 469 | if ( fd ) |
470 | { | 470 | { |
471 | char buf[100]; | 471 | char buf[100]; |
472 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 472 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
473 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 473 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
474 | ::close( fd ); | 474 | ::close( fd ); |
475 | } | 475 | } |
476 | } | 476 | } |
477 | return res; | 477 | return res; |
478 | } | 478 | } |
479 | 479 | ||
480 | bool Zaurus::setDisplayStatus( bool on ) | 480 | bool Zaurus::setDisplayStatus( bool on ) |
481 | { | 481 | { |
482 | bool res = false; | 482 | bool res = false; |
483 | if ( m_embedix ) | 483 | if ( m_embedix ) |
484 | { | 484 | { |
485 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 485 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
486 | if ( fd ) | 486 | if ( fd ) |
487 | { | 487 | { |
488 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 488 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
489 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 489 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
490 | ::close ( fd ); | 490 | ::close ( fd ); |
491 | } | 491 | } |
492 | } | 492 | } |
493 | else | 493 | else |
494 | { | 494 | { |
495 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 495 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
496 | if ( fd ) | 496 | if ( fd ) |
497 | { | 497 | { |
498 | char buf[10]; | 498 | char buf[10]; |
499 | buf[0] = on ? '1' : '0'; | 499 | buf[0] = on ? '1' : '0'; |
500 | buf[1] = '\0'; | 500 | buf[1] = '\0'; |
501 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 501 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
502 | ::close( fd ); | 502 | ::close( fd ); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | return res; | 505 | return res; |
506 | } | 506 | } |
507 | 507 | ||
508 | bool Zaurus::suspend() | 508 | bool Zaurus::suspend() |
509 | { | 509 | { |
510 | qDebug("ODevice::suspend"); | 510 | qDebug("ODevice::suspend"); |
511 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 511 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
512 | return false; | 512 | return false; |
513 | 513 | ||
514 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 514 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
515 | return false; | 515 | return false; |
516 | 516 | ||
517 | bool res = false; | 517 | bool res = false; |
518 | ODevice::sendSuspendmsg(); | 518 | ODevice::sendSuspendmsg(); |
519 | 519 | ||
520 | struct timeval tvs, tvn; | 520 | struct timeval tvs, tvn; |
521 | ::gettimeofday ( &tvs, 0 ); | 521 | ::gettimeofday ( &tvs, 0 ); |
522 | 522 | ||
523 | ::sync(); // flush fs caches | 523 | ::sync(); // flush fs caches |
524 | res = ( ::system ( "apm --suspend" ) == 0 ); | 524 | res = ( ::system ( "apm --suspend" ) == 0 ); |
525 | 525 | ||
526 | // This is needed because the apm implementation is asynchronous and we | 526 | // This is needed because the apm implementation is asynchronous and we |
527 | // can not be sure when exactly the device is really suspended | 527 | // can not be sure when exactly the device is really suspended |
528 | if ( res ) { | 528 | if ( res ) { |
529 | do { // Yes, wait 15 seconds. This APM sucks big time. | 529 | do { // Yes, wait 15 seconds. This APM sucks big time. |
530 | ::usleep ( 200 * 1000 ); | 530 | ::usleep ( 200 * 1000 ); |
531 | ::gettimeofday ( &tvn, 0 ); | 531 | ::gettimeofday ( &tvn, 0 ); |
532 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 532 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
533 | } | 533 | } |
534 | 534 | ||
535 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 535 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
536 | return res; | 536 | return res; |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | Transformation Zaurus::rotation() const | 540 | Transformation Zaurus::rotation() const |
541 | { | 541 | { |
542 | Transformation rot; | 542 | Transformation rot; |
543 | int handle = 0; | 543 | int handle = 0; |
544 | int retval = 0; | 544 | int retval = 0; |
545 | 545 | ||
546 | switch ( d->m_model ) { | 546 | switch ( d->m_model ) { |
547 | case Model_Zaurus_SLC3000: // fallthrough | 547 | case Model_Zaurus_SLC3000: // fallthrough |
548 | case Model_Zaurus_SLC7x0: | 548 | case Model_Zaurus_SLC7x0: |
549 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 549 | OHingeStatus hs = readHingeSensor(); |
550 | if (handle == -1) { | 550 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
551 | return Rot270; | 551 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
552 | } else { | 552 | else rot = Rot270; |
553 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | ||
554 | ::close (handle); | ||
555 | |||
556 | if (retval == 2 ) | ||
557 | rot = Rot0; | ||
558 | else | ||
559 | rot = Rot270; | ||
560 | } | ||
561 | break; | 553 | break; |
562 | case Model_Zaurus_SL6000: | 554 | case Model_Zaurus_SL6000: |
563 | case Model_Zaurus_SLB600: | 555 | case Model_Zaurus_SLB600: |
564 | case Model_Zaurus_SLA300: | 556 | case Model_Zaurus_SLA300: |
565 | case Model_Zaurus_SL5500: | 557 | case Model_Zaurus_SL5500: |
566 | case Model_Zaurus_SL5000: | 558 | case Model_Zaurus_SL5000: |
567 | default: | 559 | default: |
568 | rot = d->m_rotation; | 560 | rot = d->m_rotation; |
569 | break; | 561 | break; |
570 | } | 562 | } |
571 | 563 | ||
572 | return rot; | 564 | return rot; |
573 | } | 565 | } |
574 | ODirection Zaurus::direction() const | 566 | ODirection Zaurus::direction() const |
575 | { | 567 | { |
576 | ODirection dir; | 568 | ODirection dir; |
577 | int handle = 0; | 569 | int handle = 0; |
578 | int retval = 0; | 570 | int retval = 0; |
579 | switch ( d->m_model ) { | 571 | switch ( d->m_model ) { |
580 | case Model_Zaurus_SLC3000: // fallthrough | 572 | case Model_Zaurus_SLC3000: // fallthrough |
581 | case Model_Zaurus_SLC7x0: | 573 | case Model_Zaurus_SLC7x0: |
582 | handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); | 574 | OHingeStatus hs = readHingeSensor(); |
583 | if (handle == -1) { | 575 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
584 | dir = CW; | 576 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
585 | } else { | 577 | else dir = CW; |
586 | retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); | ||
587 | ::close (handle); | ||
588 | if (retval == 2 ) | ||
589 | dir = CCW; | ||
590 | else | ||
591 | dir = CW; | ||
592 | } | ||
593 | break; | 578 | break; |
594 | case Model_Zaurus_SL6000: | 579 | case Model_Zaurus_SL6000: |
595 | case Model_Zaurus_SLA300: | 580 | case Model_Zaurus_SLA300: |
596 | case Model_Zaurus_SLB600: | 581 | case Model_Zaurus_SLB600: |
597 | case Model_Zaurus_SL5500: | 582 | case Model_Zaurus_SL5500: |
598 | case Model_Zaurus_SL5000: | 583 | case Model_Zaurus_SL5000: |
599 | default: dir = d->m_direction; | 584 | default: dir = d->m_direction; |
600 | break; | 585 | break; |
601 | } | 586 | } |
602 | return dir; | 587 | return dir; |
603 | 588 | ||
604 | } | 589 | } |
605 | 590 | ||
606 | bool Zaurus::hasHingeSensor() const | 591 | bool Zaurus::hasHingeSensor() const |
607 | { | 592 | { |
608 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; | 593 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
609 | } | 594 | } |
610 | 595 | ||
611 | OHingeStatus Zaurus::readHingeSensor() | 596 | OHingeStatus Zaurus::readHingeSensor() const |
612 | { | 597 | { |
613 | if (m_embedix) | 598 | if (m_embedix) |
614 | { | 599 | { |
615 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 600 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
616 | if (handle == -1) | 601 | if (handle == -1) |
617 | { | 602 | { |
618 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 603 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
619 | return CASE_UNKNOWN; | 604 | return CASE_UNKNOWN; |
620 | } | 605 | } |
621 | else | 606 | else |
622 | { | 607 | { |
623 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 608 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
624 | ::close (handle); | 609 | ::close (handle); |
625 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 610 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
626 | { | 611 | { |
627 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 612 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
628 | return static_cast<OHingeStatus>( retval ); | 613 | return static_cast<OHingeStatus>( retval ); |
629 | } | 614 | } |
630 | else | 615 | else |
631 | { | 616 | { |
632 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 617 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
633 | return CASE_UNKNOWN; | 618 | return CASE_UNKNOWN; |
634 | } | 619 | } |
635 | } | 620 | } |
636 | } | 621 | } |
637 | else | 622 | else |
638 | { | 623 | { |
639 | qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); | 624 | qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); |
640 | return CASE_UNKNOWN; | 625 | return CASE_UNKNOWN; |
641 | } | 626 | } |
642 | } | 627 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index ed9cf67..c763798 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -1,138 +1,138 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2003-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; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_ZAURUS | 30 | #ifndef ODEVICE_ZAURUS |
31 | #define ODEVICE_ZAURUS | 31 | #define ODEVICE_ZAURUS |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | 34 | ||
35 | #ifndef ARRAY_SIZE | 35 | #ifndef ARRAY_SIZE |
36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | // _IO and friends are only defined in kernel headers ... | 39 | // _IO and friends are only defined in kernel headers ... |
40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
45 | 45 | ||
46 | // Audio | 46 | // Audio |
47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
48 | 48 | ||
49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
51 | 51 | ||
52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
55 | 55 | ||
56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
61 | 61 | ||
62 | // LED | 62 | // LED |
63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
66 | 66 | ||
67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
70 | 70 | ||
71 | // Rotation and Power Management | 71 | // Rotation and Power Management |
72 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 72 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
73 | 73 | ||
74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
76 | #define APM_EVT_POWER_BUTTON (1 << 0) | 76 | #define APM_EVT_POWER_BUTTON (1 << 0) |
77 | 77 | ||
78 | // Brightness | 78 | // Brightness |
79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" | 79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" |
80 | #define SHARP_FL_IOCTL_ON 1 | 80 | #define SHARP_FL_IOCTL_ON 1 |
81 | #define SHARP_FL_IOCTL_OFF 2 | 81 | #define SHARP_FL_IOCTL_OFF 2 |
82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 | 82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 |
83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 | 83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 |
84 | #define SHARP_FL_IOCTL_GET_STEP 102 | 84 | #define SHARP_FL_IOCTL_GET_STEP 102 |
85 | 85 | ||
86 | namespace Opie { | 86 | namespace Opie { |
87 | namespace Core { | 87 | namespace Core { |
88 | namespace Internal { | 88 | namespace Internal { |
89 | 89 | ||
90 | class Zaurus : public ODevice | 90 | class Zaurus : public ODevice |
91 | { | 91 | { |
92 | protected: | 92 | protected: |
93 | virtual void init(const QString&); | 93 | virtual void init(const QString&); |
94 | virtual void initButtons(); | 94 | virtual void initButtons(); |
95 | 95 | ||
96 | public: | 96 | public: |
97 | virtual bool setSoftSuspend( bool soft ); | 97 | virtual bool setSoftSuspend( bool soft ); |
98 | 98 | ||
99 | virtual bool setDisplayBrightness( int b ); | 99 | virtual bool setDisplayBrightness( int b ); |
100 | virtual bool setDisplayStatus( bool on ); | 100 | virtual bool setDisplayStatus( bool on ); |
101 | virtual int displayBrightnessResolution() const; | 101 | virtual int displayBrightnessResolution() const; |
102 | 102 | ||
103 | virtual void playAlarmSound(); | 103 | virtual void playAlarmSound(); |
104 | virtual void playKeySound(); | 104 | virtual void playKeySound(); |
105 | virtual void playTouchSound(); | 105 | virtual void playTouchSound(); |
106 | 106 | ||
107 | virtual QValueList <OLed> ledList() const; | 107 | virtual QValueList <OLed> ledList() const; |
108 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 108 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
109 | virtual OLedState ledState( OLed led ) const; | 109 | virtual OLedState ledState( OLed led ) const; |
110 | virtual bool setLedState( OLed led, OLedState st ); | 110 | virtual bool setLedState( OLed led, OLedState st ); |
111 | 111 | ||
112 | virtual bool hasHingeSensor() const; | 112 | virtual bool hasHingeSensor() const; |
113 | virtual OHingeStatus readHingeSensor(); | 113 | virtual OHingeStatus readHingeSensor() const; |
114 | 114 | ||
115 | virtual bool suspend(); | 115 | virtual bool suspend(); |
116 | virtual Transformation rotation() const; | 116 | virtual Transformation rotation() const; |
117 | virtual ODirection direction() const; | 117 | virtual ODirection direction() const; |
118 | 118 | ||
119 | protected: | 119 | protected: |
120 | virtual void buzzer( int snd ); | 120 | virtual void buzzer( int snd ); |
121 | 121 | ||
122 | OLedState m_leds[1]; | 122 | OLedState m_leds[1]; |
123 | bool m_embedix; | 123 | bool m_embedix; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | struct z_button { | 126 | struct z_button { |
127 | Qt::Key code; | 127 | Qt::Key code; |
128 | char *utext; | 128 | char *utext; |
129 | char *pix; | 129 | char *pix; |
130 | char *fpressedservice; | 130 | char *fpressedservice; |
131 | char *fpressedaction; | 131 | char *fpressedaction; |
132 | char *fheldservice; | 132 | char *fheldservice; |
133 | char *fheldaction; | 133 | char *fheldaction; |
134 | }; | 134 | }; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | #endif | 138 | #endif |