summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-19 18:06:17 (UTC)
committer kergoth <kergoth>2003-04-19 18:06:17 (UTC)
commiteb276a6663540849ef98819eeaa8f935a7e1b945 (patch) (unidiff)
tree7464e0858a367034f976088021ccec5953a0eddc
parent89ced5d0c4f4ce89a11333d80aac2f8b81d97233 (diff)
downloadopie-eb276a6663540849ef98819eeaa8f935a7e1b945.zip
opie-eb276a6663540849ef98819eeaa8f935a7e1b945.tar.gz
opie-eb276a6663540849ef98819eeaa8f935a7e1b945.tar.bz2
Add note about c700 physical screen orientation handling.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 29c8ad2..713cc90 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -125,1270 +125,1282 @@ public:
125 virtual OLedState ledState ( OLed led ) const; 125 virtual OLedState ledState ( OLed led ) const;
126 virtual bool setLedState ( OLed led, OLedState st ); 126 virtual bool setLedState ( OLed led, OLedState st );
127 127
128protected: 128protected:
129 virtual void buzzer ( int snd ); 129 virtual void buzzer ( int snd );
130 130
131 OLedState m_leds [1]; 131 OLedState m_leds [1];
132}; 132};
133 133
134 134
135struct i_button { 135struct i_button {
136 uint model; 136 uint model;
137 Qt::Key code; 137 Qt::Key code;
138 char *utext; 138 char *utext;
139 char *pix; 139 char *pix;
140 char *fpressedservice; 140 char *fpressedservice;
141 char *fpressedaction; 141 char *fpressedaction;
142 char *fheldservice; 142 char *fheldservice;
143 char *fheldaction; 143 char *fheldaction;
144} ipaq_buttons [] = { 144} ipaq_buttons [] = {
145 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 145 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
146 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 146 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
147 "devicebuttons/ipaq_calendar", 147 "devicebuttons/ipaq_calendar",
148 "datebook", "nextView()", 148 "datebook", "nextView()",
149 "today", "raise()" }, 149 "today", "raise()" },
150 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 150 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
151 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 151 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
152 "devicebuttons/ipaq_contact", 152 "devicebuttons/ipaq_contact",
153 "addressbook", "raise()", 153 "addressbook", "raise()",
154 "addressbook", "beamBusinessCard()" }, 154 "addressbook", "beamBusinessCard()" },
155 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 155 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
156 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 156 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
157 "devicebuttons/ipaq_menu", 157 "devicebuttons/ipaq_menu",
158 "QPE/TaskBar", "toggleMenu()", 158 "QPE/TaskBar", "toggleMenu()",
159 "QPE/TaskBar", "toggleStartMenu()" }, 159 "QPE/TaskBar", "toggleStartMenu()" },
160 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 160 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
161 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 161 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
162 "devicebuttons/ipaq_mail", 162 "devicebuttons/ipaq_mail",
163 "mail", "raise()", 163 "mail", "raise()",
164 "mail", "newMail()" }, 164 "mail", "newMail()" },
165 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 165 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
166 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 166 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
167 "devicebuttons/ipaq_home", 167 "devicebuttons/ipaq_home",
168 "QPE/Launcher", "home()", 168 "QPE/Launcher", "home()",
169 "buttonsettings", "raise()" }, 169 "buttonsettings", "raise()" },
170 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 170 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
171 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 171 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
172 "devicebuttons/ipaq_record", 172 "devicebuttons/ipaq_record",
173 "QPE/VMemo", "toggleRecord()", 173 "QPE/VMemo", "toggleRecord()",
174 "sound", "raise()" }, 174 "sound", "raise()" },
175}; 175};
176 176
177struct z_button { 177struct z_button {
178 Qt::Key code; 178 Qt::Key code;
179 char *utext; 179 char *utext;
180 char *pix; 180 char *pix;
181 char *fpressedservice; 181 char *fpressedservice;
182 char *fpressedaction; 182 char *fpressedaction;
183 char *fheldservice; 183 char *fheldservice;
184 char *fheldaction; 184 char *fheldaction;
185} z_buttons [] = { 185} z_buttons [] = {
186 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 186 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
187 "devicebuttons/z_calendar", 187 "devicebuttons/z_calendar",
188 "datebook", "nextView()", 188 "datebook", "nextView()",
189 "today", "raise()" }, 189 "today", "raise()" },
190 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 190 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
191 "devicebuttons/z_contact", 191 "devicebuttons/z_contact",
192 "addressbook", "raise()", 192 "addressbook", "raise()",
193 "addressbook", "beamBusinessCard()" }, 193 "addressbook", "beamBusinessCard()" },
194 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 194 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
195 "devicebuttons/z_home", 195 "devicebuttons/z_home",
196 "QPE/Launcher", "home()", 196 "QPE/Launcher", "home()",
197 "buttonsettings", "raise()" }, 197 "buttonsettings", "raise()" },
198 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 198 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
199 "devicebuttons/z_menu", 199 "devicebuttons/z_menu",
200 "QPE/TaskBar", "toggleMenu()", 200 "QPE/TaskBar", "toggleMenu()",
201 "QPE/TaskBar", "toggleStartMenu()" }, 201 "QPE/TaskBar", "toggleStartMenu()" },
202 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 202 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
203 "devicebuttons/z_mail", 203 "devicebuttons/z_mail",
204 "mail", "raise()", 204 "mail", "raise()",
205 "mail", "newMail()" }, 205 "mail", "newMail()" },
206}; 206};
207 207
208static QCString makeChannel ( const char *str ) 208static QCString makeChannel ( const char *str )
209{ 209{
210 if ( str && !::strchr ( str, '/' )) 210 if ( str && !::strchr ( str, '/' ))
211 return QCString ( "QPE/Application/" ) + str; 211 return QCString ( "QPE/Application/" ) + str;
212 else 212 else
213 return str; 213 return str;
214} 214}
215 215
216 216
217 217
218 218
219ODevice *ODevice::inst ( ) 219ODevice *ODevice::inst ( )
220{ 220{
221 static ODevice *dev = 0; 221 static ODevice *dev = 0;
222 222
223 if ( !dev ) { 223 if ( !dev ) {
224 if ( QFile::exists ( "/proc/hal/model" )) 224 if ( QFile::exists ( "/proc/hal/model" ))
225 dev = new iPAQ ( ); 225 dev = new iPAQ ( );
226 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 226 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
227 dev = new Zaurus ( ); 227 dev = new Zaurus ( );
228 else 228 else
229 dev = new ODevice ( ); 229 dev = new ODevice ( );
230 230
231 dev-> init ( ); 231 dev-> init ( );
232 } 232 }
233 return dev; 233 return dev;
234} 234}
235 235
236 236
237/************************************************** 237/**************************************************
238 * 238 *
239 * common 239 * common
240 * 240 *
241 **************************************************/ 241 **************************************************/
242 242
243 243
244ODevice::ODevice ( ) 244ODevice::ODevice ( )
245{ 245{
246 d = new ODeviceData; 246 d = new ODeviceData;
247 247
248 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 248 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
249 249
250 d-> m_modelstr = "Unknown"; 250 d-> m_modelstr = "Unknown";
251 d-> m_model = Model_Unknown; 251 d-> m_model = Model_Unknown;
252 d-> m_vendorstr = "Unknown"; 252 d-> m_vendorstr = "Unknown";
253 d-> m_vendor = Vendor_Unknown; 253 d-> m_vendor = Vendor_Unknown;
254 d-> m_systemstr = "Unknown"; 254 d-> m_systemstr = "Unknown";
255 d-> m_system = System_Unknown; 255 d-> m_system = System_Unknown;
256 d-> m_sysverstr = "0.0"; 256 d-> m_sysverstr = "0.0";
257 d-> m_rotation = Rot0; 257 d-> m_rotation = Rot0;
258 d-> m_direction = CW; 258 d-> m_direction = CW;
259 259
260 d-> m_holdtime = 1000; // 1000ms 260 d-> m_holdtime = 1000; // 1000ms
261 d-> m_buttons = 0; 261 d-> m_buttons = 0;
262} 262}
263 263
264void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 264void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
265{ 265{
266 if ( msg == "deviceButtonMappingChanged()" ) { 266 if ( msg == "deviceButtonMappingChanged()" ) {
267 reloadButtonMapping ( ); 267 reloadButtonMapping ( );
268 } 268 }
269} 269}
270 270
271void ODevice::init ( ) 271void ODevice::init ( )
272{ 272{
273} 273}
274 274
275/** 275/**
276 * This method initialises the button mapping 276 * This method initialises the button mapping
277 */ 277 */
278void ODevice::initButtons ( ) 278void ODevice::initButtons ( )
279{ 279{
280 if ( d-> m_buttons ) 280 if ( d-> m_buttons )
281 return; 281 return;
282 282
283 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 283 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
284 284
285 // Simulation uses iPAQ 3660 device buttons 285 // Simulation uses iPAQ 3660 device buttons
286 286
287 qDebug ( "init Buttons" ); 287 qDebug ( "init Buttons" );
288 d-> m_buttons = new QValueList <ODeviceButton>; 288 d-> m_buttons = new QValueList <ODeviceButton>;
289 289
290 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 290 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
291 i_button *ib = ipaq_buttons + i; 291 i_button *ib = ipaq_buttons + i;
292 ODeviceButton b; 292 ODeviceButton b;
293 293
294 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 294 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
295 b. setKeycode ( ib-> code ); 295 b. setKeycode ( ib-> code );
296 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 296 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
297 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 297 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
298 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 298 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
299 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 299 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
300 d-> m_buttons-> append ( b ); 300 d-> m_buttons-> append ( b );
301 } 301 }
302 } 302 }
303 reloadButtonMapping ( ); 303 reloadButtonMapping ( );
304 304
305 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 305 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
306 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 306 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
307} 307}
308 308
309ODevice::~ODevice ( ) 309ODevice::~ODevice ( )
310{ 310{
311 delete d; 311 delete d;
312} 312}
313 313
314bool ODevice::setSoftSuspend ( bool /*soft*/ ) 314bool ODevice::setSoftSuspend ( bool /*soft*/ )
315{ 315{
316 return false; 316 return false;
317} 317}
318 318
319//#include <linux/apm_bios.h> 319//#include <linux/apm_bios.h>
320 320
321#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 321#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
322 322
323/** 323/**
324 * This method will try to suspend the device 324 * This method will try to suspend the device
325 * It only works if the user is the QWS Server and the apm application 325 * It only works if the user is the QWS Server and the apm application
326 * is installed. 326 * is installed.
327 * It tries to suspend and then waits some time cause some distributions 327 * It tries to suspend and then waits some time cause some distributions
328 * do have asynchronus apm implementations. 328 * do have asynchronus apm implementations.
329 * This method will either fail and return false or it'll suspend the 329 * This method will either fail and return false or it'll suspend the
330 * device and return once the device got woken up 330 * device and return once the device got woken up
331 * 331 *
332 * @return if the device got suspended 332 * @return if the device got suspended
333 */ 333 */
334bool ODevice::suspend ( ) 334bool ODevice::suspend ( )
335{ 335{
336 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 336 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
337 return false; 337 return false;
338 338
339 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 339 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
340 return false; 340 return false;
341 341
342 bool res = false; 342 bool res = false;
343 343
344 struct timeval tvs, tvn; 344 struct timeval tvs, tvn;
345 ::gettimeofday ( &tvs, 0 ); 345 ::gettimeofday ( &tvs, 0 );
346 346
347 ::sync ( ); // flush fs caches 347 ::sync ( ); // flush fs caches
348 res = ( ::system ( "apm --suspend" ) == 0 ); 348 res = ( ::system ( "apm --suspend" ) == 0 );
349 349
350 // This is needed because the iPAQ apm implementation is asynchronous and we 350 // This is needed because the iPAQ apm implementation is asynchronous and we
351 // can not be sure when exactly the device is really suspended 351 // can not be sure when exactly the device is really suspended
352 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 352 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
353 353
354 if ( res ) { 354 if ( res ) {
355 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 355 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
356 ::usleep ( 200 * 1000 ); 356 ::usleep ( 200 * 1000 );
357 ::gettimeofday ( &tvn, 0 ); 357 ::gettimeofday ( &tvn, 0 );
358 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 358 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
359 } 359 }
360 360
361 return res; 361 return res;
362} 362}
363 363
364//#include <linux/fb.h> better not rely on kernel headers in userspace ... 364//#include <linux/fb.h> better not rely on kernel headers in userspace ...
365 365
366#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 366#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
367 367
368/* VESA Blanking Levels */ 368/* VESA Blanking Levels */
369#define VESA_NO_BLANKING 0 369#define VESA_NO_BLANKING 0
370#define VESA_VSYNC_SUSPEND 1 370#define VESA_VSYNC_SUSPEND 1
371#define VESA_HSYNC_SUSPEND 2 371#define VESA_HSYNC_SUSPEND 2
372#define VESA_POWERDOWN 3 372#define VESA_POWERDOWN 3
373 373
374/** 374/**
375 * This sets the display on or off 375 * This sets the display on or off
376 */ 376 */
377bool ODevice::setDisplayStatus ( bool on ) 377bool ODevice::setDisplayStatus ( bool on )
378{ 378{
379 if ( d-> m_model == Model_Unknown ) 379 if ( d-> m_model == Model_Unknown )
380 return false; 380 return false;
381 381
382 bool res = false; 382 bool res = false;
383 int fd; 383 int fd;
384 384
385 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 385 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
386 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 386 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
387 ::close ( fd ); 387 ::close ( fd );
388 } 388 }
389 return res; 389 return res;
390} 390}
391 391
392/** 392/**
393 * This sets the display brightness 393 * This sets the display brightness
394 * @return success or failure 394 * @return success or failure
395 */ 395 */
396bool ODevice::setDisplayBrightness ( int p) 396bool ODevice::setDisplayBrightness ( int p)
397{ 397{
398 Q_UNUSED( p ) 398 Q_UNUSED( p )
399 return false; 399 return false;
400} 400}
401 401
402int ODevice::displayBrightnessResolution ( ) const 402int ODevice::displayBrightnessResolution ( ) const
403{ 403{
404 return 16; 404 return 16;
405} 405}
406 406
407/** 407/**
408 * This returns the vendor as string 408 * This returns the vendor as string
409 * @return Vendor as QString 409 * @return Vendor as QString
410 */ 410 */
411QString ODevice::vendorString ( ) const 411QString ODevice::vendorString ( ) const
412{ 412{
413 return d-> m_vendorstr; 413 return d-> m_vendorstr;
414} 414}
415 415
416/** 416/**
417 * This returns the vendor as one of the values of OVendor 417 * This returns the vendor as one of the values of OVendor
418 * @return OVendor 418 * @return OVendor
419 */ 419 */
420OVendor ODevice::vendor ( ) const 420OVendor ODevice::vendor ( ) const
421{ 421{
422 return d-> m_vendor; 422 return d-> m_vendor;
423} 423}
424 424
425/** 425/**
426 * This returns the model as a string 426 * This returns the model as a string
427 * @return A string representing the model 427 * @return A string representing the model
428 */ 428 */
429QString ODevice::modelString ( ) const 429QString ODevice::modelString ( ) const
430{ 430{
431 return d-> m_modelstr; 431 return d-> m_modelstr;
432} 432}
433 433
434/** 434/**
435 * This does return the OModel used 435 * This does return the OModel used
436 */ 436 */
437OModel ODevice::model ( ) const 437OModel ODevice::model ( ) const
438{ 438{
439 return d-> m_model; 439 return d-> m_model;
440} 440}
441 441
442/** 442/**
443 * This does return the systen name 443 * This does return the systen name
444 */ 444 */
445QString ODevice::systemString ( ) const 445QString ODevice::systemString ( ) const
446{ 446{
447 return d-> m_systemstr; 447 return d-> m_systemstr;
448} 448}
449 449
450/** 450/**
451 * Return System as OSystem value 451 * Return System as OSystem value
452 */ 452 */
453OSystem ODevice::system ( ) const 453OSystem ODevice::system ( ) const
454{ 454{
455 return d-> m_system; 455 return d-> m_system;
456} 456}
457 457
458/** 458/**
459 * @return the version string of the base system 459 * @return the version string of the base system
460 */ 460 */
461QString ODevice::systemVersionString ( ) const 461QString ODevice::systemVersionString ( ) const
462{ 462{
463 return d-> m_sysverstr; 463 return d-> m_sysverstr;
464} 464}
465 465
466/** 466/**
467 * @return the current Transformation 467 * @return the current Transformation
468 */ 468 */
469Transformation ODevice::rotation ( ) const 469Transformation ODevice::rotation ( ) const
470{ 470{
471 return d-> m_rotation; 471 return d-> m_rotation;
472} 472}
473 473
474/** 474/**
475 * @return the current rotation direction 475 * @return the current rotation direction
476 */ 476 */
477ODirection ODevice::direction ( ) const 477ODirection ODevice::direction ( ) const
478{ 478{
479 return d-> m_direction; 479 return d-> m_direction;
480} 480}
481 481
482/** 482/**
483 * This plays an alarmSound 483 * This plays an alarmSound
484 */ 484 */
485void ODevice::alarmSound ( ) 485void ODevice::alarmSound ( )
486{ 486{
487#ifndef QT_NO_SOUND 487#ifndef QT_NO_SOUND
488 static Sound snd ( "alarm" ); 488 static Sound snd ( "alarm" );
489 489
490 if ( snd. isFinished ( )) 490 if ( snd. isFinished ( ))
491 snd. play ( ); 491 snd. play ( );
492#endif 492#endif
493} 493}
494 494
495/** 495/**
496 * This plays a key sound 496 * This plays a key sound
497 */ 497 */
498void ODevice::keySound ( ) 498void ODevice::keySound ( )
499{ 499{
500#ifndef QT_NO_SOUND 500#ifndef QT_NO_SOUND
501 static Sound snd ( "keysound" ); 501 static Sound snd ( "keysound" );
502 502
503 if ( snd. isFinished ( )) 503 if ( snd. isFinished ( ))
504 snd. play ( ); 504 snd. play ( );
505#endif 505#endif
506} 506}
507 507
508/** 508/**
509 * This plays a touch sound 509 * This plays a touch sound
510 */ 510 */
511void ODevice::touchSound ( ) 511void ODevice::touchSound ( )
512{ 512{
513 513
514#ifndef QT_NO_SOUND 514#ifndef QT_NO_SOUND
515 static Sound snd ( "touchsound" ); 515 static Sound snd ( "touchsound" );
516 516
517 if ( snd. isFinished ( )) 517 if ( snd. isFinished ( ))
518 snd. play ( ); 518 snd. play ( );
519#endif 519#endif
520} 520}
521 521
522/** 522/**
523 * This method will return a list of leds 523 * This method will return a list of leds
524 * available on this device 524 * available on this device
525 * @return a list of LEDs. 525 * @return a list of LEDs.
526 */ 526 */
527QValueList <OLed> ODevice::ledList ( ) const 527QValueList <OLed> ODevice::ledList ( ) const
528{ 528{
529 return QValueList <OLed> ( ); 529 return QValueList <OLed> ( );
530} 530}
531 531
532/** 532/**
533 * This does return the state of the LEDs 533 * This does return the state of the LEDs
534 */ 534 */
535QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 535QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
536{ 536{
537 return QValueList <OLedState> ( ); 537 return QValueList <OLedState> ( );
538} 538}
539 539
540/** 540/**
541 * @return the state for a given OLed 541 * @return the state for a given OLed
542 */ 542 */
543OLedState ODevice::ledState ( OLed /*which*/ ) const 543OLedState ODevice::ledState ( OLed /*which*/ ) const
544{ 544{
545 return Led_Off; 545 return Led_Off;
546} 546}
547 547
548/** 548/**
549 * Set the state for a LED 549 * Set the state for a LED
550 * @param which Which OLed to use 550 * @param which Which OLed to use
551 * @param st The state to set 551 * @param st The state to set
552 * @return success or failure 552 * @return success or failure
553 */ 553 */
554bool ODevice::setLedState ( OLed which, OLedState st ) 554bool ODevice::setLedState ( OLed which, OLedState st )
555{ 555{
556 Q_UNUSED( which ) 556 Q_UNUSED( which )
557 Q_UNUSED( st ) 557 Q_UNUSED( st )
558 return false; 558 return false;
559} 559}
560 560
561/** 561/**
562 * @return if the device has a light sensor 562 * @return if the device has a light sensor
563 */ 563 */
564bool ODevice::hasLightSensor ( ) const 564bool ODevice::hasLightSensor ( ) const
565{ 565{
566 return false; 566 return false;
567} 567}
568 568
569/** 569/**
570 * @return a value from the light senso 570 * @return a value from the light senso
571 */ 571 */
572int ODevice::readLightSensor ( ) 572int ODevice::readLightSensor ( )
573{ 573{
574 return -1; 574 return -1;
575} 575}
576 576
577/** 577/**
578 * @return the light sensor resolution whatever that is ;) 578 * @return the light sensor resolution whatever that is ;)
579 */ 579 */
580int ODevice::lightSensorResolution ( ) const 580int ODevice::lightSensorResolution ( ) const
581{ 581{
582 return 0; 582 return 0;
583} 583}
584 584
585/** 585/**
586 * @return a list of hardware buttons 586 * @return a list of hardware buttons
587 */ 587 */
588const QValueList <ODeviceButton> &ODevice::buttons ( ) 588const QValueList <ODeviceButton> &ODevice::buttons ( )
589{ 589{
590 initButtons ( ); 590 initButtons ( );
591 591
592 return *d-> m_buttons; 592 return *d-> m_buttons;
593} 593}
594 594
595/** 595/**
596 * @return The amount of time that would count as a hold 596 * @return The amount of time that would count as a hold
597 */ 597 */
598uint ODevice::buttonHoldTime ( ) const 598uint ODevice::buttonHoldTime ( ) const
599{ 599{
600 return d-> m_holdtime; 600 return d-> m_holdtime;
601} 601}
602 602
603/** 603/**
604 * This method return a ODeviceButton for a key code 604 * This method return a ODeviceButton for a key code
605 * or 0 if no special hardware button is available for the device 605 * or 0 if no special hardware button is available for the device
606 * 606 *
607 * @return The devicebutton or 0l 607 * @return The devicebutton or 0l
608 * @see ODeviceButton 608 * @see ODeviceButton
609 */ 609 */
610const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 610const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
611{ 611{
612 initButtons ( ); 612 initButtons ( );
613 613
614 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 614 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
615 if ( (*it). keycode ( ) == code ) 615 if ( (*it). keycode ( ) == code )
616 return &(*it); 616 return &(*it);
617 } 617 }
618 return 0; 618 return 0;
619} 619}
620 620
621void ODevice::reloadButtonMapping ( ) 621void ODevice::reloadButtonMapping ( )
622{ 622{
623 initButtons ( ); 623 initButtons ( );
624 624
625 Config cfg ( "ButtonSettings" ); 625 Config cfg ( "ButtonSettings" );
626 626
627 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 627 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
628 ODeviceButton &b = ( *d-> m_buttons ) [i]; 628 ODeviceButton &b = ( *d-> m_buttons ) [i];
629 QString group = "Button" + QString::number ( i ); 629 QString group = "Button" + QString::number ( i );
630 630
631 QCString pch, hch; 631 QCString pch, hch;
632 QCString pm, hm; 632 QCString pm, hm;
633 QByteArray pdata, hdata; 633 QByteArray pdata, hdata;
634 634
635 if ( cfg. hasGroup ( group )) { 635 if ( cfg. hasGroup ( group )) {
636 cfg. setGroup ( group ); 636 cfg. setGroup ( group );
637 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 637 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
638 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 638 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
639 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 639 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
640 640
641 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 641 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
642 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 642 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
643 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 643 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
644 } 644 }
645 645
646 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 646 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
647 647
648 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 648 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
649 } 649 }
650} 650}
651 651
652void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 652void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
653{ 653{
654 initButtons ( ); 654 initButtons ( );
655 655
656 QString mb_chan; 656 QString mb_chan;
657 657
658 if ( button >= (int) d-> m_buttons-> count ( )) 658 if ( button >= (int) d-> m_buttons-> count ( ))
659 return; 659 return;
660 660
661 ODeviceButton &b = ( *d-> m_buttons ) [button]; 661 ODeviceButton &b = ( *d-> m_buttons ) [button];
662 b. setPressedAction ( action ); 662 b. setPressedAction ( action );
663 663
664 mb_chan=b. pressedAction ( ). channel ( ); 664 mb_chan=b. pressedAction ( ). channel ( );
665 665
666 Config buttonFile ( "ButtonSettings" ); 666 Config buttonFile ( "ButtonSettings" );
667 buttonFile. setGroup ( "Button" + QString::number ( button )); 667 buttonFile. setGroup ( "Button" + QString::number ( button ));
668 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 668 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
669 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 669 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
670 670
671 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 671 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
672 672
673 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 673 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
674} 674}
675 675
676void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 676void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
677{ 677{
678 initButtons ( ); 678 initButtons ( );
679 679
680 if ( button >= (int) d-> m_buttons-> count ( )) 680 if ( button >= (int) d-> m_buttons-> count ( ))
681 return; 681 return;
682 682
683 ODeviceButton &b = ( *d-> m_buttons ) [button]; 683 ODeviceButton &b = ( *d-> m_buttons ) [button];
684 b. setHeldAction ( action ); 684 b. setHeldAction ( action );
685 685
686 Config buttonFile ( "ButtonSettings" ); 686 Config buttonFile ( "ButtonSettings" );
687 buttonFile. setGroup ( "Button" + QString::number ( button )); 687 buttonFile. setGroup ( "Button" + QString::number ( button ));
688 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 688 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
689 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 689 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
690 690
691 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 691 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
692 692
693 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 693 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
694} 694}
695 695
696 696
697 697
698 698
699/************************************************** 699/**************************************************
700 * 700 *
701 * iPAQ 701 * iPAQ
702 * 702 *
703 **************************************************/ 703 **************************************************/
704 704
705void iPAQ::init ( ) 705void iPAQ::init ( )
706{ 706{
707 d-> m_vendorstr = "HP"; 707 d-> m_vendorstr = "HP";
708 d-> m_vendor = Vendor_HP; 708 d-> m_vendor = Vendor_HP;
709 709
710 QFile f ( "/proc/hal/model" ); 710 QFile f ( "/proc/hal/model" );
711 711
712 if ( f. open ( IO_ReadOnly )) { 712 if ( f. open ( IO_ReadOnly )) {
713 QTextStream ts ( &f ); 713 QTextStream ts ( &f );
714 714
715 d-> m_modelstr = "H" + ts. readLine ( ); 715 d-> m_modelstr = "H" + ts. readLine ( );
716 716
717 if ( d-> m_modelstr == "H3100" ) 717 if ( d-> m_modelstr == "H3100" )
718 d-> m_model = Model_iPAQ_H31xx; 718 d-> m_model = Model_iPAQ_H31xx;
719 else if ( d-> m_modelstr == "H3600" ) 719 else if ( d-> m_modelstr == "H3600" )
720 d-> m_model = Model_iPAQ_H36xx; 720 d-> m_model = Model_iPAQ_H36xx;
721 else if ( d-> m_modelstr == "H3700" ) 721 else if ( d-> m_modelstr == "H3700" )
722 d-> m_model = Model_iPAQ_H37xx; 722 d-> m_model = Model_iPAQ_H37xx;
723 else if ( d-> m_modelstr == "H3800" ) 723 else if ( d-> m_modelstr == "H3800" )
724 d-> m_model = Model_iPAQ_H38xx; 724 d-> m_model = Model_iPAQ_H38xx;
725 else if ( d-> m_modelstr == "H3900" ) 725 else if ( d-> m_modelstr == "H3900" )
726 d-> m_model = Model_iPAQ_H39xx; 726 d-> m_model = Model_iPAQ_H39xx;
727 else 727 else
728 d-> m_model = Model_Unknown; 728 d-> m_model = Model_Unknown;
729 729
730 f. close ( ); 730 f. close ( );
731 } 731 }
732 732
733 switch ( d-> m_model ) { 733 switch ( d-> m_model ) {
734 case Model_iPAQ_H31xx: 734 case Model_iPAQ_H31xx:
735 case Model_iPAQ_H38xx: 735 case Model_iPAQ_H38xx:
736 d-> m_rotation = Rot90; 736 d-> m_rotation = Rot90;
737 break; 737 break;
738 case Model_iPAQ_H36xx: 738 case Model_iPAQ_H36xx:
739 case Model_iPAQ_H37xx: 739 case Model_iPAQ_H37xx:
740 case Model_iPAQ_H39xx: 740 case Model_iPAQ_H39xx:
741 default: 741 default:
742 d-> m_rotation = Rot270; 742 d-> m_rotation = Rot270;
743 break; 743 break;
744 } 744 }
745 745
746 f. setName ( "/etc/familiar-version" ); 746 f. setName ( "/etc/familiar-version" );
747 if ( f. open ( IO_ReadOnly )) { 747 if ( f. open ( IO_ReadOnly )) {
748 d-> m_systemstr = "Familiar"; 748 d-> m_systemstr = "Familiar";
749 d-> m_system = System_Familiar; 749 d-> m_system = System_Familiar;
750 750
751 QTextStream ts ( &f ); 751 QTextStream ts ( &f );
752 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 752 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
753 753
754 f. close ( ); 754 f. close ( );
755 } else { 755 } else {
756 f. setName ( "/etc/oz_version" ); 756 f. setName ( "/etc/oz_version" );
757 757
758 if ( f. open ( IO_ReadOnly )) { 758 if ( f. open ( IO_ReadOnly )) {
759 d-> m_systemstr = "OpenEmbedded/iPaq"; 759 d-> m_systemstr = "OpenEmbedded/iPaq";
760 d-> m_system = System_Familiar; 760 d-> m_system = System_Familiar;
761 761
762 QTextStream ts ( &f ); 762 QTextStream ts ( &f );
763 ts.setDevice ( &f ); 763 ts.setDevice ( &f );
764 d-> m_sysverstr = ts. readLine ( ); 764 d-> m_sysverstr = ts. readLine ( );
765 f. close ( ); 765 f. close ( );
766 } 766 }
767 } 767 }
768 768
769 769
770 770
771 771
772 772
773 m_leds [0] = m_leds [1] = Led_Off; 773 m_leds [0] = m_leds [1] = Led_Off;
774 774
775 m_power_timer = 0; 775 m_power_timer = 0;
776 776
777} 777}
778 778
779void iPAQ::initButtons ( ) 779void iPAQ::initButtons ( )
780{ 780{
781 if ( d-> m_buttons ) 781 if ( d-> m_buttons )
782 return; 782 return;
783 783
784 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 784 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
785 785
786 if ( d-> m_qwsserver ) 786 if ( d-> m_qwsserver )
787 QWSServer::setKeyboardFilter ( this ); 787 QWSServer::setKeyboardFilter ( this );
788 788
789 d-> m_buttons = new QValueList <ODeviceButton>; 789 d-> m_buttons = new QValueList <ODeviceButton>;
790 790
791 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 791 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
792 i_button *ib = ipaq_buttons + i; 792 i_button *ib = ipaq_buttons + i;
793 ODeviceButton b; 793 ODeviceButton b;
794 794
795 if (( ib-> model & d-> m_model ) == d-> m_model ) { 795 if (( ib-> model & d-> m_model ) == d-> m_model ) {
796 b. setKeycode ( ib-> code ); 796 b. setKeycode ( ib-> code );
797 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 797 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
798 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 798 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
799 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 799 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
800 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 800 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
801 801
802 d-> m_buttons-> append ( b ); 802 d-> m_buttons-> append ( b );
803 } 803 }
804 } 804 }
805 reloadButtonMapping ( ); 805 reloadButtonMapping ( );
806 806
807 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 807 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
808 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 808 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
809} 809}
810 810
811 811
812//#include <linux/h3600_ts.h> // including kernel headers is evil ... 812//#include <linux/h3600_ts.h> // including kernel headers is evil ...
813 813
814typedef struct { 814typedef struct {
815 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 815 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
816 unsigned char TotalTime; /* Units of 5 seconds */ 816 unsigned char TotalTime; /* Units of 5 seconds */
817 unsigned char OnTime; /* units of 100m/s */ 817 unsigned char OnTime; /* units of 100m/s */
818 unsigned char OffTime; /* units of 100m/s */ 818 unsigned char OffTime; /* units of 100m/s */
819} LED_IN; 819} LED_IN;
820 820
821typedef struct { 821typedef struct {
822 unsigned char mode; 822 unsigned char mode;
823 unsigned char pwr; 823 unsigned char pwr;
824 unsigned char brightness; 824 unsigned char brightness;
825} FLITE_IN; 825} FLITE_IN;
826 826
827#define LED_ON OD_IOW( 'f', 5, LED_IN ) 827#define LED_ON OD_IOW( 'f', 5, LED_IN )
828#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 828#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
829 829
830 830
831QValueList <OLed> iPAQ::ledList ( ) const 831QValueList <OLed> iPAQ::ledList ( ) const
832{ 832{
833 QValueList <OLed> vl; 833 QValueList <OLed> vl;
834 vl << Led_Power; 834 vl << Led_Power;
835 835
836 if ( d-> m_model == Model_iPAQ_H38xx ) 836 if ( d-> m_model == Model_iPAQ_H38xx )
837 vl << Led_BlueTooth; 837 vl << Led_BlueTooth;
838 return vl; 838 return vl;
839} 839}
840 840
841QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 841QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
842{ 842{
843 QValueList <OLedState> vl; 843 QValueList <OLedState> vl;
844 844
845 if ( l == Led_Power ) 845 if ( l == Led_Power )
846 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 846 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
847 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 847 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
848 vl << Led_Off; // << Led_On << ??? 848 vl << Led_Off; // << Led_On << ???
849 849
850 return vl; 850 return vl;
851} 851}
852 852
853OLedState iPAQ::ledState ( OLed l ) const 853OLedState iPAQ::ledState ( OLed l ) const
854{ 854{
855 switch ( l ) { 855 switch ( l ) {
856 case Led_Power: 856 case Led_Power:
857 return m_leds [0]; 857 return m_leds [0];
858 case Led_BlueTooth: 858 case Led_BlueTooth:
859 return m_leds [1]; 859 return m_leds [1];
860 default: 860 default:
861 return Led_Off; 861 return Led_Off;
862 } 862 }
863} 863}
864 864
865bool iPAQ::setLedState ( OLed l, OLedState st ) 865bool iPAQ::setLedState ( OLed l, OLedState st )
866{ 866{
867 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 867 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
868 868
869 if ( l == Led_Power ) { 869 if ( l == Led_Power ) {
870 if ( fd >= 0 ) { 870 if ( fd >= 0 ) {
871 LED_IN leds; 871 LED_IN leds;
872 ::memset ( &leds, 0, sizeof( leds )); 872 ::memset ( &leds, 0, sizeof( leds ));
873 leds. TotalTime = 0; 873 leds. TotalTime = 0;
874 leds. OnTime = 0; 874 leds. OnTime = 0;
875 leds. OffTime = 1; 875 leds. OffTime = 1;
876 leds. OffOnBlink = 2; 876 leds. OffOnBlink = 2;
877 877
878 switch ( st ) { 878 switch ( st ) {
879 case Led_Off : leds. OffOnBlink = 0; break; 879 case Led_Off : leds. OffOnBlink = 0; break;
880 case Led_On : leds. OffOnBlink = 1; break; 880 case Led_On : leds. OffOnBlink = 1; break;
881 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 881 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
882 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 882 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
883 } 883 }
884 884
885 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 885 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
886 m_leds [0] = st; 886 m_leds [0] = st;
887 return true; 887 return true;
888 } 888 }
889 } 889 }
890 } 890 }
891 return false; 891 return false;
892} 892}
893 893
894 894
895bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 895bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
896{ 896{
897 int newkeycode = keycode; 897 int newkeycode = keycode;
898 898
899 switch ( keycode ) { 899 switch ( keycode ) {
900 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 900 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
901 case HardKey_Menu: { 901 case HardKey_Menu: {
902 if (( d-> m_model == Model_iPAQ_H38xx ) || 902 if (( d-> m_model == Model_iPAQ_H38xx ) ||
903 ( d-> m_model == Model_iPAQ_H39xx )) { 903 ( d-> m_model == Model_iPAQ_H39xx )) {
904 newkeycode = HardKey_Mail; 904 newkeycode = HardKey_Mail;
905 } 905 }
906 break; 906 break;
907 } 907 }
908 908
909 // Rotate cursor keys 180° 909 // Rotate cursor keys 180°
910 case Key_Left : 910 case Key_Left :
911 case Key_Right: 911 case Key_Right:
912 case Key_Up : 912 case Key_Up :
913 case Key_Down : { 913 case Key_Down : {
914 if (( d-> m_model == Model_iPAQ_H31xx ) || 914 if (( d-> m_model == Model_iPAQ_H31xx ) ||
915 ( d-> m_model == Model_iPAQ_H38xx )) { 915 ( d-> m_model == Model_iPAQ_H38xx )) {
916 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 916 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
917 } 917 }
918 break; 918 break;
919 } 919 }
920 920
921 // map Power Button short/long press to F34/F35 921 // map Power Button short/long press to F34/F35
922 case Key_SysReq: { 922 case Key_SysReq: {
923 if ( isPress ) { 923 if ( isPress ) {
924 if ( m_power_timer ) 924 if ( m_power_timer )
925 killTimer ( m_power_timer ); 925 killTimer ( m_power_timer );
926 m_power_timer = startTimer ( 500 ); 926 m_power_timer = startTimer ( 500 );
927 } 927 }
928 else if ( m_power_timer ) { 928 else if ( m_power_timer ) {
929 killTimer ( m_power_timer ); 929 killTimer ( m_power_timer );
930 m_power_timer = 0; 930 m_power_timer = 0;
931 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 931 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
932 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 932 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
933 } 933 }
934 newkeycode = Key_unknown; 934 newkeycode = Key_unknown;
935 break; 935 break;
936 } 936 }
937 } 937 }
938 938
939 if ( newkeycode != keycode ) { 939 if ( newkeycode != keycode ) {
940 if ( newkeycode != Key_unknown ) 940 if ( newkeycode != Key_unknown )
941 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 941 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
942 return true; 942 return true;
943 } 943 }
944 else 944 else
945 return false; 945 return false;
946} 946}
947 947
948void iPAQ::timerEvent ( QTimerEvent * ) 948void iPAQ::timerEvent ( QTimerEvent * )
949{ 949{
950 killTimer ( m_power_timer ); 950 killTimer ( m_power_timer );
951 m_power_timer = 0; 951 m_power_timer = 0;
952 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 952 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
953 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 953 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
954} 954}
955 955
956 956
957void iPAQ::alarmSound ( ) 957void iPAQ::alarmSound ( )
958{ 958{
959#ifndef QT_NO_SOUND 959#ifndef QT_NO_SOUND
960 static Sound snd ( "alarm" ); 960 static Sound snd ( "alarm" );
961 int fd; 961 int fd;
962 int vol; 962 int vol;
963 bool vol_reset = false; 963 bool vol_reset = false;
964 964
965 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 965 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
966 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 966 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
967 Config cfg ( "qpe" ); 967 Config cfg ( "qpe" );
968 cfg. setGroup ( "Volume" ); 968 cfg. setGroup ( "Volume" );
969 969
970 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 970 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
971 if ( volalarm < 0 ) 971 if ( volalarm < 0 )
972 volalarm = 0; 972 volalarm = 0;
973 else if ( volalarm > 100 ) 973 else if ( volalarm > 100 )
974 volalarm = 100; 974 volalarm = 100;
975 volalarm |= ( volalarm << 8 ); 975 volalarm |= ( volalarm << 8 );
976 976
977 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 977 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
978 vol_reset = true; 978 vol_reset = true;
979 } 979 }
980 } 980 }
981 981
982 snd. play ( ); 982 snd. play ( );
983 while ( !snd. isFinished ( )) 983 while ( !snd. isFinished ( ))
984 qApp-> processEvents ( ); 984 qApp-> processEvents ( );
985 985
986 if ( fd >= 0 ) { 986 if ( fd >= 0 ) {
987 if ( vol_reset ) 987 if ( vol_reset )
988 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 988 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
989 ::close ( fd ); 989 ::close ( fd );
990 } 990 }
991#endif 991#endif
992} 992}
993 993
994 994
995bool iPAQ::setSoftSuspend ( bool soft ) 995bool iPAQ::setSoftSuspend ( bool soft )
996{ 996{
997 bool res = false; 997 bool res = false;
998 int fd; 998 int fd;
999 999
1000 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1000 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1001 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1001 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1002 res = true; 1002 res = true;
1003 else 1003 else
1004 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1004 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1005 1005
1006 ::close ( fd ); 1006 ::close ( fd );
1007 } 1007 }
1008 else 1008 else
1009 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1009 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1010 1010
1011 return res; 1011 return res;
1012} 1012}
1013 1013
1014 1014
1015bool iPAQ::setDisplayBrightness ( int bright ) 1015bool iPAQ::setDisplayBrightness ( int bright )
1016{ 1016{
1017 bool res = false; 1017 bool res = false;
1018 int fd; 1018 int fd;
1019 1019
1020 if ( bright > 255 ) 1020 if ( bright > 255 )
1021 bright = 255; 1021 bright = 255;
1022 if ( bright < 0 ) 1022 if ( bright < 0 )
1023 bright = 0; 1023 bright = 0;
1024 1024
1025 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1025 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1026 FLITE_IN bl; 1026 FLITE_IN bl;
1027 bl. mode = 1; 1027 bl. mode = 1;
1028 bl. pwr = bright ? 1 : 0; 1028 bl. pwr = bright ? 1 : 0;
1029 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1029 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1030 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1030 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1031 ::close ( fd ); 1031 ::close ( fd );
1032 } 1032 }
1033 return res; 1033 return res;
1034} 1034}
1035 1035
1036int iPAQ::displayBrightnessResolution ( ) const 1036int iPAQ::displayBrightnessResolution ( ) const
1037{ 1037{
1038 switch ( model ( )) { 1038 switch ( model ( )) {
1039 case Model_iPAQ_H31xx: 1039 case Model_iPAQ_H31xx:
1040 case Model_iPAQ_H36xx: 1040 case Model_iPAQ_H36xx:
1041 case Model_iPAQ_H37xx: 1041 case Model_iPAQ_H37xx:
1042 return 128; // really 256, but >128 could damage the LCD 1042 return 128; // really 256, but >128 could damage the LCD
1043 1043
1044 case Model_iPAQ_H38xx: 1044 case Model_iPAQ_H38xx:
1045 case Model_iPAQ_H39xx: 1045 case Model_iPAQ_H39xx:
1046 return 64; 1046 return 64;
1047 1047
1048 default: 1048 default:
1049 return 2; 1049 return 2;
1050 } 1050 }
1051} 1051}
1052 1052
1053 1053
1054bool iPAQ::hasLightSensor ( ) const 1054bool iPAQ::hasLightSensor ( ) const
1055{ 1055{
1056 return true; 1056 return true;
1057} 1057}
1058 1058
1059int iPAQ::readLightSensor ( ) 1059int iPAQ::readLightSensor ( )
1060{ 1060{
1061 int fd; 1061 int fd;
1062 int val = -1; 1062 int val = -1;
1063 1063
1064 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1064 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1065 char buffer [8]; 1065 char buffer [8];
1066 1066
1067 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1067 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1068 char *endptr; 1068 char *endptr;
1069 1069
1070 buffer [4] = 0; 1070 buffer [4] = 0;
1071 val = ::strtol ( buffer + 2, &endptr, 16 ); 1071 val = ::strtol ( buffer + 2, &endptr, 16 );
1072 1072
1073 if ( *endptr != 0 ) 1073 if ( *endptr != 0 )
1074 val = -1; 1074 val = -1;
1075 } 1075 }
1076 ::close ( fd ); 1076 ::close ( fd );
1077 } 1077 }
1078 1078
1079 return val; 1079 return val;
1080} 1080}
1081 1081
1082int iPAQ::lightSensorResolution ( ) const 1082int iPAQ::lightSensorResolution ( ) const
1083{ 1083{
1084 return 256; 1084 return 256;
1085} 1085}
1086 1086
1087/************************************************** 1087/**************************************************
1088 * 1088 *
1089 * Zaurus 1089 * Zaurus
1090 * 1090 *
1091 **************************************************/ 1091 **************************************************/
1092 1092
1093 1093
1094 1094
1095void Zaurus::init ( ) 1095void Zaurus::init ( )
1096{ 1096{
1097 d-> m_vendorstr = "Sharp"; 1097 d-> m_vendorstr = "Sharp";
1098 d-> m_vendor = Vendor_Sharp; 1098 d-> m_vendor = Vendor_Sharp;
1099 1099
1100 QFile f ( "/proc/filesystems" ); 1100 QFile f ( "/proc/filesystems" );
1101 1101
1102 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1102 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1103 d-> m_vendorstr = "OpenZaurus Team"; 1103 d-> m_vendorstr = "OpenZaurus Team";
1104 d-> m_systemstr = "OpenZaurus"; 1104 d-> m_systemstr = "OpenZaurus";
1105 d-> m_system = System_OpenZaurus; 1105 d-> m_system = System_OpenZaurus;
1106 1106
1107 f. close ( ); 1107 f. close ( );
1108 1108
1109 f. setName ( "/etc/oz_version" ); 1109 f. setName ( "/etc/oz_version" );
1110 if ( f. open ( IO_ReadOnly )) { 1110 if ( f. open ( IO_ReadOnly )) {
1111 QTextStream ts ( &f ); 1111 QTextStream ts ( &f );
1112 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1112 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1113 f. close ( ); 1113 f. close ( );
1114 } 1114 }
1115 } 1115 }
1116 else { 1116 else {
1117 d-> m_systemstr = "Zaurus"; 1117 d-> m_systemstr = "Zaurus";
1118 d-> m_system = System_Zaurus; 1118 d-> m_system = System_Zaurus;
1119 } 1119 }
1120 1120
1121 f. setName ( "/proc/deviceinfo/product" ); 1121 f. setName ( "/proc/deviceinfo/product" );
1122 if ( f. open ( IO_ReadOnly ) ) { 1122 if ( f. open ( IO_ReadOnly ) ) {
1123 QTextStream ts ( &f ); 1123 QTextStream ts ( &f );
1124 QString model = ts. readLine ( ); 1124 QString model = ts. readLine ( );
1125 f. close ( ); 1125 f. close ( );
1126 1126
1127 d-> m_modelstr = QString("Zaurus ") + model; 1127 d-> m_modelstr = QString("Zaurus ") + model;
1128 if ( model == "SL-5500" ) 1128 if ( model == "SL-5500" )
1129 d-> m_model = Model_Zaurus_SL5500; 1129 d-> m_model = Model_Zaurus_SL5500;
1130 else if ( model == "SL-C700" ) 1130 else if ( model == "SL-C700" )
1131 d-> m_model = Model_Zaurus_SLC700; 1131 d-> m_model = Model_Zaurus_SLC700;
1132 else if ( model == "SL-A300" ) 1132 else if ( model == "SL-A300" )
1133 d-> m_model = Model_Zaurus_SLA300; 1133 d-> m_model = Model_Zaurus_SLA300;
1134 else if ( model == "SL-B600" || model == "SL-5600" ) 1134 else if ( model == "SL-B600" || model == "SL-5600" )
1135 d-> m_model = Model_Zaurus_SLB600; 1135 d-> m_model = Model_Zaurus_SLB600;
1136 else 1136 else
1137 d-> m_model = Model_Zaurus_SL5000; 1137 d-> m_model = Model_Zaurus_SL5000;
1138 } 1138 }
1139 else { 1139 else {
1140 d-> m_model = Model_Zaurus_SL5000; 1140 d-> m_model = Model_Zaurus_SL5000;
1141 d-> m_modelstr = "Zaurus (model unknown)"; 1141 d-> m_modelstr = "Zaurus (model unknown)";
1142 } 1142 }
1143 1143
1144 switch ( d-> m_model ) { 1144 switch ( d-> m_model ) {
1145 case Model_Zaurus_SLA300: 1145 case Model_Zaurus_SLA300:
1146 d-> m_rotation = Rot0; 1146 d-> m_rotation = Rot0;
1147 break; 1147 break;
1148 case Model_Zaurus_SLC700: 1148 case Model_Zaurus_SLC700:
1149 /* note for C700, we must check the display rotation 1149 bool flipstate = false;
1150 * sensor to set an appropriate value 1150 // Note: need to 1) set flipstate based on physical screen orientation
1151 */ 1151 // and 2) check to see if the user overrode the rotation direction
1152 // using appearance, and if so, remove that item from the Config to
1153 // ensure the rotate applet flips us back to the previous state.
1154 if ( flipstate ) {
1155 // 480x640
1156 d-> m_rotation = Rot0;
1157 d-> m_direction = CW;
1158 } else {
1159 // 640x480
1160 d-> m_rotation = Rot270;
1161 d-> m_direction = CCW;
1162 }
1163 break;
1152 case Model_Zaurus_SLB600: 1164 case Model_Zaurus_SLB600:
1153 case Model_Zaurus_SL5500: 1165 case Model_Zaurus_SL5500:
1154 case Model_Zaurus_SL5000: 1166 case Model_Zaurus_SL5000:
1155 default: 1167 default:
1156 d-> m_rotation = Rot270; 1168 d-> m_rotation = Rot270;
1157 break; 1169 break;
1158 } 1170 }
1159 m_leds [0] = Led_Off; 1171 m_leds [0] = Led_Off;
1160} 1172}
1161 1173
1162void Zaurus::initButtons ( ) 1174void Zaurus::initButtons ( )
1163{ 1175{
1164 if ( d-> m_buttons ) 1176 if ( d-> m_buttons )
1165 return; 1177 return;
1166 1178
1167 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 1179 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
1168 1180
1169 d-> m_buttons = new QValueList <ODeviceButton>; 1181 d-> m_buttons = new QValueList <ODeviceButton>;
1170 1182
1171 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { 1183 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
1172 z_button *zb = z_buttons + i; 1184 z_button *zb = z_buttons + i;
1173 ODeviceButton b; 1185 ODeviceButton b;
1174 1186
1175 b. setKeycode ( zb-> code ); 1187 b. setKeycode ( zb-> code );
1176 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1188 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1177 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1189 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1178 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1190 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1179 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1191 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1180 1192
1181 d-> m_buttons-> append ( b ); 1193 d-> m_buttons-> append ( b );
1182 } 1194 }
1183 1195
1184 reloadButtonMapping ( ); 1196 reloadButtonMapping ( );
1185 1197
1186 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1198 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1187 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1199 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1188} 1200}
1189 1201
1190#include <unistd.h> 1202#include <unistd.h>
1191#include <fcntl.h> 1203#include <fcntl.h>
1192#include <sys/ioctl.h> 1204#include <sys/ioctl.h>
1193 1205
1194//#include <asm/sharp_char.h> // including kernel headers is evil ... 1206//#include <asm/sharp_char.h> // including kernel headers is evil ...
1195 1207
1196#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1208#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1197 1209
1198 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1210 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1199#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1211#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1200 1212
1201#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1213#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1202#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1214#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1203#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1215#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1204 1216
1205/* --- for SHARP_BUZZER device --- */ 1217/* --- for SHARP_BUZZER device --- */
1206 1218
1207 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1219 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1208//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1220//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1209 1221
1210#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1222#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1211#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1223#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1212#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1224#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1213#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1225#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1214#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1226#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1215 1227
1216//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1228//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1217//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1229//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1218 1230
1219//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1231//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1220//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1232//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1221//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1233//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1222//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1234//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1223//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1235//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1224//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1236//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1225//#define SHARP_PDA_APPSTART 9 /* application start */ 1237//#define SHARP_PDA_APPSTART 9 /* application start */
1226//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1238//#define SHARP_PDA_APPQUIT 10 /* application ends */
1227 1239
1228//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1240//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1229//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1241//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1230//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1242//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1231//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1243//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1232// 1244//
1233 1245
1234 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1246 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1235#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1247#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1236 1248
1237typedef struct sharp_led_status { 1249typedef struct sharp_led_status {
1238 int which; /* select which LED status is wanted. */ 1250 int which; /* select which LED status is wanted. */
1239 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1251 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1240} sharp_led_status; 1252} sharp_led_status;
1241 1253
1242#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1254#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1243 1255
1244#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1256#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1245#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1257#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1246#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1258#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1247 1259
1248// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1260// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1249 1261
1250#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1262#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1251#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1263#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1252#define APM_EVT_POWER_BUTTON (1 << 0) 1264#define APM_EVT_POWER_BUTTON (1 << 0)
1253 1265
1254#define FL_IOCTL_STEP_CONTRAST 100 1266#define FL_IOCTL_STEP_CONTRAST 100
1255 1267
1256 1268
1257void Zaurus::buzzer ( int sound ) 1269void Zaurus::buzzer ( int sound )
1258{ 1270{
1259 static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1271 static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1260 1272
1261 if ( fd >= 0 ) { 1273 if ( fd >= 0 ) {
1262 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1274 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1263 ::close ( fd ); 1275 ::close ( fd );
1264 } 1276 }
1265} 1277}
1266 1278
1267 1279
1268void Zaurus::alarmSound ( ) 1280void Zaurus::alarmSound ( )
1269{ 1281{
1270 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1282 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1271} 1283}
1272 1284
1273void Zaurus::touchSound ( ) 1285void Zaurus::touchSound ( )
1274{ 1286{
1275 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1287 buzzer ( SHARP_BUZ_TOUCHSOUND );
1276} 1288}
1277 1289
1278void Zaurus::keySound ( ) 1290void Zaurus::keySound ( )
1279{ 1291{
1280 buzzer ( SHARP_BUZ_KEYSOUND ); 1292 buzzer ( SHARP_BUZ_KEYSOUND );
1281} 1293}
1282 1294
1283 1295
1284QValueList <OLed> Zaurus::ledList ( ) const 1296QValueList <OLed> Zaurus::ledList ( ) const
1285{ 1297{
1286 QValueList <OLed> vl; 1298 QValueList <OLed> vl;
1287 vl << Led_Mail; 1299 vl << Led_Mail;
1288 return vl; 1300 return vl;
1289} 1301}
1290 1302
1291QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1303QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1292{ 1304{
1293 QValueList <OLedState> vl; 1305 QValueList <OLedState> vl;
1294 1306
1295 if ( l == Led_Mail ) 1307 if ( l == Led_Mail )
1296 vl << Led_Off << Led_On << Led_BlinkSlow; 1308 vl << Led_Off << Led_On << Led_BlinkSlow;
1297 return vl; 1309 return vl;
1298} 1310}
1299 1311
1300OLedState Zaurus::ledState ( OLed which ) const 1312OLedState Zaurus::ledState ( OLed which ) const
1301{ 1313{
1302 if ( which == Led_Mail ) 1314 if ( which == Led_Mail )
1303 return m_leds [0]; 1315 return m_leds [0];
1304 else 1316 else
1305 return Led_Off; 1317 return Led_Off;
1306} 1318}
1307 1319
1308bool Zaurus::setLedState ( OLed which, OLedState st ) 1320bool Zaurus::setLedState ( OLed which, OLedState st )
1309{ 1321{
1310 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1322 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1311 1323
1312 if ( which == Led_Mail ) { 1324 if ( which == Led_Mail ) {
1313 if ( fd >= 0 ) { 1325 if ( fd >= 0 ) {
1314 struct sharp_led_status leds; 1326 struct sharp_led_status leds;
1315 ::memset ( &leds, 0, sizeof( leds )); 1327 ::memset ( &leds, 0, sizeof( leds ));
1316 leds. which = SHARP_LED_MAIL_EXISTS; 1328 leds. which = SHARP_LED_MAIL_EXISTS;
1317 bool ok = true; 1329 bool ok = true;
1318 1330
1319 switch ( st ) { 1331 switch ( st ) {
1320 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1332 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1321 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1333 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1322 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1334 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1323 default : ok = false; 1335 default : ok = false;
1324 } 1336 }
1325 1337
1326 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1338 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1327 m_leds [0] = st; 1339 m_leds [0] = st;
1328 return true; 1340 return true;
1329 } 1341 }
1330 } 1342 }
1331 } 1343 }
1332 return false; 1344 return false;
1333} 1345}
1334 1346
1335bool Zaurus::setSoftSuspend ( bool soft ) 1347bool Zaurus::setSoftSuspend ( bool soft )
1336{ 1348{
1337 bool res = false; 1349 bool res = false;
1338 int fd; 1350 int fd;
1339 1351
1340 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1352 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1341 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1353 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1342 1354
1343 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1355 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1344 1356
1345 if ( sources >= 0 ) { 1357 if ( sources >= 0 ) {
1346 if ( soft ) 1358 if ( soft )
1347 sources &= ~APM_EVT_POWER_BUTTON; 1359 sources &= ~APM_EVT_POWER_BUTTON;
1348 else 1360 else
1349 sources |= APM_EVT_POWER_BUTTON; 1361 sources |= APM_EVT_POWER_BUTTON;
1350 1362
1351 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1363 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1352 res = true; 1364 res = true;
1353 else 1365 else
1354 perror ( "APM_IOCGEVTSRC" ); 1366 perror ( "APM_IOCGEVTSRC" );
1355 } 1367 }
1356 else 1368 else
1357 perror ( "APM_IOCGEVTSRC" ); 1369 perror ( "APM_IOCGEVTSRC" );
1358 1370
1359 ::close ( fd ); 1371 ::close ( fd );
1360 } 1372 }
1361 else 1373 else
1362 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1374 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1363 1375
1364 return res; 1376 return res;
1365} 1377}
1366 1378
1367 1379
1368bool Zaurus::setDisplayBrightness ( int bright ) 1380bool Zaurus::setDisplayBrightness ( int bright )
1369{ 1381{
1370 bool res = false; 1382 bool res = false;
1371 int fd; 1383 int fd;
1372 1384
1373 if ( bright > 255 ) 1385 if ( bright > 255 )
1374 bright = 255; 1386 bright = 255;
1375 if ( bright < 0 ) 1387 if ( bright < 0 )
1376 bright = 0; 1388 bright = 0;
1377 1389
1378 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1390 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1379 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1391 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1380 if ( bright && !bl ) 1392 if ( bright && !bl )
1381 bl = 1; 1393 bl = 1;
1382 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1394 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1383 ::close ( fd ); 1395 ::close ( fd );
1384 } 1396 }
1385 return res; 1397 return res;
1386} 1398}
1387 1399
1388 1400
1389int Zaurus::displayBrightnessResolution ( ) const 1401int Zaurus::displayBrightnessResolution ( ) const
1390{ 1402{
1391 return 5; 1403 return 5;
1392} 1404}
1393 1405
1394 1406