Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index a75f566..8a7e252 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -112,96 +112,97 @@ struct z_button z_buttons_c700 [] = { | |||
112 | "devicebuttons/z_hinge2", | 112 | "devicebuttons/z_hinge2", |
113 | "QPE/Rotation", "rotateDefault()",0}, | 113 | "QPE/Rotation", "rotateDefault()",0}, |
114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
115 | "devicebuttons/z_hinge3", | 115 | "devicebuttons/z_hinge3", |
116 | "QPE/Rotation", "rotateDefault()",0}, | 116 | "QPE/Rotation", "rotateDefault()",0}, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | struct z_button z_buttons_6000 [] = { | 119 | struct z_button z_buttons_6000 [] = { |
120 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 120 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
121 | "devicebuttons/z_calendar", | 121 | "devicebuttons/z_calendar", |
122 | "datebook", "nextView()", | 122 | "datebook", "nextView()", |
123 | "today", "raise()" }, | 123 | "today", "raise()" }, |
124 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 124 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
125 | "devicebuttons/z_contact", | 125 | "devicebuttons/z_contact", |
126 | "addressbook", "raise()", | 126 | "addressbook", "raise()", |
127 | "addressbook", "beamBusinessCard()" }, | 127 | "addressbook", "beamBusinessCard()" }, |
128 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 128 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
129 | "devicebuttons/z_home", | 129 | "devicebuttons/z_home", |
130 | "QPE/Launcher", "home()", | 130 | "QPE/Launcher", "home()", |
131 | "buttonsettings", "raise()" }, | 131 | "buttonsettings", "raise()" }, |
132 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 132 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
133 | "devicebuttons/z_menu", | 133 | "devicebuttons/z_menu", |
134 | "QPE/TaskBar", "toggleMenu()", | 134 | "QPE/TaskBar", "toggleMenu()", |
135 | "QPE/TaskBar", "toggleStartMenu()" }, | 135 | "QPE/TaskBar", "toggleStartMenu()" }, |
136 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 136 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
137 | "devicebuttons/z_mail", | 137 | "devicebuttons/z_mail", |
138 | "opiemail", "raise()", | 138 | "opiemail", "raise()", |
139 | "opiemail", "newMail()" }, | 139 | "opiemail", "newMail()" }, |
140 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), | 140 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), |
141 | "devicebuttons/z_rotate", | 141 | "devicebuttons/z_rotate", |
142 | 0, | 142 | 0, |
143 | "QPE/Rotation", "rotateDefault()" }, | 143 | "QPE/Rotation", "rotateDefault()" }, |
144 | { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 144 | { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
145 | "devicebuttons/z_hinge3", | 145 | "devicebuttons/z_hinge3", |
146 | "QPE/VMemo", "toggleRecord()", | 146 | "QPE/VMemo", "toggleRecord()", |
147 | "sound", "raise()" }, | 147 | "sound", "raise()" }, |
148 | }; | 148 | }; |
149 | 149 | ||
150 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 150 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
151 | // class up into individual classes. We would need three classes | 151 | // class up into individual classes. We would need three classes |
152 | // | 152 | // |
153 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 153 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
154 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 154 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
155 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100) | 155 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100) |
156 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 156 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
157 | 157 | ||
158 | void Zaurus::init(const QString& cpu_info) | 158 | void Zaurus::init(const QString& cpu_info) |
159 | { | 159 | { |
160 | qDebug( "Zaurus::init()" ); | ||
160 | // Set the time to wait until the system is really suspended | 161 | // Set the time to wait until the system is really suspended |
161 | // the delta between apm --suspend and sleeping | 162 | // the delta between apm --suspend and sleeping |
162 | setAPMTimeOut( 15000 ); | 163 | setAPMTimeOut( 15000 ); |
163 | 164 | ||
164 | // generic distribution code already scanned /etc/issue at that point - | 165 | // generic distribution code already scanned /etc/issue at that point - |
165 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 166 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
166 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 167 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
167 | { | 168 | { |
168 | d->m_vendorstr = "Sharp"; | 169 | d->m_vendorstr = "Sharp"; |
169 | d->m_vendor = Vendor_Sharp; | 170 | d->m_vendor = Vendor_Sharp; |
170 | d->m_systemstr = "Zaurus"; | 171 | d->m_systemstr = "Zaurus"; |
171 | d->m_system = System_Zaurus; | 172 | d->m_system = System_Zaurus; |
172 | m_embedix = true; | 173 | m_embedix = true; |
173 | } | 174 | } |
174 | else | 175 | else |
175 | { | 176 | { |
176 | d->m_vendorstr = "OpenZaurus Team"; | 177 | d->m_vendorstr = "OpenZaurus Team"; |
177 | d->m_systemstr = "OpenZaurus"; | 178 | d->m_systemstr = "OpenZaurus"; |
178 | d->m_system = System_OpenZaurus; | 179 | d->m_system = System_OpenZaurus; |
179 | // sysver already gathered | 180 | // sysver already gathered |
180 | 181 | ||
181 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one | 182 | // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one |
182 | FILE *uname = popen("uname -r", "r"); | 183 | FILE *uname = popen("uname -r", "r"); |
183 | QFile f; | 184 | QFile f; |
184 | QString line; | 185 | QString line; |
185 | if ( f.open(IO_ReadOnly, uname) ) { | 186 | if ( f.open(IO_ReadOnly, uname) ) { |
186 | QTextStream ts ( &f ); | 187 | QTextStream ts ( &f ); |
187 | line = ts.readLine(); | 188 | line = ts.readLine(); |
188 | m_embedix = line.startsWith( "2.4." ); | 189 | m_embedix = line.startsWith( "2.4." ); |
189 | f.close(); | 190 | f.close(); |
190 | } | 191 | } |
191 | pclose(uname); | 192 | pclose(uname); |
192 | } | 193 | } |
193 | 194 | ||
194 | // check the Zaurus model | 195 | // check the Zaurus model |
195 | QString model; | 196 | QString model; |
196 | int loc = cpu_info.find( ":" ); | 197 | int loc = cpu_info.find( ":" ); |
197 | if ( loc != -1 ) | 198 | if ( loc != -1 ) |
198 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 199 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
199 | else | 200 | else |
200 | model = cpu_info; | 201 | model = cpu_info; |
201 | 202 | ||
202 | if ( model == "SHARP Corgi" ) { | 203 | if ( model == "SHARP Corgi" ) { |
203 | d->m_model = Model_Zaurus_SLC7x0; | 204 | d->m_model = Model_Zaurus_SLC7x0; |
204 | d->m_modelstr = "Zaurus SL-C700"; | 205 | d->m_modelstr = "Zaurus SL-C700"; |
205 | } else if ( model == "SHARP Shepherd" ) { | 206 | } else if ( model == "SHARP Shepherd" ) { |
206 | d->m_model = Model_Zaurus_SLC7x0; | 207 | d->m_model = Model_Zaurus_SLC7x0; |
207 | d->m_modelstr = "Zaurus SL-C750"; | 208 | d->m_modelstr = "Zaurus SL-C750"; |
@@ -214,147 +215,148 @@ void Zaurus::init(const QString& cpu_info) | |||
214 | } else if ( model == "SHARP Poodle" ) { | 215 | } else if ( model == "SHARP Poodle" ) { |
215 | d->m_model = Model_Zaurus_SLB600; | 216 | d->m_model = Model_Zaurus_SLB600; |
216 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 217 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
217 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 218 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
218 | d->m_model = Model_Zaurus_SL5500; | 219 | d->m_model = Model_Zaurus_SL5500; |
219 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 220 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
220 | } else if ( model == "SHARP Tosa" ) { | 221 | } else if ( model == "SHARP Tosa" ) { |
221 | d->m_model = Model_Zaurus_SL6000; | 222 | d->m_model = Model_Zaurus_SL6000; |
222 | d->m_modelstr = "Zaurus SL-6000"; | 223 | d->m_modelstr = "Zaurus SL-6000"; |
223 | } else if ( model == "SHARP Spitz" ) { | 224 | } else if ( model == "SHARP Spitz" ) { |
224 | d->m_model = Model_Zaurus_SLC3000; | 225 | d->m_model = Model_Zaurus_SLC3000; |
225 | d->m_modelstr = "Zaurus SL-C3000"; | 226 | d->m_modelstr = "Zaurus SL-C3000"; |
226 | } else if ( model == "SHARP Akita" ) { | 227 | } else if ( model == "SHARP Akita" ) { |
227 | d->m_model = Model_Zaurus_SLC1000; | 228 | d->m_model = Model_Zaurus_SLC1000; |
228 | d->m_modelstr = "Zaurus SL-C1000"; | 229 | d->m_modelstr = "Zaurus SL-C1000"; |
229 | } else if ( model == "SHARP Borzoi" ) { | 230 | } else if ( model == "SHARP Borzoi" ) { |
230 | d->m_model = Model_Zaurus_SLC3100; | 231 | d->m_model = Model_Zaurus_SLC3100; |
231 | d->m_modelstr = "Zaurus SL-C3100"; | 232 | d->m_modelstr = "Zaurus SL-C3100"; |
232 | } else { | 233 | } else { |
233 | d->m_model = Model_Zaurus_SL5500; | 234 | d->m_model = Model_Zaurus_SL5500; |
234 | d->m_modelstr = "Unknown Zaurus"; | 235 | d->m_modelstr = "Unknown Zaurus"; |
235 | } | 236 | } |
236 | 237 | ||
237 | // set path to backlight device in kernel 2.6 | 238 | // set path to backlight device in kernel 2.6 |
238 | switch ( d->m_model ) | 239 | switch ( d->m_model ) |
239 | { | 240 | { |
240 | case Model_Zaurus_SLB600: // fallthrough | 241 | case Model_Zaurus_SLB600: // fallthrough |
241 | case Model_Zaurus_SL5500: | 242 | case Model_Zaurus_SL5500: |
242 | m_backlightdev = "/sys/class/backlight/locomo-backlight/"; | 243 | m_backlightdev = "/sys/class/backlight/locomo-backlight/"; |
243 | break; | 244 | break; |
244 | case Model_Zaurus_SL6000: | 245 | case Model_Zaurus_SL6000: |
245 | m_backlightdev = "/sys/class/backlight/tosa-bl/"; | 246 | m_backlightdev = "/sys/class/backlight/tosa-bl/"; |
246 | break; | 247 | break; |
247 | default: | 248 | default: |
248 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; | 249 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
249 | } | 250 | } |
250 | 251 | ||
251 | // set initial rotation | 252 | // set initial rotation |
252 | switch( d->m_model ) | 253 | switch( d->m_model ) |
253 | { | 254 | { |
254 | case Model_Zaurus_SL6000: // fallthrough | 255 | case Model_Zaurus_SL6000: // fallthrough |
255 | case Model_Zaurus_SLA300: | 256 | case Model_Zaurus_SLA300: |
256 | d->m_rotation = Rot0; | 257 | d->m_rotation = Rot0; |
257 | break; | 258 | break; |
258 | case Model_Zaurus_SLC3100: // fallthrough | 259 | case Model_Zaurus_SLC3100: // fallthrough |
259 | case Model_Zaurus_SLC3000: // fallthrough | 260 | case Model_Zaurus_SLC3000: // fallthrough |
260 | case Model_Zaurus_SLC1000: // fallthrough | 261 | case Model_Zaurus_SLC1000: // fallthrough |
261 | case Model_Zaurus_SLC7x0: | 262 | case Model_Zaurus_SLC7x0: |
263 | initHingeSensor(); | ||
262 | d->m_rotation = rotation(); | 264 | d->m_rotation = rotation(); |
263 | d->m_direction = direction(); | 265 | d->m_direction = direction(); |
264 | break; | 266 | break; |
265 | case Model_Zaurus_SLB600: // fallthrough | 267 | case Model_Zaurus_SLB600: // fallthrough |
266 | case Model_Zaurus_SL5000: // fallthrough | 268 | case Model_Zaurus_SL5000: // fallthrough |
267 | case Model_Zaurus_SL5500: // fallthrough | 269 | case Model_Zaurus_SL5500: // fallthrough |
268 | default: | 270 | default: |
269 | d->m_rotation = Rot270; | 271 | d->m_rotation = Rot270; |
270 | } | 272 | } |
271 | 273 | ||
272 | // set default qte driver | 274 | // set default qte driver |
273 | switch( d->m_model ) | 275 | switch( d->m_model ) |
274 | { | 276 | { |
275 | case Model_Zaurus_SLC7x0: | 277 | case Model_Zaurus_SLC7x0: |
276 | d->m_qteDriver = "W100"; | 278 | d->m_qteDriver = "W100"; |
277 | break; | 279 | break; |
278 | default: | 280 | default: |
279 | d->m_qteDriver = "Transformed"; | 281 | d->m_qteDriver = "Transformed"; |
280 | } | 282 | } |
281 | 283 | ||
282 | m_leds[0] = Led_Off; | 284 | m_leds[0] = Led_Off; |
283 | 285 | ||
284 | if ( m_embedix ) | 286 | if ( m_embedix ) |
285 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | 287 | qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); |
286 | else | 288 | else |
287 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 289 | qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
288 | } | 290 | } |
289 | 291 | ||
290 | void Zaurus::initButtons() | 292 | void Zaurus::initButtons() |
291 | { | 293 | { |
294 | qDebug( "Zaurus::initButtons()" ); | ||
292 | if ( d->m_buttons ) | 295 | if ( d->m_buttons ) |
293 | return; | 296 | return; |
294 | 297 | ||
295 | d->m_buttons = new QValueList <ODeviceButton>; | 298 | d->m_buttons = new QValueList <ODeviceButton>; |
296 | 299 | ||
297 | struct z_button * pz_buttons; | 300 | struct z_button * pz_buttons; |
298 | int buttoncount; | 301 | int buttoncount; |
299 | switch ( d->m_model ) | 302 | switch ( d->m_model ) |
300 | { | 303 | { |
301 | case Model_Zaurus_SL6000: | 304 | case Model_Zaurus_SL6000: |
302 | pz_buttons = z_buttons_6000; | 305 | pz_buttons = z_buttons_6000; |
303 | buttoncount = ARRAY_SIZE(z_buttons_6000); | 306 | buttoncount = ARRAY_SIZE(z_buttons_6000); |
304 | break; | 307 | break; |
305 | case Model_Zaurus_SLC3100: // fallthrough | 308 | case Model_Zaurus_SLC3100: // fallthrough |
306 | case Model_Zaurus_SLC3000: // fallthrough | 309 | case Model_Zaurus_SLC3000: // fallthrough |
307 | case Model_Zaurus_SLC1000: // fallthrough | 310 | case Model_Zaurus_SLC1000: // fallthrough |
308 | case Model_Zaurus_SLC7x0: | 311 | case Model_Zaurus_SLC7x0: |
309 | if ( isQWS( ) ) | 312 | if ( isQWS( ) ) |
310 | { // setup hinge sensor stuff | 313 | { |
311 | addPreHandler(this); | 314 | addPreHandler(this); |
312 | initHingeSensor(); | ||
313 | } | 315 | } |
314 | pz_buttons = z_buttons_c700; | 316 | pz_buttons = z_buttons_c700; |
315 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 317 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
316 | break; | 318 | break; |
317 | default: | 319 | default: |
318 | pz_buttons = z_buttons; | 320 | pz_buttons = z_buttons; |
319 | buttoncount = ARRAY_SIZE(z_buttons); | 321 | buttoncount = ARRAY_SIZE(z_buttons); |
320 | break; | 322 | break; |
321 | } | 323 | } |
322 | 324 | ||
323 | for ( int i = 0; i < buttoncount; i++ ) { | 325 | for ( int i = 0; i < buttoncount; i++ ) { |
324 | struct z_button *zb = pz_buttons + i; | 326 | struct z_button *zb = pz_buttons + i; |
325 | ODeviceButton b; | 327 | ODeviceButton b; |
326 | 328 | ||
327 | b.setKeycode( zb->code ); | 329 | b.setKeycode( zb->code ); |
328 | b.setUserText( QObject::tr( "Button", zb->utext )); | 330 | b.setUserText( QObject::tr( "Button", zb->utext )); |
329 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 331 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
330 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 332 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
331 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 333 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
332 | d->m_buttons->append( b ); | 334 | d->m_buttons->append( b ); |
333 | } | 335 | } |
334 | 336 | ||
335 | reloadButtonMapping(); | 337 | reloadButtonMapping(); |
336 | } | 338 | } |
337 | 339 | ||
338 | 340 | ||
339 | 341 | ||
340 | typedef struct sharp_led_status { | 342 | typedef struct sharp_led_status { |
341 | int which; /* select which LED status is wanted. */ | 343 | int which; /* select which LED status is wanted. */ |
342 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 344 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
343 | } sharp_led_status; | 345 | } sharp_led_status; |
344 | 346 | ||
345 | void Zaurus::buzzer( int sound ) | 347 | void Zaurus::buzzer( int sound ) |
346 | { | 348 | { |
347 | #ifndef QT_NO_SOUND | 349 | #ifndef QT_NO_SOUND |
348 | Sound *snd = 0; | 350 | Sound *snd = 0; |
349 | 351 | ||
350 | // All devices except SL5500 have a DSP device | 352 | // All devices except SL5500 have a DSP device |
351 | if ( d->m_model != Model_Zaurus_SL5000 | 353 | if ( d->m_model != Model_Zaurus_SL5000 |
352 | && d->m_model != Model_Zaurus_SL5500 ) { | 354 | && d->m_model != Model_Zaurus_SL5500 ) { |
353 | 355 | ||
354 | switch ( sound ){ | 356 | switch ( sound ){ |
355 | case SHARP_BUZ_TOUCHSOUND: { | 357 | case SHARP_BUZ_TOUCHSOUND: { |
356 | static Sound touch_sound("touchsound"); | 358 | static Sound touch_sound("touchsound"); |
357 | snd = &touch_sound; | 359 | snd = &touch_sound; |
358 | } | 360 | } |
359 | break; | 361 | break; |
360 | case SHARP_BUZ_KEYSOUND: { | 362 | case SHARP_BUZ_KEYSOUND: { |
@@ -556,96 +558,97 @@ Transformation Zaurus::rotation() const | |||
556 | { | 558 | { |
557 | qDebug( "Zaurus::rotation()" ); | 559 | qDebug( "Zaurus::rotation()" ); |
558 | Transformation rot; | 560 | Transformation rot; |
559 | 561 | ||
560 | switch ( d->m_model ) { | 562 | switch ( d->m_model ) { |
561 | case Model_Zaurus_SLC3100: // fallthrough | 563 | case Model_Zaurus_SLC3100: // fallthrough |
562 | case Model_Zaurus_SLC3000: // fallthrough | 564 | case Model_Zaurus_SLC3000: // fallthrough |
563 | case Model_Zaurus_SLC1000: | 565 | case Model_Zaurus_SLC1000: |
564 | { | 566 | { |
565 | OHingeStatus hs = readHingeSensor(); | 567 | OHingeStatus hs = readHingeSensor(); |
566 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 568 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
567 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 569 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
568 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 570 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
569 | else rot = Rot270; | 571 | else rot = Rot270; |
570 | } | 572 | } |
571 | break; | 573 | break; |
572 | 574 | ||
573 | // SLC7x0 needs a special case here, because we were able to set the W100 | 575 | // SLC7x0 needs a special case here, because we were able to set the W100 |
574 | // hardware default rotation on kernel 2.6 to Rot0 | 576 | // hardware default rotation on kernel 2.6 to Rot0 |
575 | case Model_Zaurus_SLC7x0: | 577 | case Model_Zaurus_SLC7x0: |
576 | { | 578 | { |
577 | OHingeStatus hs = readHingeSensor(); | 579 | OHingeStatus hs = readHingeSensor(); |
578 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 580 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
579 | 581 | ||
580 | if ( m_embedix ) | 582 | if ( m_embedix ) |
581 | { | 583 | { |
582 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 584 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
583 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 585 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
584 | else rot = Rot270; | 586 | else rot = Rot270; |
585 | } | 587 | } |
586 | else | 588 | else |
587 | { | 589 | { |
588 | if ( hs == CASE_PORTRAIT ) rot = Rot90; | 590 | if ( hs == CASE_PORTRAIT ) rot = Rot90; |
589 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 591 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
590 | else rot = Rot0; | 592 | else rot = Rot0; |
591 | } | 593 | } |
592 | } | 594 | } |
593 | break; | 595 | break; |
594 | case Model_Zaurus_SL6000: | 596 | case Model_Zaurus_SL6000: |
595 | case Model_Zaurus_SLB600: | 597 | case Model_Zaurus_SLB600: |
596 | case Model_Zaurus_SLA300: | 598 | case Model_Zaurus_SLA300: |
597 | case Model_Zaurus_SL5500: | 599 | case Model_Zaurus_SL5500: |
598 | case Model_Zaurus_SL5000: | 600 | case Model_Zaurus_SL5000: |
599 | default: | 601 | default: |
600 | rot = d->m_rotation; | 602 | rot = d->m_rotation; |
601 | break; | 603 | break; |
602 | } | 604 | } |
603 | 605 | ||
606 | qDebug( "Zaurus::rotation() - returning '%d'", rot ); | ||
604 | return rot; | 607 | return rot; |
605 | } | 608 | } |
606 | ODirection Zaurus::direction() const | 609 | ODirection Zaurus::direction() const |
607 | { | 610 | { |
608 | ODirection dir; | 611 | ODirection dir; |
609 | 612 | ||
610 | switch ( d->m_model ) { | 613 | switch ( d->m_model ) { |
611 | case Model_Zaurus_SLC3100: // fallthrough | 614 | case Model_Zaurus_SLC3100: // fallthrough |
612 | case Model_Zaurus_SLC3000: // fallthrough | 615 | case Model_Zaurus_SLC3000: // fallthrough |
613 | case Model_Zaurus_SLC1000: // fallthrough | 616 | case Model_Zaurus_SLC1000: // fallthrough |
614 | case Model_Zaurus_SLC7x0: { | 617 | case Model_Zaurus_SLC7x0: { |
615 | OHingeStatus hs = readHingeSensor(); | 618 | OHingeStatus hs = readHingeSensor(); |
616 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 619 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
617 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 620 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
618 | else dir = CW; | 621 | else dir = CW; |
619 | } | 622 | } |
620 | break; | 623 | break; |
621 | case Model_Zaurus_SL6000: | 624 | case Model_Zaurus_SL6000: |
622 | case Model_Zaurus_SLA300: | 625 | case Model_Zaurus_SLA300: |
623 | case Model_Zaurus_SLB600: | 626 | case Model_Zaurus_SLB600: |
624 | case Model_Zaurus_SL5500: | 627 | case Model_Zaurus_SL5500: |
625 | case Model_Zaurus_SL5000: | 628 | case Model_Zaurus_SL5000: |
626 | default: dir = d->m_direction; | 629 | default: dir = d->m_direction; |
627 | break; | 630 | break; |
628 | } | 631 | } |
629 | return dir; | 632 | return dir; |
630 | 633 | ||
631 | } | 634 | } |
632 | 635 | ||
633 | bool Zaurus::hasHingeSensor() const | 636 | bool Zaurus::hasHingeSensor() const |
634 | { | 637 | { |
635 | return d->m_model == Model_Zaurus_SLC7x0 || | 638 | return d->m_model == Model_Zaurus_SLC7x0 || |
636 | d->m_model == Model_Zaurus_SLC3100 || | 639 | d->m_model == Model_Zaurus_SLC3100 || |
637 | d->m_model == Model_Zaurus_SLC3000 || | 640 | d->m_model == Model_Zaurus_SLC3000 || |
638 | d->m_model == Model_Zaurus_SLC1000; | 641 | d->m_model == Model_Zaurus_SLC1000; |
639 | } | 642 | } |
640 | 643 | ||
641 | OHingeStatus Zaurus::readHingeSensor() const | 644 | OHingeStatus Zaurus::readHingeSensor() const |
642 | { | 645 | { |
643 | if (m_embedix) | 646 | if (m_embedix) |
644 | { | 647 | { |
645 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 648 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
646 | if (handle == -1) | 649 | if (handle == -1) |
647 | { | 650 | { |
648 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 651 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
649 | return CASE_UNKNOWN; | 652 | return CASE_UNKNOWN; |
650 | } | 653 | } |
651 | else | 654 | else |
@@ -660,120 +663,129 @@ OHingeStatus Zaurus::readHingeSensor() const | |||
660 | else | 663 | else |
661 | { | 664 | { |
662 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 665 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
663 | return CASE_UNKNOWN; | 666 | return CASE_UNKNOWN; |
664 | } | 667 | } |
665 | } | 668 | } |
666 | } | 669 | } |
667 | else | 670 | else |
668 | { | 671 | { |
669 | /* | 672 | /* |
670 | * The corgi keyboard is event source 0 in OZ kernel 2.6. | 673 | * The corgi keyboard is event source 0 in OZ kernel 2.6. |
671 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 674 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
672 | * | 675 | * |
673 | * ------------------------- | 676 | * ------------------------- |
674 | * | SW0 | SW1 | CASE | | 677 | * | SW0 | SW1 | CASE | |
675 | * |-----|-----|-----------| | 678 | * |-----|-----|-----------| |
676 | * | 0 0 Landscape | | 679 | * | 0 0 Landscape | |
677 | * | 0 1 Portrait | | 680 | * | 0 1 Portrait | |
678 | * | 1 0 Unknown | | 681 | * | 1 0 Unknown | |
679 | * | 1 1 Closed | | 682 | * | 1 1 Closed | |
680 | * ------------------------- | 683 | * ------------------------- |
681 | */ | 684 | */ |
682 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 685 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
683 | bool switch0 = true; | 686 | bool switch0 = true; |
684 | bool switch1 = false; | 687 | bool switch1 = false; |
685 | if ( keyboard ) | 688 | if ( keyboard ) |
686 | { | 689 | { |
687 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); | 690 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
688 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | 691 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); |
689 | } | 692 | } |
690 | if ( switch0 ) | 693 | if ( switch0 ) |
691 | { | 694 | { |
692 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 695 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
693 | } | 696 | } |
694 | else | 697 | else |
695 | { | 698 | { |
696 | return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE; | 699 | return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE; |
697 | } | 700 | } |
698 | } | 701 | } |
699 | } | 702 | } |
700 | 703 | ||
701 | void Zaurus::initHingeSensor() | 704 | void Zaurus::initHingeSensor() |
702 | { | 705 | { |
703 | if ( m_embedix ) return; | 706 | if ( m_embedix ) return; |
704 | 707 | ||
705 | m_hinge.setName( "/dev/input/event0" ); | 708 | m_hinge.setName( "/dev/input/event0" ); |
706 | if ( !m_hinge.open( IO_ReadOnly ) ) | 709 | if ( !m_hinge.open( IO_ReadOnly ) ) |
707 | { | 710 | { |
708 | qDebug( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) ); | 711 | qWarning( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) ); |
709 | return; | 712 | return; |
710 | } | 713 | } |
711 | 714 | ||
712 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); | 715 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); |
713 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); | 716 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); |
717 | |||
718 | qDebug( "Zaurus::init() - Hinge Sensor Initialization successfully completed" ); | ||
714 | } | 719 | } |
715 | 720 | ||
716 | void Zaurus::hingeSensorTriggered() | 721 | void Zaurus::hingeSensorTriggered() |
717 | { | 722 | { |
718 | qDebug( "Zaurus::hingeSensorTriggered() - got event" ); | 723 | qDebug( "Zaurus::hingeSensorTriggered() - got event" ); |
719 | struct input_event e; | 724 | struct input_event e; |
720 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) | 725 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) |
721 | { | 726 | { |
722 | qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); | 727 | qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); |
723 | if ( e.type != EV_SW ) return; | 728 | if ( e.type != EV_SW ) return; |
724 | if ( readHingeSensor() != CASE_UNKNOWN ) | 729 | if ( readHingeSensor() != CASE_UNKNOWN ) |
725 | { | 730 | { |
726 | qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); | 731 | qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); |
727 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); | 732 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); |
728 | } | 733 | } |
729 | } | 734 | } |
730 | } | 735 | } |
731 | 736 | ||
737 | void Zaurus::systemMessage( const QCString &msg, const QByteArray & ) | ||
738 | { | ||
739 | if ( msg == "deviceButtonMappingChanged()" ) { | ||
740 | reloadButtonMapping(); | ||
741 | } | ||
742 | } | ||
743 | |||
732 | /* | 744 | /* |
733 | * Take code from iPAQ device. | 745 | * Take code from iPAQ device. |
734 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | 746 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. |
735 | * I hope that is ok - Alwin | 747 | * I hope that is ok - Alwin |
736 | */ | 748 | */ |
737 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 749 | bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
738 | { | 750 | { |
739 | int newkeycode = keycode; | 751 | int newkeycode = keycode; |
740 | 752 | ||
741 | if ( !hasHingeSensor() ) return false; | 753 | if ( !hasHingeSensor() ) return false; |
742 | 754 | ||
743 | /* map cursor keys depending on the hinge status */ | 755 | /* map cursor keys depending on the hinge status */ |
744 | switch ( keycode ) { | 756 | switch ( keycode ) { |
745 | // Rotate cursor keys | 757 | // Rotate cursor keys |
746 | case Key_Left : | 758 | case Key_Left : |
747 | case Key_Right: | 759 | case Key_Right: |
748 | case Key_Up : | 760 | case Key_Up : |
749 | case Key_Down : | 761 | case Key_Down : |
750 | { | 762 | { |
751 | if (rotation()==Rot90) { | 763 | if (rotation()==Rot90) { |
752 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 764 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
753 | } | 765 | } |
754 | } | 766 | } |
755 | break; | 767 | break; |
756 | 768 | ||
757 | } | 769 | } |
758 | if (newkeycode!=keycode) { | 770 | if (newkeycode!=keycode) { |
759 | if ( newkeycode != Key_unknown ) { | 771 | if ( newkeycode != Key_unknown ) { |
760 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 772 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
761 | } | 773 | } |
762 | return true; | 774 | return true; |
763 | } | 775 | } |
764 | return false; | 776 | return false; |
765 | } | 777 | } |
766 | 778 | ||
767 | bool Zaurus::suspend() { | 779 | bool Zaurus::suspend() { |
768 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 780 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
769 | return false; | 781 | return false; |
770 | 782 | ||
771 | bool res = false; | 783 | bool res = false; |
772 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 784 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
773 | 785 | ||
774 | struct timeval tvs, tvn; | 786 | struct timeval tvs, tvn; |
775 | ::gettimeofday ( &tvs, 0 ); | 787 | ::gettimeofday ( &tvs, 0 ); |
776 | 788 | ||
777 | ::sync(); // flush fs caches | 789 | ::sync(); // flush fs caches |
778 | res = ( ::system ( "apm --suspend" ) == 0 ); | 790 | res = ( ::system ( "apm --suspend" ) == 0 ); |
779 | 791 | ||