author | harlekin <harlekin> | 2003-04-10 21:19:45 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-04-10 21:19:45 (UTC) |
commit | b44d3aff66e7f520f6e0c08cb201cfe00994dbc5 (patch) (unidiff) | |
tree | 3356fc83d1feb2e577fc26d58f2fd9804523fa40 | |
parent | 6f7b120de8f4b883e709386882f3fe8ed925d0da (diff) | |
download | opie-b44d3aff66e7f520f6e0c08cb201cfe00994dbc5.zip opie-b44d3aff66e7f520f6e0c08cb201cfe00994dbc5.tar.gz opie-b44d3aff66e7f520f6e0c08cb201cfe00994dbc5.tar.bz2 |
openembedded/ipaq name
-rw-r--r-- | libopie/odevice.cpp | 232 |
1 files changed, 124 insertions, 108 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index cea4f35..9b2a954 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -44,144 +44,144 @@ | |||
44 | 44 | ||
45 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 45 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
46 | 46 | ||
47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
51 | 51 | ||
52 | using namespace Opie; | 52 | using namespace Opie; |
53 | 53 | ||
54 | class ODeviceData { | 54 | class ODeviceData { |
55 | public: | 55 | public: |
56 | bool m_qwsserver; | 56 | bool m_qwsserver; |
57 | 57 | ||
58 | QString m_vendorstr; | 58 | QString m_vendorstr; |
59 | OVendor m_vendor; | 59 | OVendor m_vendor; |
60 | 60 | ||
61 | QString m_modelstr; | 61 | QString m_modelstr; |
62 | OModel m_model; | 62 | OModel m_model; |
63 | 63 | ||
64 | QString m_systemstr; | 64 | QString m_systemstr; |
65 | OSystem m_system; | 65 | OSystem m_system; |
66 | 66 | ||
67 | QString m_sysverstr; | 67 | QString m_sysverstr; |
68 | 68 | ||
69 | Transformation m_rotation; | 69 | Transformation m_rotation; |
70 | 70 | ||
71 | QValueList <ODeviceButton> *m_buttons; | 71 | QValueList <ODeviceButton> *m_buttons; |
72 | uint m_holdtime; | 72 | uint m_holdtime; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
77 | protected: | 77 | protected: |
78 | virtual void init ( ); | 78 | virtual void init ( ); |
79 | virtual void initButtons ( ); | 79 | virtual void initButtons ( ); |
80 | 80 | ||
81 | public: | 81 | public: |
82 | virtual bool setSoftSuspend ( bool soft ); | 82 | virtual bool setSoftSuspend ( bool soft ); |
83 | 83 | ||
84 | virtual bool setDisplayBrightness ( int b ); | 84 | virtual bool setDisplayBrightness ( int b ); |
85 | virtual int displayBrightnessResolution ( ) const; | 85 | virtual int displayBrightnessResolution ( ) const; |
86 | 86 | ||
87 | virtual void alarmSound ( ); | 87 | virtual void alarmSound ( ); |
88 | 88 | ||
89 | virtual QValueList <OLed> ledList ( ) const; | 89 | virtual QValueList <OLed> ledList ( ) const; |
90 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 90 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
91 | virtual OLedState ledState ( OLed led ) const; | 91 | virtual OLedState ledState ( OLed led ) const; |
92 | virtual bool setLedState ( OLed led, OLedState st ); | 92 | virtual bool setLedState ( OLed led, OLedState st ); |
93 | 93 | ||
94 | virtual bool hasLightSensor ( ) const; | 94 | virtual bool hasLightSensor ( ) const; |
95 | virtual int readLightSensor ( ); | 95 | virtual int readLightSensor ( ); |
96 | virtual int lightSensorResolution ( ) const; | 96 | virtual int lightSensorResolution ( ) const; |
97 | 97 | ||
98 | protected: | 98 | protected: |
99 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 99 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
100 | virtual void timerEvent ( QTimerEvent *te ); | 100 | virtual void timerEvent ( QTimerEvent *te ); |
101 | 101 | ||
102 | int m_power_timer; | 102 | int m_power_timer; |
103 | 103 | ||
104 | OLedState m_leds [2]; | 104 | OLedState m_leds [2]; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | class Zaurus : public ODevice { | 107 | class Zaurus : public ODevice { |
108 | protected: | 108 | protected: |
109 | virtual void init ( ); | 109 | virtual void init ( ); |
110 | virtual void initButtons ( ); | 110 | virtual void initButtons ( ); |
111 | 111 | ||
112 | public: | 112 | public: |
113 | virtual bool setSoftSuspend ( bool soft ); | 113 | virtual bool setSoftSuspend ( bool soft ); |
114 | 114 | ||
115 | virtual bool setDisplayBrightness ( int b ); | 115 | virtual bool setDisplayBrightness ( int b ); |
116 | virtual int displayBrightnessResolution ( ) const; | 116 | virtual int displayBrightnessResolution ( ) const; |
117 | 117 | ||
118 | virtual void alarmSound ( ); | 118 | virtual void alarmSound ( ); |
119 | virtual void keySound ( ); | 119 | virtual void keySound ( ); |
120 | virtual void touchSound ( ); | 120 | virtual void touchSound ( ); |
121 | 121 | ||
122 | virtual QValueList <OLed> ledList ( ) const; | 122 | virtual QValueList <OLed> ledList ( ) const; |
123 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 123 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
124 | virtual OLedState ledState ( OLed led ) const; | 124 | virtual OLedState ledState ( OLed led ) const; |
125 | virtual bool setLedState ( OLed led, OLedState st ); | 125 | virtual bool setLedState ( OLed led, OLedState st ); |
126 | 126 | ||
127 | protected: | 127 | protected: |
128 | virtual void buzzer ( int snd ); | 128 | virtual void buzzer ( int snd ); |
129 | 129 | ||
130 | OLedState m_leds [1]; | 130 | OLedState m_leds [1]; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | 133 | ||
134 | struct i_button { | 134 | struct i_button { |
135 | uint model; | 135 | uint model; |
136 | Qt::Key code; | 136 | Qt::Key code; |
137 | char *utext; | 137 | char *utext; |
138 | char *pix; | 138 | char *pix; |
139 | char *fpressedservice; | 139 | char *fpressedservice; |
140 | char *fpressedaction; | 140 | char *fpressedaction; |
141 | char *fheldservice; | 141 | char *fheldservice; |
142 | char *fheldaction; | 142 | char *fheldaction; |
143 | } ipaq_buttons [] = { | 143 | } ipaq_buttons [] = { |
144 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 144 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
145 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 145 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
146 | "devicebuttons/ipaq_calendar", | 146 | "devicebuttons/ipaq_calendar", |
147 | "datebook", "nextView()", | 147 | "datebook", "nextView()", |
148 | "today", "raise()" }, | 148 | "today", "raise()" }, |
149 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 149 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
150 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 150 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
151 | "devicebuttons/ipaq_contact", | 151 | "devicebuttons/ipaq_contact", |
152 | "addressbook", "raise()", | 152 | "addressbook", "raise()", |
153 | "addressbook", "beamBusinessCard()" }, | 153 | "addressbook", "beamBusinessCard()" }, |
154 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 154 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
155 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 155 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
156 | "devicebuttons/ipaq_menu", | 156 | "devicebuttons/ipaq_menu", |
157 | "QPE/TaskBar", "toggleMenu()", | 157 | "QPE/TaskBar", "toggleMenu()", |
158 | "QPE/TaskBar", "toggleStartMenu()" }, | 158 | "QPE/TaskBar", "toggleStartMenu()" }, |
159 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 159 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
160 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 160 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
161 | "devicebuttons/ipaq_mail", | 161 | "devicebuttons/ipaq_mail", |
162 | "mail", "raise()", | 162 | "mail", "raise()", |
163 | "mail", "newMail()" }, | 163 | "mail", "newMail()" }, |
164 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 164 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
165 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 165 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
166 | "devicebuttons/ipaq_home", | 166 | "devicebuttons/ipaq_home", |
167 | "QPE/Launcher", "home()", | 167 | "QPE/Launcher", "home()", |
168 | "buttonsettings", "raise()" }, | 168 | "buttonsettings", "raise()" }, |
169 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 169 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
170 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 170 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
171 | "devicebuttons/ipaq_record", | 171 | "devicebuttons/ipaq_record", |
172 | "QPE/VMemo", "toggleRecord()", | 172 | "QPE/VMemo", "toggleRecord()", |
173 | "sound", "raise()" }, | 173 | "sound", "raise()" }, |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct z_button { | 176 | struct z_button { |
177 | Qt::Key code; | 177 | Qt::Key code; |
178 | char *utext; | 178 | char *utext; |
179 | char *pix; | 179 | char *pix; |
180 | char *fpressedservice; | 180 | char *fpressedservice; |
181 | char *fpressedaction; | 181 | char *fpressedaction; |
182 | char *fheldservice; | 182 | char *fheldservice; |
183 | char *fheldaction; | 183 | char *fheldaction; |
184 | } z_buttons [] = { | 184 | } z_buttons [] = { |
185 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 185 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
186 | "devicebuttons/z_calendar", | 186 | "devicebuttons/z_calendar", |
187 | "datebook", "nextView()", | 187 | "datebook", "nextView()", |
@@ -205,181 +205,181 @@ struct z_button { | |||
205 | }; | 205 | }; |
206 | 206 | ||
207 | static QCString makeChannel ( const char *str ) | 207 | static QCString makeChannel ( const char *str ) |
208 | { | 208 | { |
209 | if ( str && !::strchr ( str, '/' )) | 209 | if ( str && !::strchr ( str, '/' )) |
210 | return QCString ( "QPE/Application/" ) + str; | 210 | return QCString ( "QPE/Application/" ) + str; |
211 | else | 211 | else |
212 | return str; | 212 | return str; |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | ODevice *ODevice::inst ( ) | 218 | ODevice *ODevice::inst ( ) |
219 | { | 219 | { |
220 | static ODevice *dev = 0; | 220 | static ODevice *dev = 0; |
221 | 221 | ||
222 | if ( !dev ) { | 222 | if ( !dev ) { |
223 | if ( QFile::exists ( "/proc/hal/model" )) | 223 | if ( QFile::exists ( "/proc/hal/model" )) |
224 | dev = new iPAQ ( ); | 224 | dev = new iPAQ ( ); |
225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
226 | dev = new Zaurus ( ); | 226 | dev = new Zaurus ( ); |
227 | else | 227 | else |
228 | dev = new ODevice ( ); | 228 | dev = new ODevice ( ); |
229 | 229 | ||
230 | dev-> init ( ); | 230 | dev-> init ( ); |
231 | } | 231 | } |
232 | return dev; | 232 | return dev; |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | /************************************************** | 236 | /************************************************** |
237 | * | 237 | * |
238 | * common | 238 | * common |
239 | * | 239 | * |
240 | **************************************************/ | 240 | **************************************************/ |
241 | 241 | ||
242 | 242 | ||
243 | ODevice::ODevice ( ) | 243 | ODevice::ODevice ( ) |
244 | { | 244 | { |
245 | d = new ODeviceData; | 245 | d = new ODeviceData; |
246 | 246 | ||
247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
248 | 248 | ||
249 | d-> m_modelstr = "Unknown"; | 249 | d-> m_modelstr = "Unknown"; |
250 | d-> m_model = Model_Unknown; | 250 | d-> m_model = Model_Unknown; |
251 | d-> m_vendorstr = "Unknown"; | 251 | d-> m_vendorstr = "Unknown"; |
252 | d-> m_vendor = Vendor_Unknown; | 252 | d-> m_vendor = Vendor_Unknown; |
253 | d-> m_systemstr = "Unknown"; | 253 | d-> m_systemstr = "Unknown"; |
254 | d-> m_system = System_Unknown; | 254 | d-> m_system = System_Unknown; |
255 | d-> m_sysverstr = "0.0"; | 255 | d-> m_sysverstr = "0.0"; |
256 | d-> m_rotation = Rot0; | 256 | d-> m_rotation = Rot0; |
257 | 257 | ||
258 | d-> m_holdtime = 1000; // 1000ms | 258 | d-> m_holdtime = 1000; // 1000ms |
259 | d-> m_buttons = 0; | 259 | d-> m_buttons = 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
263 | { | 263 | { |
264 | if ( msg == "deviceButtonMappingChanged()" ) { | 264 | if ( msg == "deviceButtonMappingChanged()" ) { |
265 | reloadButtonMapping ( ); | 265 | reloadButtonMapping ( ); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | void ODevice::init ( ) | 269 | void ODevice::init ( ) |
270 | { | 270 | { |
271 | } | 271 | } |
272 | 272 | ||
273 | void ODevice::initButtons ( ) | 273 | void ODevice::initButtons ( ) |
274 | { | 274 | { |
275 | if ( d-> m_buttons ) | 275 | if ( d-> m_buttons ) |
276 | return; | 276 | return; |
277 | 277 | ||
278 | // Simulation uses iPAQ 3660 device buttons | 278 | // Simulation uses iPAQ 3660 device buttons |
279 | 279 | ||
280 | qDebug ( "init Buttons" ); | 280 | qDebug ( "init Buttons" ); |
281 | d-> m_buttons = new QValueList <ODeviceButton>; | 281 | d-> m_buttons = new QValueList <ODeviceButton>; |
282 | 282 | ||
283 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 283 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
284 | i_button *ib = ipaq_buttons + i; | 284 | i_button *ib = ipaq_buttons + i; |
285 | ODeviceButton b; | 285 | ODeviceButton b; |
286 | 286 | ||
287 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 287 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
288 | b. setKeycode ( ib-> code ); | 288 | b. setKeycode ( ib-> code ); |
289 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 289 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
290 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 290 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
291 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 291 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
292 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 292 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
293 | d-> m_buttons-> append ( b ); | 293 | d-> m_buttons-> append ( b ); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | reloadButtonMapping ( ); | 296 | reloadButtonMapping ( ); |
297 | 297 | ||
298 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 298 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
299 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 299 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
300 | } | 300 | } |
301 | 301 | ||
302 | ODevice::~ODevice ( ) | 302 | ODevice::~ODevice ( ) |
303 | { | 303 | { |
304 | delete d; | 304 | delete d; |
305 | } | 305 | } |
306 | 306 | ||
307 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 307 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
308 | { | 308 | { |
309 | return false; | 309 | return false; |
310 | } | 310 | } |
311 | 311 | ||
312 | //#include <linux/apm_bios.h> | 312 | //#include <linux/apm_bios.h> |
313 | 313 | ||
314 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 314 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
315 | 315 | ||
316 | 316 | ||
317 | bool ODevice::suspend ( ) | 317 | bool ODevice::suspend ( ) |
318 | { | 318 | { |
319 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 319 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
320 | return false; | 320 | return false; |
321 | 321 | ||
322 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 322 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
323 | return false; | 323 | return false; |
324 | 324 | ||
325 | bool res = false; | 325 | bool res = false; |
326 | 326 | ||
327 | struct timeval tvs, tvn; | 327 | struct timeval tvs, tvn; |
328 | ::gettimeofday ( &tvs, 0 ); | 328 | ::gettimeofday ( &tvs, 0 ); |
329 | 329 | ||
330 | ::sync ( ); // flush fs caches | 330 | ::sync ( ); // flush fs caches |
331 | res = ( ::system ( "apm --suspend" ) == 0 ); | 331 | res = ( ::system ( "apm --suspend" ) == 0 ); |
332 | 332 | ||
333 | // This is needed because the iPAQ apm implementation is asynchronous and we | 333 | // This is needed because the iPAQ apm implementation is asynchronous and we |
334 | // can not be sure when exactly the device is really suspended | 334 | // can not be sure when exactly the device is really suspended |
335 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 335 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
336 | 336 | ||
337 | if ( res ) { | 337 | if ( res ) { |
338 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 338 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
339 | ::usleep ( 200 * 1000 ); | 339 | ::usleep ( 200 * 1000 ); |
340 | ::gettimeofday ( &tvn, 0 ); | 340 | ::gettimeofday ( &tvn, 0 ); |
341 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 341 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
342 | } | 342 | } |
343 | 343 | ||
344 | return res; | 344 | return res; |
345 | } | 345 | } |
346 | 346 | ||
347 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 347 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
348 | 348 | ||
349 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 349 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
350 | 350 | ||
351 | /* VESA Blanking Levels */ | 351 | /* VESA Blanking Levels */ |
352 | #define VESA_NO_BLANKING 0 | 352 | #define VESA_NO_BLANKING 0 |
353 | #define VESA_VSYNC_SUSPEND 1 | 353 | #define VESA_VSYNC_SUSPEND 1 |
354 | #define VESA_HSYNC_SUSPEND 2 | 354 | #define VESA_HSYNC_SUSPEND 2 |
355 | #define VESA_POWERDOWN 3 | 355 | #define VESA_POWERDOWN 3 |
356 | 356 | ||
357 | 357 | ||
358 | bool ODevice::setDisplayStatus ( bool on ) | 358 | bool ODevice::setDisplayStatus ( bool on ) |
359 | { | 359 | { |
360 | if ( d-> m_model == Model_Unknown ) | 360 | if ( d-> m_model == Model_Unknown ) |
361 | return false; | 361 | return false; |
362 | 362 | ||
363 | bool res = false; | 363 | bool res = false; |
364 | int fd; | 364 | int fd; |
365 | 365 | ||
366 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 366 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
367 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 367 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
368 | ::close ( fd ); | 368 | ::close ( fd ); |
369 | } | 369 | } |
370 | return res; | 370 | return res; |
371 | } | 371 | } |
372 | 372 | ||
373 | bool ODevice::setDisplayBrightness ( int ) | 373 | bool ODevice::setDisplayBrightness ( int ) |
374 | { | 374 | { |
375 | return false; | 375 | return false; |
376 | } | 376 | } |
377 | 377 | ||
378 | int ODevice::displayBrightnessResolution ( ) const | 378 | int ODevice::displayBrightnessResolution ( ) const |
379 | { | 379 | { |
380 | return 16; | 380 | return 16; |
381 | } | 381 | } |
382 | 382 | ||
383 | QString ODevice::vendorString ( ) const | 383 | QString ODevice::vendorString ( ) const |
384 | { | 384 | { |
385 | return d-> m_vendorstr; | 385 | return d-> m_vendorstr; |
@@ -502,89 +502,89 @@ uint ODevice::buttonHoldTime ( ) const | |||
502 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 502 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
503 | { | 503 | { |
504 | initButtons ( ); | 504 | initButtons ( ); |
505 | 505 | ||
506 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 506 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
507 | if ( (*it). keycode ( ) == code ) | 507 | if ( (*it). keycode ( ) == code ) |
508 | return &(*it); | 508 | return &(*it); |
509 | } | 509 | } |
510 | return 0; | 510 | return 0; |
511 | } | 511 | } |
512 | 512 | ||
513 | void ODevice::reloadButtonMapping ( ) | 513 | void ODevice::reloadButtonMapping ( ) |
514 | { | 514 | { |
515 | initButtons ( ); | 515 | initButtons ( ); |
516 | 516 | ||
517 | Config cfg ( "ButtonSettings" ); | 517 | Config cfg ( "ButtonSettings" ); |
518 | 518 | ||
519 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 519 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
520 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 520 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
521 | QString group = "Button" + QString::number ( i ); | 521 | QString group = "Button" + QString::number ( i ); |
522 | 522 | ||
523 | QCString pch, hch; | 523 | QCString pch, hch; |
524 | QCString pm, hm; | 524 | QCString pm, hm; |
525 | QByteArray pdata, hdata; | 525 | QByteArray pdata, hdata; |
526 | 526 | ||
527 | if ( cfg. hasGroup ( group )) { | 527 | if ( cfg. hasGroup ( group )) { |
528 | cfg. setGroup ( group ); | 528 | cfg. setGroup ( group ); |
529 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 529 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
530 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 530 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
531 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 531 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
532 | 532 | ||
533 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 533 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
534 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 534 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
535 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 535 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
536 | } | 536 | } |
537 | 537 | ||
538 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 538 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
539 | 539 | ||
540 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 540 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
541 | } | 541 | } |
542 | } | 542 | } |
543 | 543 | ||
544 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 544 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
545 | { | 545 | { |
546 | initButtons ( ); | 546 | initButtons ( ); |
547 | 547 | ||
548 | QString mb_chan; | 548 | QString mb_chan; |
549 | 549 | ||
550 | if ( button >= (int) d-> m_buttons-> count ( )) | 550 | if ( button >= (int) d-> m_buttons-> count ( )) |
551 | return; | 551 | return; |
552 | 552 | ||
553 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 553 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
554 | b. setPressedAction ( action ); | 554 | b. setPressedAction ( action ); |
555 | 555 | ||
556 | mb_chan=b. pressedAction ( ). channel ( ); | 556 | mb_chan=b. pressedAction ( ). channel ( ); |
557 | 557 | ||
558 | Config buttonFile ( "ButtonSettings" ); | 558 | Config buttonFile ( "ButtonSettings" ); |
559 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 559 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
560 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 560 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
561 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 561 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
562 | 562 | ||
563 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 563 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
564 | 564 | ||
565 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 565 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
566 | } | 566 | } |
567 | 567 | ||
568 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 568 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
569 | { | 569 | { |
570 | initButtons ( ); | 570 | initButtons ( ); |
571 | 571 | ||
572 | if ( button >= (int) d-> m_buttons-> count ( )) | 572 | if ( button >= (int) d-> m_buttons-> count ( )) |
573 | return; | 573 | return; |
574 | 574 | ||
575 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 575 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
576 | b. setHeldAction ( action ); | 576 | b. setHeldAction ( action ); |
577 | 577 | ||
578 | Config buttonFile ( "ButtonSettings" ); | 578 | Config buttonFile ( "ButtonSettings" ); |
579 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 579 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
580 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 580 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
581 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 581 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
582 | 582 | ||
583 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 583 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
584 | 584 | ||
585 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 585 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
586 | } | 586 | } |
587 | 587 | ||
588 | 588 | ||
589 | 589 | ||
590 | 590 | ||
@@ -623,73 +623,89 @@ void iPAQ::init ( ) | |||
623 | } | 623 | } |
624 | 624 | ||
625 | switch ( d-> m_model ) { | 625 | switch ( d-> m_model ) { |
626 | case Model_iPAQ_H31xx: | 626 | case Model_iPAQ_H31xx: |
627 | case Model_iPAQ_H38xx: | 627 | case Model_iPAQ_H38xx: |
628 | d-> m_rotation = Rot90; | 628 | d-> m_rotation = Rot90; |
629 | break; | 629 | break; |
630 | case Model_iPAQ_H36xx: | 630 | case Model_iPAQ_H36xx: |
631 | case Model_iPAQ_H37xx: | 631 | case Model_iPAQ_H37xx: |
632 | case Model_iPAQ_H39xx: | 632 | case Model_iPAQ_H39xx: |
633 | default: | 633 | default: |
634 | d-> m_rotation = Rot270; | 634 | d-> m_rotation = Rot270; |
635 | break; | 635 | break; |
636 | } | 636 | } |
637 | 637 | ||
638 | f. setName ( "/etc/familiar-version" ); | 638 | f. setName ( "/etc/familiar-version" ); |
639 | if ( f. open ( IO_ReadOnly )) { | 639 | if ( f. open ( IO_ReadOnly )) { |
640 | d-> m_systemstr = "Familiar"; | 640 | d-> m_systemstr = "Familiar"; |
641 | d-> m_system = System_Familiar; | 641 | d-> m_system = System_Familiar; |
642 | 642 | ||
643 | QTextStream ts ( &f ); | 643 | QTextStream ts ( &f ); |
644 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 644 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
645 | 645 | ||
646 | f. close ( ); | 646 | f. close ( ); |
647 | } | 647 | } else { |
648 | f. setName ( "/etc/oz_version" ); | ||
649 | |||
650 | if ( f. open ( IO_ReadOnly )) { | ||
651 | d-> m_systemstr = "OpenEmbedded/iPaq"; | ||
652 | d-> m_system = System_Familiar; | ||
653 | |||
654 | QTextStream ts ( &f ); | ||
655 | ts.setDevice ( &f ); | ||
656 | d-> m_sysverstr = ts. readLine ( ); | ||
657 | f. close ( ); | ||
658 | } | ||
659 | } | ||
660 | |||
661 | |||
662 | |||
663 | |||
648 | 664 | ||
649 | m_leds [0] = m_leds [1] = Led_Off; | 665 | m_leds [0] = m_leds [1] = Led_Off; |
650 | 666 | ||
651 | m_power_timer = 0; | 667 | m_power_timer = 0; |
652 | 668 | ||
653 | if ( d-> m_qwsserver ) | 669 | if ( d-> m_qwsserver ) |
654 | QWSServer::setKeyboardFilter ( this ); | 670 | QWSServer::setKeyboardFilter ( this ); |
655 | } | 671 | } |
656 | 672 | ||
657 | void iPAQ::initButtons ( ) | 673 | void iPAQ::initButtons ( ) |
658 | { | 674 | { |
659 | if ( d-> m_buttons ) | 675 | if ( d-> m_buttons ) |
660 | return; | 676 | return; |
661 | 677 | ||
662 | d-> m_buttons = new QValueList <ODeviceButton>; | 678 | d-> m_buttons = new QValueList <ODeviceButton>; |
663 | 679 | ||
664 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 680 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
665 | i_button *ib = ipaq_buttons + i; | 681 | i_button *ib = ipaq_buttons + i; |
666 | ODeviceButton b; | 682 | ODeviceButton b; |
667 | 683 | ||
668 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 684 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
669 | b. setKeycode ( ib-> code ); | 685 | b. setKeycode ( ib-> code ); |
670 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 686 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
671 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 687 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
672 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 688 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
673 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 689 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
674 | 690 | ||
675 | d-> m_buttons-> append ( b ); | 691 | d-> m_buttons-> append ( b ); |
676 | } | 692 | } |
677 | } | 693 | } |
678 | reloadButtonMapping ( ); | 694 | reloadButtonMapping ( ); |
679 | 695 | ||
680 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 696 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
681 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 697 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
682 | } | 698 | } |
683 | 699 | ||
684 | 700 | ||
685 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 701 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
686 | 702 | ||
687 | typedef struct { | 703 | typedef struct { |
688 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 704 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
689 | unsigned char TotalTime; /* Units of 5 seconds */ | 705 | unsigned char TotalTime; /* Units of 5 seconds */ |
690 | unsigned char OnTime; /* units of 100m/s */ | 706 | unsigned char OnTime; /* units of 100m/s */ |
691 | unsigned char OffTime; /* units of 100m/s */ | 707 | unsigned char OffTime; /* units of 100m/s */ |
692 | } LED_IN; | 708 | } LED_IN; |
693 | 709 | ||
694 | typedef struct { | 710 | typedef struct { |
695 | unsigned char mode; | 711 | unsigned char mode; |
@@ -706,49 +722,49 @@ QValueList <OLed> iPAQ::ledList ( ) const | |||
706 | QValueList <OLed> vl; | 722 | QValueList <OLed> vl; |
707 | vl << Led_Power; | 723 | vl << Led_Power; |
708 | 724 | ||
709 | if ( d-> m_model == Model_iPAQ_H38xx ) | 725 | if ( d-> m_model == Model_iPAQ_H38xx ) |
710 | vl << Led_BlueTooth; | 726 | vl << Led_BlueTooth; |
711 | return vl; | 727 | return vl; |
712 | } | 728 | } |
713 | 729 | ||
714 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 730 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
715 | { | 731 | { |
716 | QValueList <OLedState> vl; | 732 | QValueList <OLedState> vl; |
717 | 733 | ||
718 | if ( l == Led_Power ) | 734 | if ( l == Led_Power ) |
719 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 735 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
720 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 736 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
721 | vl << Led_Off; // << Led_On << ??? | 737 | vl << Led_Off; // << Led_On << ??? |
722 | 738 | ||
723 | return vl; | 739 | return vl; |
724 | } | 740 | } |
725 | 741 | ||
726 | OLedState iPAQ::ledState ( OLed l ) const | 742 | OLedState iPAQ::ledState ( OLed l ) const |
727 | { | 743 | { |
728 | switch ( l ) { | 744 | switch ( l ) { |
729 | case Led_Power: | 745 | case Led_Power: |
730 | return m_leds [0]; | 746 | return m_leds [0]; |
731 | case Led_BlueTooth: | 747 | case Led_BlueTooth: |
732 | return m_leds [1]; | 748 | return m_leds [1]; |
733 | default: | 749 | default: |
734 | return Led_Off; | 750 | return Led_Off; |
735 | } | 751 | } |
736 | } | 752 | } |
737 | 753 | ||
738 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 754 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
739 | { | 755 | { |
740 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 756 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
741 | 757 | ||
742 | if ( l == Led_Power ) { | 758 | if ( l == Led_Power ) { |
743 | if ( fd >= 0 ) { | 759 | if ( fd >= 0 ) { |
744 | LED_IN leds; | 760 | LED_IN leds; |
745 | ::memset ( &leds, 0, sizeof( leds )); | 761 | ::memset ( &leds, 0, sizeof( leds )); |
746 | leds. TotalTime = 0; | 762 | leds. TotalTime = 0; |
747 | leds. OnTime = 0; | 763 | leds. OnTime = 0; |
748 | leds. OffTime = 1; | 764 | leds. OffTime = 1; |
749 | leds. OffOnBlink = 2; | 765 | leds. OffOnBlink = 2; |
750 | 766 | ||
751 | switch ( st ) { | 767 | switch ( st ) { |
752 | case Led_Off : leds. OffOnBlink = 0; break; | 768 | case Led_Off : leds. OffOnBlink = 0; break; |
753 | case Led_On : leds. OffOnBlink = 1; break; | 769 | case Led_On : leds. OffOnBlink = 1; break; |
754 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 770 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
@@ -760,68 +776,68 @@ bool iPAQ::setLedState ( OLed l, OLedState st ) | |||
760 | return true; | 776 | return true; |
761 | } | 777 | } |
762 | } | 778 | } |
763 | } | 779 | } |
764 | return false; | 780 | return false; |
765 | } | 781 | } |
766 | 782 | ||
767 | 783 | ||
768 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 784 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
769 | { | 785 | { |
770 | int newkeycode = keycode; | 786 | int newkeycode = keycode; |
771 | 787 | ||
772 | switch ( keycode ) { | 788 | switch ( keycode ) { |
773 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 789 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
774 | case HardKey_Menu: { | 790 | case HardKey_Menu: { |
775 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 791 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
776 | ( d-> m_model == Model_iPAQ_H39xx )) { | 792 | ( d-> m_model == Model_iPAQ_H39xx )) { |
777 | newkeycode = HardKey_Mail; | 793 | newkeycode = HardKey_Mail; |
778 | } | 794 | } |
779 | break; | 795 | break; |
780 | } | 796 | } |
781 | 797 | ||
782 | // Rotate cursor keys 180° | 798 | // Rotate cursor keys 180° |
783 | case Key_Left : | 799 | case Key_Left : |
784 | case Key_Right: | 800 | case Key_Right: |
785 | case Key_Up : | 801 | case Key_Up : |
786 | case Key_Down : { | 802 | case Key_Down : { |
787 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 803 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
788 | ( d-> m_model == Model_iPAQ_H38xx )) { | 804 | ( d-> m_model == Model_iPAQ_H38xx )) { |
789 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 805 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
790 | } | 806 | } |
791 | break; | 807 | break; |
792 | } | 808 | } |
793 | 809 | ||
794 | // map Power Button short/long press to F34/F35 | 810 | // map Power Button short/long press to F34/F35 |
795 | case Key_SysReq: { | 811 | case Key_SysReq: { |
796 | if ( isPress ) { | 812 | if ( isPress ) { |
797 | if ( m_power_timer ) | 813 | if ( m_power_timer ) |
798 | killTimer ( m_power_timer ); | 814 | killTimer ( m_power_timer ); |
799 | m_power_timer = startTimer ( 500 ); | 815 | m_power_timer = startTimer ( 500 ); |
800 | } | 816 | } |
801 | else if ( m_power_timer ) { | 817 | else if ( m_power_timer ) { |
802 | killTimer ( m_power_timer ); | 818 | killTimer ( m_power_timer ); |
803 | m_power_timer = 0; | 819 | m_power_timer = 0; |
804 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 820 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
805 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 821 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
806 | } | 822 | } |
807 | newkeycode = Key_unknown; | 823 | newkeycode = Key_unknown; |
808 | break; | 824 | break; |
809 | } | 825 | } |
810 | } | 826 | } |
811 | 827 | ||
812 | if ( newkeycode != keycode ) { | 828 | if ( newkeycode != keycode ) { |
813 | if ( newkeycode != Key_unknown ) | 829 | if ( newkeycode != Key_unknown ) |
814 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 830 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
815 | return true; | 831 | return true; |
816 | } | 832 | } |
817 | else | 833 | else |
818 | return false; | 834 | return false; |
819 | } | 835 | } |
820 | 836 | ||
821 | void iPAQ::timerEvent ( QTimerEvent * ) | 837 | void iPAQ::timerEvent ( QTimerEvent * ) |
822 | { | 838 | { |
823 | killTimer ( m_power_timer ); | 839 | killTimer ( m_power_timer ); |
824 | m_power_timer = 0; | 840 | m_power_timer = 0; |
825 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 841 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
826 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 842 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
827 | } | 843 | } |
@@ -856,109 +872,109 @@ void iPAQ::alarmSound ( ) | |||
856 | while ( !snd. isFinished ( )) | 872 | while ( !snd. isFinished ( )) |
857 | qApp-> processEvents ( ); | 873 | qApp-> processEvents ( ); |
858 | 874 | ||
859 | if ( fd >= 0 ) { | 875 | if ( fd >= 0 ) { |
860 | if ( vol_reset ) | 876 | if ( vol_reset ) |
861 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 877 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
862 | ::close ( fd ); | 878 | ::close ( fd ); |
863 | } | 879 | } |
864 | #endif | 880 | #endif |
865 | } | 881 | } |
866 | 882 | ||
867 | 883 | ||
868 | bool iPAQ::setSoftSuspend ( bool soft ) | 884 | bool iPAQ::setSoftSuspend ( bool soft ) |
869 | { | 885 | { |
870 | bool res = false; | 886 | bool res = false; |
871 | int fd; | 887 | int fd; |
872 | 888 | ||
873 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 889 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
874 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 890 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
875 | res = true; | 891 | res = true; |
876 | else | 892 | else |
877 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 893 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
878 | 894 | ||
879 | ::close ( fd ); | 895 | ::close ( fd ); |
880 | } | 896 | } |
881 | else | 897 | else |
882 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 898 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
883 | 899 | ||
884 | return res; | 900 | return res; |
885 | } | 901 | } |
886 | 902 | ||
887 | 903 | ||
888 | bool iPAQ::setDisplayBrightness ( int bright ) | 904 | bool iPAQ::setDisplayBrightness ( int bright ) |
889 | { | 905 | { |
890 | bool res = false; | 906 | bool res = false; |
891 | int fd; | 907 | int fd; |
892 | 908 | ||
893 | if ( bright > 255 ) | 909 | if ( bright > 255 ) |
894 | bright = 255; | 910 | bright = 255; |
895 | if ( bright < 0 ) | 911 | if ( bright < 0 ) |
896 | bright = 0; | 912 | bright = 0; |
897 | 913 | ||
898 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 914 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
899 | FLITE_IN bl; | 915 | FLITE_IN bl; |
900 | bl. mode = 1; | 916 | bl. mode = 1; |
901 | bl. pwr = bright ? 1 : 0; | 917 | bl. pwr = bright ? 1 : 0; |
902 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 918 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
903 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 919 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
904 | ::close ( fd ); | 920 | ::close ( fd ); |
905 | } | 921 | } |
906 | return res; | 922 | return res; |
907 | } | 923 | } |
908 | 924 | ||
909 | int iPAQ::displayBrightnessResolution ( ) const | 925 | int iPAQ::displayBrightnessResolution ( ) const |
910 | { | 926 | { |
911 | switch ( model ( )) { | 927 | switch ( model ( )) { |
912 | case Model_iPAQ_H31xx: | 928 | case Model_iPAQ_H31xx: |
913 | case Model_iPAQ_H36xx: | 929 | case Model_iPAQ_H36xx: |
914 | case Model_iPAQ_H37xx: | 930 | case Model_iPAQ_H37xx: |
915 | return 128; // really 256, but >128 could damage the LCD | 931 | return 128; // really 256, but >128 could damage the LCD |
916 | 932 | ||
917 | case Model_iPAQ_H38xx: | 933 | case Model_iPAQ_H38xx: |
918 | case Model_iPAQ_H39xx: | 934 | case Model_iPAQ_H39xx: |
919 | return 64; | 935 | return 64; |
920 | 936 | ||
921 | default: | 937 | default: |
922 | return 2; | 938 | return 2; |
923 | } | 939 | } |
924 | } | 940 | } |
925 | 941 | ||
926 | 942 | ||
927 | bool iPAQ::hasLightSensor ( ) const | 943 | bool iPAQ::hasLightSensor ( ) const |
928 | { | 944 | { |
929 | return true; | 945 | return true; |
930 | } | 946 | } |
931 | 947 | ||
932 | int iPAQ::readLightSensor ( ) | 948 | int iPAQ::readLightSensor ( ) |
933 | { | 949 | { |
934 | int fd; | 950 | int fd; |
935 | int val = -1; | 951 | int val = -1; |
936 | 952 | ||
937 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 953 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
938 | char buffer [8]; | 954 | char buffer [8]; |
939 | 955 | ||
940 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 956 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
941 | char *endptr; | 957 | char *endptr; |
942 | 958 | ||
943 | buffer [4] = 0; | 959 | buffer [4] = 0; |
944 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 960 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
945 | 961 | ||
946 | if ( *endptr != 0 ) | 962 | if ( *endptr != 0 ) |
947 | val = -1; | 963 | val = -1; |
948 | } | 964 | } |
949 | ::close ( fd ); | 965 | ::close ( fd ); |
950 | } | 966 | } |
951 | 967 | ||
952 | return val; | 968 | return val; |
953 | } | 969 | } |
954 | 970 | ||
955 | int iPAQ::lightSensorResolution ( ) const | 971 | int iPAQ::lightSensorResolution ( ) const |
956 | { | 972 | { |
957 | return 256; | 973 | return 256; |
958 | } | 974 | } |
959 | 975 | ||
960 | /************************************************** | 976 | /************************************************** |
961 | * | 977 | * |
962 | * Zaurus | 978 | * Zaurus |
963 | * | 979 | * |
964 | **************************************************/ | 980 | **************************************************/ |
@@ -967,33 +983,33 @@ int iPAQ::lightSensorResolution ( ) const | |||
967 | 983 | ||
968 | void Zaurus::init ( ) | 984 | void Zaurus::init ( ) |
969 | { | 985 | { |
970 | d-> m_vendorstr = "Sharp"; | 986 | d-> m_vendorstr = "Sharp"; |
971 | d-> m_vendor = Vendor_Sharp; | 987 | d-> m_vendor = Vendor_Sharp; |
972 | 988 | ||
973 | QFile f ( "/proc/filesystems" ); | 989 | QFile f ( "/proc/filesystems" ); |
974 | 990 | ||
975 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 991 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
976 | d-> m_vendorstr = "OpenZaurus Team"; | 992 | d-> m_vendorstr = "OpenZaurus Team"; |
977 | d-> m_systemstr = "OpenZaurus"; | 993 | d-> m_systemstr = "OpenZaurus"; |
978 | d-> m_system = System_OpenZaurus; | 994 | d-> m_system = System_OpenZaurus; |
979 | 995 | ||
980 | f. close ( ); | 996 | f. close ( ); |
981 | 997 | ||
982 | f. setName ( "/etc/oz_version" ); | 998 | f. setName ( "/etc/oz_version" ); |
983 | if ( f. open ( IO_ReadOnly )) { | 999 | if ( f. open ( IO_ReadOnly )) { |
984 | QTextStream ts ( &f ); | 1000 | QTextStream ts ( &f ); |
985 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1001 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
986 | f. close ( ); | 1002 | f. close ( ); |
987 | } | 1003 | } |
988 | } | 1004 | } |
989 | else { | 1005 | else { |
990 | d-> m_systemstr = "Zaurus"; | 1006 | d-> m_systemstr = "Zaurus"; |
991 | d-> m_system = System_Zaurus; | 1007 | d-> m_system = System_Zaurus; |
992 | } | 1008 | } |
993 | 1009 | ||
994 | f. setName ( "/proc/deviceinfo/product" ); | 1010 | f. setName ( "/proc/deviceinfo/product" ); |
995 | if ( f. open ( IO_ReadOnly ) ) { | 1011 | if ( f. open ( IO_ReadOnly ) ) { |
996 | QTextStream ts ( &f ); | 1012 | QTextStream ts ( &f ); |
997 | QString model = ts. readLine ( ); | 1013 | QString model = ts. readLine ( ); |
998 | f. close ( ); | 1014 | f. close ( ); |
999 | 1015 | ||
@@ -1023,50 +1039,50 @@ void Zaurus::init ( ) | |||
1023 | * sensor to set an appropriate value | 1039 | * sensor to set an appropriate value |
1024 | */ | 1040 | */ |
1025 | case Model_Zaurus_SLB600: | 1041 | case Model_Zaurus_SLB600: |
1026 | case Model_Zaurus_SL5500: | 1042 | case Model_Zaurus_SL5500: |
1027 | case Model_Zaurus_SL5000: | 1043 | case Model_Zaurus_SL5000: |
1028 | default: | 1044 | default: |
1029 | d-> m_rotation = Rot270; | 1045 | d-> m_rotation = Rot270; |
1030 | break; | 1046 | break; |
1031 | } | 1047 | } |
1032 | m_leds [0] = Led_Off; | 1048 | m_leds [0] = Led_Off; |
1033 | } | 1049 | } |
1034 | 1050 | ||
1035 | void Zaurus::initButtons ( ) | 1051 | void Zaurus::initButtons ( ) |
1036 | { | 1052 | { |
1037 | if ( d-> m_buttons ) | 1053 | if ( d-> m_buttons ) |
1038 | return; | 1054 | return; |
1039 | 1055 | ||
1040 | d-> m_buttons = new QValueList <ODeviceButton>; | 1056 | d-> m_buttons = new QValueList <ODeviceButton>; |
1041 | 1057 | ||
1042 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1058 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
1043 | z_button *zb = z_buttons + i; | 1059 | z_button *zb = z_buttons + i; |
1044 | ODeviceButton b; | 1060 | ODeviceButton b; |
1045 | 1061 | ||
1046 | b. setKeycode ( zb-> code ); | 1062 | b. setKeycode ( zb-> code ); |
1047 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1063 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1048 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1064 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1049 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1065 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1050 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1066 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1051 | 1067 | ||
1052 | d-> m_buttons-> append ( b ); | 1068 | d-> m_buttons-> append ( b ); |
1053 | } | 1069 | } |
1054 | 1070 | ||
1055 | reloadButtonMapping ( ); | 1071 | reloadButtonMapping ( ); |
1056 | 1072 | ||
1057 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1073 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1058 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1074 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1059 | } | 1075 | } |
1060 | 1076 | ||
1061 | #include <unistd.h> | 1077 | #include <unistd.h> |
1062 | #include <fcntl.h> | 1078 | #include <fcntl.h> |
1063 | #include <sys/ioctl.h> | 1079 | #include <sys/ioctl.h> |
1064 | 1080 | ||
1065 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1081 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1066 | 1082 | ||
1067 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1083 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1068 | 1084 | ||
1069 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1085 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1070 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1086 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1071 | 1087 | ||
1072 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1088 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
@@ -1115,151 +1131,151 @@ typedef struct sharp_led_status { | |||
1115 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1131 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1116 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1132 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1117 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1133 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1118 | 1134 | ||
1119 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1135 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1120 | 1136 | ||
1121 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1137 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1122 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1138 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1123 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1139 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1124 | 1140 | ||
1125 | #define FL_IOCTL_STEP_CONTRAST 100 | 1141 | #define FL_IOCTL_STEP_CONTRAST 100 |
1126 | 1142 | ||
1127 | 1143 | ||
1128 | void Zaurus::buzzer ( int sound ) | 1144 | void Zaurus::buzzer ( int sound ) |
1129 | { | 1145 | { |
1130 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1146 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1131 | 1147 | ||
1132 | if ( fd >= 0 ) { | 1148 | if ( fd >= 0 ) { |
1133 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1149 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1134 | ::close ( fd ); | 1150 | ::close ( fd ); |
1135 | } | 1151 | } |
1136 | } | 1152 | } |
1137 | 1153 | ||
1138 | 1154 | ||
1139 | void Zaurus::alarmSound ( ) | 1155 | void Zaurus::alarmSound ( ) |
1140 | { | 1156 | { |
1141 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1157 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1142 | } | 1158 | } |
1143 | 1159 | ||
1144 | void Zaurus::touchSound ( ) | 1160 | void Zaurus::touchSound ( ) |
1145 | { | 1161 | { |
1146 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1162 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1147 | } | 1163 | } |
1148 | 1164 | ||
1149 | void Zaurus::keySound ( ) | 1165 | void Zaurus::keySound ( ) |
1150 | { | 1166 | { |
1151 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1167 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1152 | } | 1168 | } |
1153 | 1169 | ||
1154 | 1170 | ||
1155 | QValueList <OLed> Zaurus::ledList ( ) const | 1171 | QValueList <OLed> Zaurus::ledList ( ) const |
1156 | { | 1172 | { |
1157 | QValueList <OLed> vl; | 1173 | QValueList <OLed> vl; |
1158 | vl << Led_Mail; | 1174 | vl << Led_Mail; |
1159 | return vl; | 1175 | return vl; |
1160 | } | 1176 | } |
1161 | 1177 | ||
1162 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1178 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1163 | { | 1179 | { |
1164 | QValueList <OLedState> vl; | 1180 | QValueList <OLedState> vl; |
1165 | 1181 | ||
1166 | if ( l == Led_Mail ) | 1182 | if ( l == Led_Mail ) |
1167 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1183 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1168 | return vl; | 1184 | return vl; |
1169 | } | 1185 | } |
1170 | 1186 | ||
1171 | OLedState Zaurus::ledState ( OLed which ) const | 1187 | OLedState Zaurus::ledState ( OLed which ) const |
1172 | { | 1188 | { |
1173 | if ( which == Led_Mail ) | 1189 | if ( which == Led_Mail ) |
1174 | return m_leds [0]; | 1190 | return m_leds [0]; |
1175 | else | 1191 | else |
1176 | return Led_Off; | 1192 | return Led_Off; |
1177 | } | 1193 | } |
1178 | 1194 | ||
1179 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1195 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1180 | { | 1196 | { |
1181 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1197 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1182 | 1198 | ||
1183 | if ( which == Led_Mail ) { | 1199 | if ( which == Led_Mail ) { |
1184 | if ( fd >= 0 ) { | 1200 | if ( fd >= 0 ) { |
1185 | struct sharp_led_status leds; | 1201 | struct sharp_led_status leds; |
1186 | ::memset ( &leds, 0, sizeof( leds )); | 1202 | ::memset ( &leds, 0, sizeof( leds )); |
1187 | leds. which = SHARP_LED_MAIL_EXISTS; | 1203 | leds. which = SHARP_LED_MAIL_EXISTS; |
1188 | bool ok = true; | 1204 | bool ok = true; |
1189 | 1205 | ||
1190 | switch ( st ) { | 1206 | switch ( st ) { |
1191 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1207 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1192 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1208 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1193 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1209 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1194 | default : ok = false; | 1210 | default : ok = false; |
1195 | } | 1211 | } |
1196 | 1212 | ||
1197 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1213 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1198 | m_leds [0] = st; | 1214 | m_leds [0] = st; |
1199 | return true; | 1215 | return true; |
1200 | } | 1216 | } |
1201 | } | 1217 | } |
1202 | } | 1218 | } |
1203 | return false; | 1219 | return false; |
1204 | } | 1220 | } |
1205 | 1221 | ||
1206 | bool Zaurus::setSoftSuspend ( bool soft ) | 1222 | bool Zaurus::setSoftSuspend ( bool soft ) |
1207 | { | 1223 | { |
1208 | bool res = false; | 1224 | bool res = false; |
1209 | int fd; | 1225 | int fd; |
1210 | 1226 | ||
1211 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1227 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1212 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1228 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1213 | 1229 | ||
1214 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1230 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1215 | 1231 | ||
1216 | if ( sources >= 0 ) { | 1232 | if ( sources >= 0 ) { |
1217 | if ( soft ) | 1233 | if ( soft ) |
1218 | sources &= ~APM_EVT_POWER_BUTTON; | 1234 | sources &= ~APM_EVT_POWER_BUTTON; |
1219 | else | 1235 | else |
1220 | sources |= APM_EVT_POWER_BUTTON; | 1236 | sources |= APM_EVT_POWER_BUTTON; |
1221 | 1237 | ||
1222 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1238 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1223 | res = true; | 1239 | res = true; |
1224 | else | 1240 | else |
1225 | perror ( "APM_IOCGEVTSRC" ); | 1241 | perror ( "APM_IOCGEVTSRC" ); |
1226 | } | 1242 | } |
1227 | else | 1243 | else |
1228 | perror ( "APM_IOCGEVTSRC" ); | 1244 | perror ( "APM_IOCGEVTSRC" ); |
1229 | 1245 | ||
1230 | ::close ( fd ); | 1246 | ::close ( fd ); |
1231 | } | 1247 | } |
1232 | else | 1248 | else |
1233 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1249 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1234 | 1250 | ||
1235 | return res; | 1251 | return res; |
1236 | } | 1252 | } |
1237 | 1253 | ||
1238 | 1254 | ||
1239 | bool Zaurus::setDisplayBrightness ( int bright ) | 1255 | bool Zaurus::setDisplayBrightness ( int bright ) |
1240 | { | 1256 | { |
1241 | bool res = false; | 1257 | bool res = false; |
1242 | int fd; | 1258 | int fd; |
1243 | 1259 | ||
1244 | if ( bright > 255 ) | 1260 | if ( bright > 255 ) |
1245 | bright = 255; | 1261 | bright = 255; |
1246 | if ( bright < 0 ) | 1262 | if ( bright < 0 ) |
1247 | bright = 0; | 1263 | bright = 0; |
1248 | 1264 | ||
1249 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1265 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1250 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1266 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1251 | if ( bright && !bl ) | 1267 | if ( bright && !bl ) |
1252 | bl = 1; | 1268 | bl = 1; |
1253 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1269 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1254 | ::close ( fd ); | 1270 | ::close ( fd ); |
1255 | } | 1271 | } |
1256 | return res; | 1272 | return res; |
1257 | } | 1273 | } |
1258 | 1274 | ||
1259 | 1275 | ||
1260 | int Zaurus::displayBrightnessResolution ( ) const | 1276 | int Zaurus::displayBrightnessResolution ( ) const |
1261 | { | 1277 | { |
1262 | return 5; | 1278 | return 5; |
1263 | } | 1279 | } |
1264 | 1280 | ||
1265 | 1281 | ||