summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_mypal.cpp65
2 files changed, 32 insertions, 36 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 6dc1295..b18fd32 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -440,27 +440,26 @@ int iPAQ::displayBrightnessResolution() const
440 switch ( model()) { 440 switch ( model()) {
441 case Model_iPAQ_H31xx: 441 case Model_iPAQ_H31xx:
442 case Model_iPAQ_H36xx: 442 case Model_iPAQ_H36xx:
443 case Model_iPAQ_H37xx: 443 case Model_iPAQ_H37xx:
444 return 128; // really 256, but >128 could damage the LCD 444 return 128; // really 256, but >128 could damage the LCD
445 445
446 case Model_iPAQ_H38xx: 446 case Model_iPAQ_H38xx:
447 case Model_iPAQ_H39xx: 447 case Model_iPAQ_H39xx:
448 return 64; 448 return 64;
449 case Model_iPAQ_H5xxx: 449 case Model_iPAQ_H5xxx:
450 case Model_iPAQ_HX4700: 450 case Model_iPAQ_HX4700:
451 case Model_iPAQ_H4xxx: 451 case Model_iPAQ_H4xxx:
452 return 255;
453 case Model_iPAQ_H191x: 452 case Model_iPAQ_H191x:
454 return 7; 453 return 255;
455 case Model_iPAQ_H1940: 454 case Model_iPAQ_H1940:
456 return 44; 455 return 44;
457 default: 456 default:
458 return 2; 457 return 2;
459 } 458 }
460} 459}
461 460
462bool iPAQ::setDisplayStatus ( bool on ) 461bool iPAQ::setDisplayStatus ( bool on )
463{ 462{
464 bool res = false; 463 bool res = false;
465 464
466 QString cmdline; 465 QString cmdline;
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp
index 73b31cb..28e92bf 100644
--- a/libopie2/opiecore/device/odevice_mypal.cpp
+++ b/libopie2/opiecore/device/odevice_mypal.cpp
@@ -131,36 +131,40 @@ void MyPal::initButtons()
131 131
132 d->m_buttons->append ( b ); 132 d->m_buttons->append ( b );
133 } 133 }
134 } 134 }
135 reloadButtonMapping(); 135 reloadButtonMapping();
136} 136}
137 137
138bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 138bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
139{ 139{
140 int newkeycode = keycode; 140 int newkeycode = keycode;
141 141
142 switch ( keycode ) { 142 switch ( keycode ) {
143 case Key_Left : 143 // QT has strange screen coordinate system, so depending
144 case Key_Right: 144 // on native device screen orientation, we need to rotate cursor keys
145 case Key_Up : 145 case Key_Left :
146 case Key_Down : { 146 case Key_Right:
147 // Rotate the cursor keys by 270 147 case Key_Up :
148 // keycode - Key_Left = position of the button starting from left clockwise 148 case Key_Down : {
149 // add the rotation to it and modolo. No we've the original offset 149 int quarters;
150 // add the offset to the Key_Left key 150 switch (d->m_rotation) {
151 if ( d->m_model == Model_MyPal_716 ) 151 case Rot0: quarters = 3/*270deg*/; break;
152 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 152 case Rot90: quarters = 2/*270deg*/; break;
153 break; 153 case Rot180: quarters = 1/*270deg*/; break;
154 } 154 case Rot270: quarters = 0/*270deg*/; break;
155 }
156 newkeycode = Key_Left + ( keycode - Key_Left + quarters ) % 4;
157 break;
158 }
155 159
156 // map Power Button short/long press 160 // map Power Button short/long press
157 case HardKey_Suspend: { // Hope we don't have infinite recursion here: 161 case HardKey_Suspend: { // Hope we don't have infinite recursion here:
158 if ( isPress ) { 162 if ( isPress ) {
159 if ( m_power_timer ) 163 if ( m_power_timer )
160 killTimer ( m_power_timer ); 164 killTimer ( m_power_timer );
161 m_power_timer = startTimer ( 500 ); 165 m_power_timer = startTimer ( 500 );
162 } 166 }
163 else if ( m_power_timer ) { 167 else if ( m_power_timer ) {
164 killTimer ( m_power_timer ); 168 killTimer ( m_power_timer );
165 m_power_timer = 0; 169 m_power_timer = 0;
166 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 170 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
@@ -201,68 +205,61 @@ void MyPal::playAlarmSound()
201#endif 205#endif
202} 206}
203 207
204bool MyPal::setDisplayBrightness ( int bright ) 208bool MyPal::setDisplayBrightness ( int bright )
205{ 209{
206 bool res = false; 210 bool res = false;
207 211
208 if ( bright > 255 ) 212 if ( bright > 255 )
209 bright = 255; 213 bright = 255;
210 if ( bright < 0 ) 214 if ( bright < 0 )
211 bright = 0; 215 bright = 0;
212 216
213 QDir sysClass( "/sys/class/backlight/pxafb/" ); 217 QDir sysClass( "/sys/class/backlight/" );
214 sysClass.setFilter(QDir::Dirs); 218 sysClass.setFilter(QDir::Dirs);
215 int fd; 219 if ( sysClass.exists() && sysClass.count() > 2 ) {
216 if ( sysClass.exists() ) { 220 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" );
217 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); 221 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
218 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
219 if ( fd ) {
220 char buf[10];
221 buf[0] = bright ? 0 : 4;
222 buf[1] = '\0';
223 res = ( ::write( fd, &buf[0], 2 ) == 0 );
224 ::close( fd );
225 }
226 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
227 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
228 if ( fd ) { 222 if ( fd ) {
229 char buf[100]; 223 char buf[100];
230 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright ); 224 int val = bright * displayBrightnessResolution() / 255;
231 res = ( ::write( fd, &buf[0], len ) == 0 ); 225 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
232 ::close( fd ); 226 res = ( ::write( fd, &buf[0], len ) == 0 );
227 ::close( fd );
233 } 228 }
234 } 229 }
235 230
236 return res; 231 return res;
237} 232}
238 233
239int MyPal::displayBrightnessResolution() const 234int MyPal::displayBrightnessResolution() const
240{ 235{
241 switch ( model()) { 236 switch ( model()) {
242 case Model_MyPal_716: 237 case Model_MyPal_716:
243 return 7; 238 return 255;
244 default: 239 default:
245 return OAbstractMobileDevice::displayBrightnessResolution(); 240 return OAbstractMobileDevice::displayBrightnessResolution();
246 } 241 }
247} 242}
248 243
249bool MyPal::setDisplayStatus ( bool on ) 244bool MyPal::setDisplayStatus ( bool on )
250{ 245{
251 bool res = false; 246 bool res = false;
252 247
253 QDir sysClass( "/sys/class/lcd/" ); 248 QDir sysClass( "/sys/class/lcd/" );
254 sysClass.setFilter(QDir::Dirs); 249 sysClass.setFilter(QDir::Dirs);
255 if ( sysClass.exists() ) { 250 if ( sysClass.exists() && sysClass.count() > 2 ) {
256 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" ); 251 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" );
257 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 252 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
258 if ( fd ) { 253 if ( fd ) {
259 char buf[10]; 254 char buf[10];
260 buf[0] = on ? 0 : 4; 255 buf[0] = on ? 0 : 4;
261 buf[1] = '\0'; 256 buf[1] = '\0';
262 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 257 res = ( ::write( fd, &buf[0], 2 ) == 0 );
263 ::close( fd ); 258 ::close( fd );
264 } 259 }
260 } else {
261 res = OAbstractMobileDevice::setDisplayStatus(on);
265 } 262 }
266 263
267 return res; 264 return res;
268} 265}