summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 89b9258..59d4eb0 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -49,588 +49,585 @@
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60struct z_button z_buttons [] = { 60struct z_button z_buttons [] = {
61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
62 "devicebuttons/z_calendar", 62 "devicebuttons/z_calendar",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
66 "devicebuttons/z_contact", 66 "devicebuttons/z_contact",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
70 "devicebuttons/z_home", 70 "devicebuttons/z_home",
71 "QPE/Launcher", "home()", 71 "QPE/Launcher", "home()",
72 "buttonsettings", "raise()" }, 72 "buttonsettings", "raise()" },
73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
74 "devicebuttons/z_menu", 74 "devicebuttons/z_menu",
75 "QPE/TaskBar", "toggleMenu()", 75 "QPE/TaskBar", "toggleMenu()",
76 "QPE/TaskBar", "toggleStartMenu()" }, 76 "QPE/TaskBar", "toggleStartMenu()" },
77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
78 "devicebuttons/z_mail", 78 "devicebuttons/z_mail",
79 "opiemail", "raise()", 79 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 80 "opiemail", "newMail()" },
81}; 81};
82 82
83struct z_button z_buttons_c700 [] = { 83struct z_button z_buttons_c700 [] = {
84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
85 "devicebuttons/z_calendar", 85 "devicebuttons/z_calendar",
86 "datebook", "nextView()", 86 "datebook", "nextView()",
87 "today", "raise()" }, 87 "today", "raise()" },
88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
89 "devicebuttons/z_contact", 89 "devicebuttons/z_contact",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
93 "devicebuttons/z_home", 93 "devicebuttons/z_home",
94 "QPE/Launcher", "home()", 94 "QPE/Launcher", "home()",
95 "buttonsettings", "raise()" }, 95 "buttonsettings", "raise()" },
96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/z_menu", 97 "devicebuttons/z_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
101 "devicebuttons/z_mail", 101 "devicebuttons/z_mail",
102 "opiemail", "raise()", 102 "opiemail", "raise()",
103 "opiemail", "newMail()" }, 103 "opiemail", "newMail()" },
104 104
105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
106 "devicebuttons/z_hinge1", 106 "devicebuttons/z_hinge1",
107 "QPE/Rotation", "rotateDefault()", 107 "QPE/Rotation", "rotateDefault()",
108 "QPE/Rotation", "rotateDefault()" }, 108 "QPE/Rotation", "rotateDefault()" },
109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
110 "devicebuttons/z_hinge2", 110 "devicebuttons/z_hinge2",
111 "QPE/Rotation", "rotateDefault()", 111 "QPE/Rotation", "rotateDefault()",
112 "QPE/Rotation", "rotateDefault()" }, 112 "QPE/Rotation", "rotateDefault()" },
113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
114 "devicebuttons/z_hinge3", 114 "devicebuttons/z_hinge3",
115 "QPE/Rotation", "rotateDefault()", 115 "QPE/Rotation", "rotateDefault()",
116 "QPE/Rotation", "rotateDefault()" }, 116 "QPE/Rotation", "rotateDefault()" },
117}; 117};
118 118
119// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 119// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
120// class up into individual classes. We need three classes 120// class up into individual classes. We need three classes
121// 121//
122// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 122// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
123// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 123// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
124// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) 124// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000)
125// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 125// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
126// 126//
127// Only question right now is: Do we really need to do it? Because as soon 127// Only question right now is: Do we really need to do it? Because as soon
128// as the OpenZaurus kernel is ready, there will be a unified interface for all 128// as the OpenZaurus kernel is ready, there will be a unified interface for all
129// Zaurus models (concerning apm, backlight, buttons, etc.) 129// Zaurus models (concerning apm, backlight, buttons, etc.)
130// 130//
131// Comments? - mickeyl. 131// Comments? - mickeyl.
132 132
133void Zaurus::init(const QString& cpu_info) 133void Zaurus::init(const QString& cpu_info)
134{ 134{
135 // Set the time to wait until the system is realy suspended 135 // Set the time to wait until the system is realy suspended
136 // the delta between apm --suspend and sleeping 136 // the delta between apm --suspend and sleeping
137 setAPMTimeOut( 15000 ); 137 setAPMTimeOut( 15000 );
138 138
139 // generic distribution code already scanned /etc/issue at that point - 139 // generic distribution code already scanned /etc/issue at that point -
140 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 140 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
141 if ( d->m_sysverstr.contains( "embedix", false ) ) 141 if ( d->m_sysverstr.contains( "embedix", false ) )
142 { 142 {
143 d->m_vendorstr = "Sharp"; 143 d->m_vendorstr = "Sharp";
144 d->m_vendor = Vendor_Sharp; 144 d->m_vendor = Vendor_Sharp;
145 d->m_systemstr = "Zaurus"; 145 d->m_systemstr = "Zaurus";
146 d->m_system = System_Zaurus; 146 d->m_system = System_Zaurus;
147 m_embedix = true; 147 m_embedix = true;
148 } 148 }
149 else 149 else
150 { 150 {
151 d->m_vendorstr = "OpenZaurus Team"; 151 d->m_vendorstr = "OpenZaurus Team";
152 d->m_systemstr = "OpenZaurus"; 152 d->m_systemstr = "OpenZaurus";
153 d->m_system = System_OpenZaurus; 153 d->m_system = System_OpenZaurus;
154 // sysver already gathered 154 // sysver already gathered
155 155
156 // OpenZaurus sometimes uses the embedix kernel, check if this is one 156 // OpenZaurus sometimes uses the embedix kernel, check if this is one
157 FILE *uname = popen("uname -r", "r"); 157 FILE *uname = popen("uname -r", "r");
158 QFile f; 158 QFile f;
159 QString line; 159 QString line;
160 if ( f.open(IO_ReadOnly, uname) ) { 160 if ( f.open(IO_ReadOnly, uname) ) {
161 QTextStream ts ( &f ); 161 QTextStream ts ( &f );
162 line = ts. readLine(); 162 line = ts. readLine();
163 int loc = line. find ( "embedix" ); 163 int loc = line. find ( "embedix" );
164 if ( loc != -1 ) 164 if ( loc != -1 )
165 m_embedix = true; 165 m_embedix = true;
166 else 166 else
167 m_embedix = false; 167 m_embedix = false;
168 f.close(); 168 f.close();
169 } 169 }
170 pclose(uname); 170 pclose(uname);
171 } 171 }
172 172
173 // check the Zaurus model 173 // check the Zaurus model
174 QString model; 174 QString model;
175 int loc = cpu_info.find( ":" ); 175 int loc = cpu_info.find( ":" );
176 if ( loc != -1 ) 176 if ( loc != -1 )
177 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 177 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
178 else 178 else
179 model = cpu_info; 179 model = cpu_info;
180 180
181 if ( model == "SHARP Corgi" ) { 181 if ( model == "SHARP Corgi" ) {
182 d->m_model = Model_Zaurus_SLC7x0; 182 d->m_model = Model_Zaurus_SLC7x0;
183 d->m_modelstr = "Zaurus SL-C700"; 183 d->m_modelstr = "Zaurus SL-C700";
184 } else if ( model == "SHARP Shepherd" ) { 184 } else if ( model == "SHARP Shepherd" ) {
185 d->m_model = Model_Zaurus_SLC7x0; 185 d->m_model = Model_Zaurus_SLC7x0;
186 d->m_modelstr = "Zaurus SL-C750"; 186 d->m_modelstr = "Zaurus SL-C750";
187 } else if ( model == "SHARP Husky" ) { 187 } else if ( model == "SHARP Husky" ) {
188 d->m_model = Model_Zaurus_SLC7x0; 188 d->m_model = Model_Zaurus_SLC7x0;
189 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 189 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
190 } else if ( model == "SHARP Boxer" ) { 190 } else if ( model == "SHARP Boxer" ) {
191 d->m_model = Model_Zaurus_SLC7x0; 191 d->m_model = Model_Zaurus_SLC7x0;
192 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 192 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
193 } else if ( model == "SHARP Poodle" ) { 193 } else if ( model == "SHARP Poodle" ) {
194 d->m_model = Model_Zaurus_SLB600; 194 d->m_model = Model_Zaurus_SLB600;
195 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 195 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
196 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 196 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
197 d->m_model = Model_Zaurus_SL5500; 197 d->m_model = Model_Zaurus_SL5500;
198 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 198 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
199 } else if ( model == "SHARP Tosa" ) { 199 } else if ( model == "SHARP Tosa" ) {
200 d->m_model = Model_Zaurus_SL6000; 200 d->m_model = Model_Zaurus_SL6000;
201 d->m_modelstr = "Zaurus SL-6000"; 201 d->m_modelstr = "Zaurus SL-6000";
202 } else if ( model == "SHARP Spitz" ) { 202 } else if ( model == "SHARP Spitz" ) {
203 d->m_model = Model_Zaurus_SLC3000; 203 d->m_model = Model_Zaurus_SLC3000;
204 d->m_modelstr = "Zaurus SL-C3000"; 204 d->m_modelstr = "Zaurus SL-C3000";
205 } else { 205 } else {
206 d->m_model = Model_Zaurus_SL5500; 206 d->m_model = Model_Zaurus_SL5500;
207 d->m_modelstr = "Unknown Zaurus"; 207 d->m_modelstr = "Unknown Zaurus";
208 } 208 }
209 209
210 // set initial rotation 210 // set initial rotation
211 switch( d->m_model ) { 211 switch( d->m_model ) {
212 case Model_Zaurus_SL6000: // fallthrough 212 case Model_Zaurus_SL6000: // fallthrough
213 case Model_Zaurus_SLA300: 213 case Model_Zaurus_SLA300:
214 d->m_rotation = Rot0; 214 d->m_rotation = Rot0;
215 break; 215 break;
216 case Model_Zaurus_SLC3000: // fallthrough 216 case Model_Zaurus_SLC3000: // fallthrough
217 case Model_Zaurus_SLC7x0: 217 case Model_Zaurus_SLC7x0:
218 d->m_rotation = rotation(); 218 d->m_rotation = rotation();
219 d->m_direction = direction(); 219 d->m_direction = direction();
220 break; 220 break;
221 case Model_Zaurus_SLB600: // fallthrough 221 case Model_Zaurus_SLB600: // fallthrough
222 case Model_Zaurus_SL5000: // fallthrough 222 case Model_Zaurus_SL5000: // fallthrough
223 case Model_Zaurus_SL5500: // fallthrough 223 case Model_Zaurus_SL5500: // fallthrough
224 default: 224 default:
225 d->m_rotation = Rot270; 225 d->m_rotation = Rot270;
226 break; 226 break;
227 } 227 }
228 m_leds[0] = Led_Off; 228 m_leds[0] = Led_Off;
229 229
230 if ( m_embedix ) 230 if ( m_embedix )
231 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 231 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr );
232 else 232 else
233 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 233 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
234} 234}
235 235
236void Zaurus::initButtons() 236void Zaurus::initButtons()
237{ 237{
238 if ( d->m_buttons ) 238 if ( d->m_buttons )
239 return; 239 return;
240 240
241 if ( isQWS( ) ) {
242 addPreHandler(this);
243 }
244 241
245 d->m_buttons = new QValueList <ODeviceButton>; 242 d->m_buttons = new QValueList <ODeviceButton>;
246 243
247 struct z_button * pz_buttons; 244 struct z_button * pz_buttons;
248 int buttoncount; 245 int buttoncount;
249 switch ( d->m_model ) { 246 switch ( d->m_model ) {
250 case Model_Zaurus_SLC3000: // fallthrough 247 case Model_Zaurus_SLC3000: // fallthrough
251 case Model_Zaurus_SLC7x0: 248 case Model_Zaurus_SLC7x0:
249 if ( isQWS( ) ) {
250 addPreHandler(this); // hinge-sensor-handler
251 }
252 pz_buttons = z_buttons_c700; 252 pz_buttons = z_buttons_c700;
253 buttoncount = ARRAY_SIZE(z_buttons_c700); 253 buttoncount = ARRAY_SIZE(z_buttons_c700);
254 break; 254 break;
255 default: 255 default:
256 pz_buttons = z_buttons; 256 pz_buttons = z_buttons;
257 buttoncount = ARRAY_SIZE(z_buttons); 257 buttoncount = ARRAY_SIZE(z_buttons);
258 break; 258 break;
259 } 259 }
260 260
261 for ( int i = 0; i < buttoncount; i++ ) { 261 for ( int i = 0; i < buttoncount; i++ ) {
262 struct z_button *zb = pz_buttons + i; 262 struct z_button *zb = pz_buttons + i;
263 ODeviceButton b; 263 ODeviceButton b;
264 264
265 b.setKeycode( zb->code ); 265 b.setKeycode( zb->code );
266 b.setUserText( QObject::tr( "Button", zb->utext )); 266 b.setUserText( QObject::tr( "Button", zb->utext ));
267 b.setPixmap( Resource::loadPixmap( zb->pix )); 267 b.setPixmap( Resource::loadPixmap( zb->pix ));
268 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 268 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
269 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 269 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
270 d->m_buttons->append( b ); 270 d->m_buttons->append( b );
271 } 271 }
272 272
273 reloadButtonMapping(); 273 reloadButtonMapping();
274} 274}
275 275
276 276
277 277
278typedef struct sharp_led_status { 278typedef struct sharp_led_status {
279 int which; /* select which LED status is wanted. */ 279 int which; /* select which LED status is wanted. */
280 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 280 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
281} sharp_led_status; 281} sharp_led_status;
282 282
283void Zaurus::buzzer( int sound ) 283void Zaurus::buzzer( int sound )
284{ 284{
285#ifndef QT_NO_SOUND 285#ifndef QT_NO_SOUND
286 Sound *snd = 0; 286 Sound *snd = 0;
287 287
288 // All devices except SL5500 have a DSP device 288 // All devices except SL5500 have a DSP device
289 if ( d->m_model != Model_Zaurus_SL5000 289 if ( d->m_model != Model_Zaurus_SL5000
290 && d->m_model != Model_Zaurus_SL5500 ) { 290 && d->m_model != Model_Zaurus_SL5500 ) {
291 291
292 switch ( sound ){ 292 switch ( sound ){
293 case SHARP_BUZ_TOUCHSOUND: { 293 case SHARP_BUZ_TOUCHSOUND: {
294 static Sound touch_sound("touchsound"); 294 static Sound touch_sound("touchsound");
295 snd = &touch_sound; 295 snd = &touch_sound;
296 } 296 }
297 break; 297 break;
298 case SHARP_BUZ_KEYSOUND: { 298 case SHARP_BUZ_KEYSOUND: {
299 static Sound key_sound( "keysound" ); 299 static Sound key_sound( "keysound" );
300 snd = &key_sound; 300 snd = &key_sound;
301 } 301 }
302 break; 302 break;
303 case SHARP_BUZ_SCHEDULE_ALARM: 303 case SHARP_BUZ_SCHEDULE_ALARM:
304 default: { 304 default: {
305 static Sound alarm_sound("alarm"); 305 static Sound alarm_sound("alarm");
306 snd = &alarm_sound; 306 snd = &alarm_sound;
307 } 307 }
308 break; 308 break;
309 } 309 }
310 } 310 }
311 311
312 // If a soundname is defined, we expect that this device has 312 // If a soundname is defined, we expect that this device has
313 // sound capabilities.. Otherwise we expect to have the buzzer 313 // sound capabilities.. Otherwise we expect to have the buzzer
314 // device.. 314 // device..
315 if ( snd && snd->isFinished() ){ 315 if ( snd && snd->isFinished() ){
316 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 316 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
317 snd->play(); 317 snd->play();
318 } else if( !snd ) { 318 } else if( !snd ) {
319 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 319 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
320 320
321 if ( fd >= 0 ) { 321 if ( fd >= 0 ) {
322 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 322 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
323 ::close ( fd ); 323 ::close ( fd );
324 } 324 }
325 325
326 } 326 }
327#endif 327#endif
328} 328}
329 329
330 330
331void Zaurus::playAlarmSound() 331void Zaurus::playAlarmSound()
332{ 332{
333 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 333 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
334} 334}
335 335
336void Zaurus::playTouchSound() 336void Zaurus::playTouchSound()
337{ 337{
338 buzzer( SHARP_BUZ_TOUCHSOUND ); 338 buzzer( SHARP_BUZ_TOUCHSOUND );
339} 339}
340 340
341void Zaurus::playKeySound() 341void Zaurus::playKeySound()
342{ 342{
343 buzzer( SHARP_BUZ_KEYSOUND ); 343 buzzer( SHARP_BUZ_KEYSOUND );
344} 344}
345 345
346 346
347QValueList <OLed> Zaurus::ledList() const 347QValueList <OLed> Zaurus::ledList() const
348{ 348{
349 QValueList <OLed> vl; 349 QValueList <OLed> vl;
350 vl << Led_Mail; 350 vl << Led_Mail;
351 return vl; 351 return vl;
352} 352}
353 353
354QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 354QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
355{ 355{
356 QValueList <OLedState> vl; 356 QValueList <OLedState> vl;
357 357
358 if ( l == Led_Mail ) 358 if ( l == Led_Mail )
359 vl << Led_Off << Led_On << Led_BlinkSlow; 359 vl << Led_Off << Led_On << Led_BlinkSlow;
360 return vl; 360 return vl;
361} 361}
362 362
363OLedState Zaurus::ledState( OLed which ) const 363OLedState Zaurus::ledState( OLed which ) const
364{ 364{
365 if ( which == Led_Mail ) 365 if ( which == Led_Mail )
366 return m_leds [0]; 366 return m_leds [0];
367 else 367 else
368 return Led_Off; 368 return Led_Off;
369} 369}
370 370
371bool Zaurus::setLedState( OLed which, OLedState st ) 371bool Zaurus::setLedState( OLed which, OLedState st )
372{ 372{
373 // Currently not supported on non_embedix kernels 373 // Currently not supported on non_embedix kernels
374 if (!m_embedix) 374 if (!m_embedix)
375 { 375 {
376 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 376 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
377 return false; 377 return false;
378 } 378 }
379 379
380 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 380 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
381 381
382 if ( which == Led_Mail ) { 382 if ( which == Led_Mail ) {
383 if ( fd >= 0 ) { 383 if ( fd >= 0 ) {
384 struct sharp_led_status leds; 384 struct sharp_led_status leds;
385 ::memset ( &leds, 0, sizeof( leds )); 385 ::memset ( &leds, 0, sizeof( leds ));
386 leds. which = SHARP_LED_MAIL_EXISTS; 386 leds. which = SHARP_LED_MAIL_EXISTS;
387 bool ok = true; 387 bool ok = true;
388 388
389 switch ( st ) { 389 switch ( st ) {
390 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 390 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
391 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 391 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
392 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 392 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
393 default : ok = false; 393 default : ok = false;
394 } 394 }
395 395
396 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 396 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
397 m_leds [0] = st; 397 m_leds [0] = st;
398 return true; 398 return true;
399 } 399 }
400 } 400 }
401 } 401 }
402 return false; 402 return false;
403} 403}
404 404
405int Zaurus::displayBrightnessResolution() const 405int Zaurus::displayBrightnessResolution() const
406{ 406{
407 int res = 1; 407 int res = 1;
408 if (m_embedix) 408 if (m_embedix)
409 { 409 {
410 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 410 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
411 if ( fd ) 411 if ( fd )
412 { 412 {
413 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 413 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
414 ::close( fd ); 414 ::close( fd );
415 return value ? value : res; 415 return value ? value : res;
416 } 416 }
417 } 417 }
418 else 418 else
419 { 419 {
420 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 420 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
421 if ( fd ) 421 if ( fd )
422 { 422 {
423 char buf[100]; 423 char buf[100];
424 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 424 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
425 ::close( fd ); 425 ::close( fd );
426 } 426 }
427 } 427 }
428 return res; 428 return res;
429} 429}
430 430
431bool Zaurus::setDisplayBrightness( int bright ) 431bool Zaurus::setDisplayBrightness( int bright )
432{ 432{
433 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 433 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
434 bool res = false; 434 bool res = false;
435 435
436 if ( bright > 255 ) bright = 255; 436 if ( bright > 255 ) bright = 255;
437 if ( bright < 0 ) bright = 0; 437 if ( bright < 0 ) bright = 0;
438 438
439 int numberOfSteps = displayBrightnessResolution(); 439 int numberOfSteps = displayBrightnessResolution();
440 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 440 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
441 441
442 if ( m_embedix ) 442 if ( m_embedix )
443 { 443 {
444 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 444 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
445 if ( fd ) 445 if ( fd )
446 { 446 {
447 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 447 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
448 ::close( fd ); 448 ::close( fd );
449 } 449 }
450 } 450 }
451 else 451 else
452 { 452 {
453 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 453 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
454 if ( fd ) 454 if ( fd )
455 { 455 {
456 char buf[100]; 456 char buf[100];
457 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 457 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
458 res = ( ::write( fd, &buf[0], len ) == 0 ); 458 res = ( ::write( fd, &buf[0], len ) == 0 );
459 ::close( fd ); 459 ::close( fd );
460 } 460 }
461 } 461 }
462 return res; 462 return res;
463} 463}
464 464
465bool Zaurus::setDisplayStatus( bool on ) 465bool Zaurus::setDisplayStatus( bool on )
466{ 466{
467 bool res = false; 467 bool res = false;
468 if ( m_embedix ) 468 if ( m_embedix )
469 { 469 {
470 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 470 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
471 if ( fd ) 471 if ( fd )
472 { 472 {
473 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 473 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
474 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 474 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
475 ::close ( fd ); 475 ::close ( fd );
476 } 476 }
477 } 477 }
478 else 478 else
479 { 479 {
480 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 480 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
481 if ( fd ) 481 if ( fd )
482 { 482 {
483 char buf[10]; 483 char buf[10];
484 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 484 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
485 buf[1] = '\0'; 485 buf[1] = '\0';
486 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 486 res = ( ::write( fd, &buf[0], 2 ) == 0 );
487 ::close( fd ); 487 ::close( fd );
488 } 488 }
489 } 489 }
490 return res; 490 return res;
491} 491}
492 492
493Transformation Zaurus::rotation() const 493Transformation Zaurus::rotation() const
494{ 494{
495 qDebug( "Zaurus::rotation()" ); 495 qDebug( "Zaurus::rotation()" );
496 Transformation rot; 496 Transformation rot;
497 497
498 switch ( d->m_model ) { 498 switch ( d->m_model ) {
499 case Model_Zaurus_SLC3000: // fallthrough 499 case Model_Zaurus_SLC3000: // fallthrough
500 case Model_Zaurus_SLC7x0: 500 case Model_Zaurus_SLC7x0:
501 { 501 {
502 OHingeStatus hs = readHingeSensor(); 502 OHingeStatus hs = readHingeSensor();
503 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 503 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
504 504
505 if ( m_embedix ) 505 if ( m_embedix )
506 { 506 {
507 if ( hs == CASE_PORTRAIT ) rot = Rot0; 507 if ( hs == CASE_PORTRAIT ) rot = Rot0;
508 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 508 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
509 else rot = Rot270; 509 else rot = Rot270;
510 } 510 }
511 else 511 else
512 { 512 {
513 if ( hs == CASE_PORTRAIT ) rot = Rot90; 513 if ( hs == CASE_PORTRAIT ) rot = Rot90;
514 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 514 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
515 else rot = Rot0; 515 else rot = Rot0;
516 } 516 }
517 } 517 }
518 break; 518 break;
519 case Model_Zaurus_SL6000: 519 case Model_Zaurus_SL6000:
520 case Model_Zaurus_SLB600: 520 case Model_Zaurus_SLB600:
521 case Model_Zaurus_SLA300: 521 case Model_Zaurus_SLA300:
522 case Model_Zaurus_SL5500: 522 case Model_Zaurus_SL5500:
523 case Model_Zaurus_SL5000: 523 case Model_Zaurus_SL5000:
524 default: 524 default:
525 rot = d->m_rotation; 525 rot = d->m_rotation;
526 break; 526 break;
527 } 527 }
528 528
529 return rot; 529 return rot;
530} 530}
531ODirection Zaurus::direction() const 531ODirection Zaurus::direction() const
532{ 532{
533 ODirection dir; 533 ODirection dir;
534 534
535 switch ( d->m_model ) { 535 switch ( d->m_model ) {
536 case Model_Zaurus_SLC3000: // fallthrough 536 case Model_Zaurus_SLC3000: // fallthrough
537 case Model_Zaurus_SLC7x0: { 537 case Model_Zaurus_SLC7x0: {
538 OHingeStatus hs = readHingeSensor(); 538 OHingeStatus hs = readHingeSensor();
539 if ( hs == CASE_PORTRAIT ) dir = CCW; 539 if ( hs == CASE_PORTRAIT ) dir = CCW;
540 else if ( hs == CASE_UNKNOWN ) dir = CCW; 540 else if ( hs == CASE_UNKNOWN ) dir = CCW;
541 else dir = CW; 541 else dir = CW;
542 } 542 }
543 break; 543 break;
544 case Model_Zaurus_SL6000: 544 case Model_Zaurus_SL6000:
545 case Model_Zaurus_SLA300: 545 case Model_Zaurus_SLA300:
546 case Model_Zaurus_SLB600: 546 case Model_Zaurus_SLB600:
547 case Model_Zaurus_SL5500: 547 case Model_Zaurus_SL5500:
548 case Model_Zaurus_SL5000: 548 case Model_Zaurus_SL5000:
549 default: dir = d->m_direction; 549 default: dir = d->m_direction;
550 break; 550 break;
551 } 551 }
552 return dir; 552 return dir;
553 553
554} 554}
555 555
556bool Zaurus::hasHingeSensor() const 556bool Zaurus::hasHingeSensor() const
557{ 557{
558 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 558 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
559} 559}
560 560
561OHingeStatus Zaurus::readHingeSensor() const 561OHingeStatus Zaurus::readHingeSensor() const
562{ 562{
563 if (m_embedix) 563 if (m_embedix)
564 { 564 {
565 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 565 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
566 if (handle == -1) 566 if (handle == -1)
567 { 567 {
568 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 568 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
569 return CASE_UNKNOWN; 569 return CASE_UNKNOWN;
570 } 570 }
571 else 571 else
572 { 572 {
573 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 573 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
574 ::close (handle); 574 ::close (handle);
575 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 575 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
576 { 576 {
577 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 577 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
578 return static_cast<OHingeStatus>( retval ); 578 return static_cast<OHingeStatus>( retval );
579 } 579 }
580 else 580 else
581 { 581 {
582 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 582 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
583 return CASE_UNKNOWN; 583 return CASE_UNKNOWN;
584 } 584 }
585 } 585 }
586 } 586 }
587 else 587 else
588 { 588 {
589 // corgi keyboard is event source 0 in OZ kernel 2.6 589 // corgi keyboard is event source 0 in OZ kernel 2.6
590 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); 590 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
591 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; 591 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE;
592 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; 592 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT;
593 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; 593 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED;
594 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 594 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
595 return CASE_UNKNOWN; 595 return CASE_UNKNOWN;
596 } 596 }
597} 597}
598 598
599/* 599/*
600 * Take code from iPAQ device. 600 * Take code from iPAQ device.
601 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. 601 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction.
602 * I hope that is ok - Alwin 602 * I hope that is ok - Alwin
603 */ 603 */
604bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 604bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
605{ 605{
606 Transformation rot;
607 int newkeycode = keycode; 606 int newkeycode = keycode;
608 607
609
610 if (d->m_model!=Model_Zaurus_SLC3000 && d->m_model!=Model_Zaurus_SLC7x0) return false; 608 if (d->m_model!=Model_Zaurus_SLC3000 && d->m_model!=Model_Zaurus_SLC7x0) return false;
611 rot = rotation();
612 if (rot==Rot0) return false;
613 609
614 /* map cursor keys depending on the hinge status */ 610 /* map cursor keys depending on the hinge status */
615 switch ( keycode ) { 611 switch ( keycode ) {
616 // Rotate cursor keys 612 // Rotate cursor keys
617 case Key_Left : 613 case Key_Left :
618 case Key_Right: 614 case Key_Right:
619 case Key_Up : 615 case Key_Up :
620 case Key_Down : 616 case Key_Down :
621 { 617 {
622 if (rot==Rot90) { 618 if (rotation()==Rot90) {
623 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 619 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
624 } 620 }
625 } 621 }
626 break; 622 break;
627 623
628 } 624 }
629 if (newkeycode!=keycode) { 625 if (newkeycode!=keycode) {
630 if ( newkeycode != Key_unknown ) { 626 if ( newkeycode != Key_unknown ) {
631 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 627 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
632 } 628 }
633 return true; 629 return true;
634 } 630 }
635 return false; 631 return false;
636} 632}
633