author | schurig <schurig> | 2003-06-06 13:19:33 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-06 13:19:33 (UTC) |
commit | 78a5ebf10450a99211a5e86be1abc0397b749db3 (patch) (unidiff) | |
tree | b23ff8714bf718cefd1360525fce8a32e688611b | |
parent | fdab8e90076ead49141ed13300e0996ab8dce7da (diff) | |
download | opie-78a5ebf10450a99211a5e86be1abc0397b749db3.zip opie-78a5ebf10450a99211a5e86be1abc0397b749db3.tar.gz opie-78a5ebf10450a99211a5e86be1abc0397b749db3.tar.bz2 |
beginnings of cpu frequency changes
-rw-r--r-- | libopie/odevice.cpp | 61 | ||||
-rw-r--r-- | libopie/odevice.h | 10 |
2 files changed, 65 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index f808960..4b5a54e 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,170 +1,171 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <linux/soundcard.h> | 26 | #include <linux/soundcard.h> |
27 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | 37 | ||
38 | #include "odevice.h" | 38 | #include "odevice.h" |
39 | 39 | ||
40 | #include <qwindowsystem_qws.h> | 40 | #include <qwindowsystem_qws.h> |
41 | 41 | ||
42 | #ifndef ARRAY_SIZE | 42 | #ifndef ARRAY_SIZE |
43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | // _IO and friends are only defined in kernel headers ... | 46 | // _IO and friends are only defined in kernel headers ... |
47 | 47 | ||
48 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 48 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
49 | 49 | ||
50 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 50 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
51 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 51 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
52 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 52 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
53 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 53 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
54 | 54 | ||
55 | using namespace Opie; | 55 | using namespace Opie; |
56 | 56 | ||
57 | class ODeviceData { | 57 | class ODeviceData { |
58 | public: | 58 | public: |
59 | QString m_vendorstr; | 59 | QString m_vendorstr; |
60 | OVendor m_vendor; | 60 | OVendor m_vendor; |
61 | 61 | ||
62 | QString m_modelstr; | 62 | QString m_modelstr; |
63 | OModel m_model; | 63 | OModel m_model; |
64 | 64 | ||
65 | QString m_systemstr; | 65 | QString m_systemstr; |
66 | OSystem m_system; | 66 | OSystem m_system; |
67 | 67 | ||
68 | QString m_sysverstr; | 68 | QString m_sysverstr; |
69 | 69 | ||
70 | Transformation m_rotation; | 70 | Transformation m_rotation; |
71 | ODirection m_direction; | 71 | ODirection m_direction; |
72 | 72 | ||
73 | QValueList <ODeviceButton> *m_buttons; | 73 | QValueList <ODeviceButton> *m_buttons; |
74 | uint m_holdtime; | 74 | uint m_holdtime; |
75 | QStrList *m_cpu_frequencies; | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
78 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 79 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
79 | protected: | 80 | protected: |
80 | virtual void init ( ); | 81 | virtual void init ( ); |
81 | virtual void initButtons ( ); | 82 | virtual void initButtons ( ); |
82 | 83 | ||
83 | public: | 84 | public: |
84 | virtual bool setSoftSuspend ( bool soft ); | 85 | virtual bool setSoftSuspend ( bool soft ); |
85 | 86 | ||
86 | virtual bool setDisplayBrightness ( int b ); | 87 | virtual bool setDisplayBrightness ( int b ); |
87 | virtual int displayBrightnessResolution ( ) const; | 88 | virtual int displayBrightnessResolution ( ) const; |
88 | 89 | ||
89 | virtual void alarmSound ( ); | 90 | virtual void alarmSound ( ); |
90 | 91 | ||
91 | virtual QValueList <OLed> ledList ( ) const; | 92 | virtual QValueList <OLed> ledList ( ) const; |
92 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 93 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
93 | virtual OLedState ledState ( OLed led ) const; | 94 | virtual OLedState ledState ( OLed led ) const; |
94 | virtual bool setLedState ( OLed led, OLedState st ); | 95 | virtual bool setLedState ( OLed led, OLedState st ); |
95 | 96 | ||
96 | virtual bool hasLightSensor ( ) const; | 97 | virtual bool hasLightSensor ( ) const; |
97 | virtual int readLightSensor ( ); | 98 | virtual int readLightSensor ( ); |
98 | virtual int lightSensorResolution ( ) const; | 99 | virtual int lightSensorResolution ( ) const; |
99 | 100 | ||
100 | protected: | 101 | protected: |
101 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 102 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
102 | virtual void timerEvent ( QTimerEvent *te ); | 103 | virtual void timerEvent ( QTimerEvent *te ); |
103 | 104 | ||
104 | int m_power_timer; | 105 | int m_power_timer; |
105 | 106 | ||
106 | OLedState m_leds [2]; | 107 | OLedState m_leds [2]; |
107 | }; | 108 | }; |
108 | 109 | ||
109 | class Zaurus : public ODevice { | 110 | class Zaurus : public ODevice { |
110 | protected: | 111 | protected: |
111 | virtual void init ( ); | 112 | virtual void init ( ); |
112 | virtual void initButtons ( ); | 113 | virtual void initButtons ( ); |
113 | 114 | ||
114 | public: | 115 | public: |
115 | virtual bool setSoftSuspend ( bool soft ); | 116 | virtual bool setSoftSuspend ( bool soft ); |
116 | 117 | ||
117 | virtual bool setDisplayBrightness ( int b ); | 118 | virtual bool setDisplayBrightness ( int b ); |
118 | virtual int displayBrightnessResolution ( ) const; | 119 | virtual int displayBrightnessResolution ( ) const; |
119 | 120 | ||
120 | virtual void alarmSound ( ); | 121 | virtual void alarmSound ( ); |
121 | virtual void keySound ( ); | 122 | virtual void keySound ( ); |
122 | virtual void touchSound ( ); | 123 | virtual void touchSound ( ); |
123 | 124 | ||
124 | virtual QValueList <OLed> ledList ( ) const; | 125 | virtual QValueList <OLed> ledList ( ) const; |
125 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 126 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
126 | virtual OLedState ledState ( OLed led ) const; | 127 | virtual OLedState ledState ( OLed led ) const; |
127 | virtual bool setLedState ( OLed led, OLedState st ); | 128 | virtual bool setLedState ( OLed led, OLedState st ); |
128 | 129 | ||
129 | protected: | 130 | protected: |
130 | virtual void buzzer ( int snd ); | 131 | virtual void buzzer ( int snd ); |
131 | 132 | ||
132 | OLedState m_leds [1]; | 133 | OLedState m_leds [1]; |
133 | }; | 134 | }; |
134 | 135 | ||
135 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 136 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
136 | protected: | 137 | protected: |
137 | virtual void init ( ); | 138 | virtual void init ( ); |
138 | virtual void initButtons ( ); | 139 | virtual void initButtons ( ); |
139 | 140 | ||
140 | public: | 141 | public: |
141 | virtual bool setSoftSuspend ( bool soft ); | 142 | virtual bool setSoftSuspend ( bool soft ); |
142 | virtual bool suspend(); | 143 | virtual bool suspend(); |
143 | 144 | ||
144 | virtual bool setDisplayStatus( bool on ); | 145 | virtual bool setDisplayStatus( bool on ); |
145 | virtual bool setDisplayBrightness ( int b ); | 146 | virtual bool setDisplayBrightness ( int b ); |
146 | virtual int displayBrightnessResolution ( ) const; | 147 | virtual int displayBrightnessResolution ( ) const; |
147 | 148 | ||
148 | virtual void alarmSound ( ); | 149 | virtual void alarmSound ( ); |
149 | 150 | ||
150 | virtual QValueList <OLed> ledList ( ) const; | 151 | virtual QValueList <OLed> ledList ( ) const; |
151 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 152 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
152 | virtual OLedState ledState ( OLed led ) const; | 153 | virtual OLedState ledState ( OLed led ) const; |
153 | virtual bool setLedState ( OLed led, OLedState st ); | 154 | virtual bool setLedState ( OLed led, OLedState st ); |
154 | 155 | ||
155 | protected: | 156 | protected: |
156 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 157 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
157 | virtual void timerEvent ( QTimerEvent *te ); | 158 | virtual void timerEvent ( QTimerEvent *te ); |
158 | 159 | ||
159 | int m_power_timer; | 160 | int m_power_timer; |
160 | 161 | ||
161 | OLedState m_leds [1]; //FIXME check if really only one | 162 | OLedState m_leds [1]; //FIXME check if really only one |
162 | }; | 163 | }; |
163 | 164 | ||
164 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | 165 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { |
165 | protected: | 166 | protected: |
166 | virtual void init ( ); | 167 | virtual void init ( ); |
167 | 168 | ||
168 | public: | 169 | public: |
169 | virtual bool setSoftSuspend ( bool soft ); | 170 | virtual bool setSoftSuspend ( bool soft ); |
170 | virtual bool suspend ( ); | 171 | virtual bool suspend ( ); |
@@ -330,192 +331,193 @@ struct s_button { | |||
330 | "QPE/Rotation", "flip()", | 331 | "QPE/Rotation", "flip()", |
331 | "QPE/Rotation", "flip()" }, | 332 | "QPE/Rotation", "flip()" }, |
332 | /* | 333 | /* |
333 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 334 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
334 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 335 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
335 | "devicebuttons/simpad_lower_upper", | 336 | "devicebuttons/simpad_lower_upper", |
336 | "QPE/Launcher", "home()", | 337 | "QPE/Launcher", "home()", |
337 | "buttonsettings", "raise()" }, | 338 | "buttonsettings", "raise()" }, |
338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 339 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
339 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 340 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
340 | "devicebuttons/simpad_upper_lower", | 341 | "devicebuttons/simpad_upper_lower", |
341 | "QPE/Launcher", "home()", | 342 | "QPE/Launcher", "home()", |
342 | "buttonsettings", "raise()" }, | 343 | "buttonsettings", "raise()" }, |
343 | */ | 344 | */ |
344 | }; | 345 | }; |
345 | 346 | ||
346 | struct r_button { | 347 | struct r_button { |
347 | uint model; | 348 | uint model; |
348 | Qt::Key code; | 349 | Qt::Key code; |
349 | char *utext; | 350 | char *utext; |
350 | char *pix; | 351 | char *pix; |
351 | char *fpressedservice; | 352 | char *fpressedservice; |
352 | char *fpressedaction; | 353 | char *fpressedaction; |
353 | char *fheldservice; | 354 | char *fheldservice; |
354 | char *fheldaction; | 355 | char *fheldaction; |
355 | } ramses_buttons [] = { | 356 | } ramses_buttons [] = { |
356 | { Model_Ramses_MNCI, | 357 | { Model_Ramses_MNCI, |
357 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 358 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
358 | "devicebuttons/z_menu", | 359 | "devicebuttons/z_menu", |
359 | "QPE/TaskBar", "toggleMenu()", | 360 | "QPE/TaskBar", "toggleMenu()", |
360 | "QPE/TaskBar", "toggleStartMenu()" }, | 361 | "QPE/TaskBar", "toggleStartMenu()" }, |
361 | { Model_Ramses_MNCI, | 362 | { Model_Ramses_MNCI, |
362 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 363 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
363 | "devicebuttons/ipaq_home", | 364 | "devicebuttons/ipaq_home", |
364 | "QPE/Launcher", "home()", | 365 | "QPE/Launcher", "home()", |
365 | "buttonsettings", "raise()" }, | 366 | "buttonsettings", "raise()" }, |
366 | }; | 367 | }; |
367 | 368 | ||
368 | static QCString makeChannel ( const char *str ) | 369 | static QCString makeChannel ( const char *str ) |
369 | { | 370 | { |
370 | if ( str && !::strchr ( str, '/' )) | 371 | if ( str && !::strchr ( str, '/' )) |
371 | return QCString ( "QPE/Application/" ) + str; | 372 | return QCString ( "QPE/Application/" ) + str; |
372 | else | 373 | else |
373 | return str; | 374 | return str; |
374 | } | 375 | } |
375 | 376 | ||
376 | static inline bool isQWS() | 377 | static inline bool isQWS() |
377 | { | 378 | { |
378 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 379 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
379 | } | 380 | } |
380 | 381 | ||
381 | ODevice *ODevice::inst ( ) | 382 | ODevice *ODevice::inst ( ) |
382 | { | 383 | { |
383 | static ODevice *dev = 0; | 384 | static ODevice *dev = 0; |
384 | 385 | ||
385 | if ( !dev ) { | 386 | if ( !dev ) { |
386 | if ( QFile::exists ( "/proc/hal/model" )) | 387 | if ( QFile::exists ( "/proc/hal/model" )) |
387 | dev = new iPAQ ( ); | 388 | dev = new iPAQ ( ); |
388 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 389 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
389 | dev = new Zaurus ( ); | 390 | dev = new Zaurus ( ); |
390 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 391 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
391 | dev = new SIMpad ( ); | 392 | dev = new SIMpad ( ); |
392 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 393 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
393 | dev = new Ramses ( ); | 394 | dev = new Ramses ( ); |
394 | else | 395 | else |
395 | dev = new ODevice ( ); | 396 | dev = new ODevice ( ); |
396 | 397 | ||
397 | dev-> init ( ); | 398 | dev-> init ( ); |
398 | } | 399 | } |
399 | return dev; | 400 | return dev; |
400 | } | 401 | } |
401 | 402 | ||
402 | 403 | ||
403 | /************************************************** | 404 | /************************************************** |
404 | * | 405 | * |
405 | * common | 406 | * common |
406 | * | 407 | * |
407 | **************************************************/ | 408 | **************************************************/ |
408 | 409 | ||
409 | 410 | ||
410 | ODevice::ODevice ( ) | 411 | ODevice::ODevice ( ) |
411 | { | 412 | { |
412 | d = new ODeviceData; | 413 | d = new ODeviceData; |
413 | 414 | ||
414 | d-> m_modelstr = "Unknown"; | 415 | d-> m_modelstr = "Unknown"; |
415 | d-> m_model = Model_Unknown; | 416 | d-> m_model = Model_Unknown; |
416 | d-> m_vendorstr = "Unknown"; | 417 | d-> m_vendorstr = "Unknown"; |
417 | d-> m_vendor = Vendor_Unknown; | 418 | d-> m_vendor = Vendor_Unknown; |
418 | d-> m_systemstr = "Unknown"; | 419 | d-> m_systemstr = "Unknown"; |
419 | d-> m_system = System_Unknown; | 420 | d-> m_system = System_Unknown; |
420 | d-> m_sysverstr = "0.0"; | 421 | d-> m_sysverstr = "0.0"; |
421 | d-> m_rotation = Rot0; | 422 | d-> m_rotation = Rot0; |
422 | d-> m_direction = CW; | 423 | d-> m_direction = CW; |
423 | 424 | ||
424 | d-> m_holdtime = 1000; // 1000ms | 425 | d-> m_holdtime = 1000; // 1000ms |
425 | d-> m_buttons = 0; | 426 | d-> m_buttons = 0; |
427 | d-> m_cpu_frequencies = new QStrList; | ||
426 | } | 428 | } |
427 | 429 | ||
428 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
429 | { | 431 | { |
430 | if ( msg == "deviceButtonMappingChanged()" ) { | 432 | if ( msg == "deviceButtonMappingChanged()" ) { |
431 | reloadButtonMapping ( ); | 433 | reloadButtonMapping ( ); |
432 | } | 434 | } |
433 | } | 435 | } |
434 | 436 | ||
435 | void ODevice::init ( ) | 437 | void ODevice::init ( ) |
436 | { | 438 | { |
437 | } | 439 | } |
438 | 440 | ||
439 | /** | 441 | /** |
440 | * This method initialises the button mapping | 442 | * This method initialises the button mapping |
441 | */ | 443 | */ |
442 | void ODevice::initButtons ( ) | 444 | void ODevice::initButtons ( ) |
443 | { | 445 | { |
444 | if ( d-> m_buttons ) | 446 | if ( d-> m_buttons ) |
445 | return; | 447 | return; |
446 | 448 | ||
447 | // Simulation uses iPAQ 3660 device buttons | 449 | // Simulation uses iPAQ 3660 device buttons |
448 | 450 | ||
449 | qDebug ( "init Buttons" ); | 451 | qDebug ( "init Buttons" ); |
450 | d-> m_buttons = new QValueList <ODeviceButton>; | 452 | d-> m_buttons = new QValueList <ODeviceButton>; |
451 | 453 | ||
452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 454 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
453 | i_button *ib = ipaq_buttons + i; | 455 | i_button *ib = ipaq_buttons + i; |
454 | ODeviceButton b; | 456 | ODeviceButton b; |
455 | 457 | ||
456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 458 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
457 | b. setKeycode ( ib-> code ); | 459 | b. setKeycode ( ib-> code ); |
458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 460 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 461 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 462 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 463 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
462 | d-> m_buttons-> append ( b ); | 464 | d-> m_buttons-> append ( b ); |
463 | } | 465 | } |
464 | } | 466 | } |
465 | reloadButtonMapping ( ); | 467 | reloadButtonMapping ( ); |
466 | 468 | ||
467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
469 | } | 471 | } |
470 | 472 | ||
471 | ODevice::~ODevice ( ) | 473 | ODevice::~ODevice ( ) |
472 | { | 474 | { |
473 | delete d; | 475 | delete d; |
474 | } | 476 | } |
475 | 477 | ||
476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 478 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
477 | { | 479 | { |
478 | return false; | 480 | return false; |
479 | } | 481 | } |
480 | 482 | ||
481 | //#include <linux/apm_bios.h> | 483 | //#include <linux/apm_bios.h> |
482 | 484 | ||
483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 485 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
484 | 486 | ||
485 | /** | 487 | /** |
486 | * This method will try to suspend the device | 488 | * This method will try to suspend the device |
487 | * It only works if the user is the QWS Server and the apm application | 489 | * It only works if the user is the QWS Server and the apm application |
488 | * is installed. | 490 | * is installed. |
489 | * It tries to suspend and then waits some time cause some distributions | 491 | * It tries to suspend and then waits some time cause some distributions |
490 | * do have asynchronus apm implementations. | 492 | * do have asynchronus apm implementations. |
491 | * This method will either fail and return false or it'll suspend the | 493 | * This method will either fail and return false or it'll suspend the |
492 | * device and return once the device got woken up | 494 | * device and return once the device got woken up |
493 | * | 495 | * |
494 | * @return if the device got suspended | 496 | * @return if the device got suspended |
495 | */ | 497 | */ |
496 | bool ODevice::suspend ( ) | 498 | bool ODevice::suspend ( ) |
497 | { | 499 | { |
498 | qDebug("ODevice::suspend"); | 500 | qDebug("ODevice::suspend"); |
499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 501 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
500 | return false; | 502 | return false; |
501 | 503 | ||
502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 504 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
503 | return false; | 505 | return false; |
504 | 506 | ||
505 | bool res = false; | 507 | bool res = false; |
506 | 508 | ||
507 | struct timeval tvs, tvn; | 509 | struct timeval tvs, tvn; |
508 | ::gettimeofday ( &tvs, 0 ); | 510 | ::gettimeofday ( &tvs, 0 ); |
509 | 511 | ||
510 | ::sync ( ); // flush fs caches | 512 | ::sync ( ); // flush fs caches |
511 | res = ( ::system ( "apm --suspend" ) == 0 ); | 513 | res = ( ::system ( "apm --suspend" ) == 0 ); |
512 | 514 | ||
513 | // This is needed because the iPAQ apm implementation is asynchronous and we | 515 | // This is needed because the iPAQ apm implementation is asynchronous and we |
514 | // can not be sure when exactly the device is really suspended | 516 | // 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. | 517 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
516 | 518 | ||
517 | if ( res ) { | 519 | if ( res ) { |
518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 520 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
519 | ::usleep ( 200 * 1000 ); | 521 | ::usleep ( 200 * 1000 ); |
520 | ::gettimeofday ( &tvn, 0 ); | 522 | ::gettimeofday ( &tvn, 0 ); |
521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 523 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
@@ -680,192 +682,232 @@ void ODevice::alarmSound ( ) | |||
680 | 682 | ||
681 | if ( snd. isFinished ( )) | 683 | if ( snd. isFinished ( )) |
682 | snd. play ( ); | 684 | snd. play ( ); |
683 | #endif | 685 | #endif |
684 | } | 686 | } |
685 | 687 | ||
686 | /** | 688 | /** |
687 | * This plays a key sound | 689 | * This plays a key sound |
688 | */ | 690 | */ |
689 | void ODevice::keySound ( ) | 691 | void ODevice::keySound ( ) |
690 | { | 692 | { |
691 | #ifndef QT_NO_SOUND | 693 | #ifndef QT_NO_SOUND |
692 | static Sound snd ( "keysound" ); | 694 | static Sound snd ( "keysound" ); |
693 | 695 | ||
694 | if ( snd. isFinished ( )) | 696 | if ( snd. isFinished ( )) |
695 | snd. play ( ); | 697 | snd. play ( ); |
696 | #endif | 698 | #endif |
697 | } | 699 | } |
698 | 700 | ||
699 | /** | 701 | /** |
700 | * This plays a touch sound | 702 | * This plays a touch sound |
701 | */ | 703 | */ |
702 | void ODevice::touchSound ( ) | 704 | void ODevice::touchSound ( ) |
703 | { | 705 | { |
704 | #ifndef QT_NO_SOUND | 706 | #ifndef QT_NO_SOUND |
705 | static Sound snd ( "touchsound" ); | 707 | static Sound snd ( "touchsound" ); |
706 | 708 | ||
707 | if ( snd. isFinished ( )) | 709 | if ( snd. isFinished ( )) |
708 | snd. play ( ); | 710 | snd. play ( ); |
709 | #endif | 711 | #endif |
710 | } | 712 | } |
711 | 713 | ||
712 | /** | 714 | /** |
713 | * This method will return a list of leds | 715 | * This method will return a list of leds |
714 | * available on this device | 716 | * available on this device |
715 | * @return a list of LEDs. | 717 | * @return a list of LEDs. |
716 | */ | 718 | */ |
717 | QValueList <OLed> ODevice::ledList ( ) const | 719 | QValueList <OLed> ODevice::ledList ( ) const |
718 | { | 720 | { |
719 | return QValueList <OLed> ( ); | 721 | return QValueList <OLed> ( ); |
720 | } | 722 | } |
721 | 723 | ||
722 | /** | 724 | /** |
723 | * This does return the state of the LEDs | 725 | * This does return the state of the LEDs |
724 | */ | 726 | */ |
725 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 727 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
726 | { | 728 | { |
727 | return QValueList <OLedState> ( ); | 729 | return QValueList <OLedState> ( ); |
728 | } | 730 | } |
729 | 731 | ||
730 | /** | 732 | /** |
731 | * @return the state for a given OLed | 733 | * @return the state for a given OLed |
732 | */ | 734 | */ |
733 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 735 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
734 | { | 736 | { |
735 | return Led_Off; | 737 | return Led_Off; |
736 | } | 738 | } |
737 | 739 | ||
738 | /** | 740 | /** |
739 | * Set the state for a LED | 741 | * Set the state for a LED |
740 | * @param which Which OLed to use | 742 | * @param which Which OLed to use |
741 | * @param st The state to set | 743 | * @param st The state to set |
742 | * @return success or failure | 744 | * @return success or failure |
743 | */ | 745 | */ |
744 | bool ODevice::setLedState ( OLed which, OLedState st ) | 746 | bool ODevice::setLedState ( OLed which, OLedState st ) |
745 | { | 747 | { |
746 | Q_UNUSED( which ) | 748 | Q_UNUSED( which ) |
747 | Q_UNUSED( st ) | 749 | Q_UNUSED( st ) |
748 | return false; | 750 | return false; |
749 | } | 751 | } |
750 | 752 | ||
751 | /** | 753 | /** |
752 | * @return if the device has a light sensor | 754 | * @return if the device has a light sensor |
753 | */ | 755 | */ |
754 | bool ODevice::hasLightSensor ( ) const | 756 | bool ODevice::hasLightSensor ( ) const |
755 | { | 757 | { |
756 | return false; | 758 | return false; |
757 | } | 759 | } |
758 | 760 | ||
759 | /** | 761 | /** |
760 | * @return a value from the light senso | 762 | * @return a value from the light senso |
761 | */ | 763 | */ |
762 | int ODevice::readLightSensor ( ) | 764 | int ODevice::readLightSensor ( ) |
763 | { | 765 | { |
764 | return -1; | 766 | return -1; |
765 | } | 767 | } |
766 | 768 | ||
767 | /** | 769 | /** |
768 | * @return the light sensor resolution whatever that is ;) | 770 | * @return the light sensor resolution whatever that is ;) |
769 | */ | 771 | */ |
770 | int ODevice::lightSensorResolution ( ) const | 772 | int ODevice::lightSensorResolution ( ) const |
771 | { | 773 | { |
772 | return 0; | 774 | return 0; |
773 | } | 775 | } |
774 | 776 | ||
775 | /** | 777 | /** |
778 | * @return a list with valid CPU frequency | ||
779 | */ | ||
780 | QStrList &ODevice::cpuFrequencies ( ) const | ||
781 | { | ||
782 | qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies); | ||
783 | return *d->m_cpu_frequencies; | ||
784 | } | ||
785 | |||
786 | |||
787 | /** | ||
788 | * Set desired cpu frequency | ||
789 | * | ||
790 | * @param index index into d->m_cpu_frequencies of the frequency to be set | ||
791 | */ | ||
792 | bool ODevice::setCpuFrequency(uint index) | ||
793 | { | ||
794 | if (index >= d->m_cpu_frequencies->count()) | ||
795 | return false; | ||
796 | |||
797 | char *freq = d->m_cpu_frequencies->at(index); | ||
798 | qWarning("set freq to %s", freq); | ||
799 | |||
800 | //TODO: do the change in /proc/sys/cpu/0/speed | ||
801 | |||
802 | return false; | ||
803 | } | ||
804 | |||
805 | /** | ||
806 | * Returns current frequency index out of d->m_cpu_frequencies | ||
807 | */ | ||
808 | uint ODevice::cpuFrequency() const | ||
809 | { | ||
810 | // TODO: get freq from /proc/sys/cpu/0/speed and return index | ||
811 | |||
812 | return 0; | ||
813 | } | ||
814 | |||
815 | |||
816 | |||
817 | /** | ||
776 | * @return a list of hardware buttons | 818 | * @return a list of hardware buttons |
777 | */ | 819 | */ |
778 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 820 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
779 | { | 821 | { |
780 | initButtons ( ); | 822 | initButtons ( ); |
781 | 823 | ||
782 | return *d-> m_buttons; | 824 | return *d-> m_buttons; |
783 | } | 825 | } |
784 | 826 | ||
785 | /** | 827 | /** |
786 | * @return The amount of time that would count as a hold | 828 | * @return The amount of time that would count as a hold |
787 | */ | 829 | */ |
788 | uint ODevice::buttonHoldTime ( ) const | 830 | uint ODevice::buttonHoldTime ( ) const |
789 | { | 831 | { |
790 | return d-> m_holdtime; | 832 | return d-> m_holdtime; |
791 | } | 833 | } |
792 | 834 | ||
793 | /** | 835 | /** |
794 | * This method return a ODeviceButton for a key code | 836 | * This method return a ODeviceButton for a key code |
795 | * or 0 if no special hardware button is available for the device | 837 | * or 0 if no special hardware button is available for the device |
796 | * | 838 | * |
797 | * @return The devicebutton or 0l | 839 | * @return The devicebutton or 0l |
798 | * @see ODeviceButton | 840 | * @see ODeviceButton |
799 | */ | 841 | */ |
800 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 842 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
801 | { | 843 | { |
802 | initButtons ( ); | 844 | initButtons ( ); |
803 | 845 | ||
804 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 846 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
805 | if ( (*it). keycode ( ) == code ) | 847 | if ( (*it). keycode ( ) == code ) |
806 | return &(*it); | 848 | return &(*it); |
807 | } | 849 | } |
808 | return 0; | 850 | return 0; |
809 | } | 851 | } |
810 | 852 | ||
811 | void ODevice::reloadButtonMapping ( ) | 853 | void ODevice::reloadButtonMapping ( ) |
812 | { | 854 | { |
813 | initButtons ( ); | 855 | initButtons ( ); |
814 | 856 | ||
815 | Config cfg ( "ButtonSettings" ); | 857 | Config cfg ( "ButtonSettings" ); |
816 | 858 | ||
817 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 859 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
818 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 860 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
819 | QString group = "Button" + QString::number ( i ); | 861 | QString group = "Button" + QString::number ( i ); |
820 | 862 | ||
821 | QCString pch, hch; | 863 | QCString pch, hch; |
822 | QCString pm, hm; | 864 | QCString pm, hm; |
823 | QByteArray pdata, hdata; | 865 | QByteArray pdata, hdata; |
824 | 866 | ||
825 | if ( cfg. hasGroup ( group )) { | 867 | if ( cfg. hasGroup ( group )) { |
826 | cfg. setGroup ( group ); | 868 | cfg. setGroup ( group ); |
827 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 869 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
828 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 870 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
829 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 871 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
830 | 872 | ||
831 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 873 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
832 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 874 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
833 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 875 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
834 | } | 876 | } |
835 | 877 | ||
836 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 878 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
837 | 879 | ||
838 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 880 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
839 | } | 881 | } |
840 | } | 882 | } |
841 | 883 | ||
842 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 884 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
843 | { | 885 | { |
844 | initButtons ( ); | 886 | initButtons ( ); |
845 | 887 | ||
846 | QString mb_chan; | 888 | QString mb_chan; |
847 | 889 | ||
848 | if ( button >= (int) d-> m_buttons-> count ( )) | 890 | if ( button >= (int) d-> m_buttons-> count ( )) |
849 | return; | 891 | return; |
850 | 892 | ||
851 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 893 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
852 | b. setPressedAction ( action ); | 894 | b. setPressedAction ( action ); |
853 | 895 | ||
854 | mb_chan=b. pressedAction ( ). channel ( ); | 896 | mb_chan=b. pressedAction ( ). channel ( ); |
855 | 897 | ||
856 | Config buttonFile ( "ButtonSettings" ); | 898 | Config buttonFile ( "ButtonSettings" ); |
857 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 899 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
858 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 900 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
859 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 901 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
860 | 902 | ||
861 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 903 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
862 | 904 | ||
863 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 905 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
864 | } | 906 | } |
865 | 907 | ||
866 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 908 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
867 | { | 909 | { |
868 | initButtons ( ); | 910 | initButtons ( ); |
869 | 911 | ||
870 | if ( button >= (int) d-> m_buttons-> count ( )) | 912 | if ( button >= (int) d-> m_buttons-> count ( )) |
871 | return; | 913 | return; |
@@ -1857,246 +1899,259 @@ bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | |||
1857 | bool SIMpad::setSoftSuspend ( bool soft ) | 1899 | bool SIMpad::setSoftSuspend ( bool soft ) |
1858 | { | 1900 | { |
1859 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 1901 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
1860 | return false; | 1902 | return false; |
1861 | } | 1903 | } |
1862 | 1904 | ||
1863 | 1905 | ||
1864 | bool SIMpad::setDisplayStatus ( bool on ) | 1906 | bool SIMpad::setDisplayStatus ( bool on ) |
1865 | { | 1907 | { |
1866 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 1908 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
1867 | 1909 | ||
1868 | bool res = false; | 1910 | bool res = false; |
1869 | int fd; | 1911 | int fd; |
1870 | 1912 | ||
1871 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 1913 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
1872 | 1914 | ||
1873 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 1915 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
1874 | res = ( ::system( (const char*) cmdline ) == 0 ); | 1916 | res = ( ::system( (const char*) cmdline ) == 0 ); |
1875 | ::close ( fd ); | 1917 | ::close ( fd ); |
1876 | } | 1918 | } |
1877 | return res; | 1919 | return res; |
1878 | } | 1920 | } |
1879 | 1921 | ||
1880 | 1922 | ||
1881 | bool SIMpad::setDisplayBrightness ( int bright ) | 1923 | bool SIMpad::setDisplayBrightness ( int bright ) |
1882 | { | 1924 | { |
1883 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 1925 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
1884 | bool res = false; | 1926 | bool res = false; |
1885 | int fd; | 1927 | int fd; |
1886 | 1928 | ||
1887 | if ( bright > 255 ) | 1929 | if ( bright > 255 ) |
1888 | bright = 255; | 1930 | bright = 255; |
1889 | if ( bright < 0 ) | 1931 | if ( bright < 0 ) |
1890 | bright = 0; | 1932 | bright = 0; |
1891 | 1933 | ||
1892 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1934 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1893 | int value = 255 - bright; | 1935 | int value = 255 - bright; |
1894 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1936 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1895 | value = value << 8; | 1937 | value = value << 8; |
1896 | value += mask; | 1938 | value += mask; |
1897 | char writeCommand[100]; | 1939 | char writeCommand[100]; |
1898 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1940 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1899 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1941 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1900 | ::close ( fd ); | 1942 | ::close ( fd ); |
1901 | } | 1943 | } |
1902 | return res; | 1944 | return res; |
1903 | } | 1945 | } |
1904 | 1946 | ||
1905 | 1947 | ||
1906 | int SIMpad::displayBrightnessResolution ( ) const | 1948 | int SIMpad::displayBrightnessResolution ( ) const |
1907 | { | 1949 | { |
1908 | switch ( model ( )) { | 1950 | switch ( model ( )) { |
1909 | case Model_SIMpad_CL4: | 1951 | case Model_SIMpad_CL4: |
1910 | case Model_SIMpad_SL4: | 1952 | case Model_SIMpad_SL4: |
1911 | case Model_SIMpad_SLC: | 1953 | case Model_SIMpad_SLC: |
1912 | case Model_SIMpad_TSinus: | 1954 | case Model_SIMpad_TSinus: |
1913 | return 255; //TODO find out if this is save | 1955 | return 255; //TODO find out if this is save |
1914 | 1956 | ||
1915 | default: | 1957 | default: |
1916 | return 2; | 1958 | return 2; |
1917 | } | 1959 | } |
1918 | } | 1960 | } |
1919 | 1961 | ||
1920 | /************************************************** | 1962 | /************************************************** |
1921 | * | 1963 | * |
1922 | * Ramses | 1964 | * Ramses |
1923 | * | 1965 | * |
1924 | **************************************************/ | 1966 | **************************************************/ |
1925 | 1967 | ||
1926 | void Ramses::init() | 1968 | void Ramses::init() |
1927 | { | 1969 | { |
1928 | d->m_vendorstr = "M und N"; | 1970 | d->m_vendorstr = "M und N"; |
1929 | d->m_vendor = Vendor_MundN; | 1971 | d->m_vendor = Vendor_MundN; |
1930 | 1972 | ||
1931 | QFile f("/proc/sys/board/ramses"); | 1973 | QFile f("/proc/sys/board/ramses"); |
1932 | 1974 | ||
1933 | d->m_modelstr = "Ramses"; | 1975 | d->m_modelstr = "Ramses"; |
1934 | d->m_model = Model_Ramses_MNCI; | 1976 | d->m_model = Model_Ramses_MNCI; |
1935 | 1977 | ||
1936 | d->m_rotation = Rot0; | 1978 | d->m_rotation = Rot0; |
1937 | d->m_holdtime = 1000; | 1979 | d->m_holdtime = 1000; |
1938 | 1980 | ||
1939 | f.setName("/etc/oz_version"); | 1981 | f.setName("/etc/oz_version"); |
1940 | 1982 | ||
1941 | if (f.open(IO_ReadOnly)) { | 1983 | if (f.open(IO_ReadOnly)) { |
1942 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1984 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1943 | d->m_system = System_OpenZaurus; | 1985 | d->m_system = System_OpenZaurus; |
1944 | 1986 | ||
1945 | QTextStream ts(&f); | 1987 | QTextStream ts(&f); |
1946 | ts.setDevice(&f); | 1988 | ts.setDevice(&f); |
1947 | d->m_sysverstr = ts.readLine(); | 1989 | d->m_sysverstr = ts.readLine(); |
1948 | f.close(); | 1990 | f.close(); |
1949 | } | 1991 | } |
1950 | 1992 | ||
1951 | m_power_timer = 0; | 1993 | m_power_timer = 0; |
1952 | 1994 | ||
1995 | qWarning("adding freq"); | ||
1996 | d->m_cpu_frequencies->append("100"); | ||
1997 | d->m_cpu_frequencies->append("200"); | ||
1998 | d->m_cpu_frequencies->append("300"); | ||
1999 | d->m_cpu_frequencies->append("400"); | ||
1953 | } | 2000 | } |
1954 | 2001 | ||
1955 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2002 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
1956 | { | 2003 | { |
1957 | Q_UNUSED( keycode ); | 2004 | Q_UNUSED( keycode ); |
1958 | Q_UNUSED( modifiers ); | 2005 | Q_UNUSED( modifiers ); |
1959 | Q_UNUSED( isPress ); | 2006 | Q_UNUSED( isPress ); |
1960 | Q_UNUSED( autoRepeat ); | 2007 | Q_UNUSED( autoRepeat ); |
1961 | return false; | 2008 | return false; |
1962 | } | 2009 | } |
1963 | 2010 | ||
1964 | void Ramses::timerEvent(QTimerEvent *) | 2011 | void Ramses::timerEvent(QTimerEvent *) |
1965 | { | 2012 | { |
1966 | killTimer(m_power_timer); | 2013 | killTimer(m_power_timer); |
1967 | m_power_timer = 0; | 2014 | m_power_timer = 0; |
1968 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2015 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
1969 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2016 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
1970 | } | 2017 | } |
1971 | 2018 | ||
1972 | 2019 | ||
1973 | bool Ramses::setSoftSuspend(bool soft) | 2020 | bool Ramses::setSoftSuspend(bool soft) |
1974 | { | 2021 | { |
1975 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2022 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
1976 | #if 0 | 2023 | #if 0 |
1977 | bool res = false; | 2024 | bool res = false; |
1978 | int fd; | 2025 | int fd; |
1979 | 2026 | ||
1980 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 2027 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
1981 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 2028 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
1982 | 2029 | ||
1983 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 2030 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
1984 | 2031 | ||
1985 | if (sources >= 0) { | 2032 | if (sources >= 0) { |
1986 | if (soft) | 2033 | if (soft) |
1987 | sources &= ~APM_EVT_POWER_BUTTON; | 2034 | sources &= ~APM_EVT_POWER_BUTTON; |
1988 | else | 2035 | else |
1989 | sources |= APM_EVT_POWER_BUTTON; | 2036 | sources |= APM_EVT_POWER_BUTTON; |
1990 | 2037 | ||
1991 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 2038 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
1992 | res = true; | 2039 | res = true; |
1993 | else | 2040 | else |
1994 | perror("APM_IOCGEVTSRC"); | 2041 | perror("APM_IOCGEVTSRC"); |
1995 | } | 2042 | } |
1996 | else | 2043 | else |
1997 | perror("APM_IOCGEVTSRC"); | 2044 | perror("APM_IOCGEVTSRC"); |
1998 | 2045 | ||
1999 | ::close(fd); | 2046 | ::close(fd); |
2000 | } | 2047 | } |
2001 | else | 2048 | else |
2002 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2049 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
2003 | 2050 | ||
2004 | return res; | 2051 | return res; |
2005 | #else | 2052 | #else |
2006 | return true; | 2053 | return true; |
2007 | #endif | 2054 | #endif |
2008 | } | 2055 | } |
2009 | 2056 | ||
2010 | bool Ramses::suspend ( ) | 2057 | bool Ramses::suspend ( ) |
2011 | { | 2058 | { |
2012 | qDebug("Ramses::suspend"); | 2059 | qDebug("Ramses::suspend"); |
2060 | return false; | ||
2013 | } | 2061 | } |
2014 | 2062 | ||
2015 | /** | 2063 | /** |
2016 | * This sets the display on or off | 2064 | * This sets the display on or off |
2017 | */ | 2065 | */ |
2018 | bool Ramses::setDisplayStatus(bool on) | 2066 | bool Ramses::setDisplayStatus(bool on) |
2019 | { | 2067 | { |
2020 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2068 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2021 | #if 0 | 2069 | #if 0 |
2022 | bool res = false; | 2070 | bool res = false; |
2023 | int fd; | 2071 | int fd; |
2024 | 2072 | ||
2025 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2073 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2026 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2074 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2027 | ::close(fd); | 2075 | ::close(fd); |
2028 | } | 2076 | } |
2029 | return res; | 2077 | return res; |
2030 | #else | 2078 | #else |
2031 | return true; | 2079 | return true; |
2032 | #endif | 2080 | #endif |
2033 | } | 2081 | } |
2034 | 2082 | ||
2035 | 2083 | ||
2036 | /* | 2084 | /* |
2037 | * We get something between 0..255 into us | 2085 | * We get something between 0..255 into us |
2038 | */ | 2086 | */ |
2039 | bool Ramses::setDisplayBrightness(int bright) | 2087 | bool Ramses::setDisplayBrightness(int bright) |
2040 | { | 2088 | { |
2041 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2089 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2042 | bool res = false; | 2090 | bool res = false; |
2043 | int fd; | 2091 | int fd; |
2044 | 2092 | ||
2045 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2093 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2046 | 2094 | ||
2047 | if (bright > 255 ) | 2095 | if (bright > 255 ) |
2048 | bright = 255; | 2096 | bright = 255; |
2049 | if (bright < 0) | 2097 | if (bright < 0) |
2050 | bright = 0; | 2098 | bright = 0; |
2051 | bright = 500-(bright * 500 / 255); | ||
2052 | 2099 | ||
2100 | // Turn backlight completely off | ||
2101 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | ||
2102 | char writeCommand[10]; | ||
2103 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | ||
2104 | res = (::write(fd, writeCommand, count) != -1); | ||
2105 | ::close(fd); | ||
2106 | } | ||
2107 | |||
2108 | // scale backlight brightness to hardware | ||
2109 | bright = 500-(bright * 500 / 255); | ||
2053 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2110 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2054 | qDebug(" %d -> pwm1", bright); | 2111 | qDebug(" %d -> pwm1", bright); |
2055 | char writeCommand[100]; | 2112 | char writeCommand[100]; |
2056 | const int count = sprintf(writeCommand, "%d\n", bright); | 2113 | const int count = sprintf(writeCommand, "%d\n", bright); |
2057 | res = (::write(fd, writeCommand, count) != -1); | 2114 | res = (::write(fd, writeCommand, count) != -1); |
2058 | ::close(fd); | 2115 | ::close(fd); |
2059 | } else { | ||
2060 | qWarning("no write"); | ||
2061 | } | 2116 | } |
2062 | return res; | 2117 | return res; |
2063 | } | 2118 | } |
2064 | 2119 | ||
2065 | 2120 | ||
2066 | int Ramses::displayBrightnessResolution() const | 2121 | int Ramses::displayBrightnessResolution() const |
2067 | { | 2122 | { |
2068 | return 32; | 2123 | return 32; |
2069 | } | 2124 | } |
2070 | 2125 | ||
2071 | bool Ramses::setDisplayContrast(int contr) | 2126 | bool Ramses::setDisplayContrast(int contr) |
2072 | { | 2127 | { |
2073 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2128 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2074 | bool res = false; | 2129 | bool res = false; |
2075 | int fd; | 2130 | int fd; |
2076 | 2131 | ||
2077 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2132 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2078 | 2133 | ||
2079 | if (contr > 255 ) | 2134 | if (contr > 255 ) |
2080 | contr = 255; | 2135 | contr = 255; |
2081 | if (contr < 0) | 2136 | if (contr < 0) |
2082 | contr = 0; | 2137 | contr = 0; |
2083 | contr = 90 - (contr * 20 / 255); | 2138 | contr = 90 - (contr * 20 / 255); |
2084 | 2139 | ||
2085 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2140 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2086 | qDebug(" %d -> pwm0", contr); | 2141 | qDebug(" %d -> pwm0", contr); |
2087 | char writeCommand[100]; | 2142 | char writeCommand[100]; |
2088 | const int count = sprintf(writeCommand, "%d\n", contr); | 2143 | const int count = sprintf(writeCommand, "%d\n", contr); |
2089 | res = (::write(fd, writeCommand, count) != -1); | 2144 | res = (::write(fd, writeCommand, count) != -1); |
2090 | res = true; | 2145 | res = true; |
2091 | ::close(fd); | 2146 | ::close(fd); |
2092 | } else { | 2147 | } else { |
2093 | qWarning("no write"); | 2148 | qWarning("no write"); |
2094 | } | 2149 | } |
2095 | return res; | 2150 | return res; |
2096 | } | 2151 | } |
2097 | 2152 | ||
2098 | 2153 | ||
2099 | int Ramses::displayContrastResolution() const | 2154 | int Ramses::displayContrastResolution() const |
2100 | { | 2155 | { |
2101 | return 20; | 2156 | return 20; |
2102 | } | 2157 | } |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 0974e8d..7f6f856 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,245 +1,249 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _LIBOPIE_ODEVICE_H_ | 20 | #ifndef _LIBOPIE_ODEVICE_H_ |
21 | #define _LIBOPIE_ODEVICE_H_ | 21 | #define _LIBOPIE_ODEVICE_H_ |
22 | 22 | ||
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qnamespace.h> | 25 | #include <qnamespace.h> |
26 | #include <qstrlist.h> | ||
26 | 27 | ||
27 | #include <opie/odevicebutton.h> | 28 | #include <opie/odevicebutton.h> |
28 | 29 | ||
29 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 30 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
30 | 31 | ||
31 | class ODeviceData; | 32 | class ODeviceData; |
32 | 33 | ||
33 | namespace Opie { | 34 | namespace Opie { |
34 | 35 | ||
35 | /** | 36 | /** |
36 | * The available devices | 37 | * The available devices |
37 | */ | 38 | */ |
38 | enum OModel { | 39 | enum OModel { |
39 | Model_Unknown, // = 0 | 40 | Model_Unknown, // = 0 |
40 | 41 | ||
41 | Model_Series_Mask = 0xff000000, | 42 | Model_Series_Mask = 0xff000000, |
42 | 43 | ||
43 | Model_iPAQ = ( 1 << 24 ), | 44 | Model_iPAQ = ( 1 << 24 ), |
44 | 45 | ||
45 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 46 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
46 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 47 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
47 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 48 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
48 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 49 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
49 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 50 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
50 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 51 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
51 | 52 | ||
52 | Model_Zaurus = ( 2 << 24 ), | 53 | Model_Zaurus = ( 2 << 24 ), |
53 | 54 | ||
54 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 55 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
55 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 56 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
56 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 57 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
57 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 58 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
58 | Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), | 59 | Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), |
59 | 60 | ||
60 | Model_SIMpad = ( 3 << 24 ), | 61 | Model_SIMpad = ( 3 << 24 ), |
61 | 62 | ||
62 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 63 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
63 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 64 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
64 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 65 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
65 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 66 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
66 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 67 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
67 | 68 | ||
68 | Model_Ramses = ( 4 << 24 ), | 69 | Model_Ramses = ( 4 << 24 ), |
69 | 70 | ||
70 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 71 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
71 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 72 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
72 | }; | 73 | }; |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * The vendor of the device | 76 | * The vendor of the device |
76 | */ | 77 | */ |
77 | enum OVendor { | 78 | enum OVendor { |
78 | Vendor_Unknown, | 79 | Vendor_Unknown, |
79 | 80 | ||
80 | Vendor_HP, | 81 | Vendor_HP, |
81 | Vendor_Sharp, | 82 | Vendor_Sharp, |
82 | Vendor_SIEMENS, | 83 | Vendor_SIEMENS, |
83 | Vendor_MundN, | 84 | Vendor_MundN, |
84 | }; | 85 | }; |
85 | 86 | ||
86 | /** | 87 | /** |
87 | * The System used | 88 | * The System used |
88 | */ | 89 | */ |
89 | enum OSystem { | 90 | enum OSystem { |
90 | System_Unknown, | 91 | System_Unknown, |
91 | 92 | ||
92 | System_Familiar, | 93 | System_Familiar, |
93 | System_Zaurus, | 94 | System_Zaurus, |
94 | System_OpenZaurus | 95 | System_OpenZaurus |
95 | }; | 96 | }; |
96 | 97 | ||
97 | enum OLedState { | 98 | enum OLedState { |
98 | Led_Off, | 99 | Led_Off, |
99 | Led_On, | 100 | Led_On, |
100 | Led_BlinkSlow, | 101 | Led_BlinkSlow, |
101 | Led_BlinkFast | 102 | Led_BlinkFast |
102 | }; | 103 | }; |
103 | 104 | ||
104 | enum OLed { | 105 | enum OLed { |
105 | Led_Mail, | 106 | Led_Mail, |
106 | Led_Power, | 107 | Led_Power, |
107 | Led_BlueTooth | 108 | Led_BlueTooth |
108 | }; | 109 | }; |
109 | 110 | ||
110 | enum OHardKey { | 111 | enum OHardKey { |
111 | HardKey_Datebook = Qt::Key_F9, | 112 | HardKey_Datebook = Qt::Key_F9, |
112 | HardKey_Contacts = Qt::Key_F10, | 113 | HardKey_Contacts = Qt::Key_F10, |
113 | HardKey_Menu = Qt::Key_F11, | 114 | HardKey_Menu = Qt::Key_F11, |
114 | HardKey_Home = Qt::Key_F12, | 115 | HardKey_Home = Qt::Key_F12, |
115 | HardKey_Mail = Qt::Key_F13, | 116 | HardKey_Mail = Qt::Key_F13, |
116 | HardKey_Record = Qt::Key_F24, | 117 | HardKey_Record = Qt::Key_F24, |
117 | HardKey_Suspend = Qt::Key_F34, | 118 | HardKey_Suspend = Qt::Key_F34, |
118 | HardKey_Backlight = Qt::Key_F35, | 119 | HardKey_Backlight = Qt::Key_F35, |
119 | }; | 120 | }; |
120 | 121 | ||
121 | enum ODirection { | 122 | enum ODirection { |
122 | CW = 0, | 123 | CW = 0, |
123 | CCW = 1, | 124 | CCW = 1, |
124 | Flip = 2, | 125 | Flip = 2, |
125 | }; | 126 | }; |
126 | 127 | ||
127 | /** | 128 | /** |
128 | * A singleton which gives informations about device specefic option | 129 | * A singleton which gives informations about device specefic option |
129 | * like the Hardware used, LEDs, the Base Distribution and | 130 | * like the Hardware used, LEDs, the Base Distribution and |
130 | * hardware key mappings. | 131 | * hardware key mappings. |
131 | * | 132 | * |
132 | * @short A small class for device specefic options | 133 | * @short A small class for device specefic options |
133 | * @see QObject | 134 | * @see QObject |
134 | * @author Robert Griebl | 135 | * @author Robert Griebl |
135 | * @version 1.0 | 136 | * @version 1.0 |
136 | */ | 137 | */ |
137 | class ODevice : public QObject { | 138 | class ODevice : public QObject { |
138 | Q_OBJECT | 139 | Q_OBJECT |
139 | 140 | ||
140 | private: | 141 | private: |
141 | /* disable copy */ | 142 | /* disable copy */ |
142 | ODevice ( const ODevice & ); | 143 | ODevice ( const ODevice & ); |
143 | 144 | ||
144 | protected: | 145 | protected: |
145 | ODevice ( ); | 146 | ODevice ( ); |
146 | virtual void init ( ); | 147 | virtual void init ( ); |
147 | virtual void initButtons ( ); | 148 | virtual void initButtons ( ); |
148 | 149 | ||
149 | ODeviceData *d; | 150 | ODeviceData *d; |
150 | 151 | ||
151 | public: | 152 | public: |
152 | // sandman do we want to allow destructions? -zecke? | 153 | // sandman do we want to allow destructions? -zecke? |
153 | virtual ~ODevice ( ); | 154 | virtual ~ODevice ( ); |
154 | 155 | ||
155 | |||
156 | static ODevice *inst ( ); | 156 | static ODevice *inst ( ); |
157 | 157 | ||
158 | // information | 158 | // information |
159 | 159 | ||
160 | QString modelString ( ) const; | 160 | QString modelString ( ) const; |
161 | OModel model ( ) const; | 161 | OModel model ( ) const; |
162 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 162 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
163 | 163 | ||
164 | QString vendorString ( ) const; | 164 | QString vendorString ( ) const; |
165 | OVendor vendor ( ) const; | 165 | OVendor vendor ( ) const; |
166 | 166 | ||
167 | QString systemString ( ) const; | 167 | QString systemString ( ) const; |
168 | OSystem system ( ) const; | 168 | OSystem system ( ) const; |
169 | 169 | ||
170 | QString systemVersionString ( ) const; | 170 | QString systemVersionString ( ) const; |
171 | 171 | ||
172 | Transformation rotation ( ) const; | 172 | Transformation rotation ( ) const; |
173 | ODirection direction ( ) const; | 173 | ODirection direction ( ) const; |
174 | 174 | ||
175 | // system | 175 | // system |
176 | 176 | ||
177 | virtual bool setSoftSuspend ( bool on ); | 177 | virtual bool setSoftSuspend ( bool on ); |
178 | virtual bool suspend ( ); | 178 | virtual bool suspend ( ); |
179 | 179 | ||
180 | virtual bool setDisplayStatus ( bool on ); | 180 | virtual bool setDisplayStatus ( bool on ); |
181 | virtual bool setDisplayBrightness ( int brightness ); | 181 | virtual bool setDisplayBrightness ( int brightness ); |
182 | virtual int displayBrightnessResolution ( ) const; | 182 | virtual int displayBrightnessResolution ( ) const; |
183 | virtual bool setDisplayContrast ( int contrast ); | 183 | virtual bool setDisplayContrast ( int contrast ); |
184 | virtual int displayContrastResolution ( ) const; | 184 | virtual int displayContrastResolution ( ) const; |
185 | 185 | ||
186 | // input / output | 186 | // input / output |
187 | //FIXME playAlarmSound and al might be better -zecke | 187 | //FIXME playAlarmSound and al might be better -zecke |
188 | virtual void alarmSound ( ); | 188 | virtual void alarmSound ( ); |
189 | virtual void keySound ( ); | 189 | virtual void keySound ( ); |
190 | virtual void touchSound ( ); | 190 | virtual void touchSound ( ); |
191 | 191 | ||
192 | virtual QValueList <OLed> ledList ( ) const; | 192 | virtual QValueList <OLed> ledList ( ) const; |
193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
194 | virtual OLedState ledState ( OLed led ) const; | 194 | virtual OLedState ledState ( OLed led ) const; |
195 | virtual bool setLedState ( OLed led, OLedState st ); | 195 | virtual bool setLedState ( OLed led, OLedState st ); |
196 | 196 | ||
197 | virtual bool hasLightSensor ( ) const; | 197 | virtual bool hasLightSensor ( ) const; |
198 | virtual int readLightSensor ( ); | 198 | virtual int readLightSensor ( ); |
199 | virtual int lightSensorResolution ( ) const; | 199 | virtual int lightSensorResolution ( ) const; |
200 | 200 | ||
201 | QStrList &cpuFrequencies() const; | ||
202 | bool setCpuFrequency(uint index); | ||
203 | uint cpuFrequency() const; | ||
204 | |||
201 | /** | 205 | /** |
202 | * Returns the available buttons on this device. The number and location | 206 | * Returns the available buttons on this device. The number and location |
203 | * of buttons will vary depending on the device. Button numbers will be assigned | 207 | * of buttons will vary depending on the device. Button numbers will be assigned |
204 | * by the device manufacturer and will be from most preferred button to least preffered | 208 | * by the device manufacturer and will be from most preferred button to least preffered |
205 | * button. Note that this list only contains "user mappable" buttons. | 209 | * button. Note that this list only contains "user mappable" buttons. |
206 | */ | 210 | */ |
207 | const QValueList<ODeviceButton> &buttons ( ); | 211 | const QValueList<ODeviceButton> &buttons ( ); |
208 | 212 | ||
209 | /** | 213 | /** |
210 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 214 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
211 | * returns 0L | 215 | * returns 0L |
212 | */ | 216 | */ |
213 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 217 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
214 | 218 | ||
215 | /** | 219 | /** |
216 | * Reassigns the pressed action for \a button. To return to the factory | 220 | * Reassigns the pressed action for \a button. To return to the factory |
217 | * default pass an empty string as \a qcopMessage. | 221 | * default pass an empty string as \a qcopMessage. |
218 | */ | 222 | */ |
219 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 223 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
220 | 224 | ||
221 | /** | 225 | /** |
222 | * Reassigns the held action for \a button. To return to the factory | 226 | * Reassigns the held action for \a button. To return to the factory |
223 | * default pass an empty string as \a qcopMessage. | 227 | * default pass an empty string as \a qcopMessage. |
224 | */ | 228 | */ |
225 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 229 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
226 | 230 | ||
227 | /** | 231 | /** |
228 | * How long (in ms) you have to press a button for a "hold" action | 232 | * How long (in ms) you have to press a button for a "hold" action |
229 | */ | 233 | */ |
230 | uint buttonHoldTime ( ) const; | 234 | uint buttonHoldTime ( ) const; |
231 | 235 | ||
232 | signals: | 236 | signals: |
233 | void buttonMappingChanged ( ); | 237 | void buttonMappingChanged ( ); |
234 | 238 | ||
235 | private slots: | 239 | private slots: |
236 | void systemMessage ( const QCString &, const QByteArray & ); | 240 | void systemMessage ( const QCString &, const QByteArray & ); |
237 | 241 | ||
238 | protected: | 242 | protected: |
239 | void reloadButtonMapping ( ); | 243 | void reloadButtonMapping ( ); |
240 | }; | 244 | }; |
241 | 245 | ||
242 | } | 246 | } |
243 | 247 | ||
244 | #endif | 248 | #endif |
245 | 249 | ||