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