-rw-r--r-- | libopie/odevice.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 160568b..f808960 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -175,786 +175,790 @@ public: | |||
175 | virtual bool setDisplayContrast ( int b ); | 175 | virtual bool setDisplayContrast ( int b ); |
176 | virtual int displayContrastResolution ( ) const; | 176 | virtual int displayContrastResolution ( ) const; |
177 | 177 | ||
178 | protected: | 178 | protected: |
179 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 179 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
180 | virtual void timerEvent ( QTimerEvent *te ); | 180 | virtual void timerEvent ( QTimerEvent *te ); |
181 | 181 | ||
182 | int m_power_timer; | 182 | int m_power_timer; |
183 | }; | 183 | }; |
184 | 184 | ||
185 | struct i_button { | 185 | struct i_button { |
186 | uint model; | 186 | uint model; |
187 | Qt::Key code; | 187 | Qt::Key code; |
188 | char *utext; | 188 | char *utext; |
189 | char *pix; | 189 | char *pix; |
190 | char *fpressedservice; | 190 | char *fpressedservice; |
191 | char *fpressedaction; | 191 | char *fpressedaction; |
192 | char *fheldservice; | 192 | char *fheldservice; |
193 | char *fheldaction; | 193 | char *fheldaction; |
194 | } ipaq_buttons [] = { | 194 | } ipaq_buttons [] = { |
195 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 195 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
196 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 196 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
197 | "devicebuttons/ipaq_calendar", | 197 | "devicebuttons/ipaq_calendar", |
198 | "datebook", "nextView()", | 198 | "datebook", "nextView()", |
199 | "today", "raise()" }, | 199 | "today", "raise()" }, |
200 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 200 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
201 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 201 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
202 | "devicebuttons/ipaq_contact", | 202 | "devicebuttons/ipaq_contact", |
203 | "addressbook", "raise()", | 203 | "addressbook", "raise()", |
204 | "addressbook", "beamBusinessCard()" }, | 204 | "addressbook", "beamBusinessCard()" }, |
205 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 205 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
206 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 206 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
207 | "devicebuttons/ipaq_menu", | 207 | "devicebuttons/ipaq_menu", |
208 | "QPE/TaskBar", "toggleMenu()", | 208 | "QPE/TaskBar", "toggleMenu()", |
209 | "QPE/TaskBar", "toggleStartMenu()" }, | 209 | "QPE/TaskBar", "toggleStartMenu()" }, |
210 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 210 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
211 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 211 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
212 | "devicebuttons/ipaq_mail", | 212 | "devicebuttons/ipaq_mail", |
213 | "mail", "raise()", | 213 | "mail", "raise()", |
214 | "mail", "newMail()" }, | 214 | "mail", "newMail()" }, |
215 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 215 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
216 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 216 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
217 | "devicebuttons/ipaq_home", | 217 | "devicebuttons/ipaq_home", |
218 | "QPE/Launcher", "home()", | 218 | "QPE/Launcher", "home()", |
219 | "buttonsettings", "raise()" }, | 219 | "buttonsettings", "raise()" }, |
220 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 220 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
221 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 221 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
222 | "devicebuttons/ipaq_record", | 222 | "devicebuttons/ipaq_record", |
223 | "QPE/VMemo", "toggleRecord()", | 223 | "QPE/VMemo", "toggleRecord()", |
224 | "sound", "raise()" }, | 224 | "sound", "raise()" }, |
225 | }; | 225 | }; |
226 | 226 | ||
227 | struct z_button { | 227 | struct z_button { |
228 | Qt::Key code; | 228 | Qt::Key code; |
229 | char *utext; | 229 | char *utext; |
230 | char *pix; | 230 | char *pix; |
231 | char *fpressedservice; | 231 | char *fpressedservice; |
232 | char *fpressedaction; | 232 | char *fpressedaction; |
233 | char *fheldservice; | 233 | char *fheldservice; |
234 | char *fheldaction; | 234 | char *fheldaction; |
235 | } z_buttons [] = { | 235 | } z_buttons [] = { |
236 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 236 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
237 | "devicebuttons/z_calendar", | 237 | "devicebuttons/z_calendar", |
238 | "datebook", "nextView()", | 238 | "datebook", "nextView()", |
239 | "today", "raise()" }, | 239 | "today", "raise()" }, |
240 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 240 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
241 | "devicebuttons/z_contact", | 241 | "devicebuttons/z_contact", |
242 | "addressbook", "raise()", | 242 | "addressbook", "raise()", |
243 | "addressbook", "beamBusinessCard()" }, | 243 | "addressbook", "beamBusinessCard()" }, |
244 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 244 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
245 | "devicebuttons/z_home", | 245 | "devicebuttons/z_home", |
246 | "QPE/Launcher", "home()", | 246 | "QPE/Launcher", "home()", |
247 | "buttonsettings", "raise()" }, | 247 | "buttonsettings", "raise()" }, |
248 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 248 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
249 | "devicebuttons/z_menu", | 249 | "devicebuttons/z_menu", |
250 | "QPE/TaskBar", "toggleMenu()", | 250 | "QPE/TaskBar", "toggleMenu()", |
251 | "QPE/TaskBar", "toggleStartMenu()" }, | 251 | "QPE/TaskBar", "toggleStartMenu()" }, |
252 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 252 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
253 | "devicebuttons/z_mail", | 253 | "devicebuttons/z_mail", |
254 | "mail", "raise()", | 254 | "mail", "raise()", |
255 | "mail", "newMail()" }, | 255 | "mail", "newMail()" }, |
256 | }; | 256 | }; |
257 | 257 | ||
258 | struct z_button z_buttons_c700 [] = { | 258 | struct z_button z_buttons_c700 [] = { |
259 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 259 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
260 | "devicebuttons/z_calendar", | 260 | "devicebuttons/z_calendar", |
261 | "datebook", "nextView()", | 261 | "datebook", "nextView()", |
262 | "today", "raise()" }, | 262 | "today", "raise()" }, |
263 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 263 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
264 | "devicebuttons/z_contact", | 264 | "devicebuttons/z_contact", |
265 | "addressbook", "raise()", | 265 | "addressbook", "raise()", |
266 | "addressbook", "beamBusinessCard()" }, | 266 | "addressbook", "beamBusinessCard()" }, |
267 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 267 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
268 | "devicebuttons/z_home", | 268 | "devicebuttons/z_home", |
269 | "QPE/Launcher", "home()", | 269 | "QPE/Launcher", "home()", |
270 | "buttonsettings", "raise()" }, | 270 | "buttonsettings", "raise()" }, |
271 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 271 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
272 | "devicebuttons/z_menu", | 272 | "devicebuttons/z_menu", |
273 | "QPE/TaskBar", "toggleMenu()", | 273 | "QPE/TaskBar", "toggleMenu()", |
274 | "QPE/TaskBar", "toggleStartMenu()" }, | 274 | "QPE/TaskBar", "toggleStartMenu()" }, |
275 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 275 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
276 | "", | 276 | "", |
277 | "QPE/Rotation", "flip()", | 277 | "QPE/Rotation", "flip()", |
278 | "QPE/Rotation", "flip()" }, | 278 | "QPE/Rotation", "flip()" }, |
279 | }; | 279 | }; |
280 | 280 | ||
281 | struct s_button { | 281 | struct s_button { |
282 | uint model; | 282 | uint model; |
283 | Qt::Key code; | 283 | Qt::Key code; |
284 | char *utext; | 284 | char *utext; |
285 | char *pix; | 285 | char *pix; |
286 | char *fpressedservice; | 286 | char *fpressedservice; |
287 | char *fpressedaction; | 287 | char *fpressedaction; |
288 | char *fheldservice; | 288 | char *fheldservice; |
289 | char *fheldaction; | 289 | char *fheldaction; |
290 | } simpad_buttons [] = { | 290 | } simpad_buttons [] = { |
291 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 291 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
292 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 292 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
293 | "devicebuttons/simpad_lower_up", | 293 | "devicebuttons/simpad_lower_up", |
294 | "datebook", "nextView()", | 294 | "datebook", "nextView()", |
295 | "today", "raise()" }, | 295 | "today", "raise()" }, |
296 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 296 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
297 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 297 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
298 | "devicebuttons/simpad_lower_down", | 298 | "devicebuttons/simpad_lower_down", |
299 | "addressbook", "raise()", | 299 | "addressbook", "raise()", |
300 | "addressbook", "beamBusinessCard()" }, | 300 | "addressbook", "beamBusinessCard()" }, |
301 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 301 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
302 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 302 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
303 | "devicebuttons/simpad_lower_right", | 303 | "devicebuttons/simpad_lower_right", |
304 | "QPE/TaskBar", "toggleMenu()", | 304 | "QPE/TaskBar", "toggleMenu()", |
305 | "QPE/TaskBar", "toggleStartMenu()" }, | 305 | "QPE/TaskBar", "toggleStartMenu()" }, |
306 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 306 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
307 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 307 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
308 | "devicebuttons/simpad_lower_left", | 308 | "devicebuttons/simpad_lower_left", |
309 | "mail", "raise()", | 309 | "mail", "raise()", |
310 | "mail", "newMail()" }, | 310 | "mail", "newMail()" }, |
311 | 311 | ||
312 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 312 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
313 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 313 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
314 | "devicebuttons/simpad_upper_up", | 314 | "devicebuttons/simpad_upper_up", |
315 | "QPE/Launcher", "home()", | 315 | "QPE/Launcher", "home()", |
316 | "buttonsettings", "raise()" }, | 316 | "buttonsettings", "raise()" }, |
317 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 317 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
318 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 318 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
319 | "devicebuttons/simpad_upper_down", | 319 | "devicebuttons/simpad_upper_down", |
320 | "addressbook", "raise()", | 320 | "addressbook", "raise()", |
321 | "addressbook", "beamBusinessCard()" }, | 321 | "addressbook", "beamBusinessCard()" }, |
322 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 322 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
323 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 323 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
324 | "devicebuttons/simpad_upper_right", | 324 | "devicebuttons/simpad_upper_right", |
325 | "QPE/TaskBar", "toggleMenu()", | 325 | "QPE/TaskBar", "toggleMenu()", |
326 | "QPE/TaskBar", "toggleStartMenu()" }, | 326 | "QPE/TaskBar", "toggleStartMenu()" }, |
327 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 327 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
328 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 328 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
329 | "devicebuttons/simpad_upper_left", | 329 | "devicebuttons/simpad_upper_left", |
330 | "QPE/Rotation", "flip()", | 330 | "QPE/Rotation", "flip()", |
331 | "QPE/Rotation", "flip()" }, | 331 | "QPE/Rotation", "flip()" }, |
332 | /* | 332 | /* |
333 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 333 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
334 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 334 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
335 | "devicebuttons/simpad_lower_upper", | 335 | "devicebuttons/simpad_lower_upper", |
336 | "QPE/Launcher", "home()", | 336 | "QPE/Launcher", "home()", |
337 | "buttonsettings", "raise()" }, | 337 | "buttonsettings", "raise()" }, |
338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
339 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 339 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
340 | "devicebuttons/simpad_upper_lower", | 340 | "devicebuttons/simpad_upper_lower", |
341 | "QPE/Launcher", "home()", | 341 | "QPE/Launcher", "home()", |
342 | "buttonsettings", "raise()" }, | 342 | "buttonsettings", "raise()" }, |
343 | */ | 343 | */ |
344 | }; | 344 | }; |
345 | 345 | ||
346 | struct r_button { | 346 | struct r_button { |
347 | uint model; | 347 | uint model; |
348 | Qt::Key code; | 348 | Qt::Key code; |
349 | char *utext; | 349 | char *utext; |
350 | char *pix; | 350 | char *pix; |
351 | char *fpressedservice; | 351 | char *fpressedservice; |
352 | char *fpressedaction; | 352 | char *fpressedaction; |
353 | char *fheldservice; | 353 | char *fheldservice; |
354 | char *fheldaction; | 354 | char *fheldaction; |
355 | } ramses_buttons [] = { | 355 | } ramses_buttons [] = { |
356 | { Model_Ramses_MNCI, | 356 | { Model_Ramses_MNCI, |
357 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 357 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
358 | "devicebuttons/z_menu", | 358 | "devicebuttons/z_menu", |
359 | "QPE/TaskBar", "toggleMenu()", | 359 | "QPE/TaskBar", "toggleMenu()", |
360 | "QPE/TaskBar", "toggleStartMenu()" }, | 360 | "QPE/TaskBar", "toggleStartMenu()" }, |
361 | { Model_Ramses_MNCI, | 361 | { Model_Ramses_MNCI, |
362 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 362 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
363 | "devicebuttons/ipaq_home", | 363 | "devicebuttons/ipaq_home", |
364 | "QPE/Launcher", "home()", | 364 | "QPE/Launcher", "home()", |
365 | "buttonsettings", "raise()" }, | 365 | "buttonsettings", "raise()" }, |
366 | }; | 366 | }; |
367 | 367 | ||
368 | static QCString makeChannel ( const char *str ) | 368 | static QCString makeChannel ( const char *str ) |
369 | { | 369 | { |
370 | if ( str && !::strchr ( str, '/' )) | 370 | if ( str && !::strchr ( str, '/' )) |
371 | return QCString ( "QPE/Application/" ) + str; | 371 | return QCString ( "QPE/Application/" ) + str; |
372 | else | 372 | else |
373 | return str; | 373 | return str; |
374 | } | 374 | } |
375 | 375 | ||
376 | static inline bool isQWS() | 376 | static inline bool isQWS() |
377 | { | 377 | { |
378 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 378 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
379 | } | 379 | } |
380 | 380 | ||
381 | ODevice *ODevice::inst ( ) | 381 | ODevice *ODevice::inst ( ) |
382 | { | 382 | { |
383 | static ODevice *dev = 0; | 383 | static ODevice *dev = 0; |
384 | 384 | ||
385 | if ( !dev ) { | 385 | if ( !dev ) { |
386 | if ( QFile::exists ( "/proc/hal/model" )) | 386 | if ( QFile::exists ( "/proc/hal/model" )) |
387 | dev = new iPAQ ( ); | 387 | dev = new iPAQ ( ); |
388 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 388 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
389 | dev = new Zaurus ( ); | 389 | dev = new Zaurus ( ); |
390 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 390 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
391 | dev = new SIMpad ( ); | 391 | dev = new SIMpad ( ); |
392 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 392 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
393 | dev = new Ramses ( ); | 393 | dev = new Ramses ( ); |
394 | else | 394 | else |
395 | dev = new ODevice ( ); | 395 | dev = new ODevice ( ); |
396 | 396 | ||
397 | dev-> init ( ); | 397 | dev-> init ( ); |
398 | } | 398 | } |
399 | return dev; | 399 | return dev; |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | /************************************************** | 403 | /************************************************** |
404 | * | 404 | * |
405 | * common | 405 | * common |
406 | * | 406 | * |
407 | **************************************************/ | 407 | **************************************************/ |
408 | 408 | ||
409 | 409 | ||
410 | ODevice::ODevice ( ) | 410 | ODevice::ODevice ( ) |
411 | { | 411 | { |
412 | d = new ODeviceData; | 412 | d = new ODeviceData; |
413 | 413 | ||
414 | d-> m_modelstr = "Unknown"; | 414 | d-> m_modelstr = "Unknown"; |
415 | d-> m_model = Model_Unknown; | 415 | d-> m_model = Model_Unknown; |
416 | d-> m_vendorstr = "Unknown"; | 416 | d-> m_vendorstr = "Unknown"; |
417 | d-> m_vendor = Vendor_Unknown; | 417 | d-> m_vendor = Vendor_Unknown; |
418 | d-> m_systemstr = "Unknown"; | 418 | d-> m_systemstr = "Unknown"; |
419 | d-> m_system = System_Unknown; | 419 | d-> m_system = System_Unknown; |
420 | d-> m_sysverstr = "0.0"; | 420 | d-> m_sysverstr = "0.0"; |
421 | d-> m_rotation = Rot0; | 421 | d-> m_rotation = Rot0; |
422 | d-> m_direction = CW; | 422 | d-> m_direction = CW; |
423 | 423 | ||
424 | d-> m_holdtime = 1000; // 1000ms | 424 | d-> m_holdtime = 1000; // 1000ms |
425 | d-> m_buttons = 0; | 425 | d-> m_buttons = 0; |
426 | } | 426 | } |
427 | 427 | ||
428 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 428 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
429 | { | 429 | { |
430 | if ( msg == "deviceButtonMappingChanged()" ) { | 430 | if ( msg == "deviceButtonMappingChanged()" ) { |
431 | reloadButtonMapping ( ); | 431 | reloadButtonMapping ( ); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | void ODevice::init ( ) | 435 | void ODevice::init ( ) |
436 | { | 436 | { |
437 | } | 437 | } |
438 | 438 | ||
439 | /** | 439 | /** |
440 | * This method initialises the button mapping | 440 | * This method initialises the button mapping |
441 | */ | 441 | */ |
442 | void ODevice::initButtons ( ) | 442 | void ODevice::initButtons ( ) |
443 | { | 443 | { |
444 | if ( d-> m_buttons ) | 444 | if ( d-> m_buttons ) |
445 | return; | 445 | return; |
446 | 446 | ||
447 | // Simulation uses iPAQ 3660 device buttons | 447 | // Simulation uses iPAQ 3660 device buttons |
448 | 448 | ||
449 | qDebug ( "init Buttons" ); | 449 | qDebug ( "init Buttons" ); |
450 | d-> m_buttons = new QValueList <ODeviceButton>; | 450 | d-> m_buttons = new QValueList <ODeviceButton>; |
451 | 451 | ||
452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
453 | i_button *ib = ipaq_buttons + i; | 453 | i_button *ib = ipaq_buttons + i; |
454 | ODeviceButton b; | 454 | ODeviceButton b; |
455 | 455 | ||
456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
457 | b. setKeycode ( ib-> code ); | 457 | b. setKeycode ( ib-> code ); |
458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
462 | d-> m_buttons-> append ( b ); | 462 | d-> m_buttons-> append ( b ); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | reloadButtonMapping ( ); | 465 | reloadButtonMapping ( ); |
466 | 466 | ||
467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
469 | } | 469 | } |
470 | 470 | ||
471 | ODevice::~ODevice ( ) | 471 | ODevice::~ODevice ( ) |
472 | { | 472 | { |
473 | delete d; | 473 | delete d; |
474 | } | 474 | } |
475 | 475 | ||
476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
477 | { | 477 | { |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | 480 | ||
481 | //#include <linux/apm_bios.h> | 481 | //#include <linux/apm_bios.h> |
482 | 482 | ||
483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
484 | 484 | ||
485 | /** | 485 | /** |
486 | * This method will try to suspend the device | 486 | * This method will try to suspend the device |
487 | * It only works if the user is the QWS Server and the apm application | 487 | * It only works if the user is the QWS Server and the apm application |
488 | * is installed. | 488 | * is installed. |
489 | * It tries to suspend and then waits some time cause some distributions | 489 | * It tries to suspend and then waits some time cause some distributions |
490 | * do have asynchronus apm implementations. | 490 | * do have asynchronus apm implementations. |
491 | * This method will either fail and return false or it'll suspend the | 491 | * This method will either fail and return false or it'll suspend the |
492 | * device and return once the device got woken up | 492 | * device and return once the device got woken up |
493 | * | 493 | * |
494 | * @return if the device got suspended | 494 | * @return if the device got suspended |
495 | */ | 495 | */ |
496 | bool ODevice::suspend ( ) | 496 | bool ODevice::suspend ( ) |
497 | { | 497 | { |
498 | qDebug("ODevice::suspend"); | 498 | qDebug("ODevice::suspend"); |
499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
500 | return false; | 500 | return false; |
501 | 501 | ||
502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
503 | return false; | 503 | return false; |
504 | 504 | ||
505 | bool res = false; | 505 | bool res = false; |
506 | 506 | ||
507 | struct timeval tvs, tvn; | 507 | struct timeval tvs, tvn; |
508 | ::gettimeofday ( &tvs, 0 ); | 508 | ::gettimeofday ( &tvs, 0 ); |
509 | 509 | ||
510 | ::sync ( ); // flush fs caches | 510 | ::sync ( ); // flush fs caches |
511 | res = ( ::system ( "apm --suspend" ) == 0 ); | 511 | res = ( ::system ( "apm --suspend" ) == 0 ); |
512 | 512 | ||
513 | // This is needed because the iPAQ apm implementation is asynchronous and we | 513 | // This is needed because the iPAQ apm implementation is asynchronous and we |
514 | // can not be sure when exactly the device is really suspended | 514 | // can not be sure when exactly the device is really suspended |
515 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 515 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
516 | 516 | ||
517 | if ( res ) { | 517 | if ( res ) { |
518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
519 | ::usleep ( 200 * 1000 ); | 519 | ::usleep ( 200 * 1000 ); |
520 | ::gettimeofday ( &tvn, 0 ); | 520 | ::gettimeofday ( &tvn, 0 ); |
521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
522 | } | 522 | } |
523 | 523 | ||
524 | return res; | 524 | return res; |
525 | } | 525 | } |
526 | 526 | ||
527 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 527 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
528 | 528 | ||
529 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 529 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
530 | 530 | ||
531 | /* VESA Blanking Levels */ | 531 | /* VESA Blanking Levels */ |
532 | #define VESA_NO_BLANKING 0 | 532 | #define VESA_NO_BLANKING 0 |
533 | #define VESA_VSYNC_SUSPEND 1 | 533 | #define VESA_VSYNC_SUSPEND 1 |
534 | #define VESA_HSYNC_SUSPEND 2 | 534 | #define VESA_HSYNC_SUSPEND 2 |
535 | #define VESA_POWERDOWN 3 | 535 | #define VESA_POWERDOWN 3 |
536 | 536 | ||
537 | /** | 537 | /** |
538 | * This sets the display on or off | 538 | * This sets the display on or off |
539 | */ | 539 | */ |
540 | bool ODevice::setDisplayStatus ( bool on ) | 540 | bool ODevice::setDisplayStatus ( bool on ) |
541 | { | 541 | { |
542 | qDebug("ODevice::setDisplayStatus(%d)", on); | 542 | qDebug("ODevice::setDisplayStatus(%d)", on); |
543 | 543 | ||
544 | if ( d-> m_model == Model_Unknown ) | 544 | if ( d-> m_model == Model_Unknown ) |
545 | return false; | 545 | return false; |
546 | 546 | ||
547 | bool res = false; | 547 | bool res = false; |
548 | int fd; | 548 | int fd; |
549 | 549 | ||
550 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 550 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
551 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 551 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
552 | ::close ( fd ); | 552 | ::close ( fd ); |
553 | } | 553 | } |
554 | return res; | 554 | return res; |
555 | } | 555 | } |
556 | 556 | ||
557 | /** | 557 | /** |
558 | * This sets the display brightness | 558 | * This sets the display brightness |
559 | * | ||
560 | * @param p The brightness to be set on a scale from 0 to 255 | ||
559 | * @return success or failure | 561 | * @return success or failure |
560 | */ | 562 | */ |
561 | bool ODevice::setDisplayBrightness ( int p) | 563 | bool ODevice::setDisplayBrightness ( int p) |
562 | { | 564 | { |
563 | Q_UNUSED( p ) | 565 | Q_UNUSED( p ) |
564 | return false; | 566 | return false; |
565 | } | 567 | } |
566 | 568 | ||
567 | /** | 569 | /** |
568 | * @return return the max value for the brightness settings slider | 570 | * @return returns the number of steppings on the brightness slider |
571 | * in the Light-'n-Power settings. | ||
569 | */ | 572 | */ |
570 | int ODevice::displayBrightnessResolution ( ) const | 573 | int ODevice::displayBrightnessResolution ( ) const |
571 | { | 574 | { |
572 | return 16; | 575 | return 16; |
573 | } | 576 | } |
574 | 577 | ||
575 | /** | 578 | /** |
576 | * This sets the display contrast | 579 | * This sets the display contrast |
580 | * @param p The contrast to be set on a scale from 0 to 255 | ||
577 | * @return success or failure | 581 | * @return success or failure |
578 | */ | 582 | */ |
579 | bool ODevice::setDisplayContrast ( int p) | 583 | bool ODevice::setDisplayContrast ( int p) |
580 | { | 584 | { |
581 | Q_UNUSED( p ) | 585 | Q_UNUSED( p ) |
582 | return false; | 586 | return false; |
583 | } | 587 | } |
584 | 588 | ||
585 | /** | 589 | /** |
586 | * @return return the max value for the brightness settings slider | 590 | * @return return the max value for the brightness settings slider |
587 | * or 0 if the device doesn't support setting of a contrast | 591 | * or 0 if the device doesn't support setting of a contrast |
588 | */ | 592 | */ |
589 | int ODevice::displayContrastResolution ( ) const | 593 | int ODevice::displayContrastResolution ( ) const |
590 | { | 594 | { |
591 | return 0; | 595 | return 0; |
592 | } | 596 | } |
593 | 597 | ||
594 | /** | 598 | /** |
595 | * This returns the vendor as string | 599 | * This returns the vendor as string |
596 | * @return Vendor as QString | 600 | * @return Vendor as QString |
597 | */ | 601 | */ |
598 | QString ODevice::vendorString ( ) const | 602 | QString ODevice::vendorString ( ) const |
599 | { | 603 | { |
600 | return d-> m_vendorstr; | 604 | return d-> m_vendorstr; |
601 | } | 605 | } |
602 | 606 | ||
603 | /** | 607 | /** |
604 | * This returns the vendor as one of the values of OVendor | 608 | * This returns the vendor as one of the values of OVendor |
605 | * @return OVendor | 609 | * @return OVendor |
606 | */ | 610 | */ |
607 | OVendor ODevice::vendor ( ) const | 611 | OVendor ODevice::vendor ( ) const |
608 | { | 612 | { |
609 | return d-> m_vendor; | 613 | return d-> m_vendor; |
610 | } | 614 | } |
611 | 615 | ||
612 | /** | 616 | /** |
613 | * This returns the model as a string | 617 | * This returns the model as a string |
614 | * @return A string representing the model | 618 | * @return A string representing the model |
615 | */ | 619 | */ |
616 | QString ODevice::modelString ( ) const | 620 | QString ODevice::modelString ( ) const |
617 | { | 621 | { |
618 | return d-> m_modelstr; | 622 | return d-> m_modelstr; |
619 | } | 623 | } |
620 | 624 | ||
621 | /** | 625 | /** |
622 | * This does return the OModel used | 626 | * This does return the OModel used |
623 | */ | 627 | */ |
624 | OModel ODevice::model ( ) const | 628 | OModel ODevice::model ( ) const |
625 | { | 629 | { |
626 | return d-> m_model; | 630 | return d-> m_model; |
627 | } | 631 | } |
628 | 632 | ||
629 | /** | 633 | /** |
630 | * This does return the systen name | 634 | * This does return the systen name |
631 | */ | 635 | */ |
632 | QString ODevice::systemString ( ) const | 636 | QString ODevice::systemString ( ) const |
633 | { | 637 | { |
634 | return d-> m_systemstr; | 638 | return d-> m_systemstr; |
635 | } | 639 | } |
636 | 640 | ||
637 | /** | 641 | /** |
638 | * Return System as OSystem value | 642 | * Return System as OSystem value |
639 | */ | 643 | */ |
640 | OSystem ODevice::system ( ) const | 644 | OSystem ODevice::system ( ) const |
641 | { | 645 | { |
642 | return d-> m_system; | 646 | return d-> m_system; |
643 | } | 647 | } |
644 | 648 | ||
645 | /** | 649 | /** |
646 | * @return the version string of the base system | 650 | * @return the version string of the base system |
647 | */ | 651 | */ |
648 | QString ODevice::systemVersionString ( ) const | 652 | QString ODevice::systemVersionString ( ) const |
649 | { | 653 | { |
650 | return d-> m_sysverstr; | 654 | return d-> m_sysverstr; |
651 | } | 655 | } |
652 | 656 | ||
653 | /** | 657 | /** |
654 | * @return the current Transformation | 658 | * @return the current Transformation |
655 | */ | 659 | */ |
656 | Transformation ODevice::rotation ( ) const | 660 | Transformation ODevice::rotation ( ) const |
657 | { | 661 | { |
658 | return d-> m_rotation; | 662 | return d-> m_rotation; |
659 | } | 663 | } |
660 | 664 | ||
661 | /** | 665 | /** |
662 | * @return the current rotation direction | 666 | * @return the current rotation direction |
663 | */ | 667 | */ |
664 | ODirection ODevice::direction ( ) const | 668 | ODirection ODevice::direction ( ) const |
665 | { | 669 | { |
666 | return d-> m_direction; | 670 | return d-> m_direction; |
667 | } | 671 | } |
668 | 672 | ||
669 | /** | 673 | /** |
670 | * This plays an alarmSound | 674 | * This plays an alarmSound |
671 | */ | 675 | */ |
672 | void ODevice::alarmSound ( ) | 676 | void ODevice::alarmSound ( ) |
673 | { | 677 | { |
674 | #ifndef QT_NO_SOUND | 678 | #ifndef QT_NO_SOUND |
675 | static Sound snd ( "alarm" ); | 679 | static Sound snd ( "alarm" ); |
676 | 680 | ||
677 | if ( snd. isFinished ( )) | 681 | if ( snd. isFinished ( )) |
678 | snd. play ( ); | 682 | snd. play ( ); |
679 | #endif | 683 | #endif |
680 | } | 684 | } |
681 | 685 | ||
682 | /** | 686 | /** |
683 | * This plays a key sound | 687 | * This plays a key sound |
684 | */ | 688 | */ |
685 | void ODevice::keySound ( ) | 689 | void ODevice::keySound ( ) |
686 | { | 690 | { |
687 | #ifndef QT_NO_SOUND | 691 | #ifndef QT_NO_SOUND |
688 | static Sound snd ( "keysound" ); | 692 | static Sound snd ( "keysound" ); |
689 | 693 | ||
690 | if ( snd. isFinished ( )) | 694 | if ( snd. isFinished ( )) |
691 | snd. play ( ); | 695 | snd. play ( ); |
692 | #endif | 696 | #endif |
693 | } | 697 | } |
694 | 698 | ||
695 | /** | 699 | /** |
696 | * This plays a touch sound | 700 | * This plays a touch sound |
697 | */ | 701 | */ |
698 | void ODevice::touchSound ( ) | 702 | void ODevice::touchSound ( ) |
699 | { | 703 | { |
700 | #ifndef QT_NO_SOUND | 704 | #ifndef QT_NO_SOUND |
701 | static Sound snd ( "touchsound" ); | 705 | static Sound snd ( "touchsound" ); |
702 | 706 | ||
703 | if ( snd. isFinished ( )) | 707 | if ( snd. isFinished ( )) |
704 | snd. play ( ); | 708 | snd. play ( ); |
705 | #endif | 709 | #endif |
706 | } | 710 | } |
707 | 711 | ||
708 | /** | 712 | /** |
709 | * This method will return a list of leds | 713 | * This method will return a list of leds |
710 | * available on this device | 714 | * available on this device |
711 | * @return a list of LEDs. | 715 | * @return a list of LEDs. |
712 | */ | 716 | */ |
713 | QValueList <OLed> ODevice::ledList ( ) const | 717 | QValueList <OLed> ODevice::ledList ( ) const |
714 | { | 718 | { |
715 | return QValueList <OLed> ( ); | 719 | return QValueList <OLed> ( ); |
716 | } | 720 | } |
717 | 721 | ||
718 | /** | 722 | /** |
719 | * This does return the state of the LEDs | 723 | * This does return the state of the LEDs |
720 | */ | 724 | */ |
721 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 725 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
722 | { | 726 | { |
723 | return QValueList <OLedState> ( ); | 727 | return QValueList <OLedState> ( ); |
724 | } | 728 | } |
725 | 729 | ||
726 | /** | 730 | /** |
727 | * @return the state for a given OLed | 731 | * @return the state for a given OLed |
728 | */ | 732 | */ |
729 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 733 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
730 | { | 734 | { |
731 | return Led_Off; | 735 | return Led_Off; |
732 | } | 736 | } |
733 | 737 | ||
734 | /** | 738 | /** |
735 | * Set the state for a LED | 739 | * Set the state for a LED |
736 | * @param which Which OLed to use | 740 | * @param which Which OLed to use |
737 | * @param st The state to set | 741 | * @param st The state to set |
738 | * @return success or failure | 742 | * @return success or failure |
739 | */ | 743 | */ |
740 | bool ODevice::setLedState ( OLed which, OLedState st ) | 744 | bool ODevice::setLedState ( OLed which, OLedState st ) |
741 | { | 745 | { |
742 | Q_UNUSED( which ) | 746 | Q_UNUSED( which ) |
743 | Q_UNUSED( st ) | 747 | Q_UNUSED( st ) |
744 | return false; | 748 | return false; |
745 | } | 749 | } |
746 | 750 | ||
747 | /** | 751 | /** |
748 | * @return if the device has a light sensor | 752 | * @return if the device has a light sensor |
749 | */ | 753 | */ |
750 | bool ODevice::hasLightSensor ( ) const | 754 | bool ODevice::hasLightSensor ( ) const |
751 | { | 755 | { |
752 | return false; | 756 | return false; |
753 | } | 757 | } |
754 | 758 | ||
755 | /** | 759 | /** |
756 | * @return a value from the light senso | 760 | * @return a value from the light senso |
757 | */ | 761 | */ |
758 | int ODevice::readLightSensor ( ) | 762 | int ODevice::readLightSensor ( ) |
759 | { | 763 | { |
760 | return -1; | 764 | return -1; |
761 | } | 765 | } |
762 | 766 | ||
763 | /** | 767 | /** |
764 | * @return the light sensor resolution whatever that is ;) | 768 | * @return the light sensor resolution whatever that is ;) |
765 | */ | 769 | */ |
766 | int ODevice::lightSensorResolution ( ) const | 770 | int ODevice::lightSensorResolution ( ) const |
767 | { | 771 | { |
768 | return 0; | 772 | return 0; |
769 | } | 773 | } |
770 | 774 | ||
771 | /** | 775 | /** |
772 | * @return a list of hardware buttons | 776 | * @return a list of hardware buttons |
773 | */ | 777 | */ |
774 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 778 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
775 | { | 779 | { |
776 | initButtons ( ); | 780 | initButtons ( ); |
777 | 781 | ||
778 | return *d-> m_buttons; | 782 | return *d-> m_buttons; |
779 | } | 783 | } |
780 | 784 | ||
781 | /** | 785 | /** |
782 | * @return The amount of time that would count as a hold | 786 | * @return The amount of time that would count as a hold |
783 | */ | 787 | */ |
784 | uint ODevice::buttonHoldTime ( ) const | 788 | uint ODevice::buttonHoldTime ( ) const |
785 | { | 789 | { |
786 | return d-> m_holdtime; | 790 | return d-> m_holdtime; |
787 | } | 791 | } |
788 | 792 | ||
789 | /** | 793 | /** |
790 | * This method return a ODeviceButton for a key code | 794 | * This method return a ODeviceButton for a key code |
791 | * or 0 if no special hardware button is available for the device | 795 | * or 0 if no special hardware button is available for the device |
792 | * | 796 | * |
793 | * @return The devicebutton or 0l | 797 | * @return The devicebutton or 0l |
794 | * @see ODeviceButton | 798 | * @see ODeviceButton |
795 | */ | 799 | */ |
796 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 800 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
797 | { | 801 | { |
798 | initButtons ( ); | 802 | initButtons ( ); |
799 | 803 | ||
800 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 804 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
801 | if ( (*it). keycode ( ) == code ) | 805 | if ( (*it). keycode ( ) == code ) |
802 | return &(*it); | 806 | return &(*it); |
803 | } | 807 | } |
804 | return 0; | 808 | return 0; |
805 | } | 809 | } |
806 | 810 | ||
807 | void ODevice::reloadButtonMapping ( ) | 811 | void ODevice::reloadButtonMapping ( ) |
808 | { | 812 | { |
809 | initButtons ( ); | 813 | initButtons ( ); |
810 | 814 | ||
811 | Config cfg ( "ButtonSettings" ); | 815 | Config cfg ( "ButtonSettings" ); |
812 | 816 | ||
813 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 817 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
814 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 818 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
815 | QString group = "Button" + QString::number ( i ); | 819 | QString group = "Button" + QString::number ( i ); |
816 | 820 | ||
817 | QCString pch, hch; | 821 | QCString pch, hch; |
818 | QCString pm, hm; | 822 | QCString pm, hm; |
819 | QByteArray pdata, hdata; | 823 | QByteArray pdata, hdata; |
820 | 824 | ||
821 | if ( cfg. hasGroup ( group )) { | 825 | if ( cfg. hasGroup ( group )) { |
822 | cfg. setGroup ( group ); | 826 | cfg. setGroup ( group ); |
823 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 827 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
824 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 828 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
825 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 829 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
826 | 830 | ||
827 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 831 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
828 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 832 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
829 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 833 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
830 | } | 834 | } |
831 | 835 | ||
832 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 836 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
833 | 837 | ||
834 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 838 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
835 | } | 839 | } |
836 | } | 840 | } |
837 | 841 | ||
838 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 842 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
839 | { | 843 | { |
840 | initButtons ( ); | 844 | initButtons ( ); |
841 | 845 | ||
842 | QString mb_chan; | 846 | QString mb_chan; |
843 | 847 | ||
844 | if ( button >= (int) d-> m_buttons-> count ( )) | 848 | if ( button >= (int) d-> m_buttons-> count ( )) |
845 | return; | 849 | return; |
846 | 850 | ||
847 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 851 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
848 | b. setPressedAction ( action ); | 852 | b. setPressedAction ( action ); |
849 | 853 | ||
850 | mb_chan=b. pressedAction ( ). channel ( ); | 854 | mb_chan=b. pressedAction ( ). channel ( ); |
851 | 855 | ||
852 | Config buttonFile ( "ButtonSettings" ); | 856 | Config buttonFile ( "ButtonSettings" ); |
853 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 857 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
854 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 858 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
855 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 859 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
856 | 860 | ||
857 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 861 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
858 | 862 | ||
859 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 863 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
860 | } | 864 | } |
861 | 865 | ||
862 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 866 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
863 | { | 867 | { |
864 | initButtons ( ); | 868 | initButtons ( ); |
865 | 869 | ||
866 | if ( button >= (int) d-> m_buttons-> count ( )) | 870 | if ( button >= (int) d-> m_buttons-> count ( )) |
867 | return; | 871 | return; |
868 | 872 | ||
869 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 873 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
870 | b. setHeldAction ( action ); | 874 | b. setHeldAction ( action ); |
871 | 875 | ||
872 | Config buttonFile ( "ButtonSettings" ); | 876 | Config buttonFile ( "ButtonSettings" ); |
873 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 877 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
874 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 878 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
875 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 879 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
876 | 880 | ||
877 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 881 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
878 | 882 | ||
879 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 883 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
880 | } | 884 | } |
881 | 885 | ||
882 | 886 | ||
883 | 887 | ||
884 | 888 | ||
885 | /************************************************** | 889 | /************************************************** |
886 | * | 890 | * |
887 | * iPAQ | 891 | * iPAQ |
888 | * | 892 | * |
889 | **************************************************/ | 893 | **************************************************/ |
890 | 894 | ||
891 | void iPAQ::init ( ) | 895 | void iPAQ::init ( ) |
892 | { | 896 | { |
893 | d-> m_vendorstr = "HP"; | 897 | d-> m_vendorstr = "HP"; |
894 | d-> m_vendor = Vendor_HP; | 898 | d-> m_vendor = Vendor_HP; |
895 | 899 | ||
896 | QFile f ( "/proc/hal/model" ); | 900 | QFile f ( "/proc/hal/model" ); |
897 | 901 | ||
898 | if ( f. open ( IO_ReadOnly )) { | 902 | if ( f. open ( IO_ReadOnly )) { |
899 | QTextStream ts ( &f ); | 903 | QTextStream ts ( &f ); |
900 | 904 | ||
901 | d-> m_modelstr = "H" + ts. readLine ( ); | 905 | d-> m_modelstr = "H" + ts. readLine ( ); |
902 | 906 | ||
903 | if ( d-> m_modelstr == "H3100" ) | 907 | if ( d-> m_modelstr == "H3100" ) |
904 | d-> m_model = Model_iPAQ_H31xx; | 908 | d-> m_model = Model_iPAQ_H31xx; |
905 | else if ( d-> m_modelstr == "H3600" ) | 909 | else if ( d-> m_modelstr == "H3600" ) |
906 | d-> m_model = Model_iPAQ_H36xx; | 910 | d-> m_model = Model_iPAQ_H36xx; |
907 | else if ( d-> m_modelstr == "H3700" ) | 911 | else if ( d-> m_modelstr == "H3700" ) |
908 | d-> m_model = Model_iPAQ_H37xx; | 912 | d-> m_model = Model_iPAQ_H37xx; |
909 | else if ( d-> m_modelstr == "H3800" ) | 913 | else if ( d-> m_modelstr == "H3800" ) |
910 | d-> m_model = Model_iPAQ_H38xx; | 914 | d-> m_model = Model_iPAQ_H38xx; |
911 | else if ( d-> m_modelstr == "H3900" ) | 915 | else if ( d-> m_modelstr == "H3900" ) |
912 | d-> m_model = Model_iPAQ_H39xx; | 916 | d-> m_model = Model_iPAQ_H39xx; |
913 | else | 917 | else |
914 | d-> m_model = Model_Unknown; | 918 | d-> m_model = Model_Unknown; |
915 | 919 | ||
916 | f. close ( ); | 920 | f. close ( ); |
917 | } | 921 | } |
918 | 922 | ||
919 | switch ( d-> m_model ) { | 923 | switch ( d-> m_model ) { |
920 | case Model_iPAQ_H31xx: | 924 | case Model_iPAQ_H31xx: |
921 | case Model_iPAQ_H38xx: | 925 | case Model_iPAQ_H38xx: |
922 | d-> m_rotation = Rot90; | 926 | d-> m_rotation = Rot90; |
923 | break; | 927 | break; |
924 | case Model_iPAQ_H36xx: | 928 | case Model_iPAQ_H36xx: |
925 | case Model_iPAQ_H37xx: | 929 | case Model_iPAQ_H37xx: |
926 | case Model_iPAQ_H39xx: | 930 | case Model_iPAQ_H39xx: |
927 | default: | 931 | default: |
928 | d-> m_rotation = Rot270; | 932 | d-> m_rotation = Rot270; |
929 | break; | 933 | break; |
930 | } | 934 | } |
931 | 935 | ||
932 | f. setName ( "/etc/familiar-version" ); | 936 | f. setName ( "/etc/familiar-version" ); |
933 | if ( f. open ( IO_ReadOnly )) { | 937 | if ( f. open ( IO_ReadOnly )) { |
934 | d-> m_systemstr = "Familiar"; | 938 | d-> m_systemstr = "Familiar"; |
935 | d-> m_system = System_Familiar; | 939 | d-> m_system = System_Familiar; |
936 | 940 | ||
937 | QTextStream ts ( &f ); | 941 | QTextStream ts ( &f ); |
938 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 942 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
939 | 943 | ||
940 | f. close ( ); | 944 | f. close ( ); |
941 | } else { | 945 | } else { |
942 | f. setName ( "/etc/oz_version" ); | 946 | f. setName ( "/etc/oz_version" ); |
943 | 947 | ||
944 | if ( f. open ( IO_ReadOnly )) { | 948 | if ( f. open ( IO_ReadOnly )) { |
945 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 949 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
946 | d-> m_system = System_Familiar; | 950 | d-> m_system = System_Familiar; |
947 | 951 | ||
948 | QTextStream ts ( &f ); | 952 | QTextStream ts ( &f ); |
949 | ts.setDevice ( &f ); | 953 | ts.setDevice ( &f ); |
950 | d-> m_sysverstr = ts. readLine ( ); | 954 | d-> m_sysverstr = ts. readLine ( ); |
951 | f. close ( ); | 955 | f. close ( ); |
952 | } | 956 | } |
953 | } | 957 | } |
954 | 958 | ||
955 | 959 | ||
956 | 960 | ||
957 | 961 | ||
958 | 962 | ||
959 | m_leds [0] = m_leds [1] = Led_Off; | 963 | m_leds [0] = m_leds [1] = Led_Off; |
960 | 964 | ||
@@ -1689,410 +1693,410 @@ void SIMpad::initButtons ( ) | |||
1689 | 1693 | ||
1690 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1694 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1691 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1695 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1692 | } | 1696 | } |
1693 | 1697 | ||
1694 | // SIMpad boardcontrol register CS3 | 1698 | // SIMpad boardcontrol register CS3 |
1695 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 1699 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
1696 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 1700 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
1697 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 1701 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
1698 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 1702 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
1699 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 1703 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
1700 | #define SIMPAD_DISPLAY_ON 0x0010 | 1704 | #define SIMPAD_DISPLAY_ON 0x0010 |
1701 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 1705 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
1702 | #define SIMPAD_MQ_RESET 0x0040 | 1706 | #define SIMPAD_MQ_RESET 0x0040 |
1703 | #define SIMPAD_PCMCIA_RESET 0x0080 | 1707 | #define SIMPAD_PCMCIA_RESET 0x0080 |
1704 | #define SIMPAD_DECT_POWER_ON 0x0100 | 1708 | #define SIMPAD_DECT_POWER_ON 0x0100 |
1705 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 1709 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
1706 | #define SIMPAD_RS232_ON 0x0400 | 1710 | #define SIMPAD_RS232_ON 0x0400 |
1707 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 1711 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
1708 | #define SIMPAD_LED2_ON 0x1000 | 1712 | #define SIMPAD_LED2_ON 0x1000 |
1709 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 1713 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
1710 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 1714 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
1711 | #define SIMPAD_RESET_SIMCARD 0x8000 | 1715 | #define SIMPAD_RESET_SIMCARD 0x8000 |
1712 | 1716 | ||
1713 | //SIMpad touchscreen backlight strength control | 1717 | //SIMpad touchscreen backlight strength control |
1714 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 1718 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
1715 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 1719 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
1716 | 1720 | ||
1717 | QValueList <OLed> SIMpad::ledList ( ) const | 1721 | QValueList <OLed> SIMpad::ledList ( ) const |
1718 | { | 1722 | { |
1719 | QValueList <OLed> vl; | 1723 | QValueList <OLed> vl; |
1720 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 1724 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
1721 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 1725 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
1722 | return vl; | 1726 | return vl; |
1723 | } | 1727 | } |
1724 | 1728 | ||
1725 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 1729 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
1726 | { | 1730 | { |
1727 | QValueList <OLedState> vl; | 1731 | QValueList <OLedState> vl; |
1728 | 1732 | ||
1729 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 1733 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
1730 | vl << Led_Off << Led_On; | 1734 | vl << Led_Off << Led_On; |
1731 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 1735 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
1732 | //vl << Led_Off; | 1736 | //vl << Led_Off; |
1733 | return vl; | 1737 | return vl; |
1734 | } | 1738 | } |
1735 | 1739 | ||
1736 | OLedState SIMpad::ledState ( OLed l ) const | 1740 | OLedState SIMpad::ledState ( OLed l ) const |
1737 | { | 1741 | { |
1738 | switch ( l ) { | 1742 | switch ( l ) { |
1739 | case Led_Power: | 1743 | case Led_Power: |
1740 | return m_leds [0]; | 1744 | return m_leds [0]; |
1741 | //case Led_Mail: | 1745 | //case Led_Mail: |
1742 | //return m_leds [1]; | 1746 | //return m_leds [1]; |
1743 | default: | 1747 | default: |
1744 | return Led_Off; | 1748 | return Led_Off; |
1745 | } | 1749 | } |
1746 | } | 1750 | } |
1747 | 1751 | ||
1748 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 1752 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
1749 | { | 1753 | { |
1750 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 1754 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
1751 | 1755 | ||
1752 | if ( l == Led_Power ) { | 1756 | if ( l == Led_Power ) { |
1753 | if ( fd >= 0 ) { | 1757 | if ( fd >= 0 ) { |
1754 | LED_IN leds; | 1758 | LED_IN leds; |
1755 | ::memset ( &leds, 0, sizeof( leds )); | 1759 | ::memset ( &leds, 0, sizeof( leds )); |
1756 | leds. TotalTime = 0; | 1760 | leds. TotalTime = 0; |
1757 | leds. OnTime = 0; | 1761 | leds. OnTime = 0; |
1758 | leds. OffTime = 1; | 1762 | leds. OffTime = 1; |
1759 | leds. OffOnBlink = 2; | 1763 | leds. OffOnBlink = 2; |
1760 | 1764 | ||
1761 | switch ( st ) { | 1765 | switch ( st ) { |
1762 | case Led_Off : leds. OffOnBlink = 0; break; | 1766 | case Led_Off : leds. OffOnBlink = 0; break; |
1763 | case Led_On : leds. OffOnBlink = 1; break; | 1767 | case Led_On : leds. OffOnBlink = 1; break; |
1764 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1768 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1765 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1769 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1766 | } | 1770 | } |
1767 | 1771 | ||
1768 | { | 1772 | { |
1769 | /*TODO Implement this like that: | 1773 | /*TODO Implement this like that: |
1770 | read from cs3 | 1774 | read from cs3 |
1771 | && with SIMPAD_LED2_ON | 1775 | && with SIMPAD_LED2_ON |
1772 | write to cs3 */ | 1776 | write to cs3 */ |
1773 | m_leds [0] = st; | 1777 | m_leds [0] = st; |
1774 | return true; | 1778 | return true; |
1775 | } | 1779 | } |
1776 | } | 1780 | } |
1777 | } | 1781 | } |
1778 | return false; | 1782 | return false; |
1779 | } | 1783 | } |
1780 | 1784 | ||
1781 | 1785 | ||
1782 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1786 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1783 | { | 1787 | { |
1784 | //TODO | 1788 | //TODO |
1785 | return false; | 1789 | return false; |
1786 | } | 1790 | } |
1787 | 1791 | ||
1788 | void SIMpad::timerEvent ( QTimerEvent * ) | 1792 | void SIMpad::timerEvent ( QTimerEvent * ) |
1789 | { | 1793 | { |
1790 | killTimer ( m_power_timer ); | 1794 | killTimer ( m_power_timer ); |
1791 | m_power_timer = 0; | 1795 | m_power_timer = 0; |
1792 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1796 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1793 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1797 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1794 | } | 1798 | } |
1795 | 1799 | ||
1796 | 1800 | ||
1797 | void SIMpad::alarmSound ( ) | 1801 | void SIMpad::alarmSound ( ) |
1798 | { | 1802 | { |
1799 | #ifndef QT_NO_SOUND | 1803 | #ifndef QT_NO_SOUND |
1800 | static Sound snd ( "alarm" ); | 1804 | static Sound snd ( "alarm" ); |
1801 | int fd; | 1805 | int fd; |
1802 | int vol; | 1806 | int vol; |
1803 | bool vol_reset = false; | 1807 | bool vol_reset = false; |
1804 | 1808 | ||
1805 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1809 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1806 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1810 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1807 | Config cfg ( "qpe" ); | 1811 | Config cfg ( "qpe" ); |
1808 | cfg. setGroup ( "Volume" ); | 1812 | cfg. setGroup ( "Volume" ); |
1809 | 1813 | ||
1810 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1814 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1811 | if ( volalarm < 0 ) | 1815 | if ( volalarm < 0 ) |
1812 | volalarm = 0; | 1816 | volalarm = 0; |
1813 | else if ( volalarm > 100 ) | 1817 | else if ( volalarm > 100 ) |
1814 | volalarm = 100; | 1818 | volalarm = 100; |
1815 | volalarm |= ( volalarm << 8 ); | 1819 | volalarm |= ( volalarm << 8 ); |
1816 | 1820 | ||
1817 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1821 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1818 | vol_reset = true; | 1822 | vol_reset = true; |
1819 | } | 1823 | } |
1820 | } | 1824 | } |
1821 | 1825 | ||
1822 | snd. play ( ); | 1826 | snd. play ( ); |
1823 | while ( !snd. isFinished ( )) | 1827 | while ( !snd. isFinished ( )) |
1824 | qApp-> processEvents ( ); | 1828 | qApp-> processEvents ( ); |
1825 | 1829 | ||
1826 | if ( fd >= 0 ) { | 1830 | if ( fd >= 0 ) { |
1827 | if ( vol_reset ) | 1831 | if ( vol_reset ) |
1828 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1832 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1829 | ::close ( fd ); | 1833 | ::close ( fd ); |
1830 | } | 1834 | } |
1831 | #endif | 1835 | #endif |
1832 | } | 1836 | } |
1833 | 1837 | ||
1834 | 1838 | ||
1835 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 1839 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
1836 | { | 1840 | { |
1837 | qDebug( "ODevice for SIMpad: suspend()" ); | 1841 | qDebug( "ODevice for SIMpad: suspend()" ); |
1838 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 1842 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
1839 | return false; | 1843 | return false; |
1840 | 1844 | ||
1841 | bool res = false; | 1845 | bool res = false; |
1842 | 1846 | ||
1843 | struct timeval tvs, tvn; | 1847 | struct timeval tvs, tvn; |
1844 | ::gettimeofday ( &tvs, 0 ); | 1848 | ::gettimeofday ( &tvs, 0 ); |
1845 | 1849 | ||
1846 | ::sync ( ); // flush fs caches | 1850 | ::sync ( ); // flush fs caches |
1847 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) | 1851 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) |
1848 | 1852 | ||
1849 | return res; | 1853 | return res; |
1850 | } | 1854 | } |
1851 | 1855 | ||
1852 | 1856 | ||
1853 | bool SIMpad::setSoftSuspend ( bool soft ) | 1857 | bool SIMpad::setSoftSuspend ( bool soft ) |
1854 | { | 1858 | { |
1855 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 1859 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
1856 | return false; | 1860 | return false; |
1857 | } | 1861 | } |
1858 | 1862 | ||
1859 | 1863 | ||
1860 | bool SIMpad::setDisplayStatus ( bool on ) | 1864 | bool SIMpad::setDisplayStatus ( bool on ) |
1861 | { | 1865 | { |
1862 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 1866 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
1863 | 1867 | ||
1864 | bool res = false; | 1868 | bool res = false; |
1865 | int fd; | 1869 | int fd; |
1866 | 1870 | ||
1867 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 1871 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
1868 | 1872 | ||
1869 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 1873 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
1870 | res = ( ::system( (const char*) cmdline ) == 0 ); | 1874 | res = ( ::system( (const char*) cmdline ) == 0 ); |
1871 | ::close ( fd ); | 1875 | ::close ( fd ); |
1872 | } | 1876 | } |
1873 | return res; | 1877 | return res; |
1874 | } | 1878 | } |
1875 | 1879 | ||
1876 | 1880 | ||
1877 | bool SIMpad::setDisplayBrightness ( int bright ) | 1881 | bool SIMpad::setDisplayBrightness ( int bright ) |
1878 | { | 1882 | { |
1879 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 1883 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
1880 | bool res = false; | 1884 | bool res = false; |
1881 | int fd; | 1885 | int fd; |
1882 | 1886 | ||
1883 | if ( bright > 255 ) | 1887 | if ( bright > 255 ) |
1884 | bright = 255; | 1888 | bright = 255; |
1885 | if ( bright < 0 ) | 1889 | if ( bright < 0 ) |
1886 | bright = 0; | 1890 | bright = 0; |
1887 | 1891 | ||
1888 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1892 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1889 | int value = 255 - bright; | 1893 | int value = 255 - bright; |
1890 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1894 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1891 | value = value << 8; | 1895 | value = value << 8; |
1892 | value += mask; | 1896 | value += mask; |
1893 | char writeCommand[100]; | 1897 | char writeCommand[100]; |
1894 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1898 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1895 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1899 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1896 | ::close ( fd ); | 1900 | ::close ( fd ); |
1897 | } | 1901 | } |
1898 | return res; | 1902 | return res; |
1899 | } | 1903 | } |
1900 | 1904 | ||
1901 | 1905 | ||
1902 | int SIMpad::displayBrightnessResolution ( ) const | 1906 | int SIMpad::displayBrightnessResolution ( ) const |
1903 | { | 1907 | { |
1904 | switch ( model ( )) { | 1908 | switch ( model ( )) { |
1905 | case Model_SIMpad_CL4: | 1909 | case Model_SIMpad_CL4: |
1906 | case Model_SIMpad_SL4: | 1910 | case Model_SIMpad_SL4: |
1907 | case Model_SIMpad_SLC: | 1911 | case Model_SIMpad_SLC: |
1908 | case Model_SIMpad_TSinus: | 1912 | case Model_SIMpad_TSinus: |
1909 | return 255; //TODO find out if this is save | 1913 | return 255; //TODO find out if this is save |
1910 | 1914 | ||
1911 | default: | 1915 | default: |
1912 | return 2; | 1916 | return 2; |
1913 | } | 1917 | } |
1914 | } | 1918 | } |
1915 | 1919 | ||
1916 | /************************************************** | 1920 | /************************************************** |
1917 | * | 1921 | * |
1918 | * Ramses | 1922 | * Ramses |
1919 | * | 1923 | * |
1920 | **************************************************/ | 1924 | **************************************************/ |
1921 | 1925 | ||
1922 | void Ramses::init() | 1926 | void Ramses::init() |
1923 | { | 1927 | { |
1924 | d->m_vendorstr = "M und N"; | 1928 | d->m_vendorstr = "M und N"; |
1925 | d->m_vendor = Vendor_MundN; | 1929 | d->m_vendor = Vendor_MundN; |
1926 | 1930 | ||
1927 | QFile f("/proc/sys/board/ramses"); | 1931 | QFile f("/proc/sys/board/ramses"); |
1928 | 1932 | ||
1929 | d->m_modelstr = "Ramses"; | 1933 | d->m_modelstr = "Ramses"; |
1930 | d->m_model = Model_Ramses_MNCI; | 1934 | d->m_model = Model_Ramses_MNCI; |
1931 | 1935 | ||
1932 | d->m_rotation = Rot0; | 1936 | d->m_rotation = Rot0; |
1933 | d->m_holdtime = 1000; | 1937 | d->m_holdtime = 1000; |
1934 | 1938 | ||
1935 | f.setName("/etc/oz_version"); | 1939 | f.setName("/etc/oz_version"); |
1936 | 1940 | ||
1937 | if (f.open(IO_ReadOnly)) { | 1941 | if (f.open(IO_ReadOnly)) { |
1938 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1942 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1939 | d->m_system = System_OpenZaurus; | 1943 | d->m_system = System_OpenZaurus; |
1940 | 1944 | ||
1941 | QTextStream ts(&f); | 1945 | QTextStream ts(&f); |
1942 | ts.setDevice(&f); | 1946 | ts.setDevice(&f); |
1943 | d->m_sysverstr = ts.readLine(); | 1947 | d->m_sysverstr = ts.readLine(); |
1944 | f.close(); | 1948 | f.close(); |
1945 | } | 1949 | } |
1946 | 1950 | ||
1947 | m_power_timer = 0; | 1951 | m_power_timer = 0; |
1948 | 1952 | ||
1949 | } | 1953 | } |
1950 | 1954 | ||
1951 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 1955 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
1952 | { | 1956 | { |
1953 | Q_UNUSED( keycode ); | 1957 | Q_UNUSED( keycode ); |
1954 | Q_UNUSED( modifiers ); | 1958 | Q_UNUSED( modifiers ); |
1955 | Q_UNUSED( isPress ); | 1959 | Q_UNUSED( isPress ); |
1956 | Q_UNUSED( autoRepeat ); | 1960 | Q_UNUSED( autoRepeat ); |
1957 | return false; | 1961 | return false; |
1958 | } | 1962 | } |
1959 | 1963 | ||
1960 | void Ramses::timerEvent(QTimerEvent *) | 1964 | void Ramses::timerEvent(QTimerEvent *) |
1961 | { | 1965 | { |
1962 | killTimer(m_power_timer); | 1966 | killTimer(m_power_timer); |
1963 | m_power_timer = 0; | 1967 | m_power_timer = 0; |
1964 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 1968 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
1965 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 1969 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
1966 | } | 1970 | } |
1967 | 1971 | ||
1968 | 1972 | ||
1969 | bool Ramses::setSoftSuspend(bool soft) | 1973 | bool Ramses::setSoftSuspend(bool soft) |
1970 | { | 1974 | { |
1971 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 1975 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
1972 | #if 0 | 1976 | #if 0 |
1973 | bool res = false; | 1977 | bool res = false; |
1974 | int fd; | 1978 | int fd; |
1975 | 1979 | ||
1976 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 1980 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
1977 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 1981 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
1978 | 1982 | ||
1979 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 1983 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
1980 | 1984 | ||
1981 | if (sources >= 0) { | 1985 | if (sources >= 0) { |
1982 | if (soft) | 1986 | if (soft) |
1983 | sources &= ~APM_EVT_POWER_BUTTON; | 1987 | sources &= ~APM_EVT_POWER_BUTTON; |
1984 | else | 1988 | else |
1985 | sources |= APM_EVT_POWER_BUTTON; | 1989 | sources |= APM_EVT_POWER_BUTTON; |
1986 | 1990 | ||
1987 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 1991 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
1988 | res = true; | 1992 | res = true; |
1989 | else | 1993 | else |
1990 | perror("APM_IOCGEVTSRC"); | 1994 | perror("APM_IOCGEVTSRC"); |
1991 | } | 1995 | } |
1992 | else | 1996 | else |
1993 | perror("APM_IOCGEVTSRC"); | 1997 | perror("APM_IOCGEVTSRC"); |
1994 | 1998 | ||
1995 | ::close(fd); | 1999 | ::close(fd); |
1996 | } | 2000 | } |
1997 | else | 2001 | else |
1998 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2002 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
1999 | 2003 | ||
2000 | return res; | 2004 | return res; |
2001 | #else | 2005 | #else |
2002 | return true; | 2006 | return true; |
2003 | #endif | 2007 | #endif |
2004 | } | 2008 | } |
2005 | 2009 | ||
2006 | bool Ramses::suspend ( ) | 2010 | bool Ramses::suspend ( ) |
2007 | { | 2011 | { |
2008 | qDebug("Ramses::suspend"); | 2012 | qDebug("Ramses::suspend"); |
2009 | } | 2013 | } |
2010 | 2014 | ||
2011 | /** | 2015 | /** |
2012 | * This sets the display on or off | 2016 | * This sets the display on or off |
2013 | */ | 2017 | */ |
2014 | bool Ramses::setDisplayStatus(bool on) | 2018 | bool Ramses::setDisplayStatus(bool on) |
2015 | { | 2019 | { |
2016 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2020 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2017 | #if 0 | 2021 | #if 0 |
2018 | bool res = false; | 2022 | bool res = false; |
2019 | int fd; | 2023 | int fd; |
2020 | 2024 | ||
2021 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2025 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2022 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2026 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2023 | ::close(fd); | 2027 | ::close(fd); |
2024 | } | 2028 | } |
2025 | return res; | 2029 | return res; |
2026 | #else | 2030 | #else |
2027 | return true; | 2031 | return true; |
2028 | #endif | 2032 | #endif |
2029 | } | 2033 | } |
2030 | 2034 | ||
2031 | 2035 | ||
2032 | /* | 2036 | /* |
2033 | * We get something between 0..255 into us | 2037 | * We get something between 0..255 into us |
2034 | */ | 2038 | */ |
2035 | bool Ramses::setDisplayBrightness(int bright) | 2039 | bool Ramses::setDisplayBrightness(int bright) |
2036 | { | 2040 | { |
2037 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2041 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2038 | bool res = false; | 2042 | bool res = false; |
2039 | int fd; | 2043 | int fd; |
2040 | 2044 | ||
2041 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2045 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2042 | 2046 | ||
2043 | if (bright > 255 ) | 2047 | if (bright > 255 ) |
2044 | bright = 255; | 2048 | bright = 255; |
2045 | if (bright < 0) | 2049 | if (bright < 0) |
2046 | bright = 0; | 2050 | bright = 0; |
2047 | bright = 500-(bright * 500 / 255); | 2051 | bright = 500-(bright * 500 / 255); |
2048 | 2052 | ||
2049 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2053 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2050 | qDebug(" %d -> pwm1", bright); | 2054 | qDebug(" %d -> pwm1", bright); |
2051 | char writeCommand[100]; | 2055 | char writeCommand[100]; |
2052 | const int count = sprintf(writeCommand, "%d\n", bright); | 2056 | const int count = sprintf(writeCommand, "%d\n", bright); |
2053 | res = (::write(fd, writeCommand, count) != -1); | 2057 | res = (::write(fd, writeCommand, count) != -1); |
2054 | ::close(fd); | 2058 | ::close(fd); |
2055 | } else { | 2059 | } else { |
2056 | qWarning("no write"); | 2060 | qWarning("no write"); |
2057 | } | 2061 | } |
2058 | return res; | 2062 | return res; |
2059 | } | 2063 | } |
2060 | 2064 | ||
2061 | 2065 | ||
2062 | int Ramses::displayBrightnessResolution() const | 2066 | int Ramses::displayBrightnessResolution() const |
2063 | { | 2067 | { |
2064 | return 32; | 2068 | return 32; |
2065 | } | 2069 | } |
2066 | 2070 | ||
2067 | bool Ramses::setDisplayContrast(int contr) | 2071 | bool Ramses::setDisplayContrast(int contr) |
2068 | { | 2072 | { |
2069 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2073 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2070 | bool res = false; | 2074 | bool res = false; |
2071 | int fd; | 2075 | int fd; |
2072 | 2076 | ||
2073 | // pwm0 contrast: 35 steps 65..100 (dunkel->hell) | 2077 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2074 | 2078 | ||
2075 | if (contr > 255 ) | 2079 | if (contr > 255 ) |
2076 | contr = 255; | 2080 | contr = 255; |
2077 | if (contr < 0) | 2081 | if (contr < 0) |
2078 | contr = 0; | 2082 | contr = 0; |
2079 | contr = 65 + (contr * 350 / 255); | 2083 | contr = 90 - (contr * 20 / 255); |
2080 | 2084 | ||
2081 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2085 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2082 | qDebug(" %d -> pwm0", contr); | 2086 | qDebug(" %d -> pwm0", contr); |
2083 | char writeCommand[100]; | 2087 | char writeCommand[100]; |
2084 | const int count = sprintf(writeCommand, "%d\n", contr); | 2088 | const int count = sprintf(writeCommand, "%d\n", contr); |
2085 | res = (::write(fd, writeCommand, count) != -1); | 2089 | res = (::write(fd, writeCommand, count) != -1); |
2086 | res = true; | 2090 | res = true; |
2087 | ::close(fd); | 2091 | ::close(fd); |
2088 | } else { | 2092 | } else { |
2089 | qWarning("no write"); | 2093 | qWarning("no write"); |
2090 | } | 2094 | } |
2091 | return res; | 2095 | return res; |
2092 | } | 2096 | } |
2093 | 2097 | ||
2094 | 2098 | ||
2095 | int Ramses::displayContrastResolution() const | 2099 | int Ramses::displayContrastResolution() const |
2096 | { | 2100 | { |
2097 | return 32; | 2101 | return 20; |
2098 | } | 2102 | } |