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