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