-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_mypal.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 2d734a4..5272a3c 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -312,153 +312,153 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
312 | // map Power Button short/long press to F34/F35 | 312 | // map Power Button short/long press to F34/F35 |
313 | case Key_SysReq: { | 313 | case Key_SysReq: { |
314 | if ( isPress ) { | 314 | if ( isPress ) { |
315 | if ( m_power_timer ) | 315 | if ( m_power_timer ) |
316 | killTimer ( m_power_timer ); | 316 | killTimer ( m_power_timer ); |
317 | m_power_timer = startTimer ( 500 ); | 317 | m_power_timer = startTimer ( 500 ); |
318 | } | 318 | } |
319 | else if ( m_power_timer ) { | 319 | else if ( m_power_timer ) { |
320 | killTimer ( m_power_timer ); | 320 | killTimer ( m_power_timer ); |
321 | m_power_timer = 0; | 321 | m_power_timer = 0; |
322 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 322 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
323 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 323 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
324 | } | 324 | } |
325 | newkeycode = Key_unknown; | 325 | newkeycode = Key_unknown; |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | if ( newkeycode != keycode ) { | 330 | if ( newkeycode != keycode ) { |
331 | if ( newkeycode != Key_unknown ) | 331 | if ( newkeycode != Key_unknown ) |
332 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 332 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
333 | return true; | 333 | return true; |
334 | } | 334 | } |
335 | else | 335 | else |
336 | return false; | 336 | return false; |
337 | } | 337 | } |
338 | 338 | ||
339 | void iPAQ::timerEvent ( QTimerEvent * ) | 339 | void iPAQ::timerEvent ( QTimerEvent * ) |
340 | { | 340 | { |
341 | killTimer ( m_power_timer ); | 341 | killTimer ( m_power_timer ); |
342 | m_power_timer = 0; | 342 | m_power_timer = 0; |
343 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 343 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
344 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 344 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void iPAQ::playAlarmSound() | 348 | void iPAQ::playAlarmSound() |
349 | { | 349 | { |
350 | #ifndef QT_NO_SOUND | 350 | #ifndef QT_NO_SOUND |
351 | static Sound snd ( "alarm" ); | 351 | static Sound snd ( "alarm" ); |
352 | if(!snd.isFinished()) | 352 | if(!snd.isFinished()) |
353 | return; | 353 | return; |
354 | 354 | ||
355 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 355 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
356 | snd. play(); | 356 | snd. play(); |
357 | #endif | 357 | #endif |
358 | } | 358 | } |
359 | 359 | ||
360 | bool iPAQ::setDisplayBrightness ( int bright ) | 360 | bool iPAQ::setDisplayBrightness ( int bright ) |
361 | { | 361 | { |
362 | bool res = false; | 362 | bool res = false; |
363 | int fd; | 363 | int fd; |
364 | 364 | ||
365 | if ( bright > 255 ) | 365 | if ( bright > 255 ) |
366 | bright = 255; | 366 | bright = 255; |
367 | if ( bright < 0 ) | 367 | if ( bright < 0 ) |
368 | bright = 0; | 368 | bright = 0; |
369 | 369 | ||
370 | QString cmdline; | 370 | QString cmdline; |
371 | 371 | ||
372 | switch ( model()) { | 372 | switch ( model()) { |
373 | case Model_iPAQ_H191x: | 373 | case Model_iPAQ_H191x: |
374 | if ( !bright ) | 374 | if ( !bright ) |
375 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); | 375 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); |
376 | else | 376 | else |
377 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); | 377 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); |
378 | // No Global::shellQuote as we gurantee it to be sane | 378 | // No Global::shellQuote as we gurantee it to be sane |
379 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 379 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
380 | break; | 380 | break; |
381 | default: | 381 | default: |
382 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 382 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
383 | FLITE_IN bl; | 383 | FLITE_IN bl; |
384 | bl. mode = 1; | 384 | bl. mode = 1; |
385 | bl. pwr = bright ? 1 : 0; | 385 | bl. pwr = bright ? 1 : 0; |
386 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 386 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
387 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 387 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
388 | ::close ( fd ); | 388 | ::close ( fd ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | return res; | 391 | return res; |
392 | } | 392 | } |
393 | 393 | ||
394 | int iPAQ::displayBrightnessResolution() const | 394 | int iPAQ::displayBrightnessResolution() const |
395 | { | 395 | { |
396 | switch ( model()) { | 396 | switch ( model()) { |
397 | case Model_iPAQ_H31xx: | 397 | case Model_iPAQ_H31xx: |
398 | case Model_iPAQ_H36xx: | 398 | case Model_iPAQ_H36xx: |
399 | case Model_iPAQ_H37xx: | 399 | case Model_iPAQ_H37xx: |
400 | return 128; // really 256, but >128 could damage the LCD | 400 | return 128; // really 256, but >128 could damage the LCD |
401 | 401 | ||
402 | case Model_iPAQ_H38xx: | 402 | case Model_iPAQ_H38xx: |
403 | case Model_iPAQ_H39xx: | 403 | case Model_iPAQ_H39xx: |
404 | return 64; | 404 | return 64; |
405 | case Model_iPAQ_H5xxx: | 405 | case Model_iPAQ_H5xxx: |
406 | return 255; | 406 | return 255; |
407 | case Model_iPAQ_H191x: | 407 | case Model_iPAQ_H191x: |
408 | return 183; | 408 | return 7; |
409 | case Model_iPAQ_H1940: | 409 | case Model_iPAQ_H1940: |
410 | return 44; | 410 | return 44; |
411 | default: | 411 | default: |
412 | return 2; | 412 | return 2; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | 415 | ||
416 | bool iPAQ::setDisplayStatus ( bool on ) | 416 | bool iPAQ::setDisplayStatus ( bool on ) |
417 | { | 417 | { |
418 | bool res = false; | 418 | bool res = false; |
419 | 419 | ||
420 | QString cmdline; | 420 | QString cmdline; |
421 | 421 | ||
422 | if ( model() == Model_iPAQ_H191x ) { | 422 | if ( model() == Model_iPAQ_H191x ) { |
423 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 423 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); |
424 | } else { | 424 | } else { |
425 | return OAbstractMobileDevice::setDisplayStatus(on); | 425 | return OAbstractMobileDevice::setDisplayStatus(on); |
426 | } | 426 | } |
427 | 427 | ||
428 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 428 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
429 | 429 | ||
430 | return res; | 430 | return res; |
431 | } | 431 | } |
432 | 432 | ||
433 | bool iPAQ::hasLightSensor() const | 433 | bool iPAQ::hasLightSensor() const |
434 | { | 434 | { |
435 | return true; | 435 | return true; |
436 | } | 436 | } |
437 | 437 | ||
438 | int iPAQ::readLightSensor() | 438 | int iPAQ::readLightSensor() |
439 | { | 439 | { |
440 | int fd; | 440 | int fd; |
441 | int val = -1; | 441 | int val = -1; |
442 | 442 | ||
443 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 443 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
444 | char buffer [8]; | 444 | char buffer [8]; |
445 | 445 | ||
446 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 446 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
447 | char *endptr; | 447 | char *endptr; |
448 | 448 | ||
449 | buffer [4] = 0; | 449 | buffer [4] = 0; |
450 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 450 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
451 | 451 | ||
452 | if ( *endptr != 0 ) | 452 | if ( *endptr != 0 ) |
453 | val = -1; | 453 | val = -1; |
454 | } | 454 | } |
455 | ::close ( fd ); | 455 | ::close ( fd ); |
456 | } | 456 | } |
457 | 457 | ||
458 | return val; | 458 | return val; |
459 | } | 459 | } |
460 | 460 | ||
461 | int iPAQ::lightSensorResolution() const | 461 | int iPAQ::lightSensorResolution() const |
462 | { | 462 | { |
463 | return 256; | 463 | return 256; |
464 | } | 464 | } |
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp index 45c70ae..da0272e 100644 --- a/libopie2/opiecore/device/odevice_mypal.cpp +++ b/libopie2/opiecore/device/odevice_mypal.cpp | |||
@@ -108,145 +108,145 @@ void MyPal::initButtons() | |||
108 | if ( d->m_buttons ) | 108 | if ( d->m_buttons ) |
109 | return; | 109 | return; |
110 | 110 | ||
111 | if ( isQWS( ) ) { | 111 | if ( isQWS( ) ) { |
112 | addPreHandler(this); | 112 | addPreHandler(this); |
113 | } | 113 | } |
114 | 114 | ||
115 | d->m_buttons = new QValueList <ODeviceButton>; | 115 | d->m_buttons = new QValueList <ODeviceButton>; |
116 | 116 | ||
117 | for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) { | 117 | for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) { |
118 | m_button *mb = mypal_buttons + i; | 118 | m_button *mb = mypal_buttons + i; |
119 | ODeviceButton b; | 119 | ODeviceButton b; |
120 | 120 | ||
121 | if (( mb->model & d->m_model ) == d->m_model ) { | 121 | if (( mb->model & d->m_model ) == d->m_model ) { |
122 | b. setKeycode ( mb->code ); | 122 | b. setKeycode ( mb->code ); |
123 | b. setUserText ( QObject::tr ( "Button", mb->utext )); | 123 | b. setUserText ( QObject::tr ( "Button", mb->utext )); |
124 | b. setPixmap ( OResource::loadPixmap ( mb->pix )); | 124 | b. setPixmap ( OResource::loadPixmap ( mb->pix )); |
125 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction )); | 125 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction )); |
126 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction )); | 126 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction )); |
127 | 127 | ||
128 | d->m_buttons->append ( b ); | 128 | d->m_buttons->append ( b ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | reloadButtonMapping(); | 131 | reloadButtonMapping(); |
132 | } | 132 | } |
133 | 133 | ||
134 | bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 134 | bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
135 | { | 135 | { |
136 | int newkeycode = keycode; | 136 | int newkeycode = keycode; |
137 | 137 | ||
138 | switch ( keycode ) { | 138 | switch ( keycode ) { |
139 | case Key_Left : | 139 | case Key_Left : |
140 | case Key_Right: | 140 | case Key_Right: |
141 | case Key_Up : | 141 | case Key_Up : |
142 | case Key_Down : { | 142 | case Key_Down : { |
143 | // Rotate the cursor keys by 270 | 143 | // Rotate the cursor keys by 270 |
144 | // keycode - Key_Left = position of the button starting from left clockwise | 144 | // keycode - Key_Left = position of the button starting from left clockwise |
145 | // add the rotation to it and modolo. No we've the original offset | 145 | // add the rotation to it and modolo. No we've the original offset |
146 | // add the offset to the Key_Left key | 146 | // add the offset to the Key_Left key |
147 | if ( d->m_model == Model_MyPal_716 ) | 147 | if ( d->m_model == Model_MyPal_716 ) |
148 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 148 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | 151 | ||
152 | // map Power Button short/long press to F34/F35 | 152 | // map Power Button short/long press to F34/F35 |
153 | case Key_SysReq: { | 153 | case Key_SysReq: { |
154 | if ( isPress ) { | 154 | if ( isPress ) { |
155 | if ( m_power_timer ) | 155 | if ( m_power_timer ) |
156 | killTimer ( m_power_timer ); | 156 | killTimer ( m_power_timer ); |
157 | m_power_timer = startTimer ( 500 ); | 157 | m_power_timer = startTimer ( 500 ); |
158 | } | 158 | } |
159 | else if ( m_power_timer ) { | 159 | else if ( m_power_timer ) { |
160 | killTimer ( m_power_timer ); | 160 | killTimer ( m_power_timer ); |
161 | m_power_timer = 0; | 161 | m_power_timer = 0; |
162 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 162 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
163 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 163 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
164 | } | 164 | } |
165 | newkeycode = Key_unknown; | 165 | newkeycode = Key_unknown; |
166 | break; | 166 | break; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | if ( newkeycode != keycode ) { | 170 | if ( newkeycode != keycode ) { |
171 | if ( newkeycode != Key_unknown ) | 171 | if ( newkeycode != Key_unknown ) |
172 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 172 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
173 | return true; | 173 | return true; |
174 | } | 174 | } |
175 | else | 175 | else |
176 | return false; | 176 | return false; |
177 | } | 177 | } |
178 | 178 | ||
179 | void MyPal::timerEvent ( QTimerEvent * ) | 179 | void MyPal::timerEvent ( QTimerEvent * ) |
180 | { | 180 | { |
181 | killTimer ( m_power_timer ); | 181 | killTimer ( m_power_timer ); |
182 | m_power_timer = 0; | 182 | m_power_timer = 0; |
183 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 183 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
184 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 184 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void MyPal::playAlarmSound() | 188 | void MyPal::playAlarmSound() |
189 | { | 189 | { |
190 | #ifndef QT_NO_SOUND | 190 | #ifndef QT_NO_SOUND |
191 | static Sound snd ( "alarm" ); | 191 | static Sound snd ( "alarm" ); |
192 | if(!snd.isFinished()) | 192 | if(!snd.isFinished()) |
193 | return; | 193 | return; |
194 | 194 | ||
195 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 195 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
196 | snd. play(); | 196 | snd. play(); |
197 | #endif | 197 | #endif |
198 | } | 198 | } |
199 | 199 | ||
200 | bool MyPal::setDisplayBrightness ( int bright ) | 200 | bool MyPal::setDisplayBrightness ( int bright ) |
201 | { | 201 | { |
202 | bool res = false; | 202 | bool res = false; |
203 | 203 | ||
204 | if ( bright > 220 ) | 204 | if ( bright > 255 ) |
205 | bright = 220; | 205 | bright = 255; |
206 | if ( bright < 0 ) | 206 | if ( bright < 0 ) |
207 | bright = 0; | 207 | bright = 0; |
208 | 208 | ||
209 | QString cmdline; | 209 | QString cmdline; |
210 | 210 | ||
211 | switch ( model()) { | 211 | switch ( model()) { |
212 | case Model_MyPal_716: | 212 | case Model_MyPal_716: |
213 | if ( !bright ) | 213 | if ( !bright ) |
214 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); | 214 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); |
215 | else | 215 | else |
216 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); | 216 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); |
217 | // No Global::shellQuote as we gurantee it to be sane | 217 | // No Global::shellQuote as we gurantee it to be sane |
218 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 218 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
219 | break; | 219 | break; |
220 | default: | 220 | default: |
221 | res = OAbstractMobileDevice::setDisplayBrightness(bright); | 221 | res = OAbstractMobileDevice::setDisplayBrightness(bright); |
222 | } | 222 | } |
223 | 223 | ||
224 | return res; | 224 | return res; |
225 | } | 225 | } |
226 | 226 | ||
227 | int MyPal::displayBrightnessResolution() const | 227 | int MyPal::displayBrightnessResolution() const |
228 | { | 228 | { |
229 | switch ( model()) { | 229 | switch ( model()) { |
230 | case Model_MyPal_716: | 230 | case Model_MyPal_716: |
231 | return 220; | 231 | return 7; |
232 | default: | 232 | default: |
233 | return OAbstractMobileDevice::displayBrightnessResolution(); | 233 | return OAbstractMobileDevice::displayBrightnessResolution(); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | bool MyPal::setDisplayStatus ( bool on ) | 237 | bool MyPal::setDisplayStatus ( bool on ) |
238 | { | 238 | { |
239 | bool res = false; | 239 | bool res = false; |
240 | 240 | ||
241 | QString cmdline; | 241 | QString cmdline; |
242 | 242 | ||
243 | if ( model() == Model_MyPal_716 ) { | 243 | if ( model() == Model_MyPal_716 ) { |
244 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 244 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); |
245 | } else { | 245 | } else { |
246 | return OAbstractMobileDevice::setDisplayStatus(on); | 246 | return OAbstractMobileDevice::setDisplayStatus(on); |
247 | } | 247 | } |
248 | 248 | ||
249 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 249 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
250 | 250 | ||
251 | return res; | 251 | return res; |
252 | } | 252 | } |